Documentation ¶
Index ¶
- func ChunkWithIndex(blockID flow.Identifier, index int) *flow.Chunk
- func ContainerBlockFixture(parent *flow.Header, receipts []*flow.ExecutionReceipt) *flow.Block
- func CreateExecutionResult(blockID flow.Identifier, ...) (*flow.ExecutionResult, *chunks.Assignment)
- func EvenChunkIndexAssigner(index uint64, chunkNum int) bool
- func ExecutionResultForkFixture(t *testing.T) (*flow.ExecutionResult, *flow.ExecutionResult, *flow.Collection, *flow.Block)
- func ExtendStateWithFinalizedBlocks(t *testing.T, completeExecutionReceipts CompleteExecutionReceiptList, ...) []*flow.Block
- func FromChunkID(chunkID flow.Identifier) flow.ChunkDataPack
- func MockChunkAssignmentFixture(chunkAssigner *mock.ChunkAssigner, verIds flow.IdentityList, ...) (flow.IdentifierList, flow.IdentifierList)
- func MockLastSealedHeight(state *mockprotocol.State, height uint64)
- func NewVerificationHappyPathTest(t *testing.T, staked bool, blockCount int, eventRepetition int, ...)
- func RespondChunkDataPackRequestImmediately(t *testing.T, completeERs CompleteExecutionReceiptList, ...) bool
- func SetupChunkDataPackProvider(t *testing.T, hub *stub.Hub, exeIdentity *flow.Identity, ...) (*enginemock.GenericNode, *mocknetwork.Engine, *sync.WaitGroup)
- func SetupMockConsensusNode(t *testing.T, log zerolog.Logger, hub *stub.Hub, conIdentity *flow.Identity, ...) (*enginemock.GenericNode, *mocknetwork.Engine, *sync.WaitGroup)
- func WithAssignee(assignee flow.Identifier) func(flow.Identifier, uint64, *chunks.Assignment) *flow.Chunk
- func WithChunks(setAssignees ...func(flow.Identifier, uint64, *chunks.Assignment) *flow.Chunk) func(*flow.ExecutionResult, *chunks.Assignment)
- type ChunkAssignerFunc
- type CompleteExecutionReceipt
- type CompleteExecutionReceiptBuilder
- type CompleteExecutionReceiptBuilderOpt
- func WithChain(chain flow.Chain) CompleteExecutionReceiptBuilderOpt
- func WithChunksCount(count int) CompleteExecutionReceiptBuilderOpt
- func WithCopies(count int) CompleteExecutionReceiptBuilderOpt
- func WithExecutorIDs(executorIDs flow.IdentifierList) CompleteExecutionReceiptBuilderOpt
- func WithResults(count int) CompleteExecutionReceiptBuilderOpt
- type CompleteExecutionReceiptList
- func (c CompleteExecutionReceiptList) ChunkDataResponseOf(t *testing.T, chunkID flow.Identifier) *messages.ChunkDataResponse
- func (c CompleteExecutionReceiptList) ChunkOf(t *testing.T, resultID flow.Identifier, chunkIndex uint64) *flow.Chunk
- func (c CompleteExecutionReceiptList) ReceiptDataOf(t *testing.T, chunkID flow.Identifier) *ExecutionReceiptData
- type ExecutionReceiptData
- func ExecutionReceiptsFromParentBlockFixture(t *testing.T, parent *flow.Header, builder *CompleteExecutionReceiptBuilder) ([]*flow.ExecutionReceipt, []*ExecutionReceiptData, *flow.Header)
- func ExecutionResultFixture(t *testing.T, chunkCount int, chain flow.Chain, refBlkHeader *flow.Header) (*flow.ExecutionResult, *ExecutionReceiptData)
- func ExecutionResultFromParentBlockFixture(t *testing.T, parent *flow.Header, builder *CompleteExecutionReceiptBuilder) (*flow.ExecutionResult, *ExecutionReceiptData)
- type MockChunkDataProviderFunc
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ChunkWithIndex ¶
func ChunkWithIndex(blockID flow.Identifier, index int) *flow.Chunk
func ContainerBlockFixture ¶
ContainerBlockFixture builds and returns a block that contains input execution receipts.
func CreateExecutionResult ¶
func CreateExecutionResult(blockID flow.Identifier, options ...func(result *flow.ExecutionResult, assignments *chunks.Assignment)) (*flow.ExecutionResult, *chunks.Assignment)
func EvenChunkIndexAssigner ¶
EvenChunkIndexAssigner is a helper function that returns true for the even indices in [0, chunkNum-1] It also returns true if the index corresponds to the system chunk.
func ExecutionResultForkFixture ¶ added in v0.23.2
func ExecutionResultForkFixture(t *testing.T) (*flow.ExecutionResult, *flow.ExecutionResult, *flow.Collection, *flow.Block)
ExecutionResultForkFixture creates two conflicting execution results out of the same block ID. Each execution result has two chunks. First chunks of both results are the same, i.e., have same ID. It returns both results, their shared block, and collection corresponding to their first chunk.
func ExtendStateWithFinalizedBlocks ¶
func ExtendStateWithFinalizedBlocks(t *testing.T, completeExecutionReceipts CompleteExecutionReceiptList, state protocol.MutableState) []*flow.Block
ExtendStateWithFinalizedBlocks is a test helper to extend the execution state and return the list of blocks. It receives a list of complete execution receipt fixtures in the form of (R1,1 <- R1,2 <- ... <- C1) <- (R2,1 <- R2,2 <- ... <- C2) <- ..... Where R and C are the reference and container blocks. Reference blocks contain guarantees, and container blocks contain execution receipt for their preceding reference blocks, e.g., C1 contains receipts for R1,1, R1,2, etc. Note: for sake of simplicity we do not include guarantees in the container blocks for now.
func FromChunkID ¶
func FromChunkID(chunkID flow.Identifier) flow.ChunkDataPack
func MockChunkAssignmentFixture ¶
func MockChunkAssignmentFixture(chunkAssigner *mock.ChunkAssigner, verIds flow.IdentityList, completeERs CompleteExecutionReceiptList, isAssigned ChunkAssignerFunc) (flow.IdentifierList, flow.IdentifierList)
MockChunkAssignmentFixture is a test helper that mocks a chunk assigner for a set of verification nodes for the execution results in the given complete execution receipts, and based on the given chunk assigner function.
It returns the list of chunk locator ids assigned to the input verification nodes, as well as the list of their chunk IDs. All verification nodes are assigned the same chunks.
func MockLastSealedHeight ¶
func MockLastSealedHeight(state *mockprotocol.State, height uint64)
MockLastSealedHeight mocks the protocol state for the specified last sealed height.
func NewVerificationHappyPathTest ¶ added in v0.17.1
func NewVerificationHappyPathTest(t *testing.T, staked bool, blockCount int, eventRepetition int, verCollector module.VerificationMetrics, mempoolCollector module.MempoolMetrics, retry int, ops ...CompleteExecutionReceiptBuilderOpt)
func RespondChunkDataPackRequestImmediately ¶ added in v0.17.6
func RespondChunkDataPackRequestImmediately(t *testing.T, completeERs CompleteExecutionReceiptList, chunkID flow.Identifier, verID flow.Identifier, con network.Conduit) bool
RespondChunkDataPackRequestImmediately immediately qualifies a chunk data request for reply by chunk data provider.
func SetupChunkDataPackProvider ¶
func SetupChunkDataPackProvider(t *testing.T, hub *stub.Hub, exeIdentity *flow.Identity, participants flow.IdentityList, chainID flow.ChainID, completeERs CompleteExecutionReceiptList, assignedChunkIDs flow.IdentifierList, provider MockChunkDataProviderFunc) (*enginemock.GenericNode, *mocknetwork.Engine, *sync.WaitGroup)
SetupChunkDataPackProvider creates and returns an execution node that only has a chunk data pack provider engine.
The mock chunk provider engine replies the chunk back requests by invoking the injected provider method. All chunk data pack requests should come from a verification node, and should has one of the assigned chunk IDs. Otherwise, it fails the test.
func SetupMockConsensusNode ¶
func SetupMockConsensusNode(t *testing.T, log zerolog.Logger, hub *stub.Hub, conIdentity *flow.Identity, verIdentities flow.IdentityList, othersIdentity flow.IdentityList, completeERs CompleteExecutionReceiptList, chainID flow.ChainID, assignedChunkIDs flow.IdentifierList) (*enginemock.GenericNode, *mocknetwork.Engine, *sync.WaitGroup)
SetupMockConsensusNode creates and returns a mock consensus node (conIdentity) and its registered engine in the network (hub). It mocks the process method of the consensus engine to receive a message from a certain verification node (verIdentity) evaluates whether it is a result approval about an assigned chunk to that verifier node.
func WithAssignee ¶
func WithAssignee(assignee flow.Identifier) func(flow.Identifier, uint64, *chunks.Assignment) *flow.Chunk
func WithChunks ¶
func WithChunks(setAssignees ...func(flow.Identifier, uint64, *chunks.Assignment) *flow.Chunk) func(*flow.ExecutionResult, *chunks.Assignment)
Types ¶
type ChunkAssignerFunc ¶
type CompleteExecutionReceipt ¶
type CompleteExecutionReceipt struct { ContainerBlock *flow.Block // block that contains execution receipt of reference block // TODO: this is a temporary field to support finder engine logic // It should be removed once we replace finder engine. Receipts []*flow.ExecutionReceipt // copy of execution receipts in container block ReceiptsData []*ExecutionReceiptData // execution receipts data of the container block }
CompleteExecutionReceipt is a test helper struct that represents a container block accompanied with all data required to verify its execution receipts. TODO update this as needed based on execution requirements
func CompleteExecutionReceiptChainFixture ¶
func CompleteExecutionReceiptChainFixture(t *testing.T, root *flow.Header, count int, opts ...CompleteExecutionReceiptBuilderOpt) []*CompleteExecutionReceipt
CompleteExecutionReceiptChainFixture is a test fixture that creates a chain of blocks of size `count`. The chain is in the form of root <- R1,1 <- R1,2 <- ... <- C1 <- R2,1 <- R2,2 <- ... <- C2 <- ... In this chain R refers to reference blocks that contain guarantees. C refers to a container block that contains an execution receipt for its preceding reference blocks. e.g., C1 contains an execution receipt for R1,1, R1,2, etc, and C2 contains a receipt for R2,1, R2,2, etc. For sake of simplicity and test, container blocks (i.e., C) do not contain any guarantee.
It returns a slice of complete execution receipt fixtures that contains a container block as well as all data to verify its contained receipts.
func CompleteExecutionReceiptFixture ¶
func CompleteExecutionReceiptFixture(t *testing.T, chunks int, chain flow.Chain, root *flow.Header) *CompleteExecutionReceipt
CompleteExecutionReceiptFixture returns complete execution receipt with an execution receipt referencing the block collections.
chunks determines the number of chunks inside each receipt. The output is an execution result with chunks+1 chunks, where the last chunk accounts for the system chunk. TODO: remove this function once new verification architecture is in place.
type CompleteExecutionReceiptBuilder ¶
type CompleteExecutionReceiptBuilder struct {
// contains filtered or unexported fields
}
CompleteExecutionReceiptBuilder is a test helper struct that specifies the parameters to build a CompleteExecutionReceipt.
type CompleteExecutionReceiptBuilderOpt ¶
type CompleteExecutionReceiptBuilderOpt func(builder *CompleteExecutionReceiptBuilder)
func WithChain ¶
func WithChain(chain flow.Chain) CompleteExecutionReceiptBuilderOpt
func WithChunksCount ¶
func WithChunksCount(count int) CompleteExecutionReceiptBuilderOpt
func WithCopies ¶
func WithCopies(count int) CompleteExecutionReceiptBuilderOpt
func WithExecutorIDs ¶
func WithExecutorIDs(executorIDs flow.IdentifierList) CompleteExecutionReceiptBuilderOpt
func WithResults ¶
func WithResults(count int) CompleteExecutionReceiptBuilderOpt
type CompleteExecutionReceiptList ¶
type CompleteExecutionReceiptList []*CompleteExecutionReceipt
func (CompleteExecutionReceiptList) ChunkDataResponseOf ¶
func (c CompleteExecutionReceiptList) ChunkDataResponseOf(t *testing.T, chunkID flow.Identifier) *messages.ChunkDataResponse
ChunkDataResponseOf is a test helper method that returns a chunk data pack response message for the specified chunk ID that should belong to this complete execution receipt list.
It fails the test if no chunk with specified chunk ID is found in this complete execution receipt list.
func (CompleteExecutionReceiptList) ChunkOf ¶
func (c CompleteExecutionReceiptList) ChunkOf(t *testing.T, resultID flow.Identifier, chunkIndex uint64) *flow.Chunk
ChunkOf is a test helper method that returns the chunk of the specified index from the specified result that should belong to this complete execution receipt list.
It fails the test if no execution result with the specified identifier is found in this complete execution receipt list.
func (CompleteExecutionReceiptList) ReceiptDataOf ¶
func (c CompleteExecutionReceiptList) ReceiptDataOf(t *testing.T, chunkID flow.Identifier) *ExecutionReceiptData
ReceiptDataOf is a test helper method that returns the receipt data of the specified chunk ID that should belong to this complete execution receipt list.
It fails the test if no chunk with specified chunk ID is found in this complete execution receipt list.
type ExecutionReceiptData ¶
type ExecutionReceiptData struct { ReferenceBlock *flow.Block // block that execution receipt refers to ChunkDataPacks []*flow.ChunkDataPack SpockSecrets [][]byte }
ExecutionReceiptData is a test helper struct that represents all data required to verify the result of an execution receipt.
func ExecutionReceiptsFromParentBlockFixture ¶
func ExecutionReceiptsFromParentBlockFixture(t *testing.T, parent *flow.Header, builder *CompleteExecutionReceiptBuilder) ( []*flow.ExecutionReceipt, []*ExecutionReceiptData, *flow.Header)
ExecutionReceiptsFromParentBlockFixture creates a chain of receipts from a parent block.
By default each result refers to a distinct reference block, and it extends the block chain after generating each result (i.e., for the next result).
Each result may appear in more than one receipt depending on the builder parameters.
func ExecutionResultFixture ¶
func ExecutionResultFixture(t *testing.T, chunkCount int, chain flow.Chain, refBlkHeader *flow.Header) (*flow.ExecutionResult, *ExecutionReceiptData)
ExecutionResultFixture is a test helper that returns an execution result for the reference block header as well as the execution receipt data for that result.
func ExecutionResultFromParentBlockFixture ¶
func ExecutionResultFromParentBlockFixture(t *testing.T, parent *flow.Header, builder *CompleteExecutionReceiptBuilder) (*flow.ExecutionResult, *ExecutionReceiptData)
ExecutionResultFromParentBlockFixture is a test helper that creates a child (reference) block from the parent, as well as an execution for it.
type MockChunkDataProviderFunc ¶ added in v0.17.6
type MockChunkDataProviderFunc func(*testing.T, CompleteExecutionReceiptList, flow.Identifier, flow.Identifier, network.Conduit) bool
MockChunkDataProviderFunc is a test helper function encapsulating the logic of whether to reply a chunk data pack request.
func RespondChunkDataPackRequestAfterNTrials ¶ added in v0.17.6
func RespondChunkDataPackRequestAfterNTrials(n int) MockChunkDataProviderFunc
RespondChunkDataPackRequestAfterNTrials only qualifies a chunk data request for reply by chunk data provider after n times.