fixtures

package
v0.43.1-access-memory-... Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 29, 2025 License: AGPL-3.0 Imports: 26 Imported by: 0

README

Flow Go Fixtures Module

A context-aware test fixture generation system for Flow Go that provides deterministic, reproducible test data with shared randomness across all generators. This module replaces the standalone fixture functions with a comprehensive suite of generator objects.

Table of Contents

  1. Overview
  2. Reproducibility
  3. Concurrency
  4. Module Structure
  5. Quick Start
  6. Core Concepts
  7. Generator Suite
  8. Available Generators
  9. Migration Guide
  10. Testing
  11. Architecture

Overview

The fixtures module replaces standalone fixture functions with a suite of context-aware generator objects that:

  • Support deterministic results: All generators use the same RNG, which allows for reproducible deterministic data using a static seed.
  • Complete Objects: All generators produce complete and realistic model objects.
  • Provide context awareness: Generators can create related data that makes sense together
  • Enable easy extension: Simple and consistent API makes exending or adding new generators straight forward.
  • Improve test reproducibility: By reusing the same seed from a failed test, you can reproduce exactly the same inputs.

Reproducibility

This suite is designed to allow producing complete data types with reproducible random data. This is critical for certain test scenarios like testing hash functions or data serializers. In most cases, deterministic data is not strictly require.

However, it is very useful to be able to replay a failed test that used random data. Imagine the scenario where a test failed in CI due to some corner case bug with data handling. Since the data was randomly generated, it's extrememly difficult to reverse engineer the inputs that caused the failure. With deterministic test fixtures, we could grab the random seed used by the test from the logs, then rerun the test locally with the exact same test data.

This does require that some extra care is taken while designing the tests, especially any tests that use multiple goroutines, or any tests that run subtests with Parallel(). See Concurrency.

Concurrency

The generator suite does support concurrent usage, but it is discouraged to ensure that tests remain reproducible. Any time that the main suite or any generator are used within different goroutines or parallel subtests, the specific order that fixtures are produced with vary depending on the go scheduler. The order a fixture is generated determines the random data provided by the PRNG, thus if fixtures are produced concurrently, their output will not be deterministic!

Best Practice

To support using concurrency within your tests AND get deterministic random fixtures, you need to follow these best practices:

  1. Always use a single GeneratorSuite per test. This ensures you can replay the test individually, and allows for tests to be run in parallel without losing support for deterministic fixtures.
  2. Always generate all fixture data before executing any concurrent logic.
  3. Never generate any fixtures outside of the test's main goroutine.

It is fine to share a GeneratorSuite between subtests so long as they are not marked Parallel(). It is also fine to use a GeneratorSuite within a test suite since suite tests do not support parallelism.

Module Structure

The fixtures module is organized as follows:

utils/unittest/fixtures/
├── README.md                                    # This documentation
├── generators_test.go                           # Test suite
├── generator.go                                 # Core GeneratorSuite and options
├── util.go                                      # Utility functions
├── random.go                                    # RandomGenerator implementation
├── *Core Data Types*
├── identifier.go                                # Identifier generator
├── signature.go                                 # Signature generator
├── address.go                                   # Address generator
├── time.go                                      # Time generator
├── *Block Components*
├── block_header.go                              # Block header generator
├── block.go                                     # Block generator
├── payload.go                                   # Block payload generator
├── seal.go                                      # Block seal generator
├── *Consensus Components*
├── quorum_certificate.go                        # Quorum certificate generator
├── timeout_certificate.go                       # Timeout certificate generator
├── signer_indices.go                            # Signer indices generator
├── *Execution Components*
├── execution_result.go                          # Execution result generator
├── execution_receipt.go                         # Execution receipt generator
├── chunk.go                                     # Execution chunk generator
├── chunk_execution_data.go                      # Chunk execution data generator
├── block_execution_data.go                      # Block execution data generator
├── *Transaction Components*
├── transaction.go                               # Transaction generator
├── collection.go                                # Collection generator
├── collection_guarantee.go                      # Collection guarantee generator
├── transaction_result.go                        # Transaction result generator
├── transaction_signature.go                     # Transaction signature generator
├── proposal_key.go                              # Proposal key generator
├── *Events*
├── event.go                                     # Event generator
├── event_type.go                                # Event type generator
├── service_event.go                             # Service event generator
├── service_event_epoch_setup.go                 # Epoch setup service event generator
├── service_event_epoch_commit.go                # Epoch commit service event generator
├── service_event_epoch_recover.go               # Epoch recover service event generator
├── service_event_version_beacon.go              # Version beacon service event generator
├── service_event_protocol_state_version_upgrade.go # Protocol state version upgrade generator
├── service_event_set_epoch_extension_view_count.go # Set epoch extension view count generator
├── service_event_eject_node.go                  # Eject node service event generator
├── *Ledger Components*
├── trie_update.go                               # Trie update generator
├── ledger_path.go                               # Ledger path generator
├── ledger_payload.go                            # Ledger payload generator
├── ledger_value.go                              # Ledger value generator
├── state_commitment.go                          # State commitment generator
├── *Cryptographic Components*
├── crypto.go                                    # Cryptographic generator
├── aggregated_signature.go                      # Aggregated signature generator
└── *Identity Components*
└── identity.go                                  # Identity generator

Quick Start

Import and Create Suite
import (
    "github.com/onflow/flow-go/utils/unittest/fixtures"
)

// Create suite with random seed
suite := fixtures.NewGeneratorSuite(t)

// Create suite with specific seed for deterministic reproducible results
suite := fixtures.NewGeneratorSuite(fixtures.WithSeed(12345))
Basic Usage Examples
// Generate a block header
header := suite.Headers().Fixture()

// Generate an identifier
id := suite.Identifiers().Fixture()

// Generate a collection with 3 transactions
collection := suite.Collections().Fixture(3)

// Generate events for a transaction
txID := suite.Identifiers().Fixture()
events := suite.Events().ForTransaction(txID, 0, 3)

Core Concepts

Generator Suite

The GeneratorSuite is the central object that:

  • Manages a shared random number generator
  • Provides access to specialized generators
  • Ensures consistent randomness across all generators
Options Pattern

Most generators use an options pattern for configuration. This is an example using the default Header options factory:

// Example: Configure a block header
header := suite.Headers().Fixture(
    Header.WithHeight(100),
    Header.WithView(200),
)

Alternatively, you can use the generator itself as the factory:

// Example: Configure a block header
headerGen := suite.Headers()
header := headerGen.Fixture(
    headerGen.WithHeight(100),
    headerGen.WithView(200),
)

Using typed options allows us to namepace the options by type, avoiding name conflicts for similar options.

Error Handling

Any generators that can produce an error, check it using fixtures.NoError(err) which panics if an error is encountered.

// No error handling needed - failures will panic
result := suite.TransactionResults().Fixture()

Generator Suite

Constructor Options
// No options: Use random seed
suite := fixtures.NewGeneratorSuite(t)

// WithSeed(seed int64): Set specific seed for deterministic results
suite := fixtures.NewGeneratorSuite(fixtures.WithSeed(42))
Core Methods
// Access the random generator
random := suite.Random()

// Generate random bytes
bytes := random.RandomBytes(32)

// Generate random string
str := random.RandomString(16)
Available Generators
Generator Method Purpose
Core Data Types
Block Headers Headers() Generate block headers with proper relationships
Blocks Blocks() Generate complete blocks with headers and payloads
Identifiers Identifiers() Generate flow identifiers
Signatures Signatures() Generate cryptographic signatures
Addresses Addresses() Generate flow addresses
Time Time() Generate [time.Time] values
Consensus Components
Quorum Certificates QuorumCertificates() Generate quorum certificates
Quorum Certificates with Signer IDs QuorumCertificatesWithSignerIDs() Generate quorum certificates with signer IDs
Timeout Certificates TimeoutCertificates() Generate timeout certificates
Signer Indices SignerIndices() Generate signer index arrays
Execution Components
Execution Results ExecutionResults() Generate execution results
Execution Receipts ExecutionReceipts() Generate execution receipts
Chunks Chunks() Generate execution chunks
Chunk Execution Data ChunkExecutionDatas() Generate chunk execution data
Block Execution Data BlockExecutionDatas() Generate block execution data
Block Execution Data Entities BlockExecutionDataEntities() Generate block execution data entities
Transaction Components
Transactions Transactions() Generate transaction bodies
Collections Collections() Generate collections of transactions
Collection Guarantees CollectionGuarantees() Generate collection guarantees
Transaction Results TransactionResults() Generate transaction results
Light Transaction Results LightTransactionResults() Generate light transaction results
Transaction Signatures TransactionSignatures() Generate transaction signatures
Proposal Keys ProposalKeys() Generate proposal keys
Block Components
Payloads Payloads() Generate block payloads
Seals Seals() Generate block seals
Events
Events Events() Generate events with encoding support
Event Types EventTypes() Generate event types
Service Events ServiceEvents() Generate service events
Epoch Setups EpochSetups() Generate epoch setup service events
Epoch Commits EpochCommits() Generate epoch commit service events
Epoch Recovers EpochRecovers() Generate epoch recover service events
Version Beacons VersionBeacons() Generate version beacon service events
Protocol State Version Upgrades ProtocolStateVersionUpgrades() Generate protocol state version upgrade service events
Set Epoch Extension View Counts SetEpochExtensionViewCounts() Generate set epoch extension view count service events
Eject Nodes EjectNodes() Generate eject node service events
Ledger Components
Trie Updates TrieUpdates() Generate ledger trie updates
Ledger Paths LedgerPaths() Generate ledger paths
Ledger Payloads LedgerPayloads() Generate ledger payloads
Ledger Values LedgerValues() Generate ledger values
State Commitments StateCommitments() Generate state commitments
Cryptographic Components
Crypto Crypto() Generate cryptographic keys and signatures
Aggregated Signatures AggregatedSignatures() Generate aggregated signatures
Identity Components
Identities Identities() Generate flow identities with cryptographic keys

Generator Documentation

Random Generator

The RandomGenerator provides consistent random value generation for all other generators. It exposes all methods from *rand.Rand and provides additional convenience methods for common use cases.

Core Methods:

  • RandomBytes(n int): Generates n random bytes
  • RandomString(length uint): Generates a random string of specified length
  • Uint32(): Generates a random uint32
  • Uint64(): Generates a random uint64
  • Int31(): Generates a random int32
  • Int63(): Generates a random int64
  • Intn(n int): Generates a random int in the range [0, n)

Unsigned Integer Methods (n > 0 required):

  • Uintn(n uint): Generates a random uint strictly less than n
  • Uint32n(n uint32): Generates a random uint32 strictly less than n
  • Uint64n(n uint64): Generates a random uint64 strictly less than n

Range Methods (positive ranges only):

  • IntInRange(min, max int): Generates a random int in the inclusive range [min, max]
  • Int32InRange(min, max int32): Generates a random int32 in the inclusive range [min, max]
  • Int64InRange(min, max int64): Generates a random int64 in the inclusive range [min, max]
  • UintInRange(min, max uint): Generates a random uint in the inclusive range [min, max]
  • Uint32InRange(min, max uint32): Generates a random uint32 in the inclusive range [min, max]
  • Uint64InRange(min, max uint64): Generates a random uint64 in the inclusive range [min, max]

Generic Functions:

  • InclusiveRange[T](g *RandomGenerator, min, max T): Generic function for generating random numbers in inclusive ranges
  • RandomElement[T](g *RandomGenerator, slice []T): Selects a random element from a slice

Constraints:

  • All *n methods require n > 0 (will panic if n = 0)
  • All range methods only support positive ranges (will panic with negative ranges)
  • The RandomGenerator exposes all methods from *rand.Rand for additional functionality
random := suite.Random()

// Generate random bytes
bytes := random.RandomBytes(32)

// Generate random string
str := random.RandomString(16)

// Generate random unsigned integers less than n
uintVal := random.Uintn(100)
uint32Val := random.Uint32n(100)
uint64Val := random.Uint64n(100)

// Generate random numbers in inclusive ranges (positive ranges only)
intInRange := random.IntInRange(1, 50)
int32InRange := random.Int32InRange(1, 25)
int64InRange := random.Int64InRange(1, 100)
uintInRange := random.UintInRange(10, 90)
uint32InRange := random.Uint32InRange(5, 95)
uint64InRange := random.Uint64InRange(1, 1000)

// Use generic InclusiveRange function
numInRange := InclusiveRange(random, 1, 100)
numInRangeWithType := InclusiveRange[uint32](random, 1, 100)

// Select random element from slice
slice := []string{"apple", "banana", "cherry", "date"}
randomElement := RandomElement(random, slice)

// random also exposes all methods from *rand.Rand
val := random.Uint32()
val64 := random.Uint64()
int32Val := random.Int31()
int64Val := random.Int63()
intVal := random.Intn(100)
Block Header Generator

Generates block headers with proper field relationships and chain-specific defaults. Uses an options pattern for configuration.

Options:

  • WithHeight(height uint64): Sets the height of the block header
  • WithView(view uint64): Sets the view of the block header
  • WithChainID(chainID flow.ChainID): Sets the chain ID of the block header
  • WithParent(parent *flow.Header): Sets the parent header (ignores height, view, and chainID if set)
  • WithParentAndSoR(parent *flow.Header, source []byte): Sets the parent and source of randomness

Methods:

  • Fixture(t testing.TB, opts ...func(*blockHeaderConfig)): Generates a block header with optional configuration
headerGen := suite.Headers()

// Basic header
header := headerGen.Fixture()

// Header with specific height
header := headerGen.Fixture(
    headerGen.WithHeight(100),
)

// Header with specific view
header := headerGen.Fixture(
    headerGen.WithView(200),
)

// Header for specific chain
header := headerGen.Fixture(
    headerGen.WithChainID(flow.Testnet),
)

// Header with parent
parent := headerGen.Fixture()
child := headerGen.Fixture(
    headerGen.WithParent(parent),
)

// Header with parent and source of randomness
parent := headerGen.Fixture()
source := suite.Random().RandomBytes(32)
child := headerGen.Fixture(
    headerGen.WithParentAndSoR(parent, source),
)
Block Generator

Generates complete blocks with headers and payloads using an options pattern for configuration.

Options:

  • WithHeight(height uint64): Sets the height of the block header
  • WithView(view uint64): Sets the view of the block header
  • WithChainID(chainID flow.ChainID): Sets the chain ID of the block header
  • WithParent(parentID, parentView, parentHeight): Sets parent block information
  • WithParentHeader(parent *flow.Header): Sets parent header and derives child values
  • WithProposerID(proposerID flow.Identifier): Sets the block proposer ID
  • WithLastViewTC(lastViewTC *flow.TimeoutCertificate): Sets the timeout certificate
  • WithTimestamp(timestamp uint64): Sets the block timestamp
  • WithPayload(payload flow.Payload): Sets the block payload
  • WithHeaderBody(headerBody flow.HeaderBody): Sets the header body

Methods:

  • Fixture(opts ...BlockOption): Generates a block with optional configuration
  • List(n int, opts ...BlockOption): Generates a chain of n blocks
  • Genesis(opts ...BlockOption): Generates a genesis block
blockGen := suite.Blocks()

// Basic block
block := blockGen.Fixture()

// Block with specific height and view
block := blockGen.Fixture(
    Block.WithHeight(100),
    Block.WithView(200),
)

// Block chain with parent-child relationships
blocks := blockGen.List(5) // Creates chain of 5 blocks

// Genesis block
genesis := blockGen.Genesis(Block.WithChainID(flow.Testnet))
Primitive Generators
Identifier Generator
idGen := suite.Identifiers()

// Single identifier
id := idGen.Fixture()

// List of identifiers
ids := idGen.List(5)
Signature Generator
sigGen := suite.Signatures()

// Single signature
sig := sigGen.Fixture()

// List of signatures
sigs := sigGen.List(3)
Address Generator
addrGen := suite.Addresses()

// Default random address on default chain (Testnet)
addr := addrGen.Fixture()

// Address for specific chain
addr := addrGen.Fixture(addrGen.WithChainID(flow.Testnet))

// Service account address
addr := addrGen.Fixture(addrGen.ServiceAddress())

// Invalid address
invalidAddr := CorruptAddress(addrGen.Fixture(), flow.Testnet)
Signer Indices Generator
indicesGen := suite.SignerIndices()

