forked from ssvlabs/ssv-spec
/
happy_flow.go
87 lines (83 loc) · 3.39 KB
/
happy_flow.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
77
78
79
80
81
82
83
84
85
86
87
package tests
import (
"github.com/MatheusFranco99/ssv-spec-AleaBFT/qbft"
"github.com/MatheusFranco99/ssv-spec-AleaBFT/types"
"github.com/MatheusFranco99/ssv-spec-AleaBFT/types/testingutils"
)
// HappyFlow tests a simple full happy flow until decided
func HappyFlow() *MsgProcessingSpecTest {
pre := testingutils.BaseInstance()
msgs := []*qbft.SignedMessage{
testingutils.SignQBFTMsg(testingutils.Testing4SharesSet().Shares[1], types.OperatorID(1), &qbft.Message{
MsgType: qbft.ProposalMsgType,
Height: qbft.FirstHeight,
Round: qbft.FirstRound,
Identifier: []byte{1, 2, 3, 4},
Data: testingutils.ProposalDataBytes([]byte{1, 2, 3, 4}, nil, nil),
}),
testingutils.SignQBFTMsg(testingutils.Testing4SharesSet().Shares[1], types.OperatorID(1), &qbft.Message{
MsgType: qbft.PrepareMsgType,
Height: qbft.FirstHeight,
Round: qbft.FirstRound,
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: qbft.FirstRound,
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: qbft.FirstRound,
Identifier: []byte{1, 2, 3, 4},
Data: testingutils.PrepareDataBytes([]byte{1, 2, 3, 4}),
}),
testingutils.SignQBFTMsg(testingutils.Testing4SharesSet().Shares[1], types.OperatorID(1), &qbft.Message{
MsgType: qbft.CommitMsgType,
Height: qbft.FirstHeight,
Round: qbft.FirstRound,
Identifier: []byte{1, 2, 3, 4},
Data: testingutils.CommitDataBytes([]byte{1, 2, 3, 4}),
}),
testingutils.SignQBFTMsg(testingutils.Testing4SharesSet().Shares[2], types.OperatorID(2), &qbft.Message{
MsgType: qbft.CommitMsgType,
Height: qbft.FirstHeight,
Round: qbft.FirstRound,
Identifier: []byte{1, 2, 3, 4},
Data: testingutils.CommitDataBytes([]byte{1, 2, 3, 4}),
}),
testingutils.SignQBFTMsg(testingutils.Testing4SharesSet().Shares[3], types.OperatorID(3), &qbft.Message{
MsgType: qbft.CommitMsgType,
Height: qbft.FirstHeight,
Round: qbft.FirstRound,
Identifier: []byte{1, 2, 3, 4},
Data: testingutils.CommitDataBytes([]byte{1, 2, 3, 4}),
}),
}
return &MsgProcessingSpecTest{
Name: "happy flow",
Pre: pre,
PostRoot: "9ad5f32fb0fe5750430d63123b14da36a7576806143b093ec5898e771de8a785",
InputMessages: msgs,
OutputMessages: []*qbft.SignedMessage{
testingutils.SignQBFTMsg(testingutils.Testing4SharesSet().Shares[1], types.OperatorID(1), &qbft.Message{
MsgType: qbft.PrepareMsgType,
Height: qbft.FirstHeight,
Round: qbft.FirstRound,
Identifier: []byte{1, 2, 3, 4},
Data: testingutils.PrepareDataBytes([]byte{1, 2, 3, 4}),
}),
testingutils.SignQBFTMsg(testingutils.Testing4SharesSet().Shares[1], types.OperatorID(1), &qbft.Message{
MsgType: qbft.CommitMsgType,
Height: qbft.FirstHeight,
Round: qbft.FirstRound,
Identifier: []byte{1, 2, 3, 4},
Data: testingutils.CommitDataBytes([]byte{1, 2, 3, 4}),
}),
},
}
}