-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement messages.MarshalJustifications, messages.MarshalJustificati…
…onsWithFullData, messages.UnmarshalJustifications
- Loading branch information
1 parent
f9adf29
commit ea35d68
Showing
7 changed files
with
120 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
8 changes: 0 additions & 8 deletions
8
qbft/spectest/tests/messages/marsha_justification_with_full_data.go
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package messages | ||
|
||
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" | ||
) | ||
|
||
// MarshalJustifications tests marshalling justifications | ||
func MarshalJustifications() *tests.MsgSpecTest { | ||
ks := testingutils.Testing4SharesSet() | ||
|
||
rcMsgs := []*qbft.SignedMessage{ | ||
testingutils.TestingRoundChangeMessageWithRound(ks.Shares[1], 1, 2), | ||
} | ||
|
||
prepareMsgs := []*qbft.SignedMessage{ | ||
testingutils.TestingPrepareMessage(ks.Shares[1], types.OperatorID(1)), | ||
} | ||
|
||
msg := testingutils.TestingProposalMessageWithParams( | ||
ks.Shares[1], types.OperatorID(1), 2, qbft.FirstHeight, testingutils.TestingQBFTRootData, | ||
testingutils.MarshalJustifications(rcMsgs), testingutils.MarshalJustifications(prepareMsgs)) | ||
|
||
r, _ := msg.GetRoot() | ||
b, _ := msg.Encode() | ||
|
||
return &tests.MsgSpecTest{ | ||
Name: "marshal justifications", | ||
Messages: []*qbft.SignedMessage{ | ||
msg, | ||
}, | ||
EncodedMessages: [][]byte{ | ||
b, | ||
}, | ||
ExpectedRoots: [][32]byte{ | ||
r, | ||
}, | ||
} | ||
} |
36 changes: 36 additions & 0 deletions
36
qbft/spectest/tests/messages/marshal_justification_with_full_data.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package messages | ||
|
||
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" | ||
) | ||
|
||
// MarshalJustificationsWithFullData tests marshalling justifications with full data (should omit it) | ||
func MarshalJustificationsWithFullData() *tests.MsgSpecTest { | ||
ks := testingutils.Testing4SharesSet() | ||
|
||
encodedRCMsg, _ := testingutils.TestingRoundChangeMessageWithRound(ks.Shares[1], 1, 2).MarshalSSZ() | ||
encodedPrepareMsg, _ := testingutils.TestingPrepareMessage(ks.Shares[1], types.OperatorID(1)).MarshalSSZ() | ||
|
||
msg := testingutils.TestingProposalMessageWithParams( | ||
ks.Shares[1], types.OperatorID(1), 2, qbft.FirstHeight, testingutils.TestingQBFTRootData, | ||
[][]byte{encodedRCMsg}, [][]byte{encodedPrepareMsg}) | ||
|
||
r, _ := msg.GetRoot() | ||
b, _ := msg.Encode() | ||
|
||
return &tests.MsgSpecTest{ | ||
Name: "marshal justifications with full data", | ||
Messages: []*qbft.SignedMessage{ | ||
msg, | ||
}, | ||
EncodedMessages: [][]byte{ | ||
b, | ||
}, | ||
ExpectedRoots: [][32]byte{ | ||
r, | ||
}, | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package messages | ||
|
||
import ( | ||
"encoding/hex" | ||
|
||
"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" | ||
) | ||
|
||
// UnmarshalJustifications tests unmarshalling justifications | ||
func UnmarshalJustifications() *tests.MsgSpecTest { | ||
ks := testingutils.Testing4SharesSet() | ||
|
||
encodedRCMsg, _ := hex.DecodeString("b77c035c1d1d9c6c7cc22810c50a85c9e560ad791509055061dfe07d403edaa1304161466d49f64844b6e5cf4b09709f069debfd91438f97d414a4f64cdcb4f8cf1e9703f8da141be9f74509087e2f84492314b0341966c4b8fc16d931f6ba086c00000074000000c400000001000000000000000300000000000000000000000000000002000000000000004c000000be956fb7df4ef37531682d588320084fc914c3f0fed335263e5b44062e6c29b40000000000000000500000005000000001020304") | ||
encodedPrepareMsg, _ := hex.DecodeString("8129e6862a5120bd085e1936b4efb5a55fc7d19c0d0fda0e9ec576d18abd4a17ab3a033f5296b74c5fdaf85cb7b3da3201b63feca76b883613e3b1ca137e763a342e3b1dddbce016f8ca3cbce32c8b125dd8c25a7639819c20b539e9e7c6c5796c00000074000000c400000001000000000000000100000000000000000000000000000001000000000000004c000000be956fb7df4ef37531682d588320084fc914c3f0fed335263e5b44062e6c29b40000000000000000500000005000000001020304") | ||
|
||
msg := testingutils.TestingProposalMessageWithParams( | ||
ks.Shares[1], types.OperatorID(1), 2, qbft.FirstHeight, testingutils.TestingQBFTRootData, | ||
[][]byte{encodedRCMsg}, [][]byte{encodedPrepareMsg}) | ||
|
||
r, _ := msg.GetRoot() | ||
b, _ := msg.Encode() | ||
|
||
return &tests.MsgSpecTest{ | ||
Name: "unmarshal justifications", | ||
Messages: []*qbft.SignedMessage{ | ||
msg, | ||
}, | ||
EncodedMessages: [][]byte{ | ||
b, | ||
}, | ||
ExpectedRoots: [][32]byte{ | ||
r, | ||
}, | ||
} | ||
} |