github.com/onflow/flow-go@v0.35.7-crescendo-preview.23-atree-inlining/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/onflow/flow-go/model/bootstrap"
     9  	"github.com/onflow/flow-go/model/cluster"
    10  	"github.com/onflow/flow-go/model/flow"
    11  	"github.com/onflow/flow-go/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  	orderedParticipants := model.ToIdentityList(participants).Sort(flow.Canonical[flow.Identity]).ToSkeleton()
    36  	_, err := GenerateClusterRootQC(participants, orderedParticipants, &clusterBlock)
    37  	require.NoError(t, err)
    38  }
    39  
    40  func createClusterParticipants(t *testing.T, n int) []model.NodeInfo {
    41  	ids := unittest.IdentityListFixture(n, unittest.WithRole(flow.RoleCollection))
    42  
    43  	networkKeys := unittest.NetworkingKeys(n)
    44  	stakingKeys := unittest.StakingKeys(n)
    45  
    46  	participants := make([]model.NodeInfo, n)
    47  	for i, id := range ids {
    48  		participants[i] = model.NewPrivateNodeInfo(
    49  			id.NodeID,
    50  			id.Role,
    51  			id.Address,
    52  			id.InitialWeight,
    53  			networkKeys[i],
    54  			stakingKeys[i],
    55  		)
    56  	}
    57  
    58  	return participants
    59  }