forked from ssvlabs/ssv-spec
-
Notifications
You must be signed in to change notification settings - Fork 0
/
late_round_change_no_instance.go
69 lines (65 loc) · 2.64 KB
/
late_round_change_no_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
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"
)
// LateRoundChangeNoInstance tests process round change msg for a previously decided instance (which is no longer part of stored instances)
func LateRoundChangeNoInstance() *tests.ControllerSpecTest {
identifier := types.NewMsgID(testingutils.TestingValidatorPubKey[:], types.BNRoleAttester)
instanceData := func(height qbft.Height, postRoot string) *tests.RunInstanceData {
return &tests.RunInstanceData{
InputValue: []byte{1, 2, 3, 4},
InputMessages: []*qbft.SignedMessage{
testingutils.MultiSignQBFTMsg(
[]*bls.SecretKey{testingutils.Testing4SharesSet().Shares[1], testingutils.Testing4SharesSet().Shares[2], testingutils.Testing4SharesSet().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}),
}),
},
ExpectedDecidedState: tests.DecidedState{
DecidedVal: []byte{1, 2, 3, 4},
DecidedCnt: 1,
CalledSyncDecidedByRange: true,
DecidedByRangeValues: [2]qbft.Height{height - 3, height},
},
ControllerPostRoot: postRoot,
}
}
return &tests.ControllerSpecTest{
Name: "late round change no instance",
RunInstanceData: []*tests.RunInstanceData{
instanceData(3, "ef701ee47bd9cf0c877ebe7148bc210803da594e12837c632fd9c56f658956ff"),
instanceData(7, "d37a7c38cdea9f71111410ca3d6db6b9ca5746caa8833f722d2cf3c552ea735b"),
instanceData(11, "78bce27afd40e40c155d5701823a983a3d20ba6bae6f74dafd228f9b4f434082"),
{
InputValue: []byte{1, 2, 3, 4},
InputMessages: []*qbft.SignedMessage{
testingutils.MultiSignQBFTMsg(
[]*bls.SecretKey{testingutils.Testing4SharesSet().Shares[4]},
[]types.OperatorID{4},
&qbft.Message{
MsgType: qbft.RoundChangeMsgType,
Height: 2,
Round: qbft.FirstRound,
Identifier: identifier[:],
Data: testingutils.CommitDataBytes([]byte{1, 2, 3, 4}),
}),
},
ExpectedDecidedState: tests.DecidedState{
CalledSyncDecidedByRange: true, // leftovers from the previous calls
DecidedByRangeValues: [2]qbft.Height{8, 11},
},
ControllerPostRoot: "21a7699ab552e583595d3138b87c99aa82cae149e592c7607b964da4b793f96a",
},
},
ExpectedError: "instance not found",
}
}