diff --git a/beacon-chain/core/epoch/spectest/BUILD.bazel b/beacon-chain/core/epoch/spectest/BUILD.bazel index f8ab791d6..70ee62b87 100644 --- a/beacon-chain/core/epoch/spectest/BUILD.bazel +++ b/beacon-chain/core/epoch/spectest/BUILD.bazel @@ -26,6 +26,7 @@ go_test( ], deps = [ "//beacon-chain/core/epoch:go_default_library", + "//beacon-chain/core/epoch/precompute:go_default_library", "//beacon-chain/core/helpers:go_default_library", "//proto/beacon/p2p/v1:go_default_library", "//shared/params/spectest:go_default_library", @@ -55,6 +56,7 @@ go_test( ], deps = [ "//beacon-chain/core/epoch:go_default_library", + "//beacon-chain/core/epoch/precompute:go_default_library", "//beacon-chain/core/helpers:go_default_library", "//proto/beacon/p2p/v1:go_default_library", "//shared/params/spectest:go_default_library", diff --git a/beacon-chain/core/epoch/spectest/justification_and_finalization_test.go b/beacon-chain/core/epoch/spectest/justification_and_finalization_test.go index edb33f82c..2df30f929 100644 --- a/beacon-chain/core/epoch/spectest/justification_and_finalization_test.go +++ b/beacon-chain/core/epoch/spectest/justification_and_finalization_test.go @@ -1,10 +1,12 @@ package spectest import ( + "context" "path" "testing" "github.com/prysmaticlabs/prysm/beacon-chain/core/epoch" + "github.com/prysmaticlabs/prysm/beacon-chain/core/epoch/precompute" "github.com/prysmaticlabs/prysm/beacon-chain/core/helpers" pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1" "github.com/prysmaticlabs/prysm/shared/params/spectest" @@ -22,6 +24,7 @@ func runJustificationAndFinalizationTests(t *testing.T, config string) { t.Run(folder.Name(), func(t *testing.T) { folderPath := path.Join(testsFolderPath, folder.Name()) testutil.RunEpochOperationTest(t, folderPath, processJustificationAndFinalizationWrapper) + testutil.RunEpochOperationTest(t, folderPath, processJustificationAndFinalizationPrecomputeWrapper) }) } } @@ -53,3 +56,19 @@ func processJustificationAndFinalizationWrapper(t *testing.T, state *pb.BeaconSt return state, nil } + +func processJustificationAndFinalizationPrecomputeWrapper(t *testing.T, state *pb.BeaconState) (*pb.BeaconState, error) { + ctx := context.Background() + vp, bp := precompute.New(ctx, state) + _, bp, err := precompute.ProcessAttestations(ctx, state, vp, bp) + if err != nil { + t.Fatal(err) + } + + state, err = precompute.ProcessJustificationAndFinalizationPreCompute(state, bp) + if err != nil { + t.Fatalf("could not process justification: %v", err) + } + + return state, nil +} diff --git a/beacon-chain/core/epoch/spectest/slashings_test.go b/beacon-chain/core/epoch/spectest/slashings_test.go index c9421cc2f..2916a3a04 100644 --- a/beacon-chain/core/epoch/spectest/slashings_test.go +++ b/beacon-chain/core/epoch/spectest/slashings_test.go @@ -1,10 +1,12 @@ package spectest import ( + "context" "path" "testing" "github.com/prysmaticlabs/prysm/beacon-chain/core/epoch" + "github.com/prysmaticlabs/prysm/beacon-chain/core/epoch/precompute" pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1" "github.com/prysmaticlabs/prysm/shared/params/spectest" "github.com/prysmaticlabs/prysm/shared/testutil" @@ -20,6 +22,7 @@ func runSlashingsTests(t *testing.T, config string) { t.Run(folder.Name(), func(t *testing.T) { folderPath := path.Join(testsFolderPath, folder.Name()) testutil.RunEpochOperationTest(t, folderPath, processSlashingsWrapper) + testutil.RunEpochOperationTest(t, folderPath, processSlashingsPrecomputeWrapper) }) } } @@ -31,3 +34,15 @@ func processSlashingsWrapper(t *testing.T, state *pb.BeaconState) (*pb.BeaconSta } return state, nil } + +func processSlashingsPrecomputeWrapper(t *testing.T, state *pb.BeaconState) (*pb.BeaconState, error) { + ctx := context.Background() + vp, bp := precompute.New(ctx, state) + _, bp, err := precompute.ProcessAttestations(ctx, state, vp, bp) + if err != nil { + t.Fatal(err) + } + + state = precompute.ProcessSlashingsPrecompute(state, bp) + return state, nil +}