-
Notifications
You must be signed in to change notification settings - Fork 22
/
rc_partial_quorum.go
58 lines (51 loc) · 1.98 KB
/
rc_partial_quorum.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
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"
)
// RoundChangePartialQuorum tests a round change msgs with partial quorum
func RoundChangePartialQuorum() tests.SpecTest {
pre := testingutils.BaseInstance()
ks := testingutils.Testing4SharesSet()
sc := roundChangePartialQuorumStateComparison()
msgs := []*qbft.SignedMessage{
testingutils.TestingRoundChangeMessageWithRound(ks.Shares[2], types.OperatorID(2), 2),
testingutils.TestingRoundChangeMessageWithRound(ks.Shares[3], types.OperatorID(3), 2),
testingutils.TestingRoundChangeMessageWithRound(ks.Shares[3], types.OperatorID(3), 3),
}
return &tests.MsgProcessingSpecTest{
Name: "round change partial quorum",
Pre: pre,
PostRoot: sc.Root(),
PostState: sc.ExpectedState,
InputMessages: msgs,
OutputMessages: []*qbft.SignedMessage{
testingutils.TestingRoundChangeMessageWithParams(ks.Shares[1], types.OperatorID(1), 2, qbft.FirstHeight,
[32]byte{}, 0, [][]byte{}),
},
ExpectedTimerState: &testingutils.TimerState{
Timeouts: 1,
Round: qbft.Round(2),
},
}
}
func roundChangePartialQuorumStateComparison() *comparable.StateComparison {
ks := testingutils.Testing4SharesSet()
msgs := []*qbft.SignedMessage{
testingutils.TestingRoundChangeMessageWithRound(ks.Shares[2], types.OperatorID(2), 2),
testingutils.TestingRoundChangeMessageWithRound(ks.Shares[3], types.OperatorID(3), 2),
testingutils.TestingRoundChangeMessageWithRound(ks.Shares[3], types.OperatorID(3), 3),
}
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}
}