-
Notifications
You must be signed in to change notification settings - Fork 178
/
fixtures.go
57 lines (53 loc) · 2.07 KB
/
fixtures.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
52
53
54
55
56
57
package unittest
import (
"github.com/onflow/flow-go/engine/execution"
"github.com/onflow/flow-go/engine/execution/state/delta"
"github.com/onflow/flow-go/model/flow"
"github.com/onflow/flow-go/module/mempool/entity"
"github.com/onflow/flow-go/utils/unittest"
)
func StateInteractionsFixture() *delta.SpockSnapshot {
return delta.NewView(nil).Interactions()
}
func ComputationResultFixture(collectionsSignerIDs [][]flow.Identifier) *execution.ComputationResult {
stateViews := make([]*delta.SpockSnapshot, len(collectionsSignerIDs)+1) //+1 for system chunk
stateCommitments := make([]flow.StateCommitment, len(collectionsSignerIDs)+1)
eventHashes := make([]flow.Identifier, len(collectionsSignerIDs)+1)
proofs := make([][]byte, len(collectionsSignerIDs)+1)
for i := 0; i < len(collectionsSignerIDs)+1; i++ {
stateViews[i] = StateInteractionsFixture()
stateCommitments[i] = unittest.StateCommitmentFixture()
eventHashes[i] = unittest.IdentifierFixture()
proofs[i] = unittest.RandomBytes(2)
}
return &execution.ComputationResult{
ExecutableBlock: unittest.ExecutableBlockFixture(collectionsSignerIDs),
StateSnapshots: stateViews,
StateCommitments: stateCommitments,
EventsHashes: eventHashes,
Proofs: proofs,
}
}
func ComputationResultForBlockFixture(completeBlock *entity.ExecutableBlock) *execution.ComputationResult {
n := len(completeBlock.CompleteCollections) + 1
stateViews := make([]*delta.SpockSnapshot, n)
stateCommitments := make([]flow.StateCommitment, n)
proofs := make([][]byte, n)
events := make([]flow.EventsList, n)
eventHashes := make([]flow.Identifier, n)
for i := 0; i < n; i++ {
stateViews[i] = StateInteractionsFixture()
stateCommitments[i] = *completeBlock.StartState
proofs[i] = unittest.RandomBytes(6)
events[i] = make(flow.EventsList, 0)
eventHashes[i] = unittest.IdentifierFixture()
}
return &execution.ComputationResult{
ExecutableBlock: completeBlock,
StateSnapshots: stateViews,
StateCommitments: stateCommitments,
Proofs: proofs,
Events: events,
EventsHashes: eventHashes,
}
}