forked from ssvlabs/ssv-spec
-
Notifications
You must be signed in to change notification settings - Fork 0
/
justification_invalid_round.go
56 lines (52 loc) · 2.12 KB
/
justification_invalid_round.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
package roundchange
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"
)
// JustificationInvalidRound tests justifications with prepared round > msg round
func JustificationInvalidRound() *tests.MsgProcessingSpecTest {
pre := testingutils.BaseInstance()
pre.State.Round = 2
prepareMsgs := []*qbft.SignedMessage{
testingutils.SignQBFTMsg(testingutils.Testing4SharesSet().Shares[1], types.OperatorID(1), &qbft.Message{
MsgType: qbft.PrepareMsgType,
Height: qbft.FirstHeight,
Round: 3,
Identifier: []byte{1, 2, 3, 4},
Data: testingutils.PrepareDataBytes([]byte{1, 2, 3, 4}),
}),
testingutils.SignQBFTMsg(testingutils.Testing4SharesSet().Shares[2], types.OperatorID(2), &qbft.Message{
MsgType: qbft.PrepareMsgType,
Height: qbft.FirstHeight,
Round: 3,
Identifier: []byte{1, 2, 3, 4},
Data: testingutils.PrepareDataBytes([]byte{1, 2, 3, 4}),
}),
testingutils.SignQBFTMsg(testingutils.Testing4SharesSet().Shares[3], types.OperatorID(3), &qbft.Message{
MsgType: qbft.PrepareMsgType,
Height: qbft.FirstHeight,
Round: 3,
Identifier: []byte{1, 2, 3, 4},
Data: testingutils.PrepareDataBytes([]byte{1, 2, 3, 4}),
}),
}
msgs := []*qbft.SignedMessage{
testingutils.SignQBFTMsg(testingutils.Testing4SharesSet().Shares[1], types.OperatorID(1), &qbft.Message{
MsgType: qbft.RoundChangeMsgType,
Height: qbft.FirstHeight,
Round: 2,
Identifier: []byte{1, 2, 3, 4},
Data: testingutils.RoundChangePreparedDataBytes([]byte{1, 2, 3, 4}, qbft.FirstRound, prepareMsgs),
}),
}
return &tests.MsgProcessingSpecTest{
Name: "justification invalid round",
Pre: pre,
PostRoot: "f807a3d5343ca20e3b757fa63eae9b9dd70e09e03249048badebf54e62290103",
InputMessages: msgs,
OutputMessages: []*qbft.SignedMessage{},
ExpectedError: "invalid signed message: round change justification invalid: wrong msg round",
}
}