forked from ssvlabs/ssv-spec
-
Notifications
You must be signed in to change notification settings - Fork 0
/
late_round_change_past_instance.go
75 lines (69 loc) · 2.83 KB
/
late_round_change_past_instance.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
package latemsg
import (
"github.com/MatheusFranco99/ssv-spec-AleaBFT/qbft"
"github.com/MatheusFranco99/ssv-spec-AleaBFT/qbft/spectest/tests"
"github.com/MatheusFranco99/ssv-spec-AleaBFT/types"
"github.com/MatheusFranco99/ssv-spec-AleaBFT/types/testingutils"
"github.com/herumi/bls-eth-go-binary/bls"
)
// LateRoundChangePastInstance tests process round change msg for a previously decided instance
func LateRoundChangePastInstance() *tests.ControllerSpecTest {
identifier := types.NewMsgID(testingutils.TestingValidatorPubKey[:], types.BNRoleAttester)
ks := testingutils.Testing4SharesSet()
allMsgs := testingutils.DecidingMsgsForHeight([]byte{1, 2, 3, 4}, identifier[:], 5, ks)
msgPerHeight := make(map[qbft.Height][]*qbft.SignedMessage)
msgPerHeight[qbft.FirstHeight] = allMsgs[0:7]
msgPerHeight[1] = allMsgs[7:14]
msgPerHeight[2] = allMsgs[14:21]
msgPerHeight[3] = allMsgs[21:28]
msgPerHeight[4] = allMsgs[28:35]
msgPerHeight[5] = allMsgs[35:42]
instanceData := func(height qbft.Height, postRoot string) *tests.RunInstanceData {
return &tests.RunInstanceData{
InputValue: []byte{1, 2, 3, 4},
InputMessages: msgPerHeight[height],
ExpectedDecidedState: tests.DecidedState{
BroadcastedDecided: testingutils.MultiSignQBFTMsg(
[]*bls.SecretKey{ks.Shares[1], ks.Shares[2], ks.Shares[3]},
[]types.OperatorID{1, 2, 3},
&qbft.Message{
MsgType: qbft.CommitMsgType,
Height: height,
Round: qbft.FirstRound,
Identifier: identifier[:],
Data: testingutils.CommitDataBytes([]byte{1, 2, 3, 4}),
}),
DecidedVal: []byte{1, 2, 3, 4},
DecidedCnt: 1,
},
ControllerPostRoot: postRoot,
}
}
return &tests.ControllerSpecTest{
Name: "late round change past instance",
RunInstanceData: []*tests.RunInstanceData{
instanceData(qbft.FirstHeight, "f82a7925fa41a67b245d6f97b13c1d272632ac4efe0380847ac8c9378f5bb04b"),
instanceData(1, "d1b707e4b2251967767d9656dd89cb807460b8dabbfd468772b3c088d89fd71b"),
instanceData(2, "bff7466de84c53b1b0c39e1f5c9faf3e336622218f583a817b862f55bbf9023d"),
instanceData(3, "05944813dfd352d5b4ce730c09bbb076ade52689111ce94b201547865fe28844"),
instanceData(4, "848261610a945d4aa24174fe73471ba2c3b85f1147c9fc5a704ff77c3f1a7bbb"),
instanceData(5, "bd7d5dc577276a5262d188270dcee321198349aea6eb19e6b6d5446d3bbcd827"),
{
InputValue: []byte{1, 2, 3, 4},
InputMessages: []*qbft.SignedMessage{
testingutils.MultiSignQBFTMsg(
[]*bls.SecretKey{ks.Shares[4]},
[]types.OperatorID{4},
&qbft.Message{
MsgType: qbft.RoundChangeMsgType,
Height: 4,
Round: qbft.FirstRound,
Identifier: identifier[:],
Data: testingutils.CommitDataBytes([]byte{1, 2, 3, 4}),
}),
},
ControllerPostRoot: "d38a806fe0ca8def63b1877896348645e318b47fbdf964390046f2b13bfa14c2",
},
},
}
}