-
Notifications
You must be signed in to change notification settings - Fork 179
/
fixtures.go
51 lines (46 loc) · 1.75 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
package unittest
import (
"github.com/onflow/flow-go/crypto"
"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 {
block := unittest.ExecutableBlockFixture(collectionsSignerIDs)
startState := unittest.StateCommitmentFixture()
block.StartState = &startState
return ComputationResultForBlockFixture(block)
}
func ComputationResultForBlockFixture(
completeBlock *entity.ExecutableBlock,
) *execution.ComputationResult {
numChunks := len(completeBlock.CompleteCollections) + 1
stateViews := make([]*delta.SpockSnapshot, numChunks)
stateCommitments := make([]flow.StateCommitment, numChunks)
proofs := make([][]byte, numChunks)
events := make([]flow.EventsList, numChunks)
eventHashes := make([]flow.Identifier, numChunks)
spockHashes := make([]crypto.Signature, numChunks)
for i := 0; i < numChunks; 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{
TransactionResultIndex: make([]int, numChunks),
ExecutableBlock: completeBlock,
StateSnapshots: stateViews,
StateCommitments: stateCommitments,
Proofs: proofs,
Events: events,
EventsHashes: eventHashes,
SpockSignatures: spockHashes,
}
}