// Generate indices with total validators and signer count
indices := indicesGen.Fixture(indicesGen.WithSignerCount(10, 4))

// Generate indices at specific positions
indices := indicesGen.Fixture(indicesGen.WithIndices([]int{0, 2, 4}))

// Generate list of indices
indicesList := indicesGen.List(3, indicesGen.WithSignerCount(10, 2))
Consensus Generators
Quorum Certificate Generator
qcGen := suite.QuorumCertificates()

// Basic quorum certificate
qc := qcGen.Fixture()

// With specific view and block ID
qc := qcGen.Fixture(
    qcGen.WithView(100),
    qcGen.WithBlockID(blockID),
)

// With root block ID (sets view to 0)
qc := qcGen.Fixture(
    qcGen.WithRootBlockID(blockID),
)

// Certifies specific block
qc := qcGen.Fixture(
    qcGen.CertifiesBlock(header),
)

// With signer indices and source
qc := qcGen.Fixture(
    qcGen.WithSignerIndices(signerIndices),
    qcGen.WithRandomnessSource(source),
)

// List of certificates
qcList := qcGen.List(3)
Execution Data Generators
Chunk Execution Data Generator
cedGen := suite.ChunkExecutionDatas()

// Basic chunk execution data
ced := cedGen.Fixture()

// With minimum size
ced := cedGen.Fixture(
    cedGen.WithMinSize(100),
)

// List of chunk execution data
cedList := cedGen.List(3)
Block Execution Data Generator
bedGen := suite.BlockExecutionDatas()

// Basic block execution data
bed := bedGen.Fixture()

// With specific block ID
bed := bedGen.Fixture(
    bedGen.WithBlockID(blockID),
)

// With specific chunk execution datas
chunks := suite.ChunkExecutionDatas().List(3)
bed := bedGen.Fixture(
    bedGen.WithChunkExecutionDatas(chunks...),
)

// List of block execution data
bedList := bedGen.List(2)
Execution Result Generator
erGen := suite.ExecutionResults()

// Basic execution result
result := erGen.Fixture()

// With specific block ID
result := erGen.Fixture(
    erGen.WithBlockID(blockID),
)

// With specific chunks
chunks := suite.Chunks().List(3)
result := erGen.Fixture(
    erGen.WithChunks(chunks...),
)

// List of execution results
results := erGen.List(2)
Execution Receipt Generator
receiptGen := suite.ExecutionReceipts()

// Basic execution receipt
receipt := receiptGen.Fixture()

// With specific executor ID
receipt := receiptGen.Fixture(
    receiptGen.WithExecutorID(executorID),
)

// With specific execution result
result := suite.ExecutionResults().Fixture()
receipt := receiptGen.Fixture(
    receiptGen.WithExecutionResult(result),
)

// List of execution receipts
receipts := receiptGen.List(3)
Chunk Generator
chunkGen := suite.Chunks()

// Basic chunk
chunk := chunkGen.Fixture()

// With specific collection index
chunk := chunkGen.Fixture(
    chunkGen.WithIndex(2),
)

// List of chunks
chunks := chunkGen.List(4)
Block Execution Data Entity Generator
bedEntityGen := suite.BlockExecutionDataEntities()

// Basic block execution data entity
entity := bedEntityGen.Fixture()

// With specific block ID
entity := bedEntityGen.Fixture(
    bedEntityGen.WithBlockID(blockID),
)

// List of entities
entityList := bedEntityGen.List(2)
Transaction Generators
Transaction Generator
txGen := suite.Transactions()

// Basic transaction body
tx := txGen.Fixture()

// With custom gas limit
tx := txGen.Fixture(
    txGen.WithGasLimit(100),
)

// List of transactions
txList := txGen.List(3)
Full Transaction Generator
fullTxGen := suite.FullTransactions()

// Complete transaction (with TransactionBody embedded)
tx := fullTxGen.Fixture()

// List of complete transactions
txList := fullTxGen.List(2)
Collection Generator
colGen := suite.Collections()

// Collection with 1 transaction (default)
col := colGen.Fixture()

// Collection with specific transaction count
col := colGen.Fixture(colGen.WithTxCount(3))

// Collection with specific transactions
transactions := suite.Transactions().List(2)
col := colGen.Fixture(colGen.WithTransactions(transactions))

// List of collections each with 3 transactions
colList := colGen.List(2, colGen.WithTxCount(3))
Ledger Generators
Trie Update Generator
trieGen := suite.TrieUpdates()

// Basic trie update
trie := trieGen.Fixture()

// With specific number of paths
trie := trieGen.Fixture(
    trieGen.WithNumPaths(5),
)

// List of trie updates
trieList := trieGen.List(2)
Transaction Result Generators
Transaction Result Generator
trGen := suite.TransactionResults()

// Basic transaction result
tr := trGen.Fixture()

// With custom error message
tr := trGen.Fixture(
    trGen.WithErrorMessage("custom error"),
)

// List of results
trList := trGen.List(2)
Light Transaction Result Generator
ltrGen := suite.LightTransactionResults()

// Basic light transaction result
ltr := ltrGen.Fixture()

// With failed status
ltr := ltrGen.Fixture(
    ltrGen.WithFailed(true),
)

// List of light results
ltrList := ltrGen.List(2)
Transaction Component Generators
Transaction Signature Generator
tsGen := suite.TransactionSignatures()

// Basic transaction signature
ts := tsGen.Fixture()

// With custom signer index
ts := tsGen.Fixture(
    tsGen.WithSignerIndex(5),
)

// List of signatures
tsList := tsGen.List(2)
Proposal Key Generator
pkGen := suite.ProposalKeys()

// Basic proposal key
pk := pkGen.Fixture()

// With custom sequence number
pk := pkGen.Fixture(
    pkGen.WithSequenceNumber(100),
)

// List of proposal keys
pkList := pkGen.List(2)
Event Generators
Event Type Generator
eventTypeGen := suite.EventTypes()

// Basic event type
eventType := eventTypeGen.Fixture()

// With custom event name
eventType := eventTypeGen.Fixture(
    eventTypeGen.WithEventName("CustomEvent"),
)

// With custom contract name
eventType := eventTypeGen.Fixture(
    eventTypeGen.WithContractName("CustomContract"),
)

// With specific address
address := suite.Addresses().Fixture()
eventType := eventTypeGen.Fixture(
    eventTypeGen.WithAddress(address),
)
Event Generator
eventGen := suite.Events()

// Basic event with default CCF encoding
event := eventGen.Fixture()

// With specific encoding
eventWithCCF := eventGen.Fixture(
    eventGen.WithEncoding(entities.EventEncodingVersion_CCF_V0),
)
eventWithJSON := eventGen.Fixture(
    eventGen.WithEncoding(entities.EventEncodingVersion_JSON_CDC_V0),
)

// With custom type and encoding
event := eventGen.Fixture(
    eventGen.WithEventType("A.0x1.Test.Event"),
    eventGen.WithEncoding(entities.EventEncodingVersion_JSON_CDC_V0),
)

// Events for specific transaction
txID := suite.Identifiers().Fixture()
txEvents := eventGen.ForTransaction(txID, 0, 3)

// Events for multiple transactions
txIDs := suite.Identifiers().List(2)
allEvents := eventGen.ForTransactions(txIDs, 2)
Service Event Generators

Service events represent important protocol-level events in Flow. The suite provides generators for all types of service events.

Service Event Generator

serviceEventGen := suite.ServiceEvents()

// Basic service event (random type)
serviceEvent := serviceEventGen.Fixture()

// List of service events
serviceEvents := serviceEventGen.List(3)

Specific Service Event Types

// Epoch Setup events
epochSetup := suite.EpochSetups().Fixture()

// Epoch Commit events
epochCommit := suite.EpochCommits().Fixture()

// Epoch Recover events
epochRecover := suite.EpochRecovers().Fixture()

// Version Beacon events
versionBeacon := suite.VersionBeacons().Fixture()

// Protocol State Version Upgrade events
protocolUpgrade := suite.ProtocolStateVersionUpgrades().Fixture()

// Set Epoch Extension View Count events
setExtension := suite.SetEpochExtensionViewCounts().Fixture()

// Eject Node events
ejectNode := suite.EjectNodes().Fixture()
Identity Generator

Generates Flow identities with cryptographic keys and metadata.

identityGen := suite.Identities()

// Basic identity
identity := identityGen.Fixture()

// Identity with specific role
identity := identityGen.Fixture(identityGen.WithRole(flow.RoleConsensus))

// List of identities
identities := identityGen.List(4)
Time Generator

Generates time.Time values with various options for time-based testing scenarios.

Options:

  • WithBaseTime(baseTime time.Time): Sets the base time for generation
  • WithOffset(offset time.Duration): Sets a specific offset from the base time
  • WithOffsetRandom(max time.Duration): Sets a random offset from the base time (0 to max)
  • WithTimezone(tz *time.Location): Sets the timezone for time generation

Methods:

  • Fixture(t testing.TB, opts ...func(*timeConfig)): Generates a time.Time value with optional configuration
timeGen := suite.Time()

// Basic time fixture
time1 := timeGen.Fixture()

// Time with specific base time
now := time.Now()
time2 := timeGen.Fixture(timeGen.WithBaseTime(now))

// Time with specific base time
baseTime := time.Date(2023, 1, 1, 12, 0, 0, 0, time.UTC)
time3 := timeGen.Fixture(timeGen.WithBaseTime(baseTime))

// Time with specific offset
time4 := timeGen.Fixture(timeGen.WithOffset(time.Hour))

// Time with random offset
time5 := timeGen.Fixture(timeGen.WithOffsetRandom(24*time.Hour))

// Time in a specific timezone
time6 := timeGen.Fixture(timeGen.WithTimezone(time.FixedZone("EST", -5*3600)))

// Time with multiple options
time7 := timeGen.Fixture(
	timeGen.WithBaseTime(baseTime),
	timeGen.WithOffset(time.Hour),
	timeGen.WithTimezone(time.FixedZone("EST", -5*3600)),
)
Ledger Path Generator

Generates ledger paths with consistent randomness and deduplication.

Options:

  • WithCount(count int): Sets the number of paths to generate

Methods:

  • Fixture(t testing.TB, opts ...func(*pathConfig)): Generates a single ledger path
  • List(t testing.TB, n int, opts ...func(*pathConfig)): Generates a list of ledger paths
pathGen := suite.LedgerPaths()

// Basic path fixture
path1 := pathGen.Fixture()

// List of paths
paths := pathGen.List(3)
Ledger Payload Generator

Generates ledger payloads with consistent randomness and configurable sizes.

Options:

  • WithSize(minSize, maxSize int): Sets the payload size range
  • WithValue(value ledger.Value): Sets the value for the payload

Methods:

  • Fixture(t testing.TB, opts ...func(*payloadConfig)): Generates a single ledger payload
  • List(t testing.TB, n int, opts ...func(*payloadConfig)): Generates a list of ledger payloads
payloadGen := suite.LedgerPayloads()

// Basic payload fixture
payload1 := payloadGen.Fixture()

// Payload with specific size
payload2 := payloadGen.Fixture(payloadGen.WithSize(4, 16))

// Payload with specific value
value := suite.LedgerValues().Fixture()
payload3 := payloadGen.Fixture(payloadGen.WithValue(value))

// List of payloads
payloads := payloadGen.List(3)
Ledger Value Generator

Generates ledger values with consistent randomness and configurable sizes.

Options:

  • WithSize(minSize, maxSize int): Sets the value size range [minSize, maxSize)

Methods:

  • Fixture(t testing.TB, opts ...func(*valueConfig)): Generates a single ledger value
  • List(t testing.TB, n int, opts ...func(*valueConfig)): Generates a list of ledger values
valueGen := suite.LedgerValues()

// Basic value fixture
value1 := valueGen.Fixture()

// Value with specific size
value2 := valueGen.Fixture(valueGen.WithSize(4, 16))

// List of values
values := valueGen.List(3)

// List of values with specific size
largeValues := valueGen.List(2, valueGen.WithSize(8, 32))

Migration Guide

From Standalone Fixtures

The new fixtures module replaces standalone fixture functions. Here's how to migrate:

Old Way:

import "github.com/onflow/flow-go/utils/unittest"

// Standalone functions
header := unittest.BlockHeaderFixture()
header := unittest.BlockHeaderFixtureOnChain(flow.Testnet)
header := unittest.BlockHeaderWithParentFixture(parent)

New Way:

import "github.com/onflow/flow-go/utils/unittest/fixtures"

// Create suite once per test
suite := fixtures.NewGeneratorSuite(t) // or fixtures.WithSeed(12345)

// Use suite generators
headerGen := suite.Headers()
header := headerGen.Fixture()
header := headerGen.Fixture(headerGen.WithChainID(flow.Testnet))
header := headerGen.Fixture(headerGen.WithParent(parent))
Benefits of Migration
  1. Deterministic Results: Explicit seed control for reproducible tests
  2. Shared Randomness: All generators use the same RNG for consistency
  3. Context Awareness: Generators create related data that makes sense together
  4. Better Error Handling: Proper error handling with testing.TB
  5. Easier Extension: Simple to add new generator types

Testing

The fixtures module includes comprehensive tests:

# Run all fixture tests
go test -v ./utils/unittest/fixtures

# Run specific test
go test -v ./utils/unittest/fixtures -run TestGeneratorSuite

# Run deterministic tests
go test -v ./utils/unittest/fixtures -run TestGeneratorSuiteDeterministic
Test Coverage
  • Deterministic results with the same seed
  • Proper relationships between generated objects
  • Correct field values and constraints
  • Random seed generation when seed is not specified
  • All generator options and methods

Architecture

File Organization

The fixtures module is organized into focused files:

Category File Purpose
Core generator.go Core GeneratorSuite and options
random.go Random value generation utilities
util.go Utility functions
generators_test.go Comprehensive tests
Core Data Types identifier.go Identifier generation
signature.go Signature generation
address.go Address generation
time.go Time generation
Block Components block_header.go Block header generation
block.go Complete block generation
payload.go Block payload generation
seal.go Block seal generation
Consensus quorum_certificate.go Quorum certificate generation
timeout_certificate.go Timeout certificate generation
signer_indices.go Signer indices generation
Execution execution_result.go Execution result generation
execution_receipt.go Execution receipt generation
chunk.go Execution chunk generation
chunk_execution_data.go Chunk execution data generation
block_execution_data.go Block execution data generation
Transactions transaction.go Transaction generation
collection.go Collection generation
collection_guarantee.go Collection guarantee generation
transaction_result.go Transaction result generation
transaction_signature.go Transaction signature generation
proposal_key.go Proposal key generation
Events event.go Event generation
event_type.go Event type generation
service_event.go Service event generation
service_event_*.go Specific service event type generators
Ledger trie_update.go Trie update generation
ledger_path.go Ledger path generation
ledger_payload.go Ledger payload generation
ledger_value.go Ledger value generation
state_commitment.go State commitment generation
Cryptographic crypto.go Cryptographic key generation
aggregated_signature.go Aggregated signature generation
Identity identity.go Identity generation
Design Principles
  1. Single Responsibility: Each generator focuses on one data type
  2. Dependency Injection: Generators store instances of other generators they need
  3. Options Pattern: Flexible configuration through options
  4. Error Safety: All errors returned during fixture construction must be checked using NoError(). Important constraints on the inputs must also be checked using Assert()
  5. Deterministic: All generators use the same rand.Rand, ensuring consistent and deterministic value when the seed it set.
  6. Consistent: Easy to add new generators following established patterns.
Adding New Generators

To add a new generator:

  1. Create a new file (e.g., my_type.go)
  2. Define the options factory and options
  3. Define the generator struct with dependencies
  4. Implement the Fixture and List methods
  5. Add getter method to GeneratorSuite
  6. Add tests and update documentation

Example:

// In my_type.go
package fixtures

import "github.com/onflow/flow-go/model/flow"

// MyType is the default options factory for [flow.MyType] generation.
var MyType myTypeFactory

type myTypeFactory struct{}

type MyTypeOption func(*MyTypeGenerator, *flow.MyType)

// WithField is an option that sets the `Field` of the my type.
func (f myTypeFactory) WithField(field string) MyTypeOption {
	return func(g *MyTypeGenerator, myType *flow.MyType) {
		myType.Field = field
	}
}

