github.com/onflow/flow-go@v0.35.7-crescendo-preview.23-atree-inlining/utils/unittest/incorporated_results_seals.go (about) 1 package unittest 2 3 import "github.com/onflow/flow-go/model/flow" 4 5 var IncorporatedResultSeal incorporatedResultSealFactory 6 7 type incorporatedResultSealFactory struct{} 8 9 func (f *incorporatedResultSealFactory) Fixture(opts ...func(*flow.IncorporatedResultSeal)) *flow.IncorporatedResultSeal { 10 result := ExecutionResultFixture() 11 header := BlockHeaderFixture() 12 incorporatedBlockID := header.ID() 13 14 ir := IncorporatedResult.Fixture( 15 IncorporatedResult.WithResult(result), 16 IncorporatedResult.WithIncorporatedBlockID(incorporatedBlockID), 17 ) 18 seal := Seal.Fixture(Seal.WithResult(result)) 19 20 irSeal := &flow.IncorporatedResultSeal{ 21 IncorporatedResult: ir, 22 Seal: seal, 23 Header: header, 24 } 25 26 for _, apply := range opts { 27 apply(irSeal) 28 } 29 return irSeal 30 } 31 32 func (f *incorporatedResultSealFactory) Fixtures(n int) []*flow.IncorporatedResultSeal { 33 seals := make([]*flow.IncorporatedResultSeal, 0, n) 34 for i := 0; i < n; i++ { 35 seals = append(seals, IncorporatedResultSeal.Fixture()) 36 } 37 return seals 38 } 39 40 func (f *incorporatedResultSealFactory) WithResult(result *flow.ExecutionResult) func(*flow.IncorporatedResultSeal) { 41 return func(irSeal *flow.IncorporatedResultSeal) { 42 IncorporatedResult.WithResult(result)(irSeal.IncorporatedResult) 43 Seal.WithResult(result)(irSeal.Seal) 44 } 45 } 46 47 func (f *incorporatedResultSealFactory) WithIncorporatedBlockID(id flow.Identifier) func(*flow.IncorporatedResultSeal) { 48 return func(irSeal *flow.IncorporatedResultSeal) { 49 IncorporatedResult.WithIncorporatedBlockID(id)(irSeal.IncorporatedResult) 50 } 51 }