Skip to content

Commit

Permalink
Updated identities ordering for some tests. Changed how root QC are v…
Browse files Browse the repository at this point in the history
…alidated
  • Loading branch information
durkmurder committed Oct 4, 2023
1 parent fe04abc commit 3dd3c4d
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 7 deletions.
3 changes: 2 additions & 1 deletion consensus/follower_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import (
mockhotstuff "github.com/onflow/flow-go/consensus/hotstuff/mocks"
"github.com/onflow/flow-go/consensus/hotstuff/model"
"github.com/onflow/flow-go/model/flow"
"github.com/onflow/flow-go/model/flow/order"
"github.com/onflow/flow-go/module/irrecoverable"
"github.com/onflow/flow-go/module/metrics"
mockmodule "github.com/onflow/flow-go/module/mock"
Expand Down Expand Up @@ -75,7 +76,7 @@ type HotStuffFollowerSuite struct {
// SetupTest initializes all the components needed for the Follower.
// The follower itself is instantiated in method BeforeTest
func (s *HotStuffFollowerSuite) SetupTest() {
identities := unittest.IdentityListFixture(4, unittest.WithRole(flow.RoleConsensus))
identities := unittest.IdentityListFixture(4, unittest.WithRole(flow.RoleConsensus)).Sort(order.Canonical[flow.Identity])
s.mockConsensus = &MockConsensus{identities: identities}

// mock storage headers
Expand Down
3 changes: 2 additions & 1 deletion consensus/hotstuff/signature/packer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
"github.com/onflow/flow-go/consensus/hotstuff/mocks"
"github.com/onflow/flow-go/consensus/hotstuff/model"
"github.com/onflow/flow-go/model/flow"
"github.com/onflow/flow-go/model/flow/order"
"github.com/onflow/flow-go/module/signature"
"github.com/onflow/flow-go/utils/unittest"
)
Expand Down Expand Up @@ -54,7 +55,7 @@ func makeBlockSigData(committee flow.IdentitySkeletonList) *hotstuff.BlockSignat
// aggregated random beacon sigs are from [D,F]
func TestPackUnpack(t *testing.T) {
// prepare data for testing
committee := unittest.IdentityListFixture(6, unittest.WithRole(flow.RoleConsensus)).ToSkeleton()
committee := unittest.IdentityListFixture(6, unittest.WithRole(flow.RoleConsensus)).Sort(order.Canonical[flow.Identity]).ToSkeleton()
view := rand.Uint64()
blockSigData := makeBlockSigData(committee)

Expand Down
7 changes: 4 additions & 3 deletions consensus/hotstuff/validator/validator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import (
"github.com/onflow/flow-go/consensus/hotstuff/model"
"github.com/onflow/flow-go/model/flow"
"github.com/onflow/flow-go/model/flow/filter"
"github.com/onflow/flow-go/model/flow/order"
"github.com/onflow/flow-go/utils/unittest"
)

Expand Down Expand Up @@ -46,7 +47,7 @@ type ProposalSuite struct {
func (ps *ProposalSuite) SetupTest() {
// the leader is a random node for now
ps.finalized = uint64(rand.Uint32() + 1)
ps.participants = unittest.IdentityListFixture(8, unittest.WithRole(flow.RoleConsensus))
ps.participants = unittest.IdentityListFixture(8, unittest.WithRole(flow.RoleConsensus)).Sort(order.Canonical[flow.Identity])
ps.leader = &ps.participants[0].IdentitySkeleton

// the parent is the last finalized block, followed directly by a block from the leader
Expand Down Expand Up @@ -584,7 +585,7 @@ func (qs *QCSuite) SetupTest() {
qs.participants = unittest.IdentityListFixture(10,
unittest.WithRole(flow.RoleConsensus),
unittest.WithWeight(1),
).ToSkeleton()
).Sort(order.Canonical[flow.Identity]).ToSkeleton()

// signers are a qualified majority at 7
qs.signers = qs.participants[:7]
Expand Down Expand Up @@ -742,7 +743,7 @@ func (s *TCSuite) SetupTest() {
s.participants = unittest.IdentityListFixture(10,
unittest.WithRole(flow.RoleConsensus),
unittest.WithWeight(1),
).ToSkeleton()
).Sort(order.Canonical[flow.Identity]).ToSkeleton()

// signers are a qualified majority at 7
s.signers = s.participants[:7]
Expand Down
2 changes: 1 addition & 1 deletion module/signature/signer_indices_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import (
// 2. for the decoding step, we offer an optimized convenience function to directly
// decode to full identities: Indices --decode--> Identities
func TestEncodeDecodeIdentities(t *testing.T) {
canonicalIdentities := unittest.IdentityListFixture(20).ToSkeleton()
canonicalIdentities := unittest.IdentityListFixture(20).Sort(order.Canonical[flow.Identity]).ToSkeleton()
canonicalIdentifiers := canonicalIdentities.NodeIDs()
for s := 0; s < 20; s++ {
for e := s; e < 20; e++ {
Expand Down
2 changes: 1 addition & 1 deletion state/protocol/badger/validity.go
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ func IsValidRootSnapshotQCs(snap protocol.Snapshot) error {
// validateRootQC performs validation of root QC
// Returns nil on success
func validateRootQC(snap protocol.Snapshot) error {
identities, err := snap.Identities(filter.Adapt(filter.IsAllowedConsensusCommitteeMember))
identities, err := snap.Identities(filter.IsVotingConsensusCommitteeMember)
if err != nil {
return fmt.Errorf("could not get root snapshot identities: %w", err)
}
Expand Down

0 comments on commit 3dd3c4d

Please sign in to comment.