github.com/koko1123/flow-go-1@v0.29.6/engine/execution/state/unittest/fixtures.go (about) 1 package unittest 2 3 import ( 4 "github.com/koko1123/flow-go-1/engine/execution" 5 "github.com/koko1123/flow-go-1/engine/execution/state/delta" 6 "github.com/koko1123/flow-go-1/model/flow" 7 "github.com/koko1123/flow-go-1/module/mempool/entity" 8 "github.com/koko1123/flow-go-1/utils/unittest" 9 "github.com/onflow/flow-go/crypto" 10 ) 11 12 func StateInteractionsFixture() *delta.SpockSnapshot { 13 return delta.NewView(nil).Interactions() 14 } 15 16 func ComputationResultFixture(collectionsSignerIDs [][]flow.Identifier) *execution.ComputationResult { 17 block := unittest.ExecutableBlockFixture(collectionsSignerIDs) 18 startState := unittest.StateCommitmentFixture() 19 block.StartState = &startState 20 21 return ComputationResultForBlockFixture(block) 22 } 23 24 func ComputationResultForBlockFixture( 25 completeBlock *entity.ExecutableBlock, 26 ) *execution.ComputationResult { 27 numChunks := len(completeBlock.CompleteCollections) + 1 28 stateViews := make([]*delta.SpockSnapshot, numChunks) 29 stateCommitments := make([]flow.StateCommitment, numChunks) 30 proofs := make([][]byte, numChunks) 31 events := make([]flow.EventsList, numChunks) 32 eventHashes := make([]flow.Identifier, numChunks) 33 spockHashes := make([]crypto.Signature, numChunks) 34 for i := 0; i < numChunks; i++ { 35 stateViews[i] = StateInteractionsFixture() 36 stateCommitments[i] = *completeBlock.StartState 37 proofs[i] = unittest.RandomBytes(6) 38 events[i] = make(flow.EventsList, 0) 39 eventHashes[i] = unittest.IdentifierFixture() 40 } 41 return &execution.ComputationResult{ 42 TransactionResultIndex: make([]int, numChunks), 43 ExecutableBlock: completeBlock, 44 StateSnapshots: stateViews, 45 StateCommitments: stateCommitments, 46 Proofs: proofs, 47 Events: events, 48 EventsHashes: eventHashes, 49 SpockSignatures: spockHashes, 50 } 51 }