-
Notifications
You must be signed in to change notification settings - Fork 21
/
duplicate_msg_quorum_prepared_rc_first.go
76 lines (68 loc) · 3.14 KB
/
duplicate_msg_quorum_prepared_rc_first.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
package roundchange
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"
"github.com/bloxapp/ssv-spec/types/testingutils/comparable"
)
// DuplicateMsgQuorumPreparedRCFirst tests a duplicate rc msg (the prev prepared one first)
func DuplicateMsgQuorumPreparedRCFirst() tests.SpecTest {
pre := testingutils.BaseInstance()
pre.State.Round = 2
ks := testingutils.Testing4SharesSet()
sc := duplicateMsgQuorumPreparedRCFirstStateComparison()
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)),
}
msgs := []*qbft.SignedMessage{
testingutils.TestingRoundChangeMessageWithRoundAndRC(ks.Shares[1], types.OperatorID(1), 2,
testingutils.MarshalJustifications(prepareMsgs)),
testingutils.TestingRoundChangeMessageWithRound(ks.Shares[1], types.OperatorID(1), 2),
testingutils.TestingRoundChangeMessageWithRound(ks.Shares[2], types.OperatorID(2), 2),
testingutils.TestingRoundChangeMessageWithRound(ks.Shares[3], types.OperatorID(3), 2),
}
rcMsgs := []*qbft.SignedMessage{
testingutils.TestingRoundChangeMessageWithRoundAndRC(ks.Shares[1], types.OperatorID(1), 2,
testingutils.MarshalJustifications(prepareMsgs)),
testingutils.TestingRoundChangeMessageWithRound(ks.Shares[2], types.OperatorID(2), 2),
testingutils.TestingRoundChangeMessageWithRound(ks.Shares[3], types.OperatorID(3), 2),
}
return &tests.MsgProcessingSpecTest{
Name: "round change duplicate msg quorum (prev prepared rc first)",
Pre: pre,
PostRoot: sc.Root(),
PostState: sc.ExpectedState,
InputMessages: msgs,
OutputMessages: []*qbft.SignedMessage{
testingutils.TestingProposalMessageWithParams(ks.Shares[1], types.OperatorID(1), 2, qbft.FirstHeight,
testingutils.TestingQBFTRootData,
testingutils.MarshalJustifications(rcMsgs), testingutils.MarshalJustifications(prepareMsgs)),
},
}
}
func duplicateMsgQuorumPreparedRCFirstStateComparison() *comparable.StateComparison {
ks := testingutils.Testing4SharesSet()
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)),
}
msgs := []*qbft.SignedMessage{
testingutils.TestingRoundChangeMessageWithRoundAndRC(ks.Shares[1], types.OperatorID(1), 2,
testingutils.MarshalJustifications(prepareMsgs)),
testingutils.TestingRoundChangeMessageWithRound(ks.Shares[2], types.OperatorID(2), 2),
testingutils.TestingRoundChangeMessageWithRound(ks.Shares[3], types.OperatorID(3), 2),
}
instance := &qbft.Instance{
State: &qbft.State{
Share: testingutils.TestingShare(testingutils.Testing4SharesSet()),
ID: testingutils.TestingIdentifier,
Round: 2,
},
}
comparable.SetSignedMessages(instance, msgs)
return &comparable.StateComparison{ExpectedState: instance.State}
}