Skip to content

Commit 4e04768

Browse files
committed
spectest: fix nil-deref generating the BeaconVoteDataNil valcheck vector
BeaconVoteDataNil builds a BeaconVote with nil Source/Target, then passed *consensusData.Source / *consensusData.Target to NewSpecTest — which takes phase0.Checkpoint by value — dereferencing the nil pointers and panicking the whole vector generator (so no ssv spec-test vectors could be produced). Pass zero checkpoints instead: a nil Source/Target SSZ-encodes to a zero checkpoint, so that is the value the decoded vote carries, and the test still asserts the source-not-less-than-target rejection.
1 parent 05dea41 commit 4e04768

1 file changed

Lines changed: 6 additions & 3 deletions

File tree

ssv/spectest/tests/valcheck/valcheckattestations/attestation_data_nil.go

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,17 @@
11
package valcheckattestations
22

33
import (
4+
"github.com/attestantio/go-eth2-client/spec/phase0"
5+
46
"github.com/ssvlabs/ssv-spec/ssv/spectest/testdoc"
57
"github.com/ssvlabs/ssv-spec/ssv/spectest/tests"
68
"github.com/ssvlabs/ssv-spec/ssv/spectest/tests/valcheck"
79
"github.com/ssvlabs/ssv-spec/types"
810
"github.com/ssvlabs/ssv-spec/types/testingutils"
911
)
1012

11-
// BeaconVoteDataNil tests consensus data != nil
13+
// BeaconVoteDataNil tests value-check rejection of a BeaconVote with nil Source/Target (which encode to
14+
// zero checkpoints, so source is not less than target).
1215
func BeaconVoteDataNil() tests.SpecTest {
1316
consensusData := &types.BeaconVote{
1417
Source: nil,
@@ -23,8 +26,8 @@ func BeaconVoteDataNil() tests.SpecTest {
2326
types.RoleCommittee,
2427
testingutils.TestingDutySlot,
2528
input,
26-
*consensusData.Source,
27-
*consensusData.Target,
29+
phase0.Checkpoint{},
30+
phase0.Checkpoint{},
2831
nil,
2932
nil,
3033
types.AttestationSourceNotLessThanTargetErrorCode,

0 commit comments

Comments
 (0)