-
Notifications
You must be signed in to change notification settings - Fork 22
/
duplicate_msg_different_root.go
49 lines (45 loc) · 1.84 KB
/
duplicate_msg_different_root.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
package proposal
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"
)
// DuplicateMsgDifferentRoot tests a duplicate proposal msg processing (second one with different root)
func DuplicateMsgDifferentRoot() tests.SpecTest {
pre := testingutils.BaseInstance()
ks := testingutils.Testing4SharesSet()
sc := duplicateMsgDifferentRootStateComparison()
msgs := []*qbft.SignedMessage{
testingutils.TestingProposalMessage(ks.Shares[1], types.OperatorID(1)),
testingutils.TestingProposalMessageDifferentRoot(ks.Shares[1], types.OperatorID(1)),
}
return &tests.MsgProcessingSpecTest{
Name: "proposal duplicate message different value",
Pre: pre,
PostRoot: sc.Root(),
PostState: sc.ExpectedState,
InputMessages: msgs,
OutputMessages: []*qbft.SignedMessage{
testingutils.TestingPrepareMessage(ks.Shares[1], types.OperatorID(1)),
},
ExpectedError: "invalid signed message: proposal is not valid with current state",
}
}
func duplicateMsgDifferentRootStateComparison() *comparable.StateComparison {
ks := testingutils.Testing4SharesSet()
msgs := []*qbft.SignedMessage{
testingutils.TestingProposalMessage(ks.Shares[1], types.OperatorID(1)),
}
instance := &qbft.Instance{
State: &qbft.State{
Share: testingutils.TestingShare(testingutils.Testing4SharesSet()),
ProposalAcceptedForCurrentRound: testingutils.TestingProposalMessage(ks.Shares[1], types.OperatorID(1)),
ID: testingutils.TestingIdentifier,
Round: qbft.FirstRound,
},
}
comparable.SetSignedMessages(instance, msgs)
return &comparable.StateComparison{ExpectedState: instance.State}
}