github.com/koko1123/flow-go-1@v0.29.6/cmd/bootstrap/run/cluster_qc_test.go (about) 1 package run 2 3 import ( 4 "testing" 5 6 "github.com/stretchr/testify/require" 7 8 model "github.com/koko1123/flow-go-1/model/bootstrap" 9 "github.com/koko1123/flow-go-1/model/cluster" 10 "github.com/koko1123/flow-go-1/model/flow" 11 "github.com/koko1123/flow-go-1/utils/unittest" 12 ) 13 14 func TestGenerateClusterRootQC(t *testing.T) { 15 participants := createClusterParticipants(t, 3) 16 17 block := unittest.BlockFixture() 18 19 block.Payload.Seals = nil 20 block.Payload.Guarantees = nil 21 block.Header.ParentID = flow.ZeroID 22 block.Header.View = 3 23 block.Header.Height = 0 24 block.Header.PayloadHash = block.Payload.Hash() 25 26 clusterBlock := cluster.Block{ 27 Header: &flow.Header{ 28 ParentID: flow.ZeroID, 29 View: 42, 30 }, 31 } 32 payload := cluster.EmptyPayload(flow.ZeroID) 33 clusterBlock.SetPayload(payload) 34 35 _, err := GenerateClusterRootQC(participants, model.ToIdentityList(participants), &clusterBlock) 36 require.NoError(t, err) 37 } 38 39 func createClusterParticipants(t *testing.T, n int) []model.NodeInfo { 40 ids := unittest.IdentityListFixture(n, unittest.WithRole(flow.RoleCollection)) 41 42 networkKeys := unittest.NetworkingKeys(n) 43 stakingKeys := unittest.StakingKeys(n) 44 45 participants := make([]model.NodeInfo, n) 46 for i, id := range ids { 47 participants[i] = model.NewPrivateNodeInfo( 48 id.NodeID, 49 id.Role, 50 id.Address, 51 id.Weight, 52 networkKeys[i], 53 stakingKeys[i], 54 ) 55 } 56 57 return participants 58 }