Documentation ¶
Index ¶
- Constants
- Variables
- func AccountKeyDefaultFixture() (*flow.AccountPrivateKey, error)
- func AccountKeyFixture(seedLength int, signingAlgo crypto.SigningAlgorithm, ...) (*flow.AccountPrivateKey, error)
- func AddressFixture() flow.Address
- func AlterTransactionForCluster(tx flow.TransactionBody, clusters flow.ClusterList, target flow.IdentityList, ...) flow.TransactionBody
- func ApprovalFor(result *flow.ExecutionResult, chunkIdx uint64, approverID flow.Identifier) *flow.ResultApproval
- func AssertClosesBefore(t *testing.T, done <-chan struct{}, duration time.Duration)
- func AssertErrSubstringMatch(t testing.TB, expected, actual error)
- func AssertReturnsBefore(t *testing.T, f func(), duration time.Duration)
- func AssertSnapshotsEqual(t *testing.T, snap1, snap2 protocol.Snapshot)
- func BadgerDB(t testing.TB, dir string) *badger.DB
- func BatchFixture() flow.Batch
- func BatchListFixture(n int) []flow.Batch
- func BlockFixture() flow.Block
- func BlockFixtures(number int) []*flow.Block
- func BlockHeaderFixture(opts ...func(header *flow.Header)) flow.Header
- func BlockHeaderFixtureOnChain(chainID flow.ChainID) flow.Header
- func BlockHeaderWithParentFixture(parent *flow.Header) flow.Header
- func BlockSealsFixture(n int) []*flow.Seal
- func BlockWithGuaranteesFixture(guarantees []*flow.CollectionGuarantee) *flow.Block
- func BlockWithParentAndProposerFixture(parent *flow.Header, proposer flow.Identifier) flow.Block
- func BlockWithParentAndSeal(parent *flow.Header, sealed *flow.Header) *flow.Block
- func BlockWithParentFixture(parent *flow.Header) flow.Block
- func BootstrapExecutionResultFixture(block *flow.Block, commit flow.StateCommitment) *flow.ExecutionResult
- func BootstrapFixture(participants flow.IdentityList, opts ...func(*flow.Block)) (*flow.Block, *flow.ExecutionResult, *flow.Seal)
- func ChainFixture(nonGenesisCount int) ([]*flow.Block, *flow.ExecutionResult, *flow.Seal)
- func ChainFixtureFrom(count int, parent *flow.Header) []*flow.Block
- func ChunkDataPackFixture(chunkID flow.Identifier, opts ...func(*flow.ChunkDataPack)) *flow.ChunkDataPack
- func ChunkDataPackRequestFixture(chunkID flow.Identifier, opts ...func(*verification.ChunkDataPackRequest)) *verification.ChunkDataPackRequest
- func ChunkDataPackRequestListFixture(n int, opts ...func(*verification.ChunkDataPackRequest)) []*verification.ChunkDataPackRequest
- func ChunkDataResponseFixture(chunkID flow.Identifier, opts ...func(*messages.ChunkDataResponse)) *messages.ChunkDataResponse
- func ChunkDataResponsesFixture(n int, opts ...func(*messages.ChunkDataResponse)) []*messages.ChunkDataResponse
- func ChunkFixture(blockID flow.Identifier, collectionIndex uint) *flow.Chunk
- func ChunkListFixture(n uint, blockID flow.Identifier) flow.ChunkList
- func ChunkLocatorFixture(resultID flow.Identifier, index uint64) *chunks.Locator
- func ChunkLocatorListFixture(n uint) chunks.LocatorList
- func ChunkStatusListFixture(t *testing.T, results []*flow.ExecutionResult, n int) verification.ChunkStatusList
- func ChunkStatusListToChunkLocatorFixture(statuses []*verification.ChunkStatus) chunks.LocatorList
- func ClusterAssignment(n uint, nodes flow.IdentityList) flow.AssignmentList
- func ClusterBlockFixture() cluster.Block
- func ClusterBlockWithParent(parent *cluster.Block) cluster.Block
- func ClusterList(n uint, nodes flow.IdentityList) flow.ClusterList
- func ClusterPayloadFixture(n int) *cluster.Payload
- func CollectionFixture(n int) flow.Collection
- func CollectionGuaranteeFixture(options ...func(*flow.CollectionGuarantee)) *flow.CollectionGuarantee
- func CollectionGuaranteesFixture(n int, options ...func(*flow.CollectionGuarantee)) []*flow.CollectionGuarantee
- func CollectionGuaranteesWithCollectionIDFixture(collections []*flow.Collection) []*flow.CollectionGuarantee
- func CollectionListFixture(n int) []*flow.Collection
- func CombinedSignatureFixture(n int) crypto.Signature
- func CommitWithCounter(counter uint64) func(*flow.EpochCommit)
- func CompleteCollectionFixture() *entity.CompleteCollection
- func CompleteCollectionFromTransactions(txs []*flow.TransactionBody) *entity.CompleteCollection
- func CompleteIdentitySet(identities ...*flow.Identity) flow.IdentityList
- func Concurrently(n int, f func(int))
- func CreateNParticipantsWithMyRole(myRole flow.Role, otherRoles ...flow.Role) (flow.IdentityList, flow.Identifier, *module.Local)
- func DKGBroadcastMessageFixture() *messages.BroadcastDKGMessage
- func DKGMessageFixture() *messages.DKGMessage
- func DKGParticipantLookup(participants flow.IdentityList) map[flow.Identifier]flow.DKGParticipant
- func DKGParticipantPriv() *dkg.DKGParticipantPriv
- func EmulatorRootKey() (*flow.AccountPrivateKey, error)
- func EntityWithID(expectedID flow.Identifier) interface{}
- func EpochCommitFixture(opts ...func(*flow.EpochCommit)) *flow.EpochCommit
- func EpochSetupFixture(opts ...func(setup *flow.EpochSetup)) *flow.EpochSetup
- func EpochStatusFixture() *flow.EpochStatus
- func EventFixture(eType flow.EventType, transactionIndex uint32, eventIndex uint32, ...) flow.Event
- func ExecutableBlockFixture(collectionsSignerIDs [][]flow.Identifier) *entity.ExecutableBlock
- func ExecutableBlockFixtureWithParent(collectionsSignerIDs [][]flow.Identifier, parent *flow.Header) *entity.ExecutableBlock
- func ExecutableBlockFromTransactions(txss [][]*flow.TransactionBody) *entity.ExecutableBlock
- func ExecutionReceiptFixture(opts ...func(*flow.ExecutionReceipt)) *flow.ExecutionReceipt
- func ExecutionResultFixture(opts ...func(*flow.ExecutionResult)) *flow.ExecutionResult
- func ExecutionResultListFixture(n int, opts ...func(*flow.ExecutionResult)) []*flow.ExecutionResult
- func ExpectPanic(expectedMsg string, t *testing.T)
- func FinalizedProtocolStateWithParticipants(participants flow.IdentityList) (*flow.Block, *mockprotocol.Snapshot, *mockprotocol.State, ...)
- func FullBlockFixture() flow.Block
- func GenesisFixture() *flow.Block
- func HashFixture(size int) hash.Hash
- func HeadersFromMap(headerDB map[flow.Identifier]*flow.Header) *storage.Headers
- func IDEqual(t *testing.T, id1, id2 flow.Identifier)
- func IDsEqual(t *testing.T, id1, id2 []flow.Identifier)
- func IdentifierFixture() flow.Identifier
- func IdentifierListFixture(n int) []flow.Identifier
- func IdentityFixture(opts ...func(*flow.Identity)) *flow.Identity
- func IdentityListFixture(n int, opts ...func(*flow.Identity)) flow.IdentityList
- func IndexFixture() *flow.Index
- func InvalidAddressFixture() flow.Address
- func InvalidFormatSignature() flow.TransactionSignature
- func KeyFixture(algo crypto.SigningAlgorithm) crypto.PrivateKey
- func KeysFixture(n int, algo crypto.SigningAlgorithm) []crypto.PrivateKey
- func LogVerbose()
- func Logger() zerolog.Logger
- func MustDecodePublicKeyHex(algo crypto.SigningAlgorithm, keyHex string) crypto.PublicKey
- func MustDecodeSignatureHex(sigHex string) crypto.Signature
- func NetworkingKey() (crypto.PrivateKey, error)
- func NetworkingKeys(n int) ([]crypto.PrivateKey, error)
- func NodeInfoFixture(opts ...func(*flow.Identity)) bootstrap.NodeInfo
- func NodeInfosFixture(n int, opts ...func(*flow.Identity)) []bootstrap.NodeInfo
- func NoopTxScript() []byte
- func PayloadFixture(options ...func(*flow.Payload)) flow.Payload
- func PendingFromBlock(block *flow.Block) *flow.PendingBlock
- func PrivateNodeInfosFixture(n int, opts ...func(*flow.Identity)) []bootstrap.NodeInfo
- func ProposalFixture() *messages.BlockProposal
- func ProposalFromBlock(block *flow.Block) *messages.BlockProposal
- func ProposalKeyFixture() flow.ProposalKey
- func PublicKeysFixture(n int, algo crypto.SigningAlgorithm) []crypto.PublicKey
- func QCWithBlockID(blockID flow.Identifier) func(*flow.QuorumCertificate)
- func QCWithSignerIDs(signerIDs []flow.Identifier) func(*flow.QuorumCertificate)
- func QuorumCertificateFixture(opts ...func(*flow.QuorumCertificate)) *flow.QuorumCertificate
- func QuorumCertificatesFixtures(n uint, opts ...func(*flow.QuorumCertificate)) []*flow.QuorumCertificate
- func RandomAddressFixture() flow.Address
- func RandomBytes(n int) []byte
- func RangeFixture() flow.Range
- func RangeListFixture(n int) []flow.Range
- func ReadyDoneify(toMock interface{})
- func ReceiptAndSealForBlock(block *flow.Block) (*flow.ExecutionReceipt, *flow.Seal)
- func ReceiptChainFor(blocks []*flow.Block, result0 *flow.ExecutionResult) []*flow.ExecutionReceipt
- func ReceiptForBlockExecutorFixture(block *flow.Block, executor flow.Identifier) *flow.ExecutionReceipt
- func ReceiptForBlockFixture(block *flow.Block) *flow.ExecutionReceipt
- func ReceiptsForBlockFixture(block *flow.Block, ids []flow.Identifier) []*flow.ExecutionReceipt
- func ReconnectBlocksAndReceipts(blocks []*flow.Block, receipts []*flow.ExecutionReceipt)
- func RegisterNetwork() (*module.Network, *mocknetwork.Conduit)
- func RequireCloseBefore(t testing.TB, c <-chan struct{}, duration time.Duration, message string)
- func RequireComponentsDoneBefore(t testing.TB, duration time.Duration, components ...module.ReadyDoneAware)
- func RequireComponentsReadyBefore(t testing.TB, duration time.Duration, components ...module.ReadyDoneAware)
- func RequireConcurrentCallsReturnBefore(t *testing.T, f func(), count int, duration time.Duration, message string)
- func RequireFileEmpty(t *testing.T, path string)
- func RequireNeverClosedWithin(t *testing.T, ch <-chan struct{}, duration time.Duration, message string)
- func RequireNeverReturnBefore(t *testing.T, f func(), duration time.Duration, message string) <-chan struct{}
- func RequireReturnsBefore(t testing.TB, f func(), duration time.Duration, message string)
- func ResultApprovalFixture(opts ...func(*flow.ResultApproval)) *flow.ResultApproval
- func RootSnapshotFixture(participants flow.IdentityList, opts ...func(*flow.Block)) *inmem.Snapshot
- func RunWithBadgerDB(t testing.TB, f func(*badger.DB))
- func RunWithTempDir(t testing.TB, f func(string))
- func SealBlock(t *testing.T, st protocol.MutableState, block *flow.Block, ...) *flow.Header
- func SeedFixture(n int) []byte
- func SeedFixtures(m int, n int) [][]byte
- func SetupWithCounter(counter uint64) func(*flow.EpochSetup)
- func SignatureFixture() crypto.Signature
- func SignaturesFixture(n int) []crypto.Signature
- func StakingKey() (crypto.PrivateKey, error)
- func StakingKeys(n int) ([]crypto.PrivateKey, error)
- func StateCommitmentFixture() flow.StateCommitment
- func StateCommitmentPointerFixture() *flow.StateCommitment
- func StateDeltaFixture() *messages.ExecutionStateDelta
- func StateDeltaWithParentFixture(parent *flow.Header) *messages.ExecutionStateDelta
- func StateInteractionsFixture() *delta.Snapshot
- func StateSnapshotForKnownBlock(block *flow.Header, identities map[flow.Identifier]*flow.Identity) *protocol.Snapshot
- func StateSnapshotForUnknownBlock() *protocol.Snapshot
- func TempBadgerDB(t testing.TB) (*badger.DB, string)
- func TempDir(t testing.TB) string
- func TransactionBodyFixture(opts ...func(*flow.TransactionBody)) flow.TransactionBody
- func TransactionDSLFixture(chain flow.Chain) dsl.Transaction
- func TransactionFixture(n ...func(t *flow.Transaction)) flow.Transaction
- func TransactionForCluster(clusters flow.ClusterList, target flow.IdentityList) flow.TransactionBody
- func TransactionSignatureFixture() flow.TransactionSignature
- func VerifiableChunkDataFixture(chunkIndex uint64) *verification.VerifiableChunkData
- func VoteFixture() *hotstuff.Vote
- func WithAddress(address string) func(*flow.Identity)
- func WithAgrees(list flow.IdentifierList) func(*verification.ChunkDataPackRequest)
- func WithAllRoles() func(*flow.Identity)
- func WithAllRolesExcept(except ...flow.Role) func(*flow.Identity)
- func WithAllTheFixins(payload *flow.Payload)
- func WithApproverID(approverID flow.Identifier) func(*flow.ResultApproval)
- func WithAttestationBlock(block *flow.Block) func(*flow.ResultApproval)
- func WithBlock(block *flow.Block) func(*flow.ExecutionResult)
- func WithBlockID(id flow.Identifier) func(*flow.ResultApproval)
- func WithChunk(chunkIdx uint64) func(*flow.ResultApproval)
- func WithChunks(n uint) func(*flow.ExecutionResult)
- func WithClusterQCsFromAssignments(assignments flow.AssignmentList) func(*flow.EpochCommit)
- func WithCollRef(refID flow.Identifier) func(*flow.CollectionGuarantee)
- func WithCollection(collection *flow.Collection) func(guarantee *flow.CollectionGuarantee)
- func WithCollectionID(collectionID flow.Identifier) func(*flow.ChunkDataPack)
- func WithDKGFromParticipants(participants flow.IdentityList) func(*flow.EpochCommit)
- func WithDisagrees(list flow.IdentifierList) func(*verification.ChunkDataPackRequest)
- func WithEjected(ejected bool) func(*flow.Identity)
- func WithExecutionResultBlockID(blockID flow.Identifier) func(*flow.ExecutionResult)
- func WithExecutionResultID(id flow.Identifier) func(*flow.ResultApproval)
- func WithExecutorID(executorID flow.Identifier) func(*flow.ExecutionReceipt)
- func WithFinalView(view uint64) func(*flow.EpochSetup)
- func WithFirstView(view uint64) func(*flow.EpochSetup)
- func WithGuarantees(guarantees ...*flow.CollectionGuarantee) func(*flow.Payload)
- func WithHeaderHeight(height uint64) func(header *flow.Header)
- func WithHeight(height uint64) func(*verification.ChunkDataPackRequest)
- func WithHeightGreaterThan(height uint64) func(*verification.ChunkDataPackRequest)
- func WithKeys(identity *flow.Identity)
- func WithNetworkingKey(key crypto.PublicKey) func(*flow.Identity)
- func WithNodeID(id flow.Identifier) func(*flow.Identity)
- func WithParticipants(participants flow.IdentityList) func(*flow.EpochSetup)
- func WithPreviousResult(prevResult flow.ExecutionResult) func(*flow.ExecutionResult)
- func WithRandomPublicKeys() func(*flow.Identity)
- func WithReceipts(receipts ...*flow.ExecutionReceipt) func(*flow.Payload)
- func WithReferenceBlock(id flow.Identifier) func(tx *flow.TransactionBody)
- func WithResult(result *flow.ExecutionResult) func(*flow.ExecutionReceipt)
- func WithRole(role flow.Role) func(*flow.Identity)
- func WithSeals(seals ...*flow.Seal) func(*flow.Payload)
- func WithServiveEvents(events ...flow.ServiceEvent) func(*flow.ExecutionResult)
- func WithStake(stake uint64) func(*flow.Identity)
- func WithStakingPubKey(pubKey crypto.PublicKey) func(*flow.Identity)
- func WithStartState(startState flow.StateCommitment) func(*flow.ChunkDataPack)
- func WithTransactionDSL(txDSL dsl.Transaction) func(tx *flow.TransactionBody)
- func WithoutGuarantee(payload *flow.Payload)
- type BaseChainSuite
- type ClusterStateChecker
- func (checker *ClusterStateChecker) Assert(t *testing.T)
- func (checker *ClusterStateChecker) ExpectContainsTx(txIDs ...flow.Identifier) *ClusterStateChecker
- func (checker *ClusterStateChecker) ExpectOmitsTx(txIDs ...flow.Identifier) *ClusterStateChecker
- func (checker *ClusterStateChecker) ExpectTxCount(n int) *ClusterStateChecker
- type EpochBuilder
- func (builder *EpochBuilder) BuildBlocks(n uint)
- func (builder *EpochBuilder) BuildEpoch() *EpochBuilder
- func (builder *EpochBuilder) CompleteEpoch() *EpochBuilder
- func (builder *EpochBuilder) EpochHeights(counter uint64) (EpochHeights, bool)
- func (builder *EpochBuilder) UsingCommitOpts(opts ...func(*flow.EpochCommit)) *EpochBuilder
- func (builder *EpochBuilder) UsingSetupOpts(opts ...func(*flow.EpochSetup)) *EpochBuilder
- type EpochHeights
- type FixedStaker
Constants ¶
const GenesisStateCommitmentHex = "e821d24672039a895babe57ffd4654d9f56a8d1dda61acdaa08254c275674e76"
Pre-calculated state commitment with root account with the above private key
const ServiceAccountPrivateKeyHex = "e3a08ae3d0461cfed6d6f49bfc25fa899351c39d1bd21fdba8c87595b6c49bb4cc430201"
Variables ¶
var GenesisStateCommitment flow.StateCommitment
var GenesisTokenSupply = func() cadence.UFix64 { value, err := cadence.NewUFix64("1000000000.0") if err != nil { panic(fmt.Errorf("invalid genesis token supply: %w", err)) } return value }()
var IncorporatedResult incorporatedResultFactory
var IncorporatedResultSeal incorporatedResultSealFactory
var Seal sealFactory
var ServiceAccountPrivateKey flow.AccountPrivateKey
var ServiceAccountPublicKey flow.AccountPublicKey
Functions ¶
func AccountKeyDefaultFixture ¶ added in v0.15.0
func AccountKeyDefaultFixture() (*flow.AccountPrivateKey, error)
AccountKeyDefaultFixture returns a randomly generated ECDSA/SHA3 account key.
func AccountKeyFixture ¶
func AccountKeyFixture( seedLength int, signingAlgo crypto.SigningAlgorithm, hashAlgo hash.HashingAlgorithm, ) (*flow.AccountPrivateKey, error)
AccountKeyFixture returns a randomly generated account key.
func AddressFixture ¶
func AlterTransactionForCluster ¶
func AlterTransactionForCluster(tx flow.TransactionBody, clusters flow.ClusterList, target flow.IdentityList, after func(tx *flow.TransactionBody)) flow.TransactionBody
AlterTransactionForCluster modifies a transaction nonce until it is assigned to the target cluster.
The `after` function is run after each modification to allow for any content dependent changes to the transaction (eg. signing it).
func ApprovalFor ¶ added in v0.14.0
func ApprovalFor(result *flow.ExecutionResult, chunkIdx uint64, approverID flow.Identifier) *flow.ResultApproval
func AssertClosesBefore ¶
AssertClosesBefore asserts that the given channel closes before the duration expires.
func AssertErrSubstringMatch ¶
AssertErrSubstringMatch asserts that two errors match with substring checking on the Error method (`expected` must be a substring of `actual`, to account for the actual error being wrapped). Fails the test if either error is nil.
NOTE: This should only be used in cases where `errors.Is` cannot be, like when errors are transmitted over the network without type information.
func AssertReturnsBefore ¶
AssertReturnsBefore asserts that the given function returns before the duration expires.
func AssertSnapshotsEqual ¶ added in v0.15.0
func BatchFixture ¶
func BatchListFixture ¶
func BlockFixture ¶
func BlockFixtures ¶ added in v0.13.0
func BlockSealsFixture ¶
func BlockWithGuaranteesFixture ¶ added in v0.17.6
func BlockWithGuaranteesFixture(guarantees []*flow.CollectionGuarantee) *flow.Block
func BlockWithParentAndProposerFixture ¶ added in v0.10.0
func BlockWithParentAndSeal ¶ added in v0.10.0
func BootstrapExecutionResultFixture ¶
func BootstrapExecutionResultFixture(block *flow.Block, commit flow.StateCommitment) *flow.ExecutionResult
func BootstrapFixture ¶
func BootstrapFixture(participants flow.IdentityList, opts ...func(*flow.Block)) (*flow.Block, *flow.ExecutionResult, *flow.Seal)
BootstrapFixture generates all the artifacts necessary to bootstrap the protocol state.
func ChainFixture ¶ added in v0.11.0
ChainFixture creates a list of blocks that forms a chain
func ChainFixtureFrom ¶ added in v0.11.0
ChainFixtureFrom creates a chain of blocks starting from a given parent block, the total number of blocks in the chain is specified by the given count
func ChunkDataPackFixture ¶
func ChunkDataPackFixture(chunkID flow.Identifier, opts ...func(*flow.ChunkDataPack)) *flow.ChunkDataPack
func ChunkDataPackRequestFixture ¶ added in v0.17.0
func ChunkDataPackRequestFixture(chunkID flow.Identifier, opts ...func(*verification.ChunkDataPackRequest)) *verification.ChunkDataPackRequest
ChunkDataPackRequestFixture creates a chunk data request with some default values, i.e., one agree execution node, one disagree execution node, and height of zero. Use options to customize the request.
func ChunkDataPackRequestListFixture ¶ added in v0.17.0
func ChunkDataPackRequestListFixture(n int, opts ...func(*verification.ChunkDataPackRequest)) []*verification.ChunkDataPackRequest
ChunkDataPackRequestListFixture creates and returns a list of chunk data pack requests fixtures.
func ChunkDataResponseFixture ¶ added in v0.17.0
func ChunkDataResponseFixture(chunkID flow.Identifier, opts ...func(*messages.ChunkDataResponse)) *messages.ChunkDataResponse
ChunkDataResponseFixture creates a chunk data response with a single-transaction collection, and random chunk ID. Use options to customize the response.
func ChunkDataResponsesFixture ¶ added in v0.17.0
func ChunkDataResponsesFixture(n int, opts ...func(*messages.ChunkDataResponse)) []*messages.ChunkDataResponse
ChunkDataResponsesFixture creates a list of chunk data responses each with a single-transaction collection, and random chunk ID.
func ChunkFixture ¶
func ChunkFixture(blockID flow.Identifier, collectionIndex uint) *flow.Chunk
func ChunkListFixture ¶ added in v0.14.8
func ChunkListFixture(n uint, blockID flow.Identifier) flow.ChunkList
func ChunkLocatorFixture ¶ added in v0.15.0
func ChunkLocatorFixture(resultID flow.Identifier, index uint64) *chunks.Locator
func ChunkLocatorListFixture ¶ added in v0.15.0
func ChunkLocatorListFixture(n uint) chunks.LocatorList
func ChunkStatusListFixture ¶ added in v0.17.0
func ChunkStatusListFixture(t *testing.T, results []*flow.ExecutionResult, n int) verification.ChunkStatusList
ChunkStatusListFixture receives a set of execution results, and samples `n` chunk out of each result and creates a chunk status for them. It returns the list of sampled chunk statuses for all results.
func ChunkStatusListToChunkLocatorFixture ¶ added in v0.17.0
func ChunkStatusListToChunkLocatorFixture(statuses []*verification.ChunkStatus) chunks.LocatorList
ChunkStatusListToChunkLocatorFixture extracts chunk locators from a list of chunk statuses.
func ClusterAssignment ¶
func ClusterAssignment(n uint, nodes flow.IdentityList) flow.AssignmentList
ClusterAssignment creates an assignment list with n clusters and with nodes evenly distributed among clusters.
func ClusterBlockFixture ¶
func ClusterBlockWithParent ¶
ClusterBlockWithParent creates a new cluster consensus block that is valid with respect to the given parent block.
func ClusterList ¶ added in v0.16.0
func ClusterList(n uint, nodes flow.IdentityList) flow.ClusterList
func ClusterPayloadFixture ¶
func CollectionFixture ¶
func CollectionFixture(n int) flow.Collection
func CollectionGuaranteeFixture ¶
func CollectionGuaranteeFixture(options ...func(*flow.CollectionGuarantee)) *flow.CollectionGuarantee
func CollectionGuaranteesFixture ¶
func CollectionGuaranteesFixture(n int, options ...func(*flow.CollectionGuarantee)) []*flow.CollectionGuarantee
func CollectionGuaranteesWithCollectionIDFixture ¶ added in v0.17.6
func CollectionGuaranteesWithCollectionIDFixture(collections []*flow.Collection) []*flow.CollectionGuarantee
func CollectionListFixture ¶ added in v0.17.6
func CollectionListFixture(n int) []*flow.Collection
func CombinedSignatureFixture ¶ added in v0.15.0
func CommitWithCounter ¶
func CommitWithCounter(counter uint64) func(*flow.EpochCommit)
func CompleteCollectionFixture ¶
func CompleteCollectionFixture() *entity.CompleteCollection
func CompleteCollectionFromTransactions ¶ added in v0.19.0
func CompleteCollectionFromTransactions(txs []*flow.TransactionBody) *entity.CompleteCollection
func CompleteIdentitySet ¶
func CompleteIdentitySet(identities ...*flow.Identity) flow.IdentityList
CompleteIdentitySet takes a number of identities and completes the missing roles.
func Concurrently ¶ added in v0.18.3
func CreateNParticipantsWithMyRole ¶
func CreateNParticipantsWithMyRole(myRole flow.Role, otherRoles ...flow.Role) ( flow.IdentityList, flow.Identifier, *module.Local)
CreateNParticipantsWithMyRole creates a list of identities from given roles
func DKGBroadcastMessageFixture ¶ added in v0.20.0
func DKGBroadcastMessageFixture() *messages.BroadcastDKGMessage
DKGBroadcastMessageFixture creates a single DKG broadcast message with random fields
func DKGMessageFixture ¶ added in v0.20.0
func DKGMessageFixture() *messages.DKGMessage
DKGMessageFixture creates a single DKG message with random fields
func DKGParticipantLookup ¶ added in v0.16.0
func DKGParticipantLookup(participants flow.IdentityList) map[flow.Identifier]flow.DKGParticipant
func DKGParticipantPriv ¶ added in v0.20.0
func DKGParticipantPriv() *dkg.DKGParticipantPriv
func EmulatorRootKey ¶
func EmulatorRootKey() (*flow.AccountPrivateKey, error)
func EntityWithID ¶ added in v0.14.0
func EntityWithID(expectedID flow.Identifier) interface{}
func EpochCommitFixture ¶
func EpochCommitFixture(opts ...func(*flow.EpochCommit)) *flow.EpochCommit
func EpochSetupFixture ¶
func EpochSetupFixture(opts ...func(setup *flow.EpochSetup)) *flow.EpochSetup
EpochSetupFixture creates a valid EpochSetup with default properties for testing. The default properties can be overwritten with optional parameter functions.
func EpochStatusFixture ¶ added in v0.14.0
func EpochStatusFixture() *flow.EpochStatus
func EventFixture ¶
func EventFixture(eType flow.EventType, transactionIndex uint32, eventIndex uint32, txID flow.Identifier, payloadSize int) flow.Event
EventFixture returns an event
func ExecutableBlockFixture ¶
func ExecutableBlockFixture(collectionsSignerIDs [][]flow.Identifier) *entity.ExecutableBlock
func ExecutableBlockFixtureWithParent ¶
func ExecutableBlockFixtureWithParent(collectionsSignerIDs [][]flow.Identifier, parent *flow.Header) *entity.ExecutableBlock
func ExecutableBlockFromTransactions ¶ added in v0.19.0
func ExecutableBlockFromTransactions(txss [][]*flow.TransactionBody) *entity.ExecutableBlock
func ExecutionReceiptFixture ¶
func ExecutionReceiptFixture(opts ...func(*flow.ExecutionReceipt)) *flow.ExecutionReceipt
func ExecutionResultFixture ¶
func ExecutionResultFixture(opts ...func(*flow.ExecutionResult)) *flow.ExecutionResult
func ExecutionResultListFixture ¶ added in v0.17.0
func ExecutionResultListFixture(n int, opts ...func(*flow.ExecutionResult)) []*flow.ExecutionResult
func ExpectPanic ¶
func FinalizedProtocolStateWithParticipants ¶
func FinalizedProtocolStateWithParticipants(participants flow.IdentityList) ( *flow.Block, *mockprotocol.Snapshot, *mockprotocol.State, *mockprotocol.Snapshot)
FinalizedProtocolStateWithParticipants returns a protocol state with finalized participants
func FullBlockFixture ¶ added in v0.14.0
func GenesisFixture ¶
func HashFixture ¶
func HeadersFromMap ¶
HeadersFromMap creates a storage header mock that backed by a given map
func IdentifierFixture ¶
func IdentifierFixture() flow.Identifier
func IdentifierListFixture ¶
func IdentifierListFixture(n int) []flow.Identifier
func IdentityFixture ¶
IdentityFixture returns a node identity.
func IdentityListFixture ¶
func IdentityListFixture(n int, opts ...func(*flow.Identity)) flow.IdentityList
IdentityListFixture returns a list of node identity objects. The identities can be customized (ie. set their role) by passing in a function that modifies the input identities as required.
func IndexFixture ¶ added in v0.14.0
func InvalidAddressFixture ¶ added in v0.11.0
func InvalidFormatSignature ¶ added in v0.12.0
func InvalidFormatSignature() flow.TransactionSignature
func KeyFixture ¶
func KeyFixture(algo crypto.SigningAlgorithm) crypto.PrivateKey
func KeysFixture ¶ added in v0.17.0
func KeysFixture(n int, algo crypto.SigningAlgorithm) []crypto.PrivateKey
func LogVerbose ¶ added in v0.20.0
func LogVerbose()
func Logger ¶ added in v0.10.0
Logger returns a zerolog use -vv flag to print debugging logs for tests
func MustDecodePublicKeyHex ¶ added in v0.19.0
func MustDecodePublicKeyHex(algo crypto.SigningAlgorithm, keyHex string) crypto.PublicKey
func MustDecodeSignatureHex ¶ added in v0.19.0
func NetworkingKey ¶
func NetworkingKey() (crypto.PrivateKey, error)
func NetworkingKeys ¶
func NetworkingKeys(n int) ([]crypto.PrivateKey, error)
func NodeInfoFixture ¶ added in v0.16.1
func NodeInfosFixture ¶ added in v0.16.1
func NoopTxScript ¶
func NoopTxScript() []byte
NoopTxScript returns a Cadence script for a no-op transaction.
func PendingFromBlock ¶
func PendingFromBlock(block *flow.Block) *flow.PendingBlock
func PrivateNodeInfosFixture ¶ added in v0.20.0
func ProposalFixture ¶
func ProposalFixture() *messages.BlockProposal
func ProposalFromBlock ¶
func ProposalFromBlock(block *flow.Block) *messages.BlockProposal
func ProposalKeyFixture ¶
func ProposalKeyFixture() flow.ProposalKey
func PublicKeysFixture ¶ added in v0.17.0
func PublicKeysFixture(n int, algo crypto.SigningAlgorithm) []crypto.PublicKey
func QCWithBlockID ¶ added in v0.15.0
func QCWithBlockID(blockID flow.Identifier) func(*flow.QuorumCertificate)
func QCWithSignerIDs ¶ added in v0.20.0
func QCWithSignerIDs(signerIDs []flow.Identifier) func(*flow.QuorumCertificate)
func QuorumCertificateFixture ¶
func QuorumCertificateFixture(opts ...func(*flow.QuorumCertificate)) *flow.QuorumCertificate
func QuorumCertificatesFixtures ¶ added in v0.17.1
func QuorumCertificatesFixtures(n uint, opts ...func(*flow.QuorumCertificate)) []*flow.QuorumCertificate
func RandomAddressFixture ¶ added in v0.11.0
func RandomBytes ¶
func RangeFixture ¶
func RangeListFixture ¶
func ReadyDoneify ¶
func ReadyDoneify(toMock interface{})
ReadyDoneify sets up a generated mock to respond to Ready and Done lifecycle methods. Any mock type generated by mockery can be used.
func ReceiptAndSealForBlock ¶ added in v0.15.0
func ReceiptChainFor ¶ added in v0.14.0
func ReceiptChainFor(blocks []*flow.Block, result0 *flow.ExecutionResult) []*flow.ExecutionReceipt
func ReceiptForBlockExecutorFixture ¶ added in v0.14.1
func ReceiptForBlockExecutorFixture(block *flow.Block, executor flow.Identifier) *flow.ExecutionReceipt
func ReceiptForBlockFixture ¶ added in v0.14.0
func ReceiptForBlockFixture(block *flow.Block) *flow.ExecutionReceipt
func ReceiptsForBlockFixture ¶ added in v0.17.0
func ReceiptsForBlockFixture(block *flow.Block, ids []flow.Identifier) []*flow.ExecutionReceipt
func ReconnectBlocksAndReceipts ¶ added in v0.14.0
func ReconnectBlocksAndReceipts(blocks []*flow.Block, receipts []*flow.ExecutionReceipt)
ReconnectBlocksAndReceipts re-computes each block's PayloadHash and ParentID so that all the blocks are connected. blocks' height have to be in strict increasing order.
func RegisterNetwork ¶
func RegisterNetwork() (*module.Network, *mocknetwork.Conduit)
RegisterNetwork returns a mocked network and conduit
func RequireCloseBefore ¶ added in v0.12.0
RequireCloseBefore requires that the given channel returns before the duration expires.
func RequireComponentsDoneBefore ¶ added in v0.17.0
func RequireComponentsDoneBefore(t testing.TB, duration time.Duration, components ...module.ReadyDoneAware)
RequireComponentsDoneBefore invokes the done method of each of the input components concurrently, and fails the test if any components shutdown takes longer than the specified duration.
func RequireComponentsReadyBefore ¶ added in v0.17.0
func RequireComponentsReadyBefore(t testing.TB, duration time.Duration, components ...module.ReadyDoneAware)
RequireComponentsReadyBefore invokes the ready method of each of the input components concurrently, and fails the test if any components startup takes longer than the specified duration.
func RequireConcurrentCallsReturnBefore ¶ added in v0.11.0
func RequireConcurrentCallsReturnBefore(t *testing.T, f func(), count int, duration time.Duration, message string)
RequireConcurrentCallsReturnBefore is a test helper that runs function `f` count-many times concurrently, and requires all invocations to return within duration.
func RequireFileEmpty ¶ added in v0.14.0
func RequireNeverClosedWithin ¶ added in v0.11.0
func RequireNeverClosedWithin(t *testing.T, ch <-chan struct{}, duration time.Duration, message string)
RequireNeverClosedWithin is a test helper function that fails the test if channel `ch` is closed before the determined duration.
func RequireNeverReturnBefore ¶ added in v0.11.0
func RequireNeverReturnBefore(t *testing.T, f func(), duration time.Duration, message string) <-chan struct{}
RequireNeverReturnBefore is a test helper that tries invoking function `f` and fails the test if either: - function `f` is not invoked within 1 second. - function `f` returns before specified `duration`.
It also returns a channel that is closed once the function `f` returns and hence its openness can evaluate return status of function `f` for intervals longer than duration.
func RequireReturnsBefore ¶
RequireReturnBefore requires that the given function returns before the duration expires.
func ResultApprovalFixture ¶
func ResultApprovalFixture(opts ...func(*flow.ResultApproval)) *flow.ResultApproval
func RootSnapshotFixture ¶ added in v0.15.0
RootSnapshotFixture returns a snapshot representing a root chain state, for example one as returned from BootstrapFixture.
func RunWithBadgerDB ¶
func RunWithTempDir ¶
func SealBlock ¶ added in v0.15.0
func SealBlock(t *testing.T, st protocol.MutableState, block *flow.Block, receipt *flow.ExecutionReceipt, seal *flow.Seal) *flow.Header
SealBlock seals a block by building two blocks on it, the first containing a receipt for the block, the second containing a seal for the block. Returns the block containing the seal.
func SeedFixtures ¶
SeedFixtures returns a list of m random []byte, each having length n
func SetupWithCounter ¶
func SetupWithCounter(counter uint64) func(*flow.EpochSetup)
func SignatureFixture ¶
func SignaturesFixture ¶
func StakingKey ¶
func StakingKey() (crypto.PrivateKey, error)
func StakingKeys ¶
func StakingKeys(n int) ([]crypto.PrivateKey, error)
func StateCommitmentFixture ¶
func StateCommitmentFixture() flow.StateCommitment
func StateCommitmentPointerFixture ¶ added in v0.17.0
func StateCommitmentPointerFixture() *flow.StateCommitment
func StateDeltaFixture ¶
func StateDeltaFixture() *messages.ExecutionStateDelta
func StateDeltaWithParentFixture ¶
func StateDeltaWithParentFixture(parent *flow.Header) *messages.ExecutionStateDelta
func StateInteractionsFixture ¶ added in v0.11.0
func StateSnapshotForKnownBlock ¶ added in v0.14.0
func StateSnapshotForUnknownBlock ¶ added in v0.14.0
func TempBadgerDB ¶
func TransactionBodyFixture ¶
func TransactionBodyFixture(opts ...func(*flow.TransactionBody)) flow.TransactionBody
func TransactionDSLFixture ¶
func TransactionDSLFixture(chain flow.Chain) dsl.Transaction
func TransactionFixture ¶
func TransactionFixture(n ...func(t *flow.Transaction)) flow.Transaction
func TransactionForCluster ¶
func TransactionForCluster(clusters flow.ClusterList, target flow.IdentityList) flow.TransactionBody
TransactionForCluster generates a transaction that will be assigned to the target cluster ID.
func TransactionSignatureFixture ¶
func TransactionSignatureFixture() flow.TransactionSignature
func VerifiableChunkDataFixture ¶
func VerifiableChunkDataFixture(chunkIndex uint64) *verification.VerifiableChunkData
VerifiableChunkDataFixture returns a complete verifiable chunk with an execution receipt referencing the block/collections.
func VoteFixture ¶
func WithAddress ¶ added in v0.13.0
WithAddress sets the network address of identity fixture.
func WithAgrees ¶ added in v0.17.0
func WithAgrees(list flow.IdentifierList) func(*verification.ChunkDataPackRequest)
func WithAllRoles ¶
WithAllRoles can be used used to ensure an IdentityList fixtures contains all the roles required for a valid genesis block.
func WithAllRolesExcept ¶
Same as above, but omitting a certain role for cases where we are manually setting up nodes or a particular role.
func WithAllTheFixins ¶ added in v0.15.0
WithAllTheFixins ensures a payload contains no empty slice fields. When encoding and decoding, nil vs empty slices are not preserved, which can result in two models that are semantically equal being considered non-equal by our testing framework.
func WithApproverID ¶ added in v0.11.0
func WithApproverID(approverID flow.Identifier) func(*flow.ResultApproval)
func WithAttestationBlock ¶ added in v0.14.0
func WithAttestationBlock(block *flow.Block) func(*flow.ResultApproval)
func WithBlockID ¶ added in v0.11.0
func WithBlockID(id flow.Identifier) func(*flow.ResultApproval)
func WithChunk ¶ added in v0.11.0
func WithChunk(chunkIdx uint64) func(*flow.ResultApproval)
func WithChunks ¶ added in v0.17.0
func WithChunks(n uint) func(*flow.ExecutionResult)
func WithClusterQCsFromAssignments ¶ added in v0.20.0
func WithClusterQCsFromAssignments(assignments flow.AssignmentList) func(*flow.EpochCommit)
func WithCollRef ¶
func WithCollRef(refID flow.Identifier) func(*flow.CollectionGuarantee)
func WithCollection ¶ added in v0.14.0
func WithCollection(collection *flow.Collection) func(guarantee *flow.CollectionGuarantee)
func WithCollectionID ¶ added in v0.17.0
func WithCollectionID(collectionID flow.Identifier) func(*flow.ChunkDataPack)
func WithDKGFromParticipants ¶
func WithDKGFromParticipants(participants flow.IdentityList) func(*flow.EpochCommit)
func WithDisagrees ¶ added in v0.17.0
func WithDisagrees(list flow.IdentifierList) func(*verification.ChunkDataPackRequest)
func WithEjected ¶ added in v0.16.0
func WithExecutionResultBlockID ¶ added in v0.17.0
func WithExecutionResultBlockID(blockID flow.Identifier) func(*flow.ExecutionResult)
func WithExecutionResultID ¶
func WithExecutionResultID(id flow.Identifier) func(*flow.ResultApproval)
func WithExecutorID ¶ added in v0.11.0
func WithExecutorID(executorID flow.Identifier) func(*flow.ExecutionReceipt)
func WithFinalView ¶
func WithFinalView(view uint64) func(*flow.EpochSetup)
func WithFirstView ¶ added in v0.15.0
func WithFirstView(view uint64) func(*flow.EpochSetup)
func WithGuarantees ¶ added in v0.15.0
func WithGuarantees(guarantees ...*flow.CollectionGuarantee) func(*flow.Payload)
func WithHeaderHeight ¶ added in v0.17.0
func WithHeight ¶ added in v0.17.0
func WithHeight(height uint64) func(*verification.ChunkDataPackRequest)
func WithHeightGreaterThan ¶ added in v0.17.0
func WithHeightGreaterThan(height uint64) func(*verification.ChunkDataPackRequest)
func WithNetworkingKey ¶ added in v0.13.0
WithNetworkingKey sets the networking public key of identity fixture.
func WithNodeID ¶
func WithNodeID(id flow.Identifier) func(*flow.Identity)
WithNodeID adds a node ID with the given first byte to an identity.
func WithParticipants ¶
func WithParticipants(participants flow.IdentityList) func(*flow.EpochSetup)
func WithPreviousResult ¶ added in v0.11.0
func WithPreviousResult(prevResult flow.ExecutionResult) func(*flow.ExecutionResult)
func WithRandomPublicKeys ¶
WithRandomPublicKeys adds random public keys to an identity.
func WithReceipts ¶ added in v0.15.0
func WithReceipts(receipts ...*flow.ExecutionReceipt) func(*flow.Payload)
func WithReferenceBlock ¶
func WithReferenceBlock(id flow.Identifier) func(tx *flow.TransactionBody)
func WithResult ¶ added in v0.11.0
func WithResult(result *flow.ExecutionResult) func(*flow.ExecutionReceipt)
func WithServiveEvents ¶ added in v0.15.0
func WithServiveEvents(events ...flow.ServiceEvent) func(*flow.ExecutionResult)
func WithStakingPubKey ¶ added in v0.20.0
WithStakingPubKey adds a staking public key to the identity
func WithStartState ¶ added in v0.17.0
func WithStartState(startState flow.StateCommitment) func(*flow.ChunkDataPack)
func WithTransactionDSL ¶
func WithTransactionDSL(txDSL dsl.Transaction) func(tx *flow.TransactionBody)
func WithoutGuarantee ¶ added in v0.15.1
Types ¶
type BaseChainSuite ¶ added in v0.14.0
type BaseChainSuite struct { suite.Suite // IDENTITIES ConID flow.Identifier ExeID flow.Identifier VerID flow.Identifier Identities map[flow.Identifier]*flow.Identity Approvers flow.IdentityList // BLOCKS RootBlock flow.Block LatestSealedBlock flow.Block LatestFinalizedBlock *flow.Block UnfinalizedBlock flow.Block LatestExecutionResult *flow.ExecutionResult Blocks map[flow.Identifier]*flow.Block // PROTOCOL STATE State *protocol.State SealedSnapshot *protocol.Snapshot FinalSnapshot *protocol.Snapshot // MEMPOOLS and STORAGE which are injected into Matching Engine // mock storage.ExecutionReceipts: backed by in-memory map PersistedReceipts ReceiptsDB *storage.ExecutionReceipts ResultsDB *storage.ExecutionResults PersistedResults map[flow.Identifier]*flow.ExecutionResult // mock mempool.IncorporatedResultSeals: backed by in-memory map PendingSeals SealsPL *mempool.IncorporatedResultSeals PendingSeals map[flow.Identifier]*flow.IncorporatedResultSeal // mock BLOCK STORAGE: backed by in-memory map Blocks HeadersDB *storage.Headers // backed by map Blocks IndexDB *storage.Index // backed by map Blocks PayloadsDB *storage.Payloads // backed by map Blocks SealsDB *storage.Seals // backed by map SealsIndex SealsIndex map[flow.Identifier]*flow.Seal // last valid seal for block // mock mempool.ReceiptsForest: used to test whether or not Matching Engine stores receipts ReceiptsPL *mempool.ExecutionTree Assigner *module.ChunkAssigner Assignments map[flow.Identifier]*chunks.Assignment // index for assignments for given execution result PendingReceipts *mempool.PendingReceipts }
func (*BaseChainSuite) AddSubgraphFixtureToMempools ¶ added in v0.14.0
func (bc *BaseChainSuite) AddSubgraphFixtureToMempools(subgraph subgraphFixture)
addSubgraphFixtureToMempools adds add entities in subgraph to mempools and persistent storage mocks
func (*BaseChainSuite) Extend ¶ added in v0.14.0
func (bc *BaseChainSuite) Extend(block *flow.Block)
func (*BaseChainSuite) SetupChain ¶ added in v0.14.0
func (bc *BaseChainSuite) SetupChain()
func (*BaseChainSuite) ValidSubgraphFixture ¶ added in v0.14.0
func (bc *BaseChainSuite) ValidSubgraphFixture() subgraphFixture
Generates a valid subgraph: let
- R1 be a result which pertains to blockA
- R2 be R1's previous result, where R2 pertains to blockB
The execution results form a valid subgraph if and only if:
blockA.ParentID == blockB.ID
type ClusterStateChecker ¶
type ClusterStateChecker struct {
// contains filtered or unexported fields
}
ClusterStateChecker is a test utility for checking cluster state. First, prepare it with expectations about the state, using `Expect*` functions, then use `Check` to assert the expectations.
Duplicates are checked automatically without setting any expectations.
func NewClusterStateChecker ¶
func NewClusterStateChecker(state cluster.State) *ClusterStateChecker
NewClusterStateChecker returns a state checker for the given state.
func (*ClusterStateChecker) Assert ¶
func (checker *ClusterStateChecker) Assert(t *testing.T)
Assert checks all assertions against the cluster state. If any assertions fail, the test will fail.
func (*ClusterStateChecker) ExpectContainsTx ¶
func (checker *ClusterStateChecker) ExpectContainsTx(txIDs ...flow.Identifier) *ClusterStateChecker
ExpectContainsTx adds an expectation that the given transaction exists in the cluster state.
func (*ClusterStateChecker) ExpectOmitsTx ¶
func (checker *ClusterStateChecker) ExpectOmitsTx(txIDs ...flow.Identifier) *ClusterStateChecker
ExpectOmitsTx adds an expectation that the given transaction does not exist in the cluster state.
func (*ClusterStateChecker) ExpectTxCount ¶
func (checker *ClusterStateChecker) ExpectTxCount(n int) *ClusterStateChecker
ExpectTxCount adds an expectation for the total count of transactions in the cluster state.
type EpochBuilder ¶ added in v0.12.0
type EpochBuilder struct {
// contains filtered or unexported fields
}
EpochBuilder is a testing utility for building epochs into chain state.
func NewEpochBuilder ¶ added in v0.12.0
func NewEpochBuilder(t *testing.T, states ...protocol.MutableState) *EpochBuilder
NewEpochBuilder returns a new EpochBuilder which will build epochs using the given states. At least one state must be provided. If more than one are provided they must have the same initial state.
func (*EpochBuilder) BuildBlocks ¶ added in v0.20.0
func (builder *EpochBuilder) BuildBlocks(n uint)
BuildBlocks builds empty blocks on top of the finalized state. It is used to build epochs that are not the minimum possible length, which is the default result from chaining BuildEpoch and CompleteEpoch.
func (*EpochBuilder) BuildEpoch ¶ added in v0.12.0
func (builder *EpochBuilder) BuildEpoch() *EpochBuilder
BuildEpoch builds and finalizes a sequence of blocks comprising a minimal full epoch (epoch N). We assume the latest finalized block is within staking phase in epoch N.
| EPOCH N | | | P A B C D E F G
+------------+ +------------+ +-----------+ +-----------+ +----------+ +----------+ +----------+----------+ | ER(P-1) |->| ER(P) |->| ER(A) |->| ER(B) |->| ER(C) |->| ER(D) |->| ER(E) | ER(F) | | S(ER(P-2)) | | S(ER(P-1)) | | S(ER(P)) | | S(ER(A)) | | S(ER(B)) | | S(ER(C)) | | S(ER(D)) | S(ER(E)) | +------------+ +------------+ +-----------+ +-----------+ +----------+ +----------+ +----------+----------+
| | Setup Commit
ER(X) := ExecutionReceipt for block X S(ER(X)) := Seal for the ExecutionResult contained in ER(X) (seals block X)
A is the latest finalized block. Every block contains a receipt for the previous block and a seal for the receipt contained in the previous block. The only exception is when A is the root block, in which case block B does not contain a receipt for block A, and block C does not contain a seal for block A. This is because the root block is sealed from genesis and we can't insert duplicate seals.
D contains a seal for block B containing the EpochSetup service event. E contains a QC for D, which causes the EpochSetup to become activated.
F contains a seal for block D containing the EpochCommit service event. G contains a QC for F, which causes the EpochCommit to become activated.
To build a sequence of epochs, we call BuildEpoch, then CompleteEpoch, and so on.
Upon building an epoch N (preparing epoch N+1), we store some information about the heights of blocks in the BUILT epoch (epoch N). These can be queried with EpochHeights.
func (*EpochBuilder) CompleteEpoch ¶ added in v0.12.0
func (builder *EpochBuilder) CompleteEpoch() *EpochBuilder
CompleteEpoch caps off the current epoch by building the first block of the next epoch. We must be in the Committed phase to call CompleteEpoch. Once the epoch has been capped off, we can build the next epoch with BuildEpoch.
func (*EpochBuilder) EpochHeights ¶ added in v0.15.0
func (builder *EpochBuilder) EpochHeights(counter uint64) (EpochHeights, bool)
EpochHeights returns heights of each phase within about a built epoch.
func (*EpochBuilder) UsingCommitOpts ¶ added in v0.12.0
func (builder *EpochBuilder) UsingCommitOpts(opts ...func(*flow.EpochCommit)) *EpochBuilder
UsingCommitOpts sets options for the epoch setup event. For options targeting the same field, those added here will take precedence over defaults.
func (*EpochBuilder) UsingSetupOpts ¶ added in v0.12.0
func (builder *EpochBuilder) UsingSetupOpts(opts ...func(*flow.EpochSetup)) *EpochBuilder
UsingSetupOpts sets options for the epoch setup event. For options targeting the same field, those added here will take precedence over defaults.
type EpochHeights ¶ added in v0.15.0
type EpochHeights struct { Counter uint64 // which epoch this is Staking uint64 // first height of staking phase Setup uint64 // first height of setup phase Committed uint64 // first height of committed phase }
EpochHeights is a structure caching the results of building an epoch with EpochBuilder. It contains the first block height for each phase of the epoch.
func (EpochHeights) CommittedRange ¶ added in v0.15.0
func (epoch EpochHeights) CommittedRange() []uint64
CommittedRange returns the range of all heights in the committed phase.
func (EpochHeights) Range ¶ added in v0.15.0
func (epoch EpochHeights) Range() []uint64
Range returns the range of all heights that are in this epoch.
func (EpochHeights) SetupRange ¶ added in v0.15.0
func (epoch EpochHeights) SetupRange() []uint64
SetupRange returns the range of all heights in the setup phase.
func (EpochHeights) StakingRange ¶ added in v0.15.0
func (epoch EpochHeights) StakingRange() []uint64
StakingRange returns the range of all heights in the staking phase.
type FixedStaker ¶ added in v0.15.1
type FixedStaker struct {
Staked bool
}
func NewFixedStaker ¶ added in v0.15.1
func NewFixedStaker(initial bool) *FixedStaker
func (*FixedStaker) AmIStakedAt ¶ added in v0.15.1
func (f *FixedStaker) AmIStakedAt(_ flow.Identifier) bool