-
Notifications
You must be signed in to change notification settings - Fork 22
/
prepared_previously_justification.go
57 lines (53 loc) · 2.61 KB
/
prepared_previously_justification.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
package proposal
import (
"github.com/bloxapp/ssv-spec/qbft"
"github.com/bloxapp/ssv-spec/qbft/spectest/tests"
"github.com/bloxapp/ssv-spec/types"
"github.com/bloxapp/ssv-spec/types/testingutils"
)
// PreparedPreviouslyJustification tests a proposal for > 1 round, prepared previously with quorum of round change msgs justification
func PreparedPreviouslyJustification() tests.SpecTest {
ks := testingutils.Testing4SharesSet()
ks10 := testingutils.Testing10SharesSet() // TODO: should be 4?
pre := testingutils.BaseInstance()
prepareMsgs := []*qbft.SignedMessage{
testingutils.TestingPrepareMessage(ks.Shares[1], types.OperatorID(1)),
testingutils.TestingPrepareMessage(ks.Shares[2], types.OperatorID(2)),
testingutils.TestingPrepareMessage(ks.Shares[3], types.OperatorID(3)),
}
rcMsgs := []*qbft.SignedMessage{
testingutils.TestingRoundChangeMessageWithRoundAndRC(ks.Shares[1], types.OperatorID(1), 2,
testingutils.MarshalJustifications(prepareMsgs)),
testingutils.TestingRoundChangeMessageWithRoundAndRC(ks.Shares[2], types.OperatorID(2), 2,
testingutils.MarshalJustifications(prepareMsgs)),
testingutils.TestingRoundChangeMessageWithRoundAndRC(ks.Shares[3], types.OperatorID(3), 2,
testingutils.MarshalJustifications(prepareMsgs)),
}
msgs := []*qbft.SignedMessage{
testingutils.TestingProposalMessage(ks.Shares[1], types.OperatorID(1)),
}
msgs = append(msgs, prepareMsgs...)
msgs = append(msgs, rcMsgs...)
msgs = append(msgs,
testingutils.TestingProposalMessageWithParams(ks.Shares[1], types.OperatorID(1), 2, qbft.FirstHeight,
testingutils.TestingQBFTRootData,
testingutils.MarshalJustifications(rcMsgs), testingutils.MarshalJustifications(prepareMsgs),
),
)
return &tests.MsgProcessingSpecTest{
Name: "previously prepared proposal",
Pre: pre,
PostRoot: "bcebe00c0f95cc5c6ed593fd8be857cf6a76beeccbb78699e8a22a41dd3797fd",
InputMessages: msgs,
OutputMessages: []*qbft.SignedMessage{
testingutils.TestingPrepareMessage(ks10.Shares[1], types.OperatorID(1)),
testingutils.TestingCommitMessage(ks.Shares[1], types.OperatorID(1)),
testingutils.TestingRoundChangeMessageWithParams(ks.Shares[1], types.OperatorID(1), 2, qbft.FirstHeight,
testingutils.TestingQBFTRootData, qbft.FirstRound, testingutils.MarshalJustifications(prepareMsgs)),
testingutils.TestingProposalMessageWithParams(ks.Shares[1], types.OperatorID(1), 2, qbft.FirstHeight,
testingutils.TestingQBFTRootData,
testingutils.MarshalJustifications(rcMsgs), testingutils.MarshalJustifications(prepareMsgs)),
testingutils.TestingPrepareMessageWithRound(ks10.Shares[1], types.OperatorID(1), 2),
},
}
}