-
Notifications
You must be signed in to change notification settings - Fork 20
/
post_finish.go
141 lines (131 loc) · 6.14 KB
/
post_finish.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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
package preconsensus
import (
"fmt"
"github.com/attestantio/go-eth2-client/spec"
"github.com/bloxapp/ssv-spec/ssv"
"github.com/bloxapp/ssv-spec/ssv/spectest/tests"
"github.com/bloxapp/ssv-spec/types"
"github.com/bloxapp/ssv-spec/types/testingutils"
)
// PostFinish tests a msg received post runner finished
func PostFinish() tests.SpecTest {
ks := testingutils.Testing4SharesSet()
// TODO: check errors
// nolint
finishRunner := func(runner ssv.Runner, duty *types.Duty) ssv.Runner {
runner.GetBaseRunner().State = ssv.NewRunnerState(3, duty)
runner.GetBaseRunner().State.Finished = true
return runner
}
multiSpecTest := &tests.MultiMsgProcessingSpecTest{
Name: "pre consensus post finish",
Tests: []*tests.MsgProcessingSpecTest{
{
Name: "sync committee aggregator selection proof",
Runner: finishRunner(
testingutils.SyncCommitteeContributionRunner(ks),
&testingutils.TestingSyncCommitteeContributionDuty,
),
Duty: &testingutils.TestingSyncCommitteeContributionDuty,
Messages: []*types.SignedSSVMessage{
testingutils.SignedSSVMessageF(ks, testingutils.SSVMsgSyncCommitteeContribution(nil, testingutils.PreConsensusContributionProofMsg(ks.Shares[4], ks.Shares[4], 4, 4))),
},
PostDutyRunnerStateRoot: postFinishSyncCommitteeContributionSC().Root(),
PostDutyRunnerState: postFinishSyncCommitteeContributionSC().ExpectedState,
DontStartDuty: true,
OutputMessages: []*types.SignedPartialSignatureMessage{},
ExpectedError: "failed processing sync committee selection proof message: invalid pre-consensus message: no running duty",
},
{
Name: "aggregator selection proof",
Runner: finishRunner(
testingutils.AggregatorRunner(ks),
&testingutils.TestingAggregatorDuty,
),
Duty: &testingutils.TestingAggregatorDuty,
Messages: []*types.SignedSSVMessage{
testingutils.SignedSSVMessageF(ks, testingutils.SSVMsgAggregator(nil, testingutils.PreConsensusSelectionProofMsg(ks.Shares[4], ks.Shares[4], 4, 4))),
},
PostDutyRunnerStateRoot: postFinishAggregatorSC().Root(),
PostDutyRunnerState: postFinishAggregatorSC().ExpectedState,
DontStartDuty: true,
OutputMessages: []*types.SignedPartialSignatureMessage{},
ExpectedError: "failed processing selection proof message: invalid pre-consensus message: no running duty",
},
{
Name: "validator registration",
Runner: finishRunner(
testingutils.ValidatorRegistrationRunner(ks),
&testingutils.TestingValidatorRegistrationDuty,
),
Duty: &testingutils.TestingValidatorRegistrationDuty,
Messages: []*types.SignedSSVMessage{
testingutils.SignedSSVMessageF(ks, testingutils.SSVMsgValidatorRegistration(nil, testingutils.PreConsensusValidatorRegistrationMsg(ks.Shares[1], 1))),
},
PostDutyRunnerStateRoot: postFinishValidatorRegistrationSC().Root(),
PostDutyRunnerState: postFinishValidatorRegistrationSC().ExpectedState,
OutputMessages: []*types.SignedPartialSignatureMessage{},
DontStartDuty: true,
ExpectedError: "failed processing validator registration message: invalid pre-consensus message: no running duty",
},
{
Name: "voluntary exit",
Runner: finishRunner(
testingutils.VoluntaryExitRunner(ks),
&testingutils.TestingVoluntaryExitDuty,
),
Duty: &testingutils.TestingVoluntaryExitDuty,
Messages: []*types.SignedSSVMessage{
testingutils.SignedSSVMessageF(ks, testingutils.SSVMsgVoluntaryExit(nil, testingutils.PreConsensusVoluntaryExitMsg(ks.Shares[1], 1))),
},
PostDutyRunnerStateRoot: postFinishVoluntaryExitSC().Root(),
PostDutyRunnerState: postFinishVoluntaryExitSC().ExpectedState,
OutputMessages: []*types.SignedPartialSignatureMessage{},
DontStartDuty: true,
ExpectedError: "failed processing voluntary exit message: invalid pre-consensus message: no running duty",
},
},
}
// proposerV creates a test specification for versioned proposer.
proposerV := func(version spec.DataVersion) *tests.MsgProcessingSpecTest {
return &tests.MsgProcessingSpecTest{
Name: fmt.Sprintf("randao (%s)", version.String()),
Runner: finishRunner(
testingutils.ProposerRunner(ks),
testingutils.TestingProposerDutyV(version),
),
Duty: testingutils.TestingProposerDutyV(version),
Messages: []*types.SignedSSVMessage{
testingutils.SignedSSVMessageF(ks, testingutils.SSVMsgProposer(nil, testingutils.PreConsensusRandaoDifferentSignerMsgV(ks.Shares[4], ks.Shares[4], 4, 4, version))),
},
PostDutyRunnerStateRoot: postFinishProposerSC(version).Root(),
PostDutyRunnerState: postFinishProposerSC(version).ExpectedState,
DontStartDuty: true,
OutputMessages: []*types.SignedPartialSignatureMessage{},
ExpectedError: "failed processing randao message: invalid pre-consensus message: no running duty",
}
}
// proposerBlindedV creates a test specification for versioned proposer with blinded block.
proposerBlindedV := func(version spec.DataVersion) *tests.MsgProcessingSpecTest {
return &tests.MsgProcessingSpecTest{
Name: fmt.Sprintf("randao blinded block (%s)", version.String()),
Runner: finishRunner(
testingutils.ProposerBlindedBlockRunner(ks),
testingutils.TestingProposerDutyV(version),
),
Duty: testingutils.TestingProposerDutyV(version),
Messages: []*types.SignedSSVMessage{
testingutils.SignedSSVMessageF(ks, testingutils.SSVMsgProposer(nil, testingutils.PreConsensusRandaoDifferentSignerMsgV(ks.Shares[4], ks.Shares[4], 4, 4, version))),
},
PostDutyRunnerStateRoot: postFinishBlindedProposerSC(version).Root(),
PostDutyRunnerState: postFinishBlindedProposerSC(version).ExpectedState,
DontStartDuty: true,
OutputMessages: []*types.SignedPartialSignatureMessage{},
ExpectedError: "failed processing randao message: invalid pre-consensus message: no running duty",
}
}
for _, v := range testingutils.SupportedBlockVersions {
multiSpecTest.Tests = append(multiSpecTest.Tests, []*tests.MsgProcessingSpecTest{proposerV(v), proposerBlindedV(v)}...)
}
return multiSpecTest
}