// MyTypeGenerator generates my types with consistent randomness.
type MyTypeGenerator struct {
	myTypeFactory

	random      *RandomGenerator
	identifiers *IdentifierGenerator
	// Add other generator dependencies as needed
}

func NewMyTypeGenerator(
	random *RandomGenerator,
	identifiers *IdentifierGenerator,
) *MyTypeGenerator {
	return &MyTypeGenerator{
		random:      random,
		identifiers: identifiers,
	}
}

// Fixture generates a [flow.MyType] with random data based on the provided options.
func (g *MyTypeGenerator) Fixture(opts ...MyTypeOption) *flow.MyType {
	myType := &flow.MyType{
		ID:    g.identifiers.Fixture(),
		Field: g.random.RandomString(10),
		// Set other fields with random values
	}

	for _, opt := range opts {
		opt(g, myType)
	}

	return myType
}

// List generates a list of [flow.MyType] with random data.
func (g *MyTypeGenerator) List(n int, opts ...MyTypeOption) []*flow.MyType {
	items := make([]*flow.MyType, n)
	for i := range n {
		items[i] = g.Fixture(opts...)
	}
	return items
}
// In generator.go
func (g *GeneratorSuite) MyTypes() *MyTypeGenerator {
	return NewMyTypeGenerator(
		g.Random(),
		g.Identifiers(),
		// Pass other dependencies as needed
	)
}

Key Implementation Patterns:

  1. Factory Pattern: Each generator has a global factory variable (e.g., MyType) that provides typed options
  2. Options Pattern: Each option is a function that takes the generator and modifies the object being built
  3. Constructor Injection: Generators receive their dependencies through NewXxxGenerator() constructors
  4. Consistent API: All generators implement Fixture(opts...) and List(n int, opts...) methods
  5. Error Handling: Use fixtures.NoError(err) for any operations that might fail
  6. Embedding: Generator structs embed their factory for direct access to options methods

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Address addressFactory

Address is the default options factory for flow.Address generation.

View Source
var AggregatedSignature aggregatedSignatureFactory

AggregatedSignature is the default options factory for flow.AggregatedSignature generation.

View Source
var Block blockFactory

Block is the default options factory for flow.Block generation.

View Source
var BlockExecutionData blockExecutionDataFactory

BlockExecutionData is the default options factory for execution_data.BlockExecutionData generation.

View Source
var Chunk chunkFactory

Chunk is the default options factory for flow.Chunk generation.

View Source
var ChunkExecutionData chunkExecutionDataFactory

ChunkExecutionData is the default options factory for execution_data.ChunkExecutionData generation.

View Source
var Collection collectionFactory

Collection is the default options factory for flow.Collection generation.

View Source
var EjectNode ejectNodeFactory

EjectNode is the default options factory for flow.EjectNode generation.

View Source
var EpochCommit epochCommitFactory

EpochCommit is the default options factory for flow.EpochCommit generation.

View Source
var EpochRecover epochRecoverFactory

EpochRecover is the default options factory for flow.EpochRecover generation.

View Source
var EpochSetup epochSetupFactory

EpochSetup is the default options factory for flow.EpochSetup generation.

View Source
var Event eventFactory

Event is the default options factory for flow.Event generation.

View Source
var EventType eventTypeFactory

EventType is the default options factory for flow.EventType generation.

View Source
var ExecutionReceipt executionReceiptFactory

ExecutionReceipt is the default options factory for flow.ExecutionReceipt generation.

View Source
var ExecutionReceiptStub executionReceiptStubFactory

ExecutionReceiptStub is the default options factory for flow.ExecutionReceiptStub generation.

View Source
var ExecutionResult executionResultFactory

ExecutionResult is the default options factory for flow.ExecutionResult generation.

View Source
var Guarantee collectionGuaranteeFactory

CollectionGuarantee is the default options factory for flow.CollectionGuarantee generation.

View Source
var Header headerFactory

Header is the default options factory for flow.Header generation.

View Source
var Identifier identifierFactory

Identifier is the default options factory for flow.Identifier generation.

View Source
var Identity identityFactory

Identity is the default options factory for flow.Identity generation.

View Source
var LedgerPath ledgerPathFactory

LedgerPath is the default options factory for ledger.Path generation.

View Source
var LedgerPayload ledgerPayloadFactory

LedgerPayload is the default options factory for ledger.Payload generation.

View Source
var LedgerValue ledgerValueFactory

LedgerValue is the default options factory for ledger.Value generation.

View Source
var LightTransactionResult lightTransactionResultFactory
View Source
var Payload payloadFactory

Payload is the default options factory for flow.Payload generation.

View Source
var PrivateKey privateKeyFactory
View Source
var ProposalKey proposalKeyFactory

ProposalKey is the default options factory for flow.ProposalKey generation.

View Source
var ProtocolStateVersionUpgrade protocolStateVersionUpgradeFactory

ProtocolStateVersionUpgrade is the default options factory for flow.ProtocolStateVersionUpgrade generation.

View Source
var QuorumCertificate quorumCertificateFactory

QuorumCertificate is the default options factory for flow.QuorumCertificate generation.

View Source
var QuorumCertificateWithSignerIDs quorumCertificateWithSignerIDsFactory

QuorumCertificateWithSignerIDs is the default options factory for flow.QuorumCertificateWithSignerIDs generation.

View Source
var Seal sealFactory

Seal is the default options factory for flow.Seal generation.

View Source
var ServiceEvent serviceEventFactory

ServiceEvent is the default options factory for flow.ServiceEvent generation.

View Source
var SetEpochExtensionViewCount setEpochExtensionViewCountFactory

SetEpochExtensionViewCount is the default options factory for flow.SetEpochExtensionViewCount generation.

View Source
var Signature signatureFactory

Signature is the default options factory for crypto.Signature generation.

View Source
var SignerIndices signerIndicesFactory

SignerIndices is the default options factory for SignerIndices generation.

View Source
var StateCommitment stateCommitmentFactory

StateCommitment is the default options factory for flow.StateCommitment generation.

View Source
var Time timeFactory

Time is the default options factory for time.Time generation.

View Source
var TimeoutCertificate timeoutCertificateFactory

TimeoutCertificate is the default options factory for flow.TimeoutCertificate generation.

View Source
var Transaction transactionFactory

Transaction is the default options factory for flow.TransactionBody generation.

View Source
var TransactionResult transactionResultFactory

TransactionResult is the default options factory for flow.TransactionResult generation.

View Source
var TransactionSignature transactionSignatureFactory

TransactionSignature is the default options factory for flow.TransactionSignature generation.

View Source
var TrieUpdate trieUpdateFactory

TrieUpdate is the default options factory for ledger.TrieUpdate generation.

View Source
var VersionBeacon versionBeaconFactory

VersionBeacon is the default options factory for flow.VersionBeacon generation.

Functions

func AdjustEventsMetadata

func AdjustEventsMetadata(events []flow.Event) []flow.Event

AdjustEventsMetadata adjusts the event and transaction indexes to be sequential. The following changes are made: - Transaction Index is updated to match the actual transactions - Event Index is updated to be sequential and reset for each transaction

func Assert

func Assert(conditional bool, msg string)

Assert panics if the conditional is false, throwing the provided message.

func Assertf

func Assertf(conditional bool, msg string, args ...any)

Assertf panics if the conditional is false, throwing the provided formatted message.

func CorruptAddress

func CorruptAddress(addr flow.Address, chainID flow.ChainID) flow.Address

CorruptAddress corrupts the first byte of the address and checks that the address is invalid.

func InclusiveRange

func InclusiveRange[T ~uint64 | ~uint32 | ~uint | ~int64 | ~int32 | ~int](g *RandomGenerator, min, max T) T

InclusiveRange generates a random number of type T in the inclusive range [min, max]. Min and max MUST be positive numbers and `max` must be strictly greater than `min` or the method will panic.

func NoError

func NoError(err error)

NoError panics if the error is not nil.

func RandomElement

func RandomElement[T any](g *RandomGenerator, slice []T) T

RandomElement selects a random element from the provided slice. Returns the zero value of T if the slice is empty.

func ToCadenceEventType

func ToCadenceEventType(eventType flow.EventType) *cadence.EventType

ToCadenceEventType converts a flow.EventType to a cadence.EventType.

func ToSDKAddress

func ToSDKAddress(addr flow.Address) sdk.Address

ToSDKAddress converts a flow.Address to a sdk.Address.

Types

type AddressGenerator

type AddressGenerator struct {
	// contains filtered or unexported fields
}

AddressGenerator generates flow.Address with consistent randomness.

func NewAddressGenerator

func NewAddressGenerator(
	random *RandomGenerator,
	chainID flow.ChainID,
) *AddressGenerator

func (*AddressGenerator) Fixture

func (g *AddressGenerator) Fixture(opts ...AddressOption) flow.Address

Fixture generates a random flow.Address with the provided options. Defaults to the chain ID specified in the generator suite.

func (*AddressGenerator) List

func (g *AddressGenerator) List(n int, opts ...AddressOption) []flow.Address

List returns a list of flow.Address with the provided options.

func (AddressGenerator) ServiceAddress

func (f AddressGenerator) ServiceAddress() AddressOption

ServiceAddress is an option that generates the service account flow.Address for the given chain.

func (AddressGenerator) WithChainID

func (f AddressGenerator) WithChainID(chainID flow.ChainID) AddressOption

WithChainID is an option that generates an flow.Address for the specified chain.

func (AddressGenerator) WithIndex

func (f AddressGenerator) WithIndex(index uint64) AddressOption

WithIndex is an option that sets the index for the address.

type AddressOption

type AddressOption func(*AddressGenerator, *addressConfig)

type AggregatedSignatureGenerator

type AggregatedSignatureGenerator struct {
	// contains filtered or unexported fields
}

AggregatedSignatureGenerator generates aggregated signatures with consistent randomness.

func NewAggregatedSignatureGenerator

func NewAggregatedSignatureGenerator(
	random *RandomGenerator,
	identifiers *IdentifierGenerator,
	signatures *SignatureGenerator,
) *AggregatedSignatureGenerator

NewAggregatedSignatureGenerator creates a new AggregatedSignatureGenerator.

func (*AggregatedSignatureGenerator) Fixture

Fixture generates a flow.AggregatedSignature with random data based on the provided options.

func (*AggregatedSignatureGenerator) List

List generates a list of flow.AggregatedSignature.

func (AggregatedSignatureGenerator) WithSignerIDs

func (f AggregatedSignatureGenerator) WithSignerIDs(signerIDs flow.IdentifierList) AggregatedSignatureOption

WithSignerIDs is an option that sets the `SignerIDs` of the aggregated signature.

func (AggregatedSignatureGenerator) WithVerifierSignatures

func (f AggregatedSignatureGenerator) WithVerifierSignatures(sigs ...crypto.Signature) AggregatedSignatureOption

WithVerifierSignatures is an option that sets the `VerifierSignatures` of the aggregated signature.

type BlockExecutionDataEntityGenerator

type BlockExecutionDataEntityGenerator struct {
	*BlockExecutionDataGenerator
}

BlockExecutionDataEntityGenerator generates execution_data.BlockExecutionDataEntity with consistent randomness.

func NewBlockExecutionDataEntityGenerator

func NewBlockExecutionDataEntityGenerator(
	blockExecutionDatas *BlockExecutionDataGenerator,
) *BlockExecutionDataEntityGenerator

func (*BlockExecutionDataEntityGenerator) Fixture

Fixture generates a execution_data.BlockExecutionDataEntity with random data based on the provided options.

func (*BlockExecutionDataEntityGenerator) List

List generates a list of execution_data.BlockExecutionDataEntity.

func (BlockExecutionDataEntityGenerator) WithBlockID

func (f BlockExecutionDataEntityGenerator) WithBlockID(blockID flow.Identifier) BlockExecutionDataOption

WithBlockID is an option that sets the BlockID for the block execution data.

func (BlockExecutionDataEntityGenerator) WithChunkExecutionDatas

func (f BlockExecutionDataEntityGenerator) WithChunkExecutionDatas(chunks ...*execution_data.ChunkExecutionData) BlockExecutionDataOption

WithChunkExecutionDatas is an option that sets the ChunkExecutionDatas for the block execution data.

type BlockExecutionDataGenerator

type BlockExecutionDataGenerator struct {
	// contains filtered or unexported fields
}

BlockExecutionDataGenerator generates block execution data with consistent randomness.

func NewBlockExecutionDataGenerator

func NewBlockExecutionDataGenerator(
	random *RandomGenerator,
	identifiers *IdentifierGenerator,
	chunkExecutionDatas *ChunkExecutionDataGenerator,
) *BlockExecutionDataGenerator

func (*BlockExecutionDataGenerator) Fixture

Fixture generates a execution_data.BlockExecutionData with random data based on the provided options.

func (*BlockExecutionDataGenerator) List

List generates a list of execution_data.BlockExecutionData.

func (BlockExecutionDataGenerator) WithBlockID

func (f BlockExecutionDataGenerator) WithBlockID(blockID flow.Identifier) BlockExecutionDataOption

WithBlockID is an option that sets the BlockID for the block execution data.

func (BlockExecutionDataGenerator) WithChunkExecutionDatas

func (f BlockExecutionDataGenerator) WithChunkExecutionDatas(chunks ...*execution_data.ChunkExecutionData) BlockExecutionDataOption

WithChunkExecutionDatas is an option that sets the ChunkExecutionDatas for the block execution data.

type BlockGenerator

type BlockGenerator struct {
	// contains filtered or unexported fields
}

BlockGenerator generates blocks with consistent randomness.

func NewBlockGenerator

func NewBlockGenerator(
	random *RandomGenerator,
	identifiers *IdentifierGenerator,
	headers *HeaderGenerator,
	payloads *PayloadGenerator,
	chainID flow.ChainID,
) *BlockGenerator

func (*BlockGenerator) Fixture

func (g *BlockGenerator) Fixture(opts ...BlockOption) *flow.Block

Fixture generates a flow.Block with random data based on the provided options.

func (*BlockGenerator) Genesis

func (g *BlockGenerator) Genesis(opts ...BlockOption) *flow.Block

Genesis instantiates a genesis block. This block has view and height equal to zero. However, conceptually spork root blocks are functionally equivalent to genesis blocks. We have decided that in the long term, the protocol must support spork root blocks with height _and_ view larger than zero. The only options that are used are the chainID and the protocol state ID.

func (*BlockGenerator) List

func (g *BlockGenerator) List(n int, opts ...BlockOption) []*flow.Block

List generates a chain of flow.Block objects. The first block is generated with the given options, and the subsequent blocks are generated using only the WithParentHeader option, specifying the previous block as the parent.

func (BlockGenerator) WithChainID

func (f BlockGenerator) WithChainID(chainID flow.ChainID) BlockOption

WithChainID is an option that sets the `ChainID` of the block's header.

func (BlockGenerator) WithHeaderBody

func (f BlockGenerator) WithHeaderBody(headerBody *flow.HeaderBody) BlockOption

WithHeaderBody is an option that sets the `HeaderBody` of the block.

func (BlockGenerator) WithHeight

func (f BlockGenerator) WithHeight(height uint64) BlockOption

WithHeight is an option that sets the `Height` of the block's header.

func (BlockGenerator) WithLastViewTC

func (f BlockGenerator) WithLastViewTC(lastViewTC *flow.TimeoutCertificate) BlockOption

WithLastViewTC is an option that sets the `LastViewTC` of the block's header.

func (BlockGenerator) WithParent

func (f BlockGenerator) WithParent(parentID flow.Identifier, parentView uint64, parentHeight uint64) BlockOption

WithParent is an option that sets the `ParentID`, `ParentView`, and `Height` of the block's header based on the provided fields. `Height` is set to parent's `Height` + 1.

func (BlockGenerator) WithParentHeader

func (f BlockGenerator) WithParentHeader(parent *flow.Header) BlockOption

WithParentHeader is an option that sets the following fields of the block's header based on the provided parent header: - `View` - `Height` - `ChainID` - `Timestamp` - `ParentID` - `ParentView`

If you want a specific value for any of these fields, you should add the appropriate option after this option.

func (BlockGenerator) WithParentView

func (f BlockGenerator) WithParentView(view uint64) BlockOption

WithParentView is an option that sets the `ParentView` of the block's header.

