github.com/koko1123/flow-go-1@v0.29.6/engine/verification/utils/mocked.go (about) 1 package utils 2 3 import ( 4 "fmt" 5 6 chmodel "github.com/koko1123/flow-go-1/model/chunks" 7 "github.com/koko1123/flow-go-1/model/flow" 8 ) 9 10 // MockAssigner ... 11 type MockAssigner struct { 12 me flow.Identifier 13 isAssigned func(index uint64) bool 14 } 15 16 // NewMockAssigner ... 17 func NewMockAssigner(id flow.Identifier, f func(index uint64) bool) *MockAssigner { 18 return &MockAssigner{me: id, isAssigned: f} 19 } 20 21 // Assign assigns all input chunks to the verifier node 22 func (m *MockAssigner) Assign(result *flow.ExecutionResult, blockID flow.Identifier) (*chmodel.Assignment, error) { 23 if len(result.Chunks) == 0 { 24 return nil, fmt.Errorf("assigner called with empty chunk list") 25 } 26 a := chmodel.NewAssignment() 27 for _, c := range result.Chunks { 28 if m.isAssigned(c.Index) { 29 a.Add(c, flow.IdentifierList{m.me}) 30 } 31 } 32 33 return a, nil 34 }