Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
0
],
"StateValue": "AQIDBAUGBwgJAQIDBAUGBwgJAQIDBAUGBwgJ",
"Round": 0,
"Round": 1,
"RoundChangeJustifications": null,
"PrepareJustifications": [
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
0
],
"StateValue": null,
"Round": 0,
"Round": 1,
"RoundChangeJustifications": null,
"PrepareJustifications": [
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
0
],
"StateValue": null,
"Round": 0,
"Round": 1,
"RoundChangeJustifications": null,
"PrepareJustifications": null,
"CreateType": "CreateRoundChange",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
0
],
"StateValue": null,
"Round": 0,
"Round": 1,
"RoundChangeJustifications": null,
"PrepareJustifications": null,
"CreateType": "CreateRoundChange",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
0
],
"StateValue": "AQIDBAUGBwgJAQIDBAUGBwgJAQIDBAUGBwgJ",
"Round": 0,
"Round": 1,
"RoundChangeJustifications": null,
"PrepareJustifications": [
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
0
],
"StateValue": null,
"Round": 0,
"Round": 1,
"RoundChangeJustifications": null,
"PrepareJustifications": [
{
Expand Down
12 changes: 8 additions & 4 deletions qbft/spectest/tests/create_message_spectest.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,16 @@ func (test *CreateMsgSpecTest) Run(t *testing.T) {
}
require.NoError(t, err)

r, err2 := msg.GetRoot()
if test.Round == qbft.NoRound {
require.Fail(t, "qbft round is invalid")
}

r, err := msg.GetRoot()
if len(test.ExpectedError) != 0 {
require.EqualError(t, err2, test.ExpectedError)
require.EqualError(t, err, test.ExpectedError)
return
}
require.NoError(t, err2)
require.NoError(t, err)

if test.ExpectedRoot != hex.EncodeToString(r[:]) {
fmt.Printf("expected: %v\n", test.ExpectedRoot)
Expand Down Expand Up @@ -149,7 +153,7 @@ func (test *CreateMsgSpecTest) createRoundChange() (*types.SignedSSVMessage, err
}
}

return qbft.CreateRoundChange(state, signer, 1, test.Value[:])
return qbft.CreateRoundChange(state, signer, qbft.FirstRound, test.Value[:])
}

func (test *CreateMsgSpecTest) TestName() string {
Expand Down
6 changes: 5 additions & 1 deletion qbft/spectest/tests/messages/create_round_change.go
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
package messages

import "github.com/ssvlabs/ssv-spec/qbft/spectest/tests"
import (
"github.com/ssvlabs/ssv-spec/qbft"
"github.com/ssvlabs/ssv-spec/qbft/spectest/tests"
)

// CreateRoundChange tests creating a round change msg, not previously prepared
func CreateRoundChange() tests.SpecTest {
return &tests.CreateMsgSpecTest{
CreateType: tests.CreateRoundChange,
Name: "create round change",
Round: qbft.FirstRound,
Value: [32]byte{1, 2, 3, 4},
ExpectedRoot: "a6ffc48674f1522fb90aa7bde2aa76cac54480cf366cdd4afcd7f8b4d548809a",
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"github.com/ssvlabs/ssv-spec/types/testingutils/comparable"
)

// CreateRoundChangeNoJustificationQuorum tests creating a round change msg that was previouly prepared
// CreateRoundChangeNoJustificationQuorum tests creating a round change msg that was previously prepared
// but failed to extract a justification quorum (shouldn't happen).
// The result should be an unjustified round change.
func CreateRoundChangeNoJustificationQuorum() tests.SpecTest {
Expand All @@ -17,6 +17,7 @@ func CreateRoundChangeNoJustificationQuorum() tests.SpecTest {
return &tests.CreateMsgSpecTest{
CreateType: tests.CreateRoundChange,
Name: "create round change no justification quorum",
Round: qbft.FirstRound,
StateValue: testingutils.TestingQBFTFullData,
ExpectedState: sc.ExpectedState,
PrepareJustifications: []*types.SignedSSVMessage{
Expand All @@ -31,7 +32,7 @@ func CreateRoundChangeNoJustificationQuorumSC() *comparable.StateComparison {
expectedMsg := qbft.Message{
MsgType: qbft.RoundChangeMsgType,
Height: 0,
Round: 1,
Round: qbft.FirstRound,
Identifier: testingutils.TestingIdentifier,
Root: testingutils.TestingQBFTRootData,
DataRound: 1,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package messages

import (
"github.com/ssvlabs/ssv-spec/qbft"
"github.com/ssvlabs/ssv-spec/qbft/spectest/tests"
"github.com/ssvlabs/ssv-spec/types"
"github.com/ssvlabs/ssv-spec/types/testingutils"
Expand All @@ -12,6 +13,7 @@ func CreateRoundChangePreviouslyPrepared() tests.SpecTest {
return &tests.CreateMsgSpecTest{
CreateType: tests.CreateRoundChange,
Name: "create round change previously prepared",
Round: qbft.FirstRound,
Value: [32]byte{1, 2, 3, 4},
PrepareJustifications: []*types.SignedSSVMessage{
testingutils.TestingPrepareMessage(ks.OperatorKeys[1], types.OperatorID(1)),
Expand Down