func (BlockGenerator) WithParentVoterIndices

func (f BlockGenerator) WithParentVoterIndices(indices []byte) BlockOption

WithParentVoterIndices is an option that sets the `ParentVoterIndices` of the block's header.

func (BlockGenerator) WithParentVoterSigData

func (f BlockGenerator) WithParentVoterSigData(data []byte) BlockOption

WithParentVoterSigData is an option that sets the `ParentVoterSigData` of the block's header.

func (BlockGenerator) WithPayload

func (f BlockGenerator) WithPayload(payload *flow.Payload) BlockOption

WithPayload is an option that sets the `Payload` of the block.

func (BlockGenerator) WithProposerID

func (f BlockGenerator) WithProposerID(proposerID flow.Identifier) BlockOption

WithProposerID is an option that sets the `ProposerID` of the block's header.

func (BlockGenerator) WithTimestamp

func (f BlockGenerator) WithTimestamp(timestamp uint64) BlockOption

WithTimestamp is an option that sets the `Timestamp` of the block's header.

func (BlockGenerator) WithView

func (f BlockGenerator) WithView(view uint64) BlockOption

WithView is an option that sets the `View` of the block's header.

type BlockOption

type BlockOption func(*BlockGenerator, *blockConfig)

type ChunkExecutionDataGenerator

type ChunkExecutionDataGenerator struct {
	// contains filtered or unexported fields
}

ChunkExecutionDataGenerator generates chunk execution data with consistent randomness.

func NewChunkExecutionDataGenerator

func NewChunkExecutionDataGenerator(
	random *RandomGenerator,
	collections *CollectionGenerator,
	lightTxResults *LightTransactionResultGenerator,
	events *EventGenerator,
	trieUpdates *TrieUpdateGenerator,
) *ChunkExecutionDataGenerator

func (*ChunkExecutionDataGenerator) Fixture

Fixture generates a execution_data.ChunkExecutionData with random data based on the provided options.

func (*ChunkExecutionDataGenerator) List

List generates a list of execution_data.ChunkExecutionData.

func (ChunkExecutionDataGenerator) WithCollection

func (f ChunkExecutionDataGenerator) WithCollection(collection *flow.Collection) ChunkExecutionDataOption

WithCollection is an option that sets the collection for the chunk execution data.

func (ChunkExecutionDataGenerator) WithEvents

func (f ChunkExecutionDataGenerator) WithEvents(events flow.EventsList) ChunkExecutionDataOption

WithEvents is an option that sets the events for the chunk execution data.

func (ChunkExecutionDataGenerator) WithMinSize

func (f ChunkExecutionDataGenerator) WithMinSize(minSize int) ChunkExecutionDataOption

WithMinSize is an option that sets the minimum size for the chunk execution data.

func (ChunkExecutionDataGenerator) WithTransactionResults

func (f ChunkExecutionDataGenerator) WithTransactionResults(results ...flow.LightTransactionResult) ChunkExecutionDataOption

WithTransactionResults is an option that sets the transaction results for the chunk execution data.

func (ChunkExecutionDataGenerator) WithTrieUpdate

func (f ChunkExecutionDataGenerator) WithTrieUpdate(trieUpdate *ledger.TrieUpdate) ChunkExecutionDataOption

WithTrieUpdate is an option that sets the trie update for the chunk execution data.

type ChunkGenerator

type ChunkGenerator struct {
	// contains filtered or unexported fields
}

ChunkGenerator generates chunks with consistent randomness.

func NewChunkGenerator

func NewChunkGenerator(
	random *RandomGenerator,
	identifiers *IdentifierGenerator,
	stateCommitments *StateCommitmentGenerator,
) *ChunkGenerator

NewChunkGenerator creates a new ChunkGenerator.

func (*ChunkGenerator) Fixture

func (g *ChunkGenerator) Fixture(opts ...ChunkOption) *flow.Chunk

Fixture generates a flow.Chunk with random data based on the provided options.

func (*ChunkGenerator) List

func (g *ChunkGenerator) List(n int, opts ...ChunkOption) []*flow.Chunk

List generates a list of flow.Chunk.

func (ChunkGenerator) WithBlockID

func (f ChunkGenerator) WithBlockID(blockID flow.Identifier) ChunkOption

WithBlockID is an option that sets the `BlockID` of the chunk.

func (ChunkGenerator) WithCollectionIndex

func (f ChunkGenerator) WithCollectionIndex(collectionIndex uint) ChunkOption

WithCollectionIndex is an option that sets the `CollectionIndex` of the chunk.

func (ChunkGenerator) WithEndState

func (f ChunkGenerator) WithEndState(endState flow.StateCommitment) ChunkOption

WithEndState is an option that sets the `EndState` of the chunk.

func (ChunkGenerator) WithEventCollection

func (f ChunkGenerator) WithEventCollection(eventCollection flow.Identifier) ChunkOption

WithEventCollection is an option that sets the `EventCollection` of the chunk.

func (ChunkGenerator) WithIndex

func (f ChunkGenerator) WithIndex(index uint64) ChunkOption

WithIndex is an option that sets the `Index` of the chunk.

func (ChunkGenerator) WithNumberOfTransactions

func (f ChunkGenerator) WithNumberOfTransactions(numTxs uint64) ChunkOption

WithNumberOfTransactions is an option that sets the `NumberOfTransactions` of the chunk.

func (ChunkGenerator) WithServiceEventCount

func (f ChunkGenerator) WithServiceEventCount(count uint16) ChunkOption

WithServiceEventCount is an option that sets the `ServiceEventCount` of the chunk.

func (ChunkGenerator) WithStartState

func (f ChunkGenerator) WithStartState(startState flow.StateCommitment) ChunkOption

WithStartState is an option that sets the `StartState` of the chunk.

func (ChunkGenerator) WithTotalComputationUsed

func (f ChunkGenerator) WithTotalComputationUsed(computation uint64) ChunkOption

WithTotalComputationUsed is an option that sets the `TotalComputationUsed` of the chunk.

type ChunkOption

type ChunkOption func(*ChunkGenerator, *flow.Chunk)

type CollectionGenerator

type CollectionGenerator struct {
	// contains filtered or unexported fields
}

CollectionGenerator generates collections with consistent randomness.

func NewCollectionGenerator

func NewCollectionGenerator(
	transactions *TransactionGenerator,
) *CollectionGenerator

func (*CollectionGenerator) Fixture

func (g *CollectionGenerator) Fixture(opts ...CollectionOption) *flow.Collection

Fixture generates a flow.Collection with random data based on the provided options.

func (*CollectionGenerator) List

func (g *CollectionGenerator) List(n int, opts ...CollectionOption) []*flow.Collection

List generates a list of flow.Collection.

func (CollectionGenerator) WithTransactions

func (f CollectionGenerator) WithTransactions(transactions ...*flow.TransactionBody) CollectionOption

WithTransactions is an option that sets the transactions for the collection.

func (CollectionGenerator) WithTxCount

func (f CollectionGenerator) WithTxCount(count int) CollectionOption

WithTxCount is an option that sets the number of transactions in the collection.

type CollectionGuaranteeGenerator

type CollectionGuaranteeGenerator struct {
	// contains filtered or unexported fields
}

CollectionGuaranteeGenerator generates collection guarantees with consistent randomness.

func NewCollectionGuaranteeGenerator

func NewCollectionGuaranteeGenerator(
	random *RandomGenerator,
	identifiers *IdentifierGenerator,
	signatures *SignatureGenerator,
	signerIndices *SignerIndicesGenerator,
	chainID flow.ChainID,
) *CollectionGuaranteeGenerator

func (*CollectionGuaranteeGenerator) Fixture

Fixture generates a flow.CollectionGuarantee with random data based on the provided options.

func (*CollectionGuaranteeGenerator) List

List generates a list of flow.CollectionGuarantee with random data.

func (CollectionGuaranteeGenerator) WithClusterChainID

func (f CollectionGuaranteeGenerator) WithClusterChainID(clusterChainID flow.ChainID) CollectionGuaranteeOption

WithClusterChainID is an option that sets the `ClusterChainID` of the collection guarantee.

func (CollectionGuaranteeGenerator) WithCollectionID

func (f CollectionGuaranteeGenerator) WithCollectionID(collectionID flow.Identifier) CollectionGuaranteeOption

WithCollectionID is an option that sets the `CollectionID` of the collection guarantee.

func (CollectionGuaranteeGenerator) WithReferenceBlockID

func (f CollectionGuaranteeGenerator) WithReferenceBlockID(blockID flow.Identifier) CollectionGuaranteeOption

WithReferenceBlockID is an option that sets the `ReferenceBlockID` of the collection guarantee.

func (CollectionGuaranteeGenerator) WithSignature

func (f CollectionGuaranteeGenerator) WithSignature(signature crypto.Signature) CollectionGuaranteeOption

WithSignature is an option that sets the `Signature` of the collection guarantee.

func (CollectionGuaranteeGenerator) WithSignerIndices

func (f CollectionGuaranteeGenerator) WithSignerIndices(signerIndices []byte) CollectionGuaranteeOption

WithSignerIndices is an option that sets the `SignerIndices` of the collection guarantee.

type CollectionOption

type CollectionOption func(*CollectionGenerator, *flow.Collection)

type CryptoGenerator

type CryptoGenerator struct {
	// contains filtered or unexported fields
}

func NewCryptoGenerator

func NewCryptoGenerator(random *RandomGenerator) *CryptoGenerator

func (*CryptoGenerator) NetworkingPrivateKey

func (g *CryptoGenerator) NetworkingPrivateKey(opts ...PrivateKeyOption) crypto.PrivateKey

NetworkingPrivateKey generates a networking crypto.PrivateKey using the crypto.ECDSAP256 algorithm.

func (*CryptoGenerator) PrivateKey

PrivateKey generates a crypto.PrivateKey.

func (*CryptoGenerator) PublicKeys

func (g *CryptoGenerator) PublicKeys(n int, algo crypto.SigningAlgorithm, opts ...PrivateKeyOption) []crypto.PublicKey

PublicKeys generates a list of crypto.PublicKey.

func (*CryptoGenerator) StakingPrivateKey

func (g *CryptoGenerator) StakingPrivateKey(opts ...PrivateKeyOption) crypto.PrivateKey

StakingPrivateKey generates a staking crypto.PrivateKey using the crypto.BLSBLS12381 algorithm.

func (CryptoGenerator) WithSeed

func (f CryptoGenerator) WithSeed(seed []byte) PrivateKeyOption

WithSeed is an option that sets the seed of the private key.

type EjectNodeGenerator

type EjectNodeGenerator struct {
	// contains filtered or unexported fields
}

EjectNodeGenerator generates node ejection events with consistent randomness.

func NewEjectNodeGenerator

func NewEjectNodeGenerator(
	identifiers *IdentifierGenerator,
) *EjectNodeGenerator

NewEjectNodeGenerator creates a new EjectNodeGenerator.

func (*EjectNodeGenerator) Fixture

func (g *EjectNodeGenerator) Fixture(opts ...EjectNodeOption) *flow.EjectNode

Fixture generates a flow.EjectNode with random data based on the provided options.

func (*EjectNodeGenerator) List

func (g *EjectNodeGenerator) List(n int, opts ...EjectNodeOption) []*flow.EjectNode

List generates a list of flow.EjectNode.

func (EjectNodeGenerator) WithNodeID

func (f EjectNodeGenerator) WithNodeID(nodeID flow.Identifier) EjectNodeOption

WithNodeID is an option that sets the `NodeID` of the node to be ejected.

type EjectNodeOption

type EjectNodeOption func(*EjectNodeGenerator, *flow.EjectNode)

type EpochCommitGenerator

type EpochCommitGenerator struct {
	// contains filtered or unexported fields
}

EpochCommitGenerator generates epoch commit events with consistent randomness.

func NewEpochCommitGenerator

func NewEpochCommitGenerator(
	random *RandomGenerator,
	cryptoGen *CryptoGenerator,
	identifiers *IdentifierGenerator,
	quorumCerts *QuorumCertificateWithSignerIDsGenerator,
) *EpochCommitGenerator

NewEpochCommitGenerator creates a new EpochCommitGenerator.

func (*EpochCommitGenerator) Fixture

Fixture generates a flow.EpochCommit with random data based on the provided options.

func (*EpochCommitGenerator) List

List generates a list of flow.EpochCommit.

func (EpochCommitGenerator) WithClusterQCs

func (f EpochCommitGenerator) WithClusterQCs(qcs ...flow.ClusterQCVoteData) EpochCommitOption

WithClusterQCs is an option that sets the `ClusterQCs` of the epoch commit.

func (EpochCommitGenerator) WithClusterQCsFromAssignments

func (f EpochCommitGenerator) WithClusterQCsFromAssignments(assignments flow.AssignmentList) EpochCommitOption

WithClusterQCsFromAssignments is an option that sets the `ClusterQCs` of the epoch commit from the assignments.

func (EpochCommitGenerator) WithCounter

func (f EpochCommitGenerator) WithCounter(counter uint64) EpochCommitOption

WithCounter is an option that sets the `Counter` of the epoch commit.

func (EpochCommitGenerator) WithDKGFromParticipants

func (f EpochCommitGenerator) WithDKGFromParticipants(participants flow.IdentitySkeletonList) EpochCommitOption

WithDKGFromParticipants is an option that sets the `DKGGroupKey` and `DKGParticipantKeys` of the epoch commit from the participants.

type EpochCommitOption

type EpochCommitOption func(*EpochCommitGenerator, *flow.EpochCommit)

type EpochRecoverGenerator

type EpochRecoverGenerator struct {
	// contains filtered or unexported fields
}

EpochRecoverGenerator generates epoch recovery events with consistent randomness.

func NewEpochRecoverGenerator

func NewEpochRecoverGenerator(
	random *RandomGenerator,
	epochSetups *EpochSetupGenerator,
	epochCommits *EpochCommitGenerator,
) *EpochRecoverGenerator

NewEpochRecoverGenerator creates a new EpochRecoverGenerator.

func (*EpochRecoverGenerator) Fixture

Fixture generates a flow.EpochRecover with random data based on the provided options.

func (*EpochRecoverGenerator) List

List generates a list of flow.EpochRecover.

func (EpochRecoverGenerator) WithEpochCommit

func (f EpochRecoverGenerator) WithEpochCommit(commit flow.EpochCommit) EpochRecoverOption

WithEpochCommit is an option that sets the `EpochCommit` of the recover event.

func (EpochRecoverGenerator) WithEpochSetup

func (f EpochRecoverGenerator) WithEpochSetup(setup flow.EpochSetup) EpochRecoverOption

WithEpochSetup is an option that sets the `EpochSetup` of the recover event.

type EpochRecoverOption

type EpochRecoverOption func(*EpochRecoverGenerator, *flow.EpochRecover)

type EpochSetupGenerator

type EpochSetupGenerator struct {
	// contains filtered or unexported fields
}

EpochSetupGenerator generates epoch setup events with consistent randomness.

func NewEpochSetupGenerator

func NewEpochSetupGenerator(random *RandomGenerator, timeGen *TimeGenerator, identities *IdentityGenerator) *EpochSetupGenerator

NewEpochSetupGenerator creates a new EpochSetupGenerator.

func (*EpochSetupGenerator) Fixture

func (g *EpochSetupGenerator) Fixture(opts ...EpochSetupOption) *flow.EpochSetup

Fixture generates a flow.EpochSetup with random data based on the provided options.

func (*EpochSetupGenerator) List

func (g *EpochSetupGenerator) List(n int, opts ...EpochSetupOption) []*flow.EpochSetup

List generates a list of flow.EpochSetup.

func (EpochSetupGenerator) WithAssignments

func (f EpochSetupGenerator) WithAssignments(assignments flow.AssignmentList) EpochSetupOption

WithAssignments is an option that sets the `Assignments` of the epoch setup.

func (EpochSetupGenerator) WithCounter

func (f EpochSetupGenerator) WithCounter(counter uint64) EpochSetupOption

WithCounter is an option that sets the `Counter` of the epoch setup.

func (EpochSetupGenerator) WithDKGFinalViews

func (f EpochSetupGenerator) WithDKGFinalViews(phase1, phase2, phase3 uint64) EpochSetupOption

WithDKGFinalViews is an option that sets the `DKGPhase1FinalView`, `DKGPhase2FinalView`, and `DKGPhase3FinalView` of the epoch setup.

