forked from ssvlabs/ssv-spec
-
Notifications
You must be signed in to change notification settings - Fork 0
/
wrong_validator_index.go
65 lines (61 loc) · 2.07 KB
/
wrong_validator_index.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
package valcheckduty
import (
"encoding/json"
"github.com/MatheusFranco99/ssv-spec-AleaBFT/ssv/spectest/tests/valcheck"
"github.com/MatheusFranco99/ssv-spec-AleaBFT/types"
"github.com/MatheusFranco99/ssv-spec-AleaBFT/types/testingutils"
)
// WrongValidatorIndex tests duty.ValidatorIndex wrong
func WrongValidatorIndex() *valcheck.MultiSpecTest {
consensusDataBytsF := func(cd *types.ConsensusData) []byte {
cdCopy := &types.ConsensusData{}
b, _ := json.Marshal(cd)
if err := json.Unmarshal(b, cdCopy); err != nil {
panic(err.Error())
}
cdCopy.Duty.ValidatorIndex = testingutils.TestingValidatorIndex + 100
ret, _ := cdCopy.Encode()
return ret
}
expectedErr := "duty invalid: wrong validator index"
return &valcheck.MultiSpecTest{
Name: "wrong validator index",
Tests: []*valcheck.SpecTest{
{
Name: "sync committee aggregator",
Network: types.BeaconTestNetwork,
BeaconRole: types.BNRoleSyncCommitteeContribution,
Input: consensusDataBytsF(testingutils.TestSyncCommitteeContributionConsensusData),
ExpectedError: expectedErr,
},
{
Name: "sync committee",
Network: types.BeaconTestNetwork,
BeaconRole: types.BNRoleSyncCommittee,
Input: consensusDataBytsF(testingutils.TestSyncCommitteeConsensusData),
ExpectedError: expectedErr,
},
{
Name: "aggregator",
Network: types.BeaconTestNetwork,
BeaconRole: types.BNRoleAggregator,
Input: consensusDataBytsF(testingutils.TestAggregatorConsensusData),
ExpectedError: expectedErr,
},
{
Name: "proposer",
Network: types.BeaconTestNetwork,
BeaconRole: types.BNRoleProposer,
Input: consensusDataBytsF(testingutils.TestProposerConsensusData),
ExpectedError: expectedErr,
},
{
Name: "attester",
Network: types.BeaconTestNetwork,
BeaconRole: types.BNRoleAttester,
Input: consensusDataBytsF(testingutils.TestAttesterConsensusData),
ExpectedError: "duty invalid: wrong validator index",
},
},
}
}