github.com/onflow/flow-go@v0.35.7-crescendo-preview.23-atree-inlining/utils/unittest/identities.go (about)

     1  package unittest
     2  
     3  import (
     4  	"github.com/onflow/flow-go/model/flow"
     5  	module "github.com/onflow/flow-go/module/mock"
     6  )
     7  
     8  // CreateNParticipantsWithMyRole creates a list of identities from given roles
     9  func CreateNParticipantsWithMyRole(myRole flow.Role, otherRoles ...flow.Role) (
    10  	flow.IdentityList, flow.Identifier, *module.Local) {
    11  	// initialize the paramaters
    12  	// participants := IdentityFixture(myRole)
    13  	participants := make(flow.IdentityList, 0)
    14  	myIdentity := IdentityFixture(WithRole(myRole))
    15  	myID := myIdentity.ID()
    16  	participants = append(participants, myIdentity)
    17  	for _, role := range otherRoles {
    18  		id := IdentityFixture(WithRole(role))
    19  		participants = append(participants, id)
    20  	}
    21  
    22  	// set up local module mock
    23  	me := &module.Local{}
    24  	me.On("NodeID").Return(
    25  		func() flow.Identifier {
    26  			return myID
    27  		},
    28  	)
    29  	return participants, myID, me
    30  }