Skip to content

Commit

Permalink
fix cluster tests
Browse files Browse the repository at this point in the history
  • Loading branch information
zhangchiqing committed Mar 29, 2022
1 parent 3cb260e commit d5bc29f
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 14 deletions.
4 changes: 2 additions & 2 deletions cmd/util/cmd/epochs/cmd/reset_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ func TestReset_LocalSnapshot(t *testing.T) {
unittest.RunWithTempDir(t, func(bootDir string) {

// create a root snapshot
rootSnapshot := unittest.RootSnapshotFixture(unittest.IdentityListFixture(10))
rootSnapshot := unittest.RootSnapshotFixture(unittest.IdentityListFixture(10, unittest.WithAllRoles()))

// write snapshot to correct path in bootDir
err := writeRootSnapshot(bootDir, rootSnapshot)
Expand Down Expand Up @@ -62,7 +62,7 @@ func TestReset_LocalSnapshot(t *testing.T) {
unittest.RunWithTempDir(t, func(bootDir string) {

// create a root snapshot
rootSnapshot := unittest.RootSnapshotFixture(unittest.IdentityListFixture(10))
rootSnapshot := unittest.RootSnapshotFixture(unittest.IdentityListFixture(10, unittest.WithAllRoles()))

// write snapshot to correct path in bootDir
err := writeRootSnapshot(bootDir, rootSnapshot)
Expand Down
2 changes: 1 addition & 1 deletion engine/consensus/sealing/engine_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ func (s *SealingEngineSuite) SetupTest() {
},
)

rootHeader, err := unittest.RootSnapshotFixture(unittest.IdentityListFixture(5)).Head()
rootHeader, err := unittest.RootSnapshotFixture(unittest.IdentityListFixture(5, unittest.WithAllRoles())).Head()
require.NoError(s.T(), err)

s.engine = &Engine{
Expand Down
4 changes: 2 additions & 2 deletions model/flow/sealing_segment_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ func (suite *SealingSegmentSuite) TestBuild_MultipleFinalBlockSeals() {
// TestBuild_RootSegment tests we can build a valid root sealing segment.
func (suite *SealingSegmentSuite) TestBuild_RootSegment() {

root, result, seal := unittest.BootstrapFixture(unittest.IdentityListFixture(5))
root, result, seal := unittest.BootstrapFixture(unittest.IdentityListFixture(5, unittest.WithAllRoles()))
suite.sealsByBlockID[root.ID()] = seal
suite.addResult(result)
err := suite.builder.AddBlock(root)
Expand All @@ -277,7 +277,7 @@ func (suite *SealingSegmentSuite) TestBuild_RootSegment() {
// a single-block sealing segment with a block view not equal to 0.
func (suite *SealingSegmentSuite) TestBuild_RootSegmentWrongView() {

root, result, seal := unittest.BootstrapFixture(unittest.IdentityListFixture(5))
root, result, seal := unittest.BootstrapFixture(unittest.IdentityListFixture(5, unittest.WithAllRoles()))
root.Header.View = 10 // invalid root block view
suite.sealsByBlockID[root.ID()] = seal
suite.addResult(result)
Expand Down
4 changes: 2 additions & 2 deletions state/protocol/inmem/encodable_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import (
// in particular with differing public key implementations
func TestEncodeDecode(t *testing.T) {

participants := unittest.IdentityListFixture(10)
participants := unittest.IdentityListFixture(10, unittest.WithAllRoles())
// add a partner, which has its key represented as an encodable wrapper
// type rather than the direct crypto type
partner := unittest.IdentityFixture(unittest.WithKeys, func(identity *flow.Identity) {
Expand All @@ -41,7 +41,7 @@ func TestEncodeDecode(t *testing.T) {
// TestStrippedEncodeDecode tests that the protocol state snapshot can be encoded to JSON skipping the network address
// and decoded back successfully
func TestStrippedEncodeDecode(t *testing.T) {
participants := unittest.IdentityListFixture(10)
participants := unittest.IdentityListFixture(10, unittest.WithAllRoles())
initialSnapshot := unittest.RootSnapshotFixture(participants)

// encode the snapshot
Expand Down
4 changes: 2 additions & 2 deletions state/protocol/util_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@ import (

func TestIsSporkRootSnapshot(t *testing.T) {
t.Run("spork root", func(t *testing.T) {
snapshot := unittest.RootSnapshotFixture(unittest.IdentityListFixture(10))
snapshot := unittest.RootSnapshotFixture(unittest.IdentityListFixture(10, unittest.WithAllRoles()))
isSporkRoot, err := protocol.IsSporkRootSnapshot(snapshot)
require.NoError(t, err)
assert.True(t, isSporkRoot)
})

t.Run("other snapshot", func(t *testing.T) {
snapshot := unittest.RootSnapshotFixture(unittest.IdentityListFixture(10))
snapshot := unittest.RootSnapshotFixture(unittest.IdentityListFixture(10, unittest.WithAllRoles()))
snapshot.Encodable().SealingSegment.Blocks = unittest.BlockFixtures(5)
isSporkRoot, err := protocol.IsSporkRootSnapshot(snapshot)
require.NoError(t, err)
Expand Down
5 changes: 0 additions & 5 deletions utils/unittest/fixtures.go
Original file line number Diff line number Diff line change
Expand Up @@ -1035,11 +1035,6 @@ func IdentityListFixture(n int, opts ...func(*flow.Identity)) flow.IdentityList
for i := 0; i < n; i++ {
identity := IdentityFixture()
identity.Address = fmt.Sprintf("%x@flow.com:1234", identity.NodeID)
// ensure to have at least one collection node to create collection cluster
// otherwise, the assignment would have empty cluster
if i%4 == 3 {
identity.Role = flow.RoleCollection
}
for _, opt := range opts {
opt(identity)
}
Expand Down

0 comments on commit d5bc29f

Please sign in to comment.