func (EpochSetupGenerator) WithFinalView

func (f EpochSetupGenerator) WithFinalView(view uint64) EpochSetupOption

WithFinalView is an option that sets the `FinalView` of the epoch setup.

func (EpochSetupGenerator) WithFirstView

func (f EpochSetupGenerator) WithFirstView(view uint64) EpochSetupOption

WithFirstView is an option that sets the `FirstView` of the epoch setup.

func (EpochSetupGenerator) WithParticipants

func (f EpochSetupGenerator) WithParticipants(participants flow.IdentitySkeletonList) EpochSetupOption

WithParticipants is an option that sets the `Participants` of the epoch setup.

func (EpochSetupGenerator) WithRandomSource

func (f EpochSetupGenerator) WithRandomSource(source []byte) EpochSetupOption

WithRandomSource is an option that sets the `RandomSource` of the epoch setup.

func (EpochSetupGenerator) WithTargetDuration

func (f EpochSetupGenerator) WithTargetDuration(duration uint64) EpochSetupOption

WithTargetDuration is an option that sets the `TargetDuration` of the epoch setup.

func (EpochSetupGenerator) WithTargetEndTime

func (f EpochSetupGenerator) WithTargetEndTime(endTime uint64) EpochSetupOption

WithTargetEndTime is an option that sets the `TargetEndTime` of the epoch setup.

type EpochSetupOption

type EpochSetupOption func(*EpochSetupGenerator, *flow.EpochSetup)

type EventGenerator

type EventGenerator struct {
	// contains filtered or unexported fields
}

EventGenerator generates events with consistent randomness.

func NewEventGenerator

func NewEventGenerator(
	random *RandomGenerator,
	identifiers *IdentifierGenerator,
	eventTypes *EventTypeGenerator,
	addresses *AddressGenerator,
) *EventGenerator

func (*EventGenerator) Fixture

func (g *EventGenerator) Fixture(opts ...EventOption) flow.Event

Fixture generates a flow.Event with random data based on the provided options.

func (*EventGenerator) ForTransaction

func (g *EventGenerator) ForTransaction(transactionID flow.Identifier, transactionIndex uint32, eventCount int, opts ...EventOption) []flow.Event

ForTransaction generates a list of flow.Event for a specific transaction.

func (*EventGenerator) ForTransactions

func (g *EventGenerator) ForTransactions(transactionIDs []flow.Identifier, eventsPerTransaction int, opts ...EventOption) []flow.Event

ForTransactions generates a list of flow.Event for multiple transactions.

func (*EventGenerator) List

func (g *EventGenerator) List(n int, opts ...EventOption) []flow.Event

List generates a list of flow.Event.

func (EventGenerator) WithEncoding

func (f EventGenerator) WithEncoding(encoding entities.EventEncodingVersion) EventOption

WithEncoding is an option that sets the encoding for the event payload.

func (EventGenerator) WithEventIndex

func (f EventGenerator) WithEventIndex(eventIndex uint32) EventOption

WithEventIndex is an option that sets the event index for the event.

func (EventGenerator) WithEventType

func (f EventGenerator) WithEventType(eventType flow.EventType) EventOption

WithEventType is an option that sets the event type for the event.

func (EventGenerator) WithPayload

func (f EventGenerator) WithPayload(payload []byte) EventOption

WithPayload is an option that sets the payload for the event. Note: if payload is provided, it must already be in the desired encoding.

func (EventGenerator) WithTransactionID

func (f EventGenerator) WithTransactionID(transactionID flow.Identifier) EventOption

WithTransactionID is an option that sets the transaction ID for the event.

func (EventGenerator) WithTransactionIndex

func (f EventGenerator) WithTransactionIndex(transactionIndex uint32) EventOption

WithTransactionIndex is an option that sets the transaction index for the event.

type EventOption

type EventOption func(*EventGenerator, *eventConfig)

type EventTypeGenerator

type EventTypeGenerator struct {
	// contains filtered or unexported fields
}

EventTypeGenerator generates event types with consistent randomness.

func NewEventTypeGenerator

func NewEventTypeGenerator(
	random *RandomGenerator,
	addresses *AddressGenerator,
) *EventTypeGenerator

func (*EventTypeGenerator) Fixture

func (g *EventTypeGenerator) Fixture(opts ...EventTypeOption) flow.EventType

Fixture generates a flow.EventType with random data based on the provided options.

func (*EventTypeGenerator) List

func (g *EventTypeGenerator) List(n int, opts ...EventTypeOption) []flow.EventType

List generates a list of flow.EventType.

func (EventTypeGenerator) WithAddress

func (f EventTypeGenerator) WithAddress(address flow.Address) EventTypeOption

WithAddress is an option that sets the address for the event type.

func (EventTypeGenerator) WithContractName

func (f EventTypeGenerator) WithContractName(contractName string) EventTypeOption

WithContractName is an option that sets the contract name for the event type.

func (EventTypeGenerator) WithEventName

func (f EventTypeGenerator) WithEventName(eventName string) EventTypeOption

WithEventName is an option that sets the event name for the event type.

type EventTypeOption

type EventTypeOption func(*EventTypeGenerator, *eventTypeConfig)

type ExecutionReceiptGenerator

type ExecutionReceiptGenerator struct {
	// contains filtered or unexported fields
}

ExecutionReceiptGenerator generates execution receipts with consistent randomness.

func NewExecutionReceiptGenerator

func NewExecutionReceiptGenerator(
	random *RandomGenerator,
	identifiers *IdentifierGenerator,
	executionResults *ExecutionResultGenerator,
	signatures *SignatureGenerator,
) *ExecutionReceiptGenerator

NewExecutionReceiptGenerator creates a new ExecutionReceiptGenerator.

func (*ExecutionReceiptGenerator) Fixture

Fixture generates a flow.ExecutionReceipt with random data based on the provided options.

func (*ExecutionReceiptGenerator) List

List generates a list of flow.ExecutionReceipt.

func (ExecutionReceiptGenerator) WithExecutionResult

func (f ExecutionReceiptGenerator) WithExecutionResult(result flow.ExecutionResult) ExecutionReceiptOption

WithExecutionResult is an option that sets the `ExecutionResult` of the execution receipt.

func (ExecutionReceiptGenerator) WithExecutorID

func (f ExecutionReceiptGenerator) WithExecutorID(executorID flow.Identifier) ExecutionReceiptOption

WithExecutorID is an option that sets the `ExecutorID` of the execution receipt.

func (ExecutionReceiptGenerator) WithExecutorSignature

func (f ExecutionReceiptGenerator) WithExecutorSignature(executorSignature crypto.Signature) ExecutionReceiptOption

WithExecutorSignature is an option that sets the `ExecutorSignature` of the execution receipt.

func (ExecutionReceiptGenerator) WithSpocks

func (f ExecutionReceiptGenerator) WithSpocks(spocks ...crypto.Signature) ExecutionReceiptOption

WithSpocks is an option that sets the `Spocks` of the execution receipt.

type ExecutionReceiptOption

type ExecutionReceiptOption func(*ExecutionReceiptGenerator, *flow.ExecutionReceipt)

type ExecutionReceiptStubGenerator

type ExecutionReceiptStubGenerator struct {
	// contains filtered or unexported fields
}

ExecutionReceiptStubGenerator generates execution receipt stubs with consistent randomness.

func NewExecutionReceiptStubGenerator

func NewExecutionReceiptStubGenerator(
	random *RandomGenerator,
	identifiers *IdentifierGenerator,
	signatures *SignatureGenerator,
) *ExecutionReceiptStubGenerator

NewExecutionReceiptStubGenerator creates a new ExecutionReceiptStubGenerator.

func (*ExecutionReceiptStubGenerator) Fixture

Fixture generates a flow.ExecutionReceiptStub with random data based on the provided options.

func (*ExecutionReceiptStubGenerator) List

List generates a list of flow.ExecutionReceiptStub.

func (ExecutionReceiptStubGenerator) WithExecutorID

func (f ExecutionReceiptStubGenerator) WithExecutorID(executorID flow.Identifier) ExecutionReceiptStubOption

WithExecutorID is an option that sets the `ExecutorID` of the execution receipt stub.

func (ExecutionReceiptStubGenerator) WithExecutorSignature

func (f ExecutionReceiptStubGenerator) WithExecutorSignature(executorSignature crypto.Signature) ExecutionReceiptStubOption

WithExecutorSignature is an option that sets the `ExecutorSignature` of the execution receipt stub.

func (ExecutionReceiptStubGenerator) WithResultID

func (f ExecutionReceiptStubGenerator) WithResultID(resultID flow.Identifier) ExecutionReceiptStubOption

WithResultID is an option that sets the `ResultID` of the execution receipt stub.

func (ExecutionReceiptStubGenerator) WithSpocks

func (f ExecutionReceiptStubGenerator) WithSpocks(spocks ...crypto.Signature) ExecutionReceiptStubOption

WithSpocks is an option that sets the `Spocks` of the execution receipt stub.

type ExecutionResultGenerator

type ExecutionResultGenerator struct {
	// contains filtered or unexported fields
}

ExecutionResultGenerator generates execution results with consistent randomness.

func NewExecutionResultGenerator

func NewExecutionResultGenerator(
	random *RandomGenerator,
	identifiers *IdentifierGenerator,
	chunks *ChunkGenerator,
	serviceEvents *ServiceEventGenerator,
	stateCommitments *StateCommitmentGenerator,
) *ExecutionResultGenerator

NewExecutionResultGenerator creates a new ExecutionResultGenerator.

func (*ExecutionResultGenerator) Fixture

Fixture generates a flow.ExecutionResult with random data based on the provided options.

func (*ExecutionResultGenerator) List

List generates a list of flow.ExecutionResult.

func (ExecutionResultGenerator) WithBlock

func (f ExecutionResultGenerator) WithBlock(block *flow.Block) ExecutionResultOption

WithBlock is an option that sets the `BlockID` of the execution result and all configured `Chunks`

func (ExecutionResultGenerator) WithBlockID

func (f ExecutionResultGenerator) WithBlockID(blockID flow.Identifier) ExecutionResultOption

WithBlockID is an option that sets the `BlockID` of the execution result.

func (ExecutionResultGenerator) WithChunks

func (f ExecutionResultGenerator) WithChunks(chunks flow.ChunkList) ExecutionResultOption

WithChunks is an option that sets the `Chunks` of the execution result.

func (ExecutionResultGenerator) WithExecutionDataID

func (f ExecutionResultGenerator) WithExecutionDataID(executionDataID flow.Identifier) ExecutionResultOption

WithExecutionDataID is an option that sets the `ExecutionDataID` of the execution result.

func (ExecutionResultGenerator) WithFinalState

func (f ExecutionResultGenerator) WithFinalState(finalState flow.StateCommitment) ExecutionResultOption

WithFinalState is an option that sets the `EndState` of the last chunk.

func (ExecutionResultGenerator) WithPreviousResult

func (f ExecutionResultGenerator) WithPreviousResult(previousResult *flow.ExecutionResult) ExecutionResultOption

WithPreviousResult is an option that sets the `PreviousResultID` of the execution result, and adjusts the `StartState` of the first chunk to match the final state of the previous result.

func (ExecutionResultGenerator) WithPreviousResultID

func (f ExecutionResultGenerator) WithPreviousResultID(previousResultID flow.Identifier) ExecutionResultOption

WithPreviousResultID is an option that sets the `PreviousResultID` of the execution result.

func (ExecutionResultGenerator) WithServiceEvents

func (f ExecutionResultGenerator) WithServiceEvents(serviceEvents flow.ServiceEventList) ExecutionResultOption

WithServiceEvents is an option that sets the `ServiceEvents` of the execution result.

type ExecutionResultOption

type ExecutionResultOption func(*ExecutionResultGenerator, *flow.ExecutionResult)

type GeneratorSuite

type GeneratorSuite struct {
	// contains filtered or unexported fields
}

GeneratorSuite provides a context-aware generator system for creating test fixtures. It manages a shared random number generator and provides access to specialized generators.

func NewGeneratorSuite

func NewGeneratorSuite(opts ...GeneratorSuiteOption) *GeneratorSuite

NewGeneratorSuite creates a new generator suite with optional configuration. If no seed is specified, a random seed is generated. If no chain ID is specified, the default chain ID is flow.Emulator.

func (*GeneratorSuite) Addresses

func (g *GeneratorSuite) Addresses() *AddressGenerator

Addresses returns a shared generator for flow.Address.

func (*GeneratorSuite) AggregatedSignatures

func (g *GeneratorSuite) AggregatedSignatures() *AggregatedSignatureGenerator

AggregatedSignatures returns a generator for flow.AggregatedSignature.

func (*GeneratorSuite) BlockExecutionDataEntities

func (g *GeneratorSuite) BlockExecutionDataEntities() *BlockExecutionDataEntityGenerator

BlockExecutionDataEntities returns a generator for flow.BlockExecutionDataEntity.

func (*GeneratorSuite) BlockExecutionDatas

func (g *GeneratorSuite) BlockExecutionDatas() *BlockExecutionDataGenerator

BlockExecutionDatas returns a generator for flow.BlockExecutionData.

func (*GeneratorSuite) Blocks

func (g *GeneratorSuite) Blocks() *BlockGenerator

Blocks returns a generator for flow.Block.

func (*GeneratorSuite) ChainID

func (g *GeneratorSuite) ChainID() flow.ChainID

ChainID returns the default chain ID used by all generators.

func (*GeneratorSuite) ChunkExecutionDatas

func (g *GeneratorSuite) ChunkExecutionDatas() *ChunkExecutionDataGenerator

ChunkExecutionDatas returns a generator for flow.ChunkExecutionData.

func (*GeneratorSuite) Chunks

func (g *GeneratorSuite) Chunks() *ChunkGenerator

Chunks returns a generator for flow.Chunk.

func (*GeneratorSuite) Collections

func (g *GeneratorSuite) Collections() *CollectionGenerator

Collections returns a generator for flow.Collection.

func (*GeneratorSuite) Crypto

func (g *GeneratorSuite) Crypto() *CryptoGenerator

func (*GeneratorSuite) EjectNodes

func (g *GeneratorSuite) EjectNodes() *EjectNodeGenerator

EjectNodes returns a generator for flow.EjectNode.

func (*GeneratorSuite) EpochCommits

func (g *GeneratorSuite) EpochCommits() *EpochCommitGenerator

EpochCommits returns a generator for flow.EpochCommit.

func (*GeneratorSuite) EpochRecovers

func (g *GeneratorSuite) EpochRecovers() *EpochRecoverGenerator

EpochRecovers returns a generator for flow.EpochRecover.

func (*GeneratorSuite) EpochSetups

func (g *GeneratorSuite) EpochSetups() *EpochSetupGenerator

EpochSetups returns a generator for flow.EpochSetup.

func (*GeneratorSuite) EventTypes

func (g *GeneratorSuite) EventTypes() *EventTypeGenerator

EventTypes returns a generator for flow.EventType.

func (*GeneratorSuite) Events

func (g *GeneratorSuite) Events() *EventGenerator

Events returns a generator for flow.Event.

func (*GeneratorSuite) ExecutionReceiptStubs

func (g *GeneratorSuite) ExecutionReceiptStubs() *ExecutionReceiptStubGenerator

ExecutionReceiptStubs returns a generator for flow.ExecutionReceiptStub.

func (*GeneratorSuite) ExecutionReceipts

func (g *GeneratorSuite) ExecutionReceipts() *ExecutionReceiptGenerator

ExecutionReceipts returns a generator for flow.ExecutionReceipt.

func (*GeneratorSuite) ExecutionResults

func (g *GeneratorSuite) ExecutionResults() *ExecutionResultGenerator

ExecutionResults returns a generator for flow.ExecutionResult.

func (*GeneratorSuite) Guarantees

Guarantees returns a generator for flow.CollectionGuarantee.

func (*GeneratorSuite) Headers

func (g *GeneratorSuite) Headers() *HeaderGenerator

Headers returns a generator for flow.Header.

func (*GeneratorSuite) Identifiers

func (g *GeneratorSuite) Identifiers() *IdentifierGenerator

Identifiers returns a shared generator for flow.Identifier.

func (*GeneratorSuite) Identities

func (g *GeneratorSuite) Identities() *IdentityGenerator

