github.com/prysmaticlabs/prysm@v1.4.4/beacon-chain/core/blocks/proposer_slashing_regression_test.go (about) 1 package blocks_test 2 3 import ( 4 "io/ioutil" 5 "testing" 6 7 "github.com/prysmaticlabs/prysm/beacon-chain/core/blocks" 8 "github.com/prysmaticlabs/prysm/beacon-chain/state/v1" 9 10 pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1" 11 ethpb "github.com/prysmaticlabs/prysm/proto/eth/v1alpha1" 12 "github.com/prysmaticlabs/prysm/shared/testutil/require" 13 ) 14 15 // Beaconfuzz discovered an issue where a proposer slashing could be produced which would pass 16 // validation where we use the slashing's slot instead of the current epoch of our state for validation. 17 // This would lead to us accepting an invalid slashing by marking the respective validator as 'slashable' 18 // when it was not in actuality. 19 // See: https://github.com/sigp/beacon-fuzz/issues/91 20 func TestVerifyProposerSlashing_BeaconFuzzIssue91(t *testing.T) { 21 file, err := ioutil.ReadFile("testdata/beaconfuzz_91_beacon.ssz") 22 require.NoError(t, err) 23 rawState := &pb.BeaconState{} 24 err = rawState.UnmarshalSSZ(file) 25 require.NoError(t, err) 26 27 st, err := v1.InitializeFromProtoUnsafe(rawState) 28 require.NoError(t, err) 29 30 file, err = ioutil.ReadFile("testdata/beaconfuzz_91_proposer_slashing.ssz") 31 require.NoError(t, err) 32 slashing := ðpb.ProposerSlashing{} 33 err = slashing.UnmarshalSSZ(file) 34 require.NoError(t, err) 35 36 err = blocks.VerifyProposerSlashing(st, slashing) 37 require.ErrorContains(t, "validator with key 0x97f1d3a73197d7942695638c4fa9ac0fc3688c4f9774b905a14e3a3f171bac586c55e83ff97a1aeffb3af00adb22c6bb is not slashable", err) 38 }