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