func (*GeneratorSuite) LedgerPaths

func (g *GeneratorSuite) LedgerPaths() *LedgerPathGenerator

LedgerPaths returns a generator for ledger.Path.

func (*GeneratorSuite) LedgerPayloads

func (g *GeneratorSuite) LedgerPayloads() *LedgerPayloadGenerator

LedgerPayloads returns a generator for ledger.Payload.

func (*GeneratorSuite) LedgerValues

func (g *GeneratorSuite) LedgerValues() *LedgerValueGenerator

LedgerValues returns a generator for ledger.Value.

func (*GeneratorSuite) LightTransactionResults

func (g *GeneratorSuite) LightTransactionResults() *LightTransactionResultGenerator

LightTransactionResults returns a generator for flow.LightTransactionResult.

func (*GeneratorSuite) Payloads

func (g *GeneratorSuite) Payloads() *PayloadGenerator

Payloads returns a generator for flow.Payload.

func (*GeneratorSuite) ProposalKeys

func (g *GeneratorSuite) ProposalKeys() *ProposalKeyGenerator

ProposalKeys returns a generator for flow.ProposalKey.

func (*GeneratorSuite) ProtocolStateVersionUpgrades

func (g *GeneratorSuite) ProtocolStateVersionUpgrades() *ProtocolStateVersionUpgradeGenerator

ProtocolStateVersionUpgrades returns a generator for flow.ProtocolStateVersionUpgrade.

func (*GeneratorSuite) QuorumCertificates

func (g *GeneratorSuite) QuorumCertificates() *QuorumCertificateGenerator

QuorumCertificates returns a generator for flow.QuorumCertificate.

func (*GeneratorSuite) QuorumCertificatesWithSignerIDs

func (g *GeneratorSuite) QuorumCertificatesWithSignerIDs() *QuorumCertificateWithSignerIDsGenerator

QuorumCertificatesWithSignerIDs returns a generator for flow.QuorumCertificateWithSignerIDs.

func (*GeneratorSuite) Random

func (g *GeneratorSuite) Random() *RandomGenerator

Random returns the shared random generator.

func (*GeneratorSuite) Seals

func (g *GeneratorSuite) Seals() *SealGenerator

Seals returns a generator for flow.Seal.

func (*GeneratorSuite) ServiceEvents

func (g *GeneratorSuite) ServiceEvents() *ServiceEventGenerator

ServiceEvents returns a generator for flow.ServiceEvent.

func (*GeneratorSuite) SetEpochExtensionViewCounts

func (g *GeneratorSuite) SetEpochExtensionViewCounts() *SetEpochExtensionViewCountGenerator

SetEpochExtensionViewCounts returns a generator for flow.SetEpochExtensionViewCount.

func (*GeneratorSuite) Signatures

func (g *GeneratorSuite) Signatures() *SignatureGenerator

Signatures returns a shared generator for crypto.Signature.

func (*GeneratorSuite) SignerIndices

func (g *GeneratorSuite) SignerIndices() *SignerIndicesGenerator

SignerIndices returns a generator for flow.SignerIndices.

func (*GeneratorSuite) StateCommitments

func (g *GeneratorSuite) StateCommitments() *StateCommitmentGenerator

StateCommitments returns a generator for flow.StateCommitment.

func (*GeneratorSuite) Time

func (g *GeneratorSuite) Time() *TimeGenerator

Time returns a generator for time.Time.

func (*GeneratorSuite) TimeoutCertificates

func (g *GeneratorSuite) TimeoutCertificates() *TimeoutCertificateGenerator

TimeoutCertificates returns a generator for flow.TimeoutCertificate.

func (*GeneratorSuite) TransactionResults

func (g *GeneratorSuite) TransactionResults() *TransactionResultGenerator

TransactionResults returns a generator for flow.TransactionResult.

func (*GeneratorSuite) TransactionSignatures

func (g *GeneratorSuite) TransactionSignatures() *TransactionSignatureGenerator

TransactionSignatures returns a generator for flow.TransactionSignature.

func (*GeneratorSuite) Transactions

func (g *GeneratorSuite) Transactions() *TransactionGenerator

Transactions returns a generator for flow.TransactionBody.

func (*GeneratorSuite) TrieUpdates

func (g *GeneratorSuite) TrieUpdates() *TrieUpdateGenerator

TrieUpdates returns a generator for ledger.TrieUpdate.

func (*GeneratorSuite) VersionBeacons

func (g *GeneratorSuite) VersionBeacons() *VersionBeaconGenerator

VersionBeacons returns a generator for flow.VersionBeacon.

type GeneratorSuiteOption

type GeneratorSuiteOption func(*generatorSuiteConfig)

GeneratorSuiteOption defines an option for configuring a GeneratorSuite.

func WithChainID

func WithChainID(chainID flow.ChainID) GeneratorSuiteOption

WithChainID sets the chain ID that's used as the default for all generators.

func WithSeed

func WithSeed(seed int64) GeneratorSuiteOption

WithSeed sets the random seed used for the random number generator used by all generators. Specifying a seed makes the fixture data deterministic.

type HeaderGenerator

type HeaderGenerator struct {
	// contains filtered or unexported fields
}

HeaderGenerator generates block headers with consistent randomness.

func NewBlockHeaderGenerator

func NewBlockHeaderGenerator(
	random *RandomGenerator,
	identifiers *IdentifierGenerator,
	signatures *SignatureGenerator,
	signerIndices *SignerIndicesGenerator,
	quorumCerts *QuorumCertificateGenerator,
	timeGen *TimeGenerator,
	chainID flow.ChainID,
) *HeaderGenerator

func (*HeaderGenerator) Fixture

func (g *HeaderGenerator) Fixture(opts ...HeaderOption) *flow.Header

Fixture generates a flow.Header with random data based on the provided options.

func (*HeaderGenerator) Genesis

func (g *HeaderGenerator) Genesis(opts ...HeaderOption) *flow.Header

Genesis instantiates a genesis block header. This block has view and height equal to zero. However, conceptually spork root blocks are functionally equivalent to genesis blocks. We have decided that in the long term, the protocol must support spork root blocks with height _and_ view larger than zero. The only option that's used is the chainID.

func (*HeaderGenerator) List

func (g *HeaderGenerator) List(n int, opts ...HeaderOption) []*flow.Header

List generates a chain of flow.Header. The first header is generated with the given options, and the subsequent headers are generated using the previous header as the parent.

func (HeaderGenerator) WithChainID

func (f HeaderGenerator) WithChainID(chainID flow.ChainID) HeaderOption

WithChainID is an option that sets the `ChainID` of the block header.

func (HeaderGenerator) WithHeight

func (f HeaderGenerator) WithHeight(height uint64) HeaderOption

WithHeight is an option that sets the `Height` of the block header.

func (HeaderGenerator) WithLastViewTC

func (f HeaderGenerator) WithLastViewTC(lastViewTC *flow.TimeoutCertificate) HeaderOption

WithLastViewTC is an option that sets the `LastViewTC` of the block header.

func (HeaderGenerator) WithParent

func (f HeaderGenerator) WithParent(parentID flow.Identifier, parentView uint64, parentHeight uint64) HeaderOption

WithParent is an option that sets the `ParentID`, `ParentView`, and `Height` of the block header based on the provided fields. `Height` is set to parent's `Height` + 1.

func (HeaderGenerator) WithParentHeader

func (f HeaderGenerator) WithParentHeader(parent *flow.Header) HeaderOption

WithParentHeader is an option that sets the following fields of the block header based on the provided parent header: - `View` - `Height` - `ChainID` - `Timestamp` - `ParentID` - `ParentView`

If you want a specific value for any of these fields, you should add the appropriate option after this option.

func (HeaderGenerator) WithParentView

func (f HeaderGenerator) WithParentView(view uint64) HeaderOption

WithParentView is an option that sets the `ParentView` of the block header.

func (HeaderGenerator) WithParentVoterIndices

func (f HeaderGenerator) WithParentVoterIndices(indices []byte) HeaderOption

WithParentVoterIndices is an option that sets the `ParentVoterIndices` of the block header.

func (HeaderGenerator) WithParentVoterSigData

func (f HeaderGenerator) WithParentVoterSigData(data []byte) HeaderOption

WithParentVoterSigData is an option that sets the `ParentVoterSigData` of the block header.

func (HeaderGenerator) WithPayloadHash

func (f HeaderGenerator) WithPayloadHash(hash flow.Identifier) HeaderOption

WithPayloadHash is an option that sets the `PayloadHash` of the block header.

func (HeaderGenerator) WithProposerID

func (f HeaderGenerator) WithProposerID(proposerID flow.Identifier) HeaderOption

WithProposerID is an option that sets the `ProposerID` of the block header.

func (HeaderGenerator) WithSourceOfRandomness

func (f HeaderGenerator) WithSourceOfRandomness(source []byte) HeaderOption

WithSourceOfRandomness is an option that sets the `ParentVoterSigData` of the block header based on the provided source of randomness.

func (HeaderGenerator) WithTimestamp

func (f HeaderGenerator) WithTimestamp(timestamp uint64) HeaderOption

WithTimestamp is an option that sets the `Timestamp` of the block header.

func (HeaderGenerator) WithView

func (f HeaderGenerator) WithView(view uint64) HeaderOption

WithView is an option that sets the `View` of the block header.

type HeaderOption

type HeaderOption func(*HeaderGenerator, *flow.Header)

type IdentifierGenerator

type IdentifierGenerator struct {
	// contains filtered or unexported fields
}

IdentifierGenerator generates identifiers with consistent randomness.

func NewIdentifierGenerator

func NewIdentifierGenerator(
	random *RandomGenerator,
) *IdentifierGenerator

func (*IdentifierGenerator) Fixture

Fixture generates a random flow.Identifier.

func (*IdentifierGenerator) List

List generates a list of random flow.Identifier.

type IdentifierOption

type IdentifierOption func(*IdentifierGenerator, *identifierConfig)

type IdentityGenerator

type IdentityGenerator struct {
	// contains filtered or unexported fields
}

IdentityGenerator generates identities with consistent randomness.

func NewIdentityGenerator

func NewIdentityGenerator(
	random *RandomGenerator,
	cryptoGen *CryptoGenerator,
	identifiers *IdentifierGenerator,
	addresses *AddressGenerator,
) *IdentityGenerator

NewIdentityGenerator creates a new IdentityGenerator.

func (*IdentityGenerator) Fixture

func (g *IdentityGenerator) Fixture(opts ...IdentityOption) *flow.Identity

Fixture generates a flow.Identity with random data based on the provided options.

func (*IdentityGenerator) List

List generates a list of flow.Identity.

func (IdentityGenerator) WithAddress

func (f IdentityGenerator) WithAddress(address string) IdentityOption

WithAddress is an option that sets the `Address` of the identity.

func (IdentityGenerator) WithAllRoles

func (f IdentityGenerator) WithAllRoles() IdentityOption

WithAllRoles is an option that sets the `Role` of the identity. When used with `List()`, it will set successive identities to different roles, cycling through all roles.

func (IdentityGenerator) WithAllRolesExcept

func (f IdentityGenerator) WithAllRolesExcept(except ...flow.Role) IdentityOption

WithAllRolesExcept is an option that sets the `Role` of the identity. When used with `List()`, it will set successive identities to different roles, cycling through all roles except the ones specified.

func (IdentityGenerator) WithEpochParticipationStatus

func (f IdentityGenerator) WithEpochParticipationStatus(status flow.EpochParticipationStatus) IdentityOption

WithEpochParticipationStatus is an option that sets the `EpochParticipationStatus` of the identity.

func (IdentityGenerator) WithInitialWeight

func (f IdentityGenerator) WithInitialWeight(weight uint64) IdentityOption

WithInitialWeight is an option that sets the `InitialWeight` of the identity.

func (IdentityGenerator) WithNetworkPubKey

func (f IdentityGenerator) WithNetworkPubKey(key crypto.PublicKey) IdentityOption

WithNetworkPubKey is an option that sets the `NetworkPubKey` of the identity.

func (IdentityGenerator) WithNodeID

func (f IdentityGenerator) WithNodeID(nodeID flow.Identifier) IdentityOption

WithNodeID is an option that sets the `NodeID` of the identity.

func (IdentityGenerator) WithRole

func (f IdentityGenerator) WithRole(role flow.Role) IdentityOption

WithRole is an option that sets the `Role` of the identity.

func (IdentityGenerator) WithStakingPubKey

func (f IdentityGenerator) WithStakingPubKey(key crypto.PublicKey) IdentityOption

WithStakingPubKey is an option that sets the `StakingPubKey` of the identity.

type IdentityOption

type IdentityOption func(*IdentityGenerator, *flow.Identity)

type LedgerPathGenerator

type LedgerPathGenerator struct {
	// contains filtered or unexported fields
}

LedgerPathGenerator generates ledger paths with consistent randomness.

func NewLedgerPathGenerator

func NewLedgerPathGenerator(
	random *RandomGenerator,
) *LedgerPathGenerator

func (*LedgerPathGenerator) Fixture

func (g *LedgerPathGenerator) Fixture(opts ...LedgerPathOption) ledger.Path

Fixture generates a single random ledger.Path.

func (*LedgerPathGenerator) List

func (g *LedgerPathGenerator) List(n int, opts ...LedgerPathOption) []ledger.Path

List generates a list of random ledger.Path.

type LedgerPathOption

type LedgerPathOption func(*LedgerPathGenerator, *ledgerPathConfig)

type LedgerPayloadGenerator

type LedgerPayloadGenerator struct {
	// contains filtered or unexported fields
}

LedgerPayloadGenerator generates ledger payloads with consistent randomness.

func NewLedgerPayloadGenerator

func NewLedgerPayloadGenerator(
	random *RandomGenerator,
	ledgerValues *LedgerValueGenerator,
) *LedgerPayloadGenerator

func (*LedgerPayloadGenerator) Fixture

Fixture generates a single random ledger.Payload.

func (*LedgerPayloadGenerator) List

List generates a list of random ledger.Payload.

func (LedgerPayloadGenerator) WithSize

func (f LedgerPayloadGenerator) WithSize(minSize, maxSize int) LedgerPayloadOption

WithSize is an option that sets the payload size range.

func (LedgerPayloadGenerator) WithValue

func (f LedgerPayloadGenerator) WithValue(value ledger.Value) LedgerPayloadOption

WithValue is an option that sets the value for the payload.

type LedgerPayloadOption

type LedgerPayloadOption func(*LedgerPayloadGenerator, *payloadConfig)

type LedgerValueGenerator

type LedgerValueGenerator struct {
	// contains filtered or unexported fields
}

LedgerValueGenerator generates ledger values with consistent randomness.

func NewLedgerValueGenerator

func NewLedgerValueGenerator(
	random *RandomGenerator,
) *LedgerValueGenerator

func (*LedgerValueGenerator) Fixture

func (g *LedgerValueGenerator) Fixture(opts ...LedgerValueOption) ledger.Value

Fixture generates a single random ledger.Value.

func (*LedgerValueGenerator) List

func (g *LedgerValueGenerator) List(n int, opts ...LedgerValueOption) []ledger.Value

List generates a list of random ledger.Value.

func (LedgerValueGenerator) WithSize

func (f LedgerValueGenerator) WithSize(minSize, maxSize int) LedgerValueOption

WithSize is an option that sets the value size range [minSize, maxSize).

type LedgerValueOption

type LedgerValueOption func(*LedgerValueGenerator, *valueConfig)

type LightTransactionResultGenerator

type LightTransactionResultGenerator struct {
	*TransactionResultGenerator
}

LightTransactionResultGenerator generates light transaction results with consistent randomness.

func NewLightTransactionResultGenerator

func NewLightTransactionResultGenerator(
	txResults *TransactionResultGenerator,
) *LightTransactionResultGenerator

func (*LightTransactionResultGenerator) Fixture

Fixture generates a flow.LightTransactionResult with random data based on the provided options.

func (*LightTransactionResultGenerator) List

List generates a list of flow.LightTransactionResult.

func (LightTransactionResultGenerator) WithComputationUsed

func (f LightTransactionResultGenerator) WithComputationUsed(computationUsed uint64) TransactionResultOption

WithComputationUsed is an option that sets the computation used for the transaction result.

func (LightTransactionResultGenerator) WithErrorMessage

func (f LightTransactionResultGenerator) WithErrorMessage(errorMessage string) TransactionResultOption

WithErrorMessage is an option that sets the error message for the transaction result.

func (LightTransactionResultGenerator) WithTransactionID

func (f LightTransactionResultGenerator) WithTransactionID(transactionID flow.Identifier) TransactionResultOption

WithTransactionID is an option that sets the transaction ID for the transaction result.

type PayloadGenerator

type PayloadGenerator struct {
	// contains filtered or unexported fields
}

PayloadGenerator generates block payloads with consistent randomness.

func NewPayloadGenerator

func NewPayloadGenerator(
	random *RandomGenerator,
	identifies *IdentifierGenerator,
	guarantees *CollectionGuaranteeGenerator,
	seals *SealGenerator,
	executionReceiptStubs *ExecutionReceiptStubGenerator,
	executionResults *ExecutionResultGenerator,
) *PayloadGenerator

func (*PayloadGenerator) Fixture

func (g *PayloadGenerator) Fixture(opts ...PayloadOption) *flow.Payload

Fixture generates a flow.Payload with random data based on the provided options.

func (*PayloadGenerator) List

func (g *PayloadGenerator) List(n int, opts ...PayloadOption) []*flow.Payload

List generates a list of flow.Payload.

func (PayloadGenerator) WithGuarantees

func (f PayloadGenerator) WithGuarantees(guarantees ...*flow.CollectionGuarantee) PayloadOption

WithGuarantees is an option that sets the `Guarantees` of the payload.

func (PayloadGenerator) WithProtocolStateID

func (f PayloadGenerator) WithProtocolStateID(protocolStateID flow.Identifier) PayloadOption

WithProtocolStateID is an option that sets the `ProtocolStateID` of the payload.

func (PayloadGenerator) WithReceiptStubs

func (f PayloadGenerator) WithReceiptStubs(receipts ...*flow.ExecutionReceiptStub) PayloadOption

WithReceiptStubs is an option that sets the `Receipts` of the payload.

func (PayloadGenerator) WithReceipts

func (f PayloadGenerator) WithReceipts(receipts ...*flow.ExecutionReceipt) PayloadOption

WithReceipts is an option that sets the `Receipts` and `Results` of the payload by adding all receipts and their `ExecutionResults` to the payload.

To add only receipts, use `WithReceiptStubs` instead. e.g.

Payload.WithReceiptsStubs(
    flow.ExecutionReceiptList(receipts).Stubs()...,
)

func (PayloadGenerator) WithResults

func (f PayloadGenerator) WithResults(results flow.ExecutionResultList) PayloadOption

WithResults is an option that sets the `Results` of the payload.

func (PayloadGenerator) WithSeals

func (f PayloadGenerator) WithSeals(seals ...*flow.Seal) PayloadOption

WithSeals is an option that sets the `Seals` of the payload.

type PayloadOption

type PayloadOption func(*PayloadGenerator, *flow.Payload)

type PrivateKeyOption

type PrivateKeyOption func(*CryptoGenerator, *privateKeyConfig)

type ProposalKeyGenerator

type ProposalKeyGenerator struct {
	// contains filtered or unexported fields
}

ProposalKeyGenerator generates proposal keys with consistent randomness.

func NewProposalKeyGenerator

func NewProposalKeyGenerator(
	addresses *AddressGenerator,
) *ProposalKeyGenerator

func (*ProposalKeyGenerator) Fixture

Fixture generates a flow.ProposalKey with random data based on the provided options.

func (*ProposalKeyGenerator) List

List generates a list of flow.ProposalKey.

func (ProposalKeyGenerator) WithAddress

func (f ProposalKeyGenerator) WithAddress(address flow.Address) ProposalKeyOption

WithAddress is an option that sets the address for the proposal key.

func (ProposalKeyGenerator) WithKeyIndex

func (f ProposalKeyGenerator) WithKeyIndex(keyIndex uint32) ProposalKeyOption

WithKeyIndex is an option that sets the key index for the proposal key.

func (ProposalKeyGenerator) WithSequenceNumber

func (f ProposalKeyGenerator) WithSequenceNumber(sequenceNumber uint64) ProposalKeyOption

WithSequenceNumber is an option that sets the sequence number for the proposal key.

type ProposalKeyOption

type ProposalKeyOption func(*ProposalKeyGenerator, *flow.ProposalKey)

type ProtocolStateVersionUpgradeGenerator

type ProtocolStateVersionUpgradeGenerator struct {
	// contains filtered or unexported fields
}

ProtocolStateVersionUpgradeGenerator generates protocol state version upgrades with consistent randomness.

func NewProtocolStateVersionUpgradeGenerator

func NewProtocolStateVersionUpgradeGenerator(random *RandomGenerator) *ProtocolStateVersionUpgradeGenerator

NewProtocolStateVersionUpgradeGenerator creates a new ProtocolStateVersionUpgradeGenerator.

func (*ProtocolStateVersionUpgradeGenerator) Fixture

Fixture generates a flow.ProtocolStateVersionUpgrade with random data based on the provided options.

func (*ProtocolStateVersionUpgradeGenerator) List

List generates a list of flow.ProtocolStateVersionUpgrade.

func (ProtocolStateVersionUpgradeGenerator) WithActiveView

func (f ProtocolStateVersionUpgradeGenerator) WithActiveView(view uint64) ProtocolStateVersionUpgradeOption

WithActiveView is an option that sets the `ActiveView` of the upgrade.

func (ProtocolStateVersionUpgradeGenerator) WithNewProtocolStateVersion

func (f ProtocolStateVersionUpgradeGenerator) WithNewProtocolStateVersion(version uint64) ProtocolStateVersionUpgradeOption

WithNewProtocolStateVersion is an option that sets the `NewProtocolStateVersion` of the upgrade.

type QuorumCertificateGenerator

type QuorumCertificateGenerator struct {
	// contains filtered or unexported fields
}

QuorumCertificateGenerator generates quorum certificates with consistent randomness.

func NewQuorumCertificateGenerator

func NewQuorumCertificateGenerator(
	random *RandomGenerator,
	identifiers *IdentifierGenerator,
	signerIndices *SignerIndicesGenerator,
	signatures *SignatureGenerator,
) *QuorumCertificateGenerator

func (QuorumCertificateGenerator) CertifiesBlock

func (f QuorumCertificateGenerator) CertifiesBlock(header *flow.Header) QuorumCertificateOption

CertifiesBlock is an option that sets the block ID and view of the quorum certificate to match the provided header.

func (*QuorumCertificateGenerator) Fixture

Fixture generates a flow.QuorumCertificate with random data based on the provided options.

func (*QuorumCertificateGenerator) List

List generates a list of flow.QuorumCertificate.

func (*QuorumCertificateGenerator) QCSigDataWithSoR

func (g *QuorumCertificateGenerator) QCSigDataWithSoR(source []byte) []byte

QCSigDataWithSoR generates a flow.QuorumCertificate signature data with a source of randomness. If source is empty, a random source of randomness is generated.

func (QuorumCertificateGenerator) WithBlockID

func (f QuorumCertificateGenerator) WithBlockID(blockID flow.Identifier) QuorumCertificateOption

WithBlockID is an option that sets the block ID of the quorum certificate.

func (QuorumCertificateGenerator) WithRandomnessSource

func (f QuorumCertificateGenerator) WithRandomnessSource(source []byte) QuorumCertificateOption

WithRandomnessSource is an option that sets the source of randomness for the quorum certificate.

func (QuorumCertificateGenerator) WithRootBlockID

func (f QuorumCertificateGenerator) WithRootBlockID(blockID flow.Identifier) QuorumCertificateOption

WithRootBlockID is an option that sets the root block ID of the quorum certificate.

func (QuorumCertificateGenerator) WithSignerIndices

func (f QuorumCertificateGenerator) WithSignerIndices(signerIndices []byte) QuorumCertificateOption

WithSignerIndices is an option that sets the signer indices of the quorum certificate.

func (QuorumCertificateGenerator) WithView

func (f QuorumCertificateGenerator) WithView(view uint64) QuorumCertificateOption

WithView is an option that sets the view of the quorum certificate.

type QuorumCertificateOption

type QuorumCertificateOption func(*QuorumCertificateGenerator, *flow.QuorumCertificate)

type QuorumCertificateWithSignerIDsGenerator

type QuorumCertificateWithSignerIDsGenerator struct {
	// contains filtered or unexported fields
}

QuorumCertificateWithSignerIDsGenerator generates flow.QuorumCertificateWithSignerIDs with consistent randomness.

func NewQuorumCertificateWithSignerIDsGenerator

func NewQuorumCertificateWithSignerIDsGenerator(
	random *RandomGenerator,
	identifiers *IdentifierGenerator,
	quorumCerts *QuorumCertificateGenerator,
) *QuorumCertificateWithSignerIDsGenerator

func (*QuorumCertificateWithSignerIDsGenerator) Fixture

Fixture generates a flow.QuorumCertificateWithSignerIDs with random data based on the provided options.

func (*QuorumCertificateWithSignerIDsGenerator) List

List generates a list of flow.QuorumCertificateWithSignerIDs.

func (QuorumCertificateWithSignerIDsGenerator) WithBlockID

func (f QuorumCertificateWithSignerIDsGenerator) WithBlockID(blockID flow.Identifier) QuorumCertificateWithSignerIDsOption

WithBlockID is an option that sets the `BlockID` of the quorum certificate with signer IDs.

func (QuorumCertificateWithSignerIDsGenerator) WithSigData

func (f QuorumCertificateWithSignerIDsGenerator) WithSigData(sigData []byte) QuorumCertificateWithSignerIDsOption

WithSigData is an option that sets the `SigData` of the quorum certificate with signer IDs.

func (QuorumCertificateWithSignerIDsGenerator) WithSignerIDs

func (f QuorumCertificateWithSignerIDsGenerator) WithSignerIDs(signerIDs flow.IdentifierList) QuorumCertificateWithSignerIDsOption

WithSignerIDs is an option that sets the `SignerIDs` of the quorum certificate with signer IDs.

func (QuorumCertificateWithSignerIDsGenerator) WithView

func (f QuorumCertificateWithSignerIDsGenerator) WithView(view uint64) QuorumCertificateWithSignerIDsOption

WithView is an option that sets the `View` of the quorum certificate with signer IDs.

type RandomGenerator

type RandomGenerator struct {
	*rand.Rand
}

RandomGenerator provides random value generation with consistent randomness. Exposes all methods from *rand.Rand, as well as additional methods to reduce

func NewRandomGenerator

func NewRandomGenerator(rng *rand.Rand) *RandomGenerator

func (*RandomGenerator) Bool

func (g *RandomGenerator) Bool() bool

Bool generates a random bool.

func (*RandomGenerator) Int32InRange

func (g *RandomGenerator) Int32InRange(min, max int32) int32

Int32InRange generates a random int32 in the inclusive range [min, max]. Min and max MUST be positive numbers and `max` must be strictly greater than `min` or the method will panic.

func (*RandomGenerator) Int64InRange

func (g *RandomGenerator) Int64InRange(min, max int64) int64

Int64InRange generates a random int64 in the inclusive range [min, max]. Min and max MUST be positive numbers and `max` must be strictly greater than `min` or the method will panic.

func (*RandomGenerator) IntInRange

func (g *RandomGenerator) IntInRange(min, max int) int

IntInRange generates a random int in the inclusive range [min, max]. Min and max MUST be positive numbers and `max` must be strictly greater than `min` or the method will panic.

func (*RandomGenerator) RandomBytes

func (g *RandomGenerator) RandomBytes(n int) []byte

RandomBytes generates n random bytes.

func (*RandomGenerator) RandomString

func (g *RandomGenerator) RandomString(length uint) string

RandomString generates a random string of the specified length.

func (*RandomGenerator) Uint16n

func (g *RandomGenerator) Uint16n(n uint16) uint16

Uint16n generates a random uint16 strictly less than `n`. Uses rand.Int31n to generate a random int32 and then casts it to uint16. n MUST be > 0.

func (*RandomGenerator) Uint32InRange

func (g *RandomGenerator) Uint32InRange(min, max uint32) uint32

Uint32InRange generates a random uint32 in the inclusive range [min, max]. `max` must be strictly greater than `min` or the method will panic.

func (*RandomGenerator) Uint32n

func (g *RandomGenerator) Uint32n(n uint32) uint32

Uint32n generates a random uint32 strictly less than `n`. Uses rand.Int31n to generate a random int32 and then casts it to uint32. n MUST be > 0.

func (*RandomGenerator) Uint64InRange

func (g *RandomGenerator) Uint64InRange(min, max uint64) uint64

Uint64InRange generates a random uint64 in the inclusive range [min, max]. `max` must be strictly greater than `min` or the method will panic.

func (*RandomGenerator) Uint64n

func (g *RandomGenerator) Uint64n(n uint64) uint64

Uint64n generates a random uint64 strictly less than `n`. Uses rand.Int63n to generate a random int64 and then casts it to uint64. n MUST be > 0.

func (*RandomGenerator) UintInRange

func (g *RandomGenerator) UintInRange(min, max uint) uint

UintInRange generates a random uint in the inclusive range [min, max]. `max` must be strictly greater than `min` or the method will panic.

func (*RandomGenerator) Uintn

func (g *RandomGenerator) Uintn(n uint) uint

Uintn generates a random uint strictly less than `n`. Uses rand.Int63n to generate a random int64 and then casts it to uint. n MUST be > 0.

type SealGenerator

type SealGenerator struct {
	// contains filtered or unexported fields
}

SealGenerator generates seals with consistent randomness.

func NewSealGenerator

func NewSealGenerator(
	random *RandomGenerator,
	identifiers *IdentifierGenerator,
	stateCommitments *StateCommitmentGenerator,
	aggregatedSignatures *AggregatedSignatureGenerator,
) *SealGenerator

func (*SealGenerator) Fixture

func (g *SealGenerator) Fixture(opts ...SealOption) *flow.Seal

Fixture generates a flow.Seal with random data based on the provided options.

func (*SealGenerator) List

func (g *SealGenerator) List(n int, opts ...SealOption) []*flow.Seal

List generates a list of flow.Seal with random data.

func (SealGenerator) WithAggregatedApprovalSigs

func (f SealGenerator) WithAggregatedApprovalSigs(sigs ...flow.AggregatedSignature) SealOption

WithAggregatedApprovalSigs is an option that sets the `AggregatedApprovalSigs` of the seal.

func (SealGenerator) WithBlockID

func (f SealGenerator) WithBlockID(blockID flow.Identifier) SealOption

WithBlockID is an option that sets the `BlockID` of the seal.

func (SealGenerator) WithFinalState

func (f SealGenerator) WithFinalState(finalState flow.StateCommitment) SealOption

WithFinalState is an option that sets the `FinalState` of the seal.

func (SealGenerator) WithResultID

func (f SealGenerator) WithResultID(resultID flow.Identifier) SealOption

WithResultID is an option that sets the `ResultID` of the seal.

type SealOption

type SealOption func(*SealGenerator, *flow.Seal)

type ServiceEventGenerator

type ServiceEventGenerator struct {
	// contains filtered or unexported fields
}

ServiceEventGenerator generates service events with consistent randomness.

func NewServiceEventGenerator

func NewServiceEventGenerator(
	random *RandomGenerator,
	epochSetups *EpochSetupGenerator,
	epochCommits *EpochCommitGenerator,
	epochRecovers *EpochRecoverGenerator,
	versionBeacons *VersionBeaconGenerator,
	protocolStateVersionUpgrades *ProtocolStateVersionUpgradeGenerator,
	setEpochExtensionViewCounts *SetEpochExtensionViewCountGenerator,
	ejectNodes *EjectNodeGenerator,
) *ServiceEventGenerator

NewServiceEventGenerator creates a new ServiceEventGenerator.

func (*ServiceEventGenerator) Fixture

Fixture generates a flow.ServiceEvent with random data based on the provided options.

func (*ServiceEventGenerator) List

List generates a list of flow.ServiceEvent.

func (ServiceEventGenerator) WithEvent

func (f ServiceEventGenerator) WithEvent(eventData interface{}) ServiceEventOption

WithEvent is an option that sets the `Event` data of the service event.

func (ServiceEventGenerator) WithType

func (f ServiceEventGenerator) WithType(eventType flow.ServiceEventType) ServiceEventOption

WithType is an option that sets the `Type` of the service event.

type ServiceEventOption

type ServiceEventOption func(*ServiceEventGenerator, *flow.ServiceEvent)

type SetEpochExtensionViewCountGenerator

type SetEpochExtensionViewCountGenerator struct {
	// contains filtered or unexported fields
}

SetEpochExtensionViewCountGenerator generates epoch extension view count events with consistent randomness.

func NewSetEpochExtensionViewCountGenerator

func NewSetEpochExtensionViewCountGenerator(random *RandomGenerator) *SetEpochExtensionViewCountGenerator

NewSetEpochExtensionViewCountGenerator creates a new SetEpochExtensionViewCountGenerator.

func (*SetEpochExtensionViewCountGenerator) Fixture

Fixture generates a flow.SetEpochExtensionViewCount with random data based on the provided options.

func (*SetEpochExtensionViewCountGenerator) List

List generates a list of flow.SetEpochExtensionViewCount.

func (SetEpochExtensionViewCountGenerator) WithValue

func (f SetEpochExtensionViewCountGenerator) WithValue(value uint64) SetEpochExtensionViewCountOption

WithValue is an option that sets the `Value` of the extension view count.

type SignatureGenerator

type SignatureGenerator struct {
	// contains filtered or unexported fields
}

SignatureGenerator generates signatures with consistent randomness.

func NewSignatureGenerator

func NewSignatureGenerator(
	random *RandomGenerator,
) *SignatureGenerator

func (*SignatureGenerator) Fixture

func (g *SignatureGenerator) Fixture(opts ...SignatureOption) crypto.Signature

Fixture generates a random crypto.Signature.

func (*SignatureGenerator) List

func (g *SignatureGenerator) List(n int, opts ...SignatureOption) []crypto.Signature

List generates a list of random crypto.Signature.

type SignatureOption

type SignatureOption func(*SignatureGenerator, *signatureConfig)

type SignerIndicesGenerator

type SignerIndicesGenerator struct {
	// contains filtered or unexported fields
}

SignerIndicesGenerator generates signer indices with consistent randomness.

func NewSignerIndicesGenerator

func NewSignerIndicesGenerator(random *RandomGenerator) *SignerIndicesGenerator

func (*SignerIndicesGenerator) Fixture

func (g *SignerIndicesGenerator) Fixture(opts ...SignerIndicesOption) []byte

Fixture generates signer indices with random data based on the provided options. Uses default 10-bit vector size and count of 3 signers.

func (*SignerIndicesGenerator) List

func (g *SignerIndicesGenerator) List(n int, opts ...SignerIndicesOption) [][]byte

List generates a list of signer indices. Uses default 10-bit vector size and count of 3 signers.

func (SignerIndicesGenerator) WithIndices

func (f SignerIndicesGenerator) WithIndices(authorizedSigners int, indices []int) SignerIndicesOption

WithIndices is an option that sets the total number of indices and specific indices for signers. Note: passing an empty slice is valid and will be treated as all indices are not set.

func (SignerIndicesGenerator) WithSignerCount

func (f SignerIndicesGenerator) WithSignerCount(authorizedSigners, contributingSigners int) SignerIndicesOption

WithSignerCount is an option that sets the total number of indices and the number of signers.

type SignerIndicesOption

type SignerIndicesOption func(*SignerIndicesGenerator, *signerIndicesConfig)

type StateCommitmentGenerator

type StateCommitmentGenerator struct {
	// contains filtered or unexported fields
}

StateCommitmentGenerator generates state commitments with consistent randomness.

func NewStateCommitmentGenerator

func NewStateCommitmentGenerator(random *RandomGenerator) *StateCommitmentGenerator

NewStateCommitmentGenerator creates a new StateCommitmentGenerator.

func (*StateCommitmentGenerator) Fixture

Fixture generates a flow.StateCommitment with random data based on the provided options.

func (*StateCommitmentGenerator) List

List generates a list of flow.StateCommitment.

func (StateCommitmentGenerator) WithEmptyState

func (f StateCommitmentGenerator) WithEmptyState() StateCommitmentOption

WithEmptyState is an option that sets the state commitment to empty.

func (StateCommitmentGenerator) WithHash

func (f StateCommitmentGenerator) WithHash(h hash.Hash) StateCommitmentOption

WithHash is an option that sets the hash of the state commitment.

type StateCommitmentOption

type StateCommitmentOption func(*StateCommitmentGenerator, *flow.StateCommitment)

type TimeGenerator

type TimeGenerator struct {
	// contains filtered or unexported fields
}

TimeGenerator generates time.Time values with consistent randomness.

func NewTimeGenerator

func NewTimeGenerator(
	random *RandomGenerator,
) *TimeGenerator

func (*TimeGenerator) Fixture

func (g *TimeGenerator) Fixture(opts ...TimeOption) time.Time

Fixture generates a time.Time value. Uses default base time of 2020-07-14T16:00:00Z and timezone of UTC. The default offset is within 10 years of 2020-07-14T16:00:00Z.

func (*TimeGenerator) List

func (g *TimeGenerator) List(n int, opts ...TimeOption) []time.Time

List generates a list of time.Time values. Uses default base time of 2020-07-14T16:00:00Z and timezone of UTC. The default offset is within 10 years of 2020-07-14T16:00:00Z.

func (TimeGenerator) WithBaseTime

func (f TimeGenerator) WithBaseTime(baseTime time.Time) TimeOption

WithBaseTime is an option that sets the time produced by the generator. This will be the exact time. If you want to include a random jitter, use the WithOffsetRandom option in combination with this option.

func (TimeGenerator) WithOffset

func (f TimeGenerator) WithOffset(offset time.Duration) TimeOption

WithOffset is an option that sets the offset from the base time. This sets the exact offset of the base time.

func (TimeGenerator) WithOffsetRandom

func (f TimeGenerator) WithOffsetRandom(max time.Duration) TimeOption

WithOffsetRandom is an option that sets a random offset from the base time in the range [0, max).

func (TimeGenerator) WithTimezone

func (f TimeGenerator) WithTimezone(tz *time.Location) TimeOption

WithTimezone is an option that sets the timezone for time generation.

type TimeOption

type TimeOption func(*TimeGenerator, *timeConfig)

type TimeoutCertificateGenerator

type TimeoutCertificateGenerator struct {
	// contains filtered or unexported fields
}

TimeoutCertificateGenerator generates timeout certificates with consistent randomness.

func NewTimeoutCertificateGenerator

func NewTimeoutCertificateGenerator(
	random *RandomGenerator,
	quorumCerts *QuorumCertificateGenerator,
	signatures *SignatureGenerator,
	signerIndices *SignerIndicesGenerator,
) *TimeoutCertificateGenerator

NewTimeoutCertificateGenerator creates a new TimeoutCertificateGenerator.

func (*TimeoutCertificateGenerator) Fixture

Fixture generates a flow.TimeoutCertificate with random data based on the provided options.

func (*TimeoutCertificateGenerator) List

List generates a list of flow.TimeoutCertificate.

func (TimeoutCertificateGenerator) WithNewestQC

func (f TimeoutCertificateGenerator) WithNewestQC(qc *flow.QuorumCertificate) TimeoutCertificateOption

WithNewestQC is an option that sets the `NewestQC` of the timeout certificate.

func (TimeoutCertificateGenerator) WithNewestQCViews

func (f TimeoutCertificateGenerator) WithNewestQCViews(views []uint64) TimeoutCertificateOption

WithNewestQCViews is an option that sets the `NewestQCViews` of the timeout certificate.

func (TimeoutCertificateGenerator) WithSigData

func (f TimeoutCertificateGenerator) WithSigData(sigData []byte) TimeoutCertificateOption

WithSigData is an option that sets the `SigData` of the timeout certificate.

func (TimeoutCertificateGenerator) WithSignerIndices

func (f TimeoutCertificateGenerator) WithSignerIndices(indices []byte) TimeoutCertificateOption

WithSignerIndices is an option that sets the `SignerIndices` of the timeout certificate.

func (TimeoutCertificateGenerator) WithView

func (f TimeoutCertificateGenerator) WithView(view uint64) TimeoutCertificateOption

WithView is an option that sets the `View` of the timeout certificate.

type TimeoutCertificateOption

type TimeoutCertificateOption func(*TimeoutCertificateGenerator, *flow.TimeoutCertificate)

type TransactionGenerator

type TransactionGenerator struct {
	// contains filtered or unexported fields
}

TransactionGenerator generates transactions with consistent randomness.

func NewTransactionGenerator

func NewTransactionGenerator(
	identifiers *IdentifierGenerator,
	proposalKeys *ProposalKeyGenerator,
	addresses *AddressGenerator,
	transactionSigs *TransactionSignatureGenerator,
) *TransactionGenerator

func (*TransactionGenerator) Fixture

Fixture generates a flow.TransactionBody with random data based on the provided options.

func (*TransactionGenerator) List

List generates a list of flow.TransactionBody.

func (TransactionGenerator) WithAuthorizers

func (f TransactionGenerator) WithAuthorizers(authorizers ...flow.Address) TransactionOption

WithAuthorizers is an option that sets the authorizers for the transaction.

func (TransactionGenerator) WithEnvelopeSignatures

func (f TransactionGenerator) WithEnvelopeSignatures(signatures ...flow.TransactionSignature) TransactionOption

WithEnvelopeSignatures is an option that sets the envelope signatures for the transaction.

func (TransactionGenerator) WithGasLimit

func (f TransactionGenerator) WithGasLimit(gasLimit uint64) TransactionOption

WithGasLimit is an option that sets the gas limit for the transaction.

func (TransactionGenerator) WithPayer

func (f TransactionGenerator) WithPayer(payer flow.Address) TransactionOption

WithPayer is an option that sets the payer for the transaction.

func (TransactionGenerator) WithProposalKey

func (f TransactionGenerator) WithProposalKey(proposalKey flow.ProposalKey) TransactionOption

WithProposalKey is an option that sets the proposal key for the transaction.

func (TransactionGenerator) WithReferenceBlockID

func (f TransactionGenerator) WithReferenceBlockID(blockID flow.Identifier) TransactionOption

WithReferenceBlockID is an option that sets the reference block ID for the transaction.

func (TransactionGenerator) WithScript

func (f TransactionGenerator) WithScript(script []byte) TransactionOption

WithScript is an option that sets the script for the transaction.

type TransactionOption

type TransactionOption func(*TransactionGenerator, *flow.TransactionBody)

type TransactionResultGenerator

type TransactionResultGenerator struct {
	// contains filtered or unexported fields
}

TransactionResultGenerator generates transaction results with consistent randomness.

func NewTransactionResultGenerator

func NewTransactionResultGenerator(
	random *RandomGenerator,
	identifiers *IdentifierGenerator,
) *TransactionResultGenerator

func (*TransactionResultGenerator) Fixture

Fixture generates a flow.TransactionResult with random data based on the provided options.

func (*TransactionResultGenerator) List

List generates a list of flow.TransactionResult.

func (TransactionResultGenerator) WithComputationUsed

func (f TransactionResultGenerator) WithComputationUsed(computationUsed uint64) TransactionResultOption

WithComputationUsed is an option that sets the computation used for the transaction result.

func (TransactionResultGenerator) WithErrorMessage

func (f TransactionResultGenerator) WithErrorMessage(errorMessage string) TransactionResultOption

WithErrorMessage is an option that sets the error message for the transaction result.

func (TransactionResultGenerator) WithTransactionID

func (f TransactionResultGenerator) WithTransactionID(transactionID flow.Identifier) TransactionResultOption

WithTransactionID is an option that sets the transaction ID for the transaction result.

type TransactionResultOption

type TransactionResultOption func(*TransactionResultGenerator, *flow.TransactionResult)

type TransactionSignatureGenerator

type TransactionSignatureGenerator struct {
	// contains filtered or unexported fields
}

TransactionSignatureGenerator generates transaction signatures with consistent randomness.

func NewTransactionSignatureGenerator

func NewTransactionSignatureGenerator(
	random *RandomGenerator,
	addresses *AddressGenerator,
) *TransactionSignatureGenerator

func (*TransactionSignatureGenerator) Fixture

Fixture generates a flow.TransactionSignature with random data based on the provided options.

func (*TransactionSignatureGenerator) List

List generates a list of flow.TransactionSignature.

func (TransactionSignatureGenerator) WithAddress

func (f TransactionSignatureGenerator) WithAddress(address flow.Address) TransactionSignatureOption

WithAddress is an option that sets the address for the transaction signature.

func (TransactionSignatureGenerator) WithKeyIndex

func (f TransactionSignatureGenerator) WithKeyIndex(keyIndex uint32) TransactionSignatureOption

WithKeyIndex is an option that sets the key index for the transaction signature.

func (TransactionSignatureGenerator) WithSignature

func (f TransactionSignatureGenerator) WithSignature(sig crypto.Signature) TransactionSignatureOption

WithSignature is an option that sets the signature for the transaction signature.

func (TransactionSignatureGenerator) WithSignerIndex

func (f TransactionSignatureGenerator) WithSignerIndex(signerIndex int) TransactionSignatureOption

WithSignerIndex is an option that sets the signer index for the transaction signature.

type TrieUpdateGenerator

type TrieUpdateGenerator struct {
	// contains filtered or unexported fields
}

TrieUpdateGenerator generates trie updates with consistent randomness.

func NewTrieUpdateGenerator

func NewTrieUpdateGenerator(
	random *RandomGenerator,
	ledgerPaths *LedgerPathGenerator,
	ledgerPayloads *LedgerPayloadGenerator,
) *TrieUpdateGenerator

func (*TrieUpdateGenerator) Fixture

Fixture generates a ledger.TrieUpdate with random data based on the provided options.

func (*TrieUpdateGenerator) List

func (g *TrieUpdateGenerator) List(n int, opts ...TrieUpdateOption) []*ledger.TrieUpdate

List generates a list of ledger.TrieUpdate.

func (TrieUpdateGenerator) WithNumPaths

func (f TrieUpdateGenerator) WithNumPaths(numPaths int) TrieUpdateOption

WithNumPaths is an option that sets the number of paths for the trie update.

func (TrieUpdateGenerator) WithPaths

func (f TrieUpdateGenerator) WithPaths(paths ...ledger.Path) TrieUpdateOption

WithPaths is an option that sets the paths for the trie update.

func (TrieUpdateGenerator) WithPayloadSize

func (f TrieUpdateGenerator) WithPayloadSize(minSize, maxSize int) TrieUpdateOption

WithPayloadSize is an option that sets the payload size range for the trie update.

func (TrieUpdateGenerator) WithPayloads

func (f TrieUpdateGenerator) WithPayloads(payloads ...*ledger.Payload) TrieUpdateOption

WithPayloads is an option that sets the payloads for the trie update.

func (TrieUpdateGenerator) WithRootHash

func (f TrieUpdateGenerator) WithRootHash(rootHash ledger.RootHash) TrieUpdateOption

WithRootHash is an option that sets the root hash for the trie update.

type TrieUpdateOption

type TrieUpdateOption func(*TrieUpdateGenerator, *trieUpdateConfig)

type VersionBeaconGenerator

type VersionBeaconGenerator struct {
	// contains filtered or unexported fields
}

VersionBeaconGenerator generates version beacons with consistent randomness.

func NewVersionBeaconGenerator

func NewVersionBeaconGenerator(random *RandomGenerator) *VersionBeaconGenerator

NewVersionBeaconGenerator creates a new VersionBeaconGenerator.

func (*VersionBeaconGenerator) Fixture

Fixture generates a flow.VersionBeacon with random data based on the provided options.

func (*VersionBeaconGenerator) List

List generates a list of flow.VersionBeacon.

func (VersionBeaconGenerator) WithBoundaries

func (f VersionBeaconGenerator) WithBoundaries(boundaries ...flow.VersionBoundary) VersionBeaconOption

WithBoundaries is an option that sets the `VersionBoundaries` of the version beacon.

func (VersionBeaconGenerator) WithSequence

func (f VersionBeaconGenerator) WithSequence(sequence uint64) VersionBeaconOption

WithSequence is an option that sets the `Sequence` of the version beacon.

type VersionBeaconOption

type VersionBeaconOption func(*VersionBeaconGenerator, *flow.VersionBeacon)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL