forked from ssvlabs/ssv-spec
-
Notifications
You must be signed in to change notification settings - Fork 1
/
normal_accepts_blinded_block.go
53 lines (45 loc) · 2.48 KB
/
normal_accepts_blinded_block.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
package proposer
import (
"fmt"
"github.com/attestantio/go-eth2-client/spec"
"github.com/ssvlabs/ssv-spec-pre-cc/ssv/spectest/tests"
"github.com/ssvlabs/ssv-spec-pre-cc/types"
"github.com/ssvlabs/ssv-spec-pre-cc/types/testingutils"
)
// NormalProposerAcceptsBlindedBlock tests a full happy flow for a proposer runner that produces normal blocks but receives as proposal a blinded block
func NormalProposerAcceptsBlindedBlock() tests.SpecTest {
ks := testingutils.Testing4SharesSet()
multiSpecTest := &tests.MultiMsgProcessingSpecTest{
Name: "normal proposer accepts blinded block proposal",
Tests: []*tests.MsgProcessingSpecTest{},
}
// proposerReceivingBlindedBlockV creates a test specification for versioned normal proposer receiving blinded block as proposal.
proposerReceivingBlindedBlockV := func(version spec.DataVersion) *tests.MsgProcessingSpecTest {
return &tests.MsgProcessingSpecTest{
Name: fmt.Sprintf("normal proposer accepts blinded block proposal (%s)", version.String()),
Runner: testingutils.ProposerRunner(ks),
Duty: testingutils.TestingProposerDutyV(version),
Messages: append(
testingutils.SignedSSVMessageListF(ks, testingutils.SSVDecidingMsgsV(testingutils.TestProposerBlindedBlockConsensusDataV(version), ks, types.BNRoleProposer)), // consensus
[]*types.SignedSSVMessage{ // post consensus
testingutils.SignedSSVMessageF(ks, testingutils.SSVMsgProposer(nil, testingutils.PostConsensusProposerMsgV(ks.Shares[1], 1, version))),
testingutils.SignedSSVMessageF(ks, testingutils.SSVMsgProposer(nil, testingutils.PostConsensusProposerMsgV(ks.Shares[2], 2, version))),
testingutils.SignedSSVMessageF(ks, testingutils.SSVMsgProposer(nil, testingutils.PostConsensusProposerMsgV(ks.Shares[3], 3, version))),
}...,
),
PostDutyRunnerStateRoot: fullHappyFlowProposerReceivingBlindedBlockSC(version).Root(),
PostDutyRunnerState: fullHappyFlowProposerReceivingBlindedBlockSC(version).ExpectedState,
OutputMessages: []*types.SignedPartialSignatureMessage{
testingutils.PreConsensusRandaoMsgV(ks.Shares[1], 1, version),
testingutils.PostConsensusProposerMsgV(ks.Shares[1], 1, version),
},
BeaconBroadcastedRoots: []string{
testingutils.GetSSZRootNoError(testingutils.TestingSignedBlindedBeaconBlockV(ks, version)),
},
}
}
for _, v := range testingutils.SupportedBlockVersions {
multiSpecTest.Tests = append(multiSpecTest.Tests, []*tests.MsgProcessingSpecTest{proposerReceivingBlindedBlockV(v)}...)
}
return multiSpecTest
}