Documentation
¶
Index ¶
- Constants
- Variables
- func AccountFixture() (*flow.Account, error)
- func AccountKeyDefaultFixture() (*flow.AccountPrivateKey, error)
- func AccountKeyFixture(seedLength int, signingAlgo crypto.SigningAlgorithm, ...) (*flow.AccountPrivateKey, error)
- func AddCollectionsToBlock(block *flow.Block, collections []*flow.Collection)
- func AddVersionBeacon(t *testing.T, beacon *flow.VersionBeacon, state protocol.FollowerState)
- func AddressFixture() flow.Address
- func AllowAllPeerFilter() func(peer.ID) error
- func AlterTransactionForCluster(tx flow.TransactionBody, clusters flow.ClusterList, ...) flow.TransactionBody
- func ApprovalFor(result *flow.ExecutionResult, chunkIdx uint64, approverID flow.Identifier) *flow.ResultApproval
- func AreNumericallyClose(a, b float64, epsilon float64) bool
- func AsSlashable[T any](msg T) flow.Slashable[T]
- func AssertClosesBefore(t assert.TestingT, done <-chan struct{}, duration time.Duration, ...)
- func AssertEqualBlockSequences(t *testing.T, blocks []*flow.Block, proposals []*flow.Proposal)
- func AssertErrSubstringMatch(t testing.TB, expected, actual error)
- func AssertFloatEqual(t *testing.T, expected, actual float64, message string)
- func AssertNotClosesBefore(t assert.TestingT, done <-chan struct{}, duration time.Duration, ...)
- func AssertReturnsBefore(t *testing.T, f func(), duration time.Duration, msgAndArgs ...interface{}) bool
- func AssertSnapshotsEqual(t *testing.T, snap1, snap2 protocol.Snapshot)
- func AttestationFixture() *flow.Attestation
- func BadgerDB(t testing.TB, dir string) *badger.DB
- func BatchFixture() chainsync.Batch
- func BatchListFixture(n int) []chainsync.Batch
- func BlockEventsFixture(header *flow.Header, n int) flow.BlockEvents
- func BlockExecutionDatEntityFixture(opts ...func(*execution_data.BlockExecutionData)) *execution_data.BlockExecutionDataEntity
- func BlockExecutionDatEntityListFixture(n int) []*execution_data.BlockExecutionDataEntity
- func BlockExecutionDataFixture(opts ...func(*execution_data.BlockExecutionData)) *execution_data.BlockExecutionData
- func BlockFixture(opts ...func(*flow.Block)) *flow.Block
- func BlockFixtures(number int) []*flow.Block
- func BlockHeaderFixture(opts ...func(header *flow.Header)) *flow.Header
- func BlockHeaderFixtureOnChain(chainID flow.ChainID, opts ...func(header *flow.Header)) *flow.Header
- func BlockHeaderWithHeight(height uint64) *flow.Header
- func BlockHeaderWithParentFixture(parent *flow.Header) *flow.Header
- func BlockHeaderWithParentWithSoRFixture(parent *flow.Header, source []byte) *flow.Header
- func BlockResponseFixture(count int) *flow.BlockResponse
- func BlockSealsFixture(n int) []*flow.Seal
- func BlockWithGuaranteesFixture(guarantees []*flow.CollectionGuarantee) *flow.Block
- func BlockWithParentAndPayload(parent *flow.Header, payload flow.Payload) *flow.Block
- func BlockWithParentAndPayloadAndUniqueView(parent *flow.Header, payload flow.Payload, forbiddenViews map[uint64]struct{}) *flow.Block
- func BlockWithParentAndProposerFixture(t *testing.T, parent *flow.Header, proposer flow.Identifier) *flow.Block
- func BlockWithParentAndSeals(parent *flow.Header, seals []*flow.Header) *flow.Block
- func BlockWithParentAndUniqueView(parent *flow.Header, forbiddenViews map[uint64]struct{}) *flow.Block
- func BlockWithParentFixture(parent *flow.Header) *flow.Block
- func BlockWithParentProtocolState(parent *flow.Block) *flow.Block
- func BlockWithParentProtocolStateAndUniqueView(parent *flow.Block, forbiddenViews map[uint64]struct{}) *flow.Block
- func BlockchainFixture(length int) []*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 BootstrapFixtureWithChainID(participants flow.IdentityList, chainID flow.ChainID, ...) (*flow.Block, *flow.ExecutionResult, *flow.Seal)
- func BootstrapFixtureWithSetupAndCommit(header flow.HeaderBody, setup *flow.EpochSetup, commit *flow.EpochCommit) (*flow.Block, *flow.ExecutionResult, *flow.Seal)
- func BytesToCdcUInt8(data []byte) []cadence.Value
- func CertifiedByChild(block *flow.Block, child *flow.Block) *flow.CertifiedBlock
- func CertifyBlock(header *flow.Header) *flow.QuorumCertificate
- func ChainBlockFixtureWithRoot(root *flow.Header, n int) []*flow.Block
- 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(opts ...func(*verification.ChunkDataPackRequest)) ...
- func ChunkDataPackRequestInfoFixture() *verification.ChunkDataPackRequestInfo
- func ChunkDataPackRequestListFixture(n int, opts ...func(*verification.ChunkDataPackRequest)) verification.ChunkDataPackRequestList
- func ChunkDataPacksFixture(count int, opts ...func(*flow.ChunkDataPack)) []*flow.ChunkDataPack
- func ChunkDataPacksFixtureAndResult() ([]*flow.ChunkDataPack, *flow.ExecutionResult)
- func ChunkDataResponseMessageListFixture(chunkIDs flow.IdentifierList) []*messages.ChunkDataResponse
- func ChunkDataResponseMsgFixture(chunkID flow.Identifier, opts ...func(*messages.ChunkDataResponse)) *messages.ChunkDataResponse
- func ChunkExecutionDataFixture(t *testing.T, minSize int, opts ...func(*execution_data.ChunkExecutionData)) *execution_data.ChunkExecutionData
- func ChunkFixture(blockID flow.Identifier, collectionIndex uint, startState flow.StateCommitment, ...) *flow.Chunk
- func ChunkListFixture(n uint, blockID flow.Identifier, startState flow.StateCommitment, ...) flow.ChunkList
- func ChunkLocatorFixture(resultID flow.Identifier, index uint64) *chunks.Locator
- func ChunkLocatorListFixture(n uint) chunks.LocatorList
- func ChunkStatusListFixture(t *testing.T, blockHeight uint64, result *flow.ExecutionResult, n int) verification.ChunkStatusList
- func ChunkStatusListToChunkLocatorFixture(statuses []*verification.ChunkStatus) chunks.LocatorMap
- func ClosedChannel() <-chan struct{}
- func ClusterAssignment(n uint, nodes flow.IdentitySkeletonList) flow.AssignmentList
- func ClusterBlockFixture(opts ...func(*cluster.Block)) *cluster.Block
- func ClusterBlockFixtures(n int) []*cluster.Block
- func ClusterBlockResponseFixture(count int) *cluster.BlockResponse
- func ClusterList(n uint, nodes flow.IdentitySkeletonList) flow.ClusterList
- func ClusterPayloadFixture(transactionsCount int) *cluster.Payload
- func ClusterProposalFixture() *cluster.Proposal
- func ClusterProposalFromBlock(block *cluster.Block) *cluster.Proposal
- func CollectionFixture(n int, options ...func(*flow.Collection)) flow.Collection
- func CollectionFromTransactions(transactions ...*flow.TransactionBody) 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, options ...func(*flow.Collection)) []*flow.Collection
- 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 CrashTest(t *testing.T, scenario func(*testing.T), expectedErrorMsg string)
- func CrashTestWithExpectedStatus(t *testing.T, scenario func(*testing.T), expectedErrorMsg string, ...)
- func CreateNParticipantsWithMyRole(myRole flow.Role, otherRoles ...flow.Role) (flow.IdentityList, flow.Identifier, *module.Local)
- func CreateSendTxHttpPayload(tx flow.TransactionBody) map[string]interface{}
- func DKGBroadcastMessageFixture() *messages.BroadcastDKGMessage
- func DKGMessageFixture() *messages.DKGMessage
- func DynamicIdentityEntryFixture(opts ...func(*flow.DynamicIdentityEntry)) *flow.DynamicIdentityEntry
- func DynamicIdentityEntryListFixture(n int, opts ...func(*flow.DynamicIdentityEntry)) flow.DynamicIdentityEntryList
- func EmulatorRootKey() (*flow.AccountPrivateKey, error)
- func EncodeDecodeDifferentVersions(t *testing.T, src, dst any)
- func EngineMessageFixture() *engine.Message
- func EngineMessageFixtures(count int) []*engine.Message
- func EnsureEventsIndexSeq(t *testing.T, events []flow.Event, chainID flow.ChainID)
- func EpochCommitFixture(opts ...func(*flow.EpochCommit)) *flow.EpochCommit
- func EpochCommitFixtureByChainID(chain flow.ChainID) (flow.Event, *flow.EpochCommit)
- func EpochExtensionFixture() flow.EpochExtension
- func EpochProtocolStateEntryFixture(tentativePhase flow.EpochPhase, efmTriggered bool) flow.MinEpochStateEntry
- func EpochRecoverFixture(opts ...func(setup *flow.EpochSetup)) *flow.EpochRecover
- func EpochRecoverFixtureByChainID(chain flow.ChainID) (flow.Event, *flow.EpochRecover)
- func EpochRecoverFixtureCCF(randomSource []byte) []byte
- func EpochSetupCCFWithNonHexRandomSource() []byte
- func EpochSetupFixture(opts ...func(setup *flow.EpochSetup)) *flow.EpochSetup
- func EpochSetupFixtureByChainID(chain flow.ChainID) (flow.Event, *flow.EpochSetup)
- func EpochSetupFixtureCCF(randomSource []byte) []byte
- func EpochSetupRandomSourceFixture() []byte
- func EpochStateContainerFixture() *flow.EpochStateContainer
- func EpochStateFixture(options ...func(*flow.RichEpochStateEntry)) *flow.RichEpochStateEntry
- func EventFixture(opts ...EventOption) flow.Event
- func EventTypeFixture(chainID flow.ChainID) flow.EventType
- func EventsFixture(n int) []flow.Event
- func ExecutableBlockFixture(collectionsSignerIDs [][]flow.Identifier, startState *flow.StateCommitment) *entity.ExecutableBlock
- func ExecutableBlockFixtureWithParent(collectionsSignerIDs [][]flow.Identifier, parent *flow.Header, ...) *entity.ExecutableBlock
- func ExecutableBlockFromTransactions(chain flow.ChainID, 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 FailOnIrrecoverableError(t *testing.T, done <-chan struct{}, errCh <-chan error)
- func FinalizedProtocolStateWithParticipants(participants flow.IdentityList) (*flow.Block, *mockprotocol.Snapshot, *mockprotocol.State, ...)
- func FixedReferenceBlockID() flow.Identifier
- func FullBlockFixture() *flow.Block
- func GenerateRandomStringWithLen(commentLen uint) string
- func GenesisStateCommitmentByChainID(chainID flow.ChainID) flow.StateCommitment
- func GetFlowProtocolEventID(t *testing.T, channel channels.Channel, event interface{}) flow.Identifier
- func GetPRG(t *testing.T) *rand.Rand
- func GossipSubMessageFixture(s string, opts ...func(*pubsub_pb.Message)) *pubsub_pb.Message
- func GossipSubMessageFixtures(n int, topic string, opts ...func(*pubsub_pb.Message)) []*pubsub_pb.Message
- func HashFixture(size int) hash.Hash
- func HeaderBodyFixture(opts ...func(header flow.HeaderBody)) flow.HeaderBody
- func HeaderBodyWithParentFixture(parent *flow.Header) flow.HeaderBody
- func HeaderWithView(view uint64) func(*flow.Header)
- 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 IPPort(port string) string
- func IdentifierFixture() flow.Identifier
- func IdentifierListFixture(n int) flow.IdentifierList
- func IdentityFixture(opts ...func(*flow.Identity)) *flow.Identity
- func IdentityListFixture(n int, opts ...func(*flow.Identity)) flow.IdentityList
- func IdentityWithNetworkingKeyFixture(opts ...func(*flow.Identity)) (*flow.Identity, crypto.PrivateKey)
- func IndexFixture() *flow.Index
- func InsertAndFinalize(t *testing.T, st protocol.ParticipantState, block *flow.Block)
- func InterfaceToCdcValues(t *testing.T, vals []interface{}) []cadence.Value
- func InvalidAddressFixture() flow.Address
- func InvalidFormatSignature() flow.TransactionSignature
- func IsServiceEvent(event flow.Event, chainID flow.ChainID) bool
- func IsStorageLockAcquisitionError(err error) bool
- func KeyFixture(algo crypto.SigningAlgorithm) crypto.PrivateKey
- func KeysFixture(n int, algo crypto.SigningAlgorithm) []crypto.PrivateKey
- func LibP2PResourceLimitOverrideFixture() p2pconfig.ResourceManagerOverrideLimit
- func LightTransactionResultsFixture(n int) []flow.LightTransactionResult
- func LogVerbose()
- func Logger() zerolog.Logger
- func LoggerForTest(t *testing.T, level zerolog.Level) zerolog.Logger
- func LoggerWithLevel(level zerolog.Level) zerolog.Logger
- func LoggerWithName(mod string) zerolog.Logger
- func LoggerWithWriterAndLevel(writer io.Writer, level zerolog.Level) zerolog.Logger
- func MachineAccountFixture(t *testing.T) (bootstrap.NodeMachineAccountInfo, *sdk.Account)
- func MakeOwnerReg(key string, value string) flow.RegisterEntry
- func MatchEpochExtension(finalView, extensionLen uint64) any
- func MustDecodePublicKeyHex(algo crypto.SigningAlgorithm, keyHex string) crypto.PublicKey
- func MustDecodeSignatureHex(sigHex string) crypto.Signature
- func NetworkCodec() network.Codec
- func NetworkTopology() network.Topology
- func NetworkingKeys(n int) []crypto.PrivateKey
- func NetworkingPrivKeyFixture() crypto.PrivateKey
- func NewCertifiedBlock(block *flow.Block) *flow.CertifiedBlock
- func NewFlowClusterQCClusterStructType() *cadence.StructType
- func NewNodeVersionBeaconSemverStructType() *cadence.StructType
- func NewNodeVersionBeaconVersionBeaconEventType() *cadence.EventType
- func NewNodeVersionBeaconVersionBoundaryStructType() *cadence.StructType
- func NewProtocolStateVersionUpgradeEventType() *cadence.EventType
- func NewSealingConfigs(val uint) module.SealingConfigsSetter
- func NewStorageLockAcquisitionErrorf(msg string, args ...interface{}) error
- func NodeConfigFixture(opts ...func(*flow.Identity)) bootstrap.NodeConfig
- func NodeInfoFixture(opts ...func(*flow.Identity)) bootstrap.NodeInfo
- func NodeInfoFromIdentity(identity *flow.Identity) bootstrap.NodeInfo
- func NodeInfosFixture(n int, opts ...func(*flow.Identity)) []bootstrap.NodeInfo
- func NodeMachineAccountInfoFixture() bootstrap.NodeMachineAccountInfo
- func NoopTxScript() []byte
- func P2PRPCFixture(opts ...RPCFixtureOpt) *pubsub.RPC
- func P2PRPCGraftFixture(topic *string) *pubsub_pb.ControlGraft
- func P2PRPCGraftFixtures(topics ...string) []*pubsub_pb.ControlGraft
- func P2PRPCIHaveFixture(topic *string, messageIds ...string) *pubsub_pb.ControlIHave
- func P2PRPCIHaveFixtures(m int, topics ...string) []*pubsub_pb.ControlIHave
- func P2PRPCIWantFixture(messageIds ...string) *pubsub_pb.ControlIWant
- func P2PRPCIWantFixtures(n, m int) []*pubsub_pb.ControlIWant
- func P2PRPCPruneFixture(topic *string) *pubsub_pb.ControlPrune
- func P2PRPCPruneFixtures(topics ...string) []*pubsub_pb.ControlPrune
- func PayloadFixture(options ...func(*flow.Payload)) flow.Payload
- func PebbleDB(t testing.TB, dir string) *pebble.DB
- func PeerIDFromFlowID(identity *flow.Identity) (peer.ID, error)
- func PeerIdFixture(tb testing.TB) peer.ID
- func PeerIdFixtures(t *testing.T, n int) []peer.ID
- func PrintHeapInfo(logger zerolog.Logger)
- func PrivateKeyFixture(algo crypto.SigningAlgorithm) crypto.PrivateKey
- func PrivateKeyFixtureByIdentifier(algo crypto.SigningAlgorithm, seedLength int, id flow.Identifier) crypto.PrivateKey
- func PrivateNodeInfoFixture(opts ...func(*flow.Identity)) bootstrap.NodeInfo
- func PrivateNodeInfosFixture(n int, opts ...func(*flow.Identity)) []bootstrap.NodeInfo
- func PrivateNodeInfosFromIdentityList(il flow.IdentityList) []bootstrap.NodeInfo
- func ProposalChainFixtureFrom(count int, parent *flow.Header) []*flow.Proposal
- func ProposalFixture() *flow.Proposal
- func ProposalFixtures(number int) []*flow.Proposal
- func ProposalFromBlock(block *flow.Block) *flow.Proposal
- func ProposalHeaderFromHeader(header *flow.Header) *flow.ProposalHeader
- func ProposalKeyFixture() flow.ProposalKey
- func ProtocolStateVersionUpgradeFixture() *flow.ProtocolStateVersionUpgrade
- func ProtocolStateVersionUpgradeFixtureByChainID(chain flow.ChainID) (flow.Event, *flow.ProtocolStateVersionUpgrade)
- func PtrTo[T any](target T) *T
- func PublicKeysFixture(n int, algo crypto.SigningAlgorithm) []crypto.PublicKey
- func QCSigDataFixture() []byte
- func QCSigDataWithSoRFixture(sor []byte) []byte
- func QCWithBlockID(blockID flow.Identifier) func(*flow.QuorumCertificate)
- func QCWithRootBlockID(blockID flow.Identifier) func(*flow.QuorumCertificate)
- func QCWithSignerIndices(signerIndices []byte) func(*flow.QuorumCertificate)
- func QuorumCertificateFixture(opts ...func(*flow.QuorumCertificate)) *flow.QuorumCertificate
- func QuorumCertificateWithSignerIDsFixture(opts ...func(*flow.QuorumCertificateWithSignerIDs)) *flow.QuorumCertificateWithSignerIDs
- func QuorumCertificatesFixtures(n uint, opts ...func(*flow.QuorumCertificate)) []*flow.QuorumCertificate
- func QuorumCertificatesFromAssignments(assignment flow.AssignmentList) []*flow.QuorumCertificateWithSignerIDs
- func QuorumCertificatesWithSignerIDsFixtures(n uint, opts ...func(*flow.QuorumCertificateWithSignerIDs)) []*flow.QuorumCertificateWithSignerIDs
- func RandomAddressFixture() flow.Address
- func RandomAddressFixtureForChain(chainID flow.ChainID) flow.Address
- func RandomBeaconPriv() *encodable.RandomBeaconPrivKey
- func RandomByteSlice(t *testing.T, n int) []byte
- func RandomBytes(n int) []byte
- func RandomSDKAddressFixture() sdk.Address
- func RandomSourcesFixture(n int) [][]byte
- func RangeFixture() chainsync.Range
- func RangeListFixture(n int) []chainsync.Range
- func ReadyDoneify(toMock interface{})
- func ReceiptAndSealForBlock(block *flow.Block, serviceEvents ...flow.ServiceEvent) (*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 RechainBlocks(blocks []*flow.Block)
- func ReconnectBlocksAndReceipts(blocks []*flow.Block, receipts []*flow.ExecutionReceipt)
- func RegisterEntryFixture() flow.RegisterEntry
- func RegisterIDFixture() flow.RegisterID
- func RequireCloseBefore(t testing.TB, c <-chan struct{}, duration time.Duration, message string)
- func RequireClosed(t *testing.T, ch <-chan struct{}, 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 RequireEntityNonMalleable(t *testing.T, entity flow.IDEntity, ops ...MalleabilityCheckerOpt)
- 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 RequireNonMalleable(t *testing.T, model any, hashModel func() flow.Identifier, ...)
- func RequireNotClosed(t *testing.T, ch <-chan struct{}, message string)
- func RequireNumericallyClose(t testing.TB, a, b float64, epsilon float64, msgAndArgs ...interface{})
- func RequireReturnsBefore(t testing.TB, f func(), duration time.Duration, message string)
- func ResultApprovalFixture(opts ...func(*flow.ResultApproval)) *flow.ResultApproval
- func RootEpochProtocolStateFixture() *flow.RichEpochStateEntry
- func RootSnapshotFixture(participants flow.IdentityList, opts ...func(*flow.Block)) *inmem.Snapshot
- func RootSnapshotFixtureWithChainID(participants flow.IdentityList, chainID flow.ChainID, ...) *inmem.Snapshot
- func RunWithBadgerDB(t testing.TB, f func(*badger.DB))
- func RunWithBadgerDBAndPebbleDB(t testing.TB, f func(*badger.DB, *pebble.DB))
- func RunWithPebbleDB(t testing.TB, f func(*pebble.DB))
- func RunWithTempDir(t testing.TB, f func(string))
- func RunWithTempDirs(t testing.TB, f func(string, string))
- func RunWithTypedBadgerDB(t testing.TB, create func(badger.Options) (*badger.DB, error), ...)
- func RunWithTypedPebbleDB(t testing.TB, create func(string, *pebble.Options) (*pebble.DB, error), ...)
- func SealBlock(t *testing.T, st protocol.ParticipantState, ...) (br *flow.Block, bs *flow.Block)
- func SeedFixture(n int) []byte
- func SeedFixtures(m int, n int) [][]byte
- func ServiceEventsFixture(n int) flow.ServiceEventList
- func SetupWithCounter(counter uint64) func(*flow.EpochSetup)
- func SignatureFixture() crypto.Signature
- func SignaturesFixture(n int) []crypto.Signature
- func SignerIndicesByIndices(n int, indices []int) []byte
- func SignerIndicesFixture(n int) []byte
- func SkipBenchmarkUnless(b *testing.B, reason SkipBenchmarkReason, message string)
- func SkipUnless(t *testing.T, reason SkipReason, message string)
- func SnapshotClusterByIndex(snapshot *inmem.Snapshot, clusterIndex uint) (protocol.Cluster, error)
- func SnapshotFromBootstrapState(root *flow.Block, result *flow.ExecutionResult, seal *flow.Seal, ...) (*inmem.Snapshot, error)
- func StakingKeys(n int) []crypto.PrivateKey
- func StakingPrivKeyByIdentifier(id flow.Identifier) crypto.PrivateKey
- func StakingPrivKeyFixture() crypto.PrivateKey
- func StateCommitmentFixture() flow.StateCommitment
- func StateCommitmentPointerFixture() *flow.StateCommitment
- func StateInteractionsFixture() *snapshot.ExecutionSnapshot
- 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 TempPebbleDB(t testing.TB) (*pebble.DB, string)
- func TempPebbleDBWithOpts(t testing.TB, opts *pebble.Options) (*pebble.DB, string)
- func TempPebblePath(t *testing.T) string
- func TransactionBodyFixture(opts ...func(*flow.TransactionBody)) flow.TransactionBody
- func TransactionBodyListFixture(n int) []flow.TransactionBody
- func TransactionDSLFixture(chain flow.Chain) dsl.Transaction
- func TransactionFixture(opts ...func(*flow.TransactionBody)) flow.TransactionBody
- func TransactionForCluster(clusters flow.ClusterList, target flow.IdentitySkeletonList) flow.TransactionBody
- func TransactionResultErrorMessageFixture(opts ...func(*flow.TransactionResultErrorMessage)) flow.TransactionResultErrorMessage
- func TransactionResultErrorMessagesFixture(n int) []flow.TransactionResultErrorMessage
- func TransactionResultsFixture(n int) []flow.TransactionResult
- func TransactionSignatureFixture() flow.TransactionSignature
- func TypedBadgerDB(t testing.TB, dir string, create func(badger.Options) (*badger.DB, error)) *badger.DB
- func TypedPebbleDB(t testing.TB, dir string, ...) *pebble.DB
- func Uint64InRange(min, max uint64) uint64
- func UnsignedExecutionReceiptFixture(opts ...func(*flow.UnsignedExecutionReceipt)) *flow.UnsignedExecutionReceipt
- func VerifiableChunkDataFixture(chunkIndex uint64, opts ...func(*flow.HeaderBody)) (*verification.VerifiableChunkData, *flow.Block)
- func VerifyCdcArguments(t *testing.T, expected []cadence.Value, actual []interface{})
- func VersionBeaconFixture(options ...func(*flow.VersionBeacon)) *flow.VersionBeacon
- func VersionBeaconFixtureByChainID(chain flow.ChainID) (flow.Event, *flow.VersionBeacon)
- func ViewBasedActivatorFixture() *protocol.ViewBasedActivator[uint64]
- func VoteFixture(opts ...func(vote *hotstuff.Vote)) *hotstuff.Vote
- func VoteForBlockFixture(block *hotstuff.Block, opts ...func(vote *hotstuff.Vote)) *hotstuff.Vote
- func VoteWithBeaconSig() func(*hotstuff.Vote)
- func VoteWithStakingSig() func(*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 WithApproximateSize(bytes uint64) func(*messages.ChunkDataResponse)
- func WithAssignments(assignments flow.AssignmentList) func(*flow.EpochSetup)
- func WithAttestationBlock(block *flow.Block) func(*flow.ResultApproval)
- func WithBlock(block *flow.Block) func(*flow.ExecutionResult)
- func WithBlockExecutionDataBlockID(blockID flow.Identifier) func(*execution_data.BlockExecutionData)
- func WithBlockID(id flow.Identifier) func(*flow.ResultApproval)
- func WithBoundaries(boundaries ...flow.VersionBoundary) func(*flow.VersionBeacon)
- func WithChunk(chunkIdx uint64) func(*flow.ResultApproval)
- func WithChunkDataPackCollection(collection *flow.Collection) func(*flow.ChunkDataPack)
- func WithChunkEvents(events flow.EventsList) func(*execution_data.ChunkExecutionData)
- func WithChunkExecutionDatas(chunks ...*execution_data.ChunkExecutionData) func(*execution_data.BlockExecutionData)
- func WithChunkID(chunkID flow.Identifier) func(*verification.ChunkDataPackRequest)
- func WithChunkStartState(startState flow.StateCommitment) func(chunk *flow.Chunk)
- func WithChunks(n uint) func(*flow.ExecutionResult)
- func WithClusterQCs(qcs []flow.ClusterQCVoteData) func(*flow.EpochCommit)
- 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 WithDKGFromParticipants(participants flow.IdentitySkeletonList) func(*flow.EpochCommit)
- func WithDisagrees(list flow.IdentifierList) func(*verification.ChunkDataPackRequest)
- func WithExecutionDataID(id flow.Identifier) func(result *flow.ExecutionResult)
- func WithExecutionResultBlockID(blockID flow.Identifier) func(*flow.ExecutionResult)
- func WithExecutionResultID(id flow.Identifier) func(*flow.ResultApproval)
- func WithExecutionResults(results ...*flow.ExecutionResult) func(*flow.Payload)
- func WithExecutorID(executorID flow.Identifier) func(*flow.ExecutionReceipt)
- func WithFinalState(commit flow.StateCommitment) func(*flow.ExecutionResult)
- func WithFinalView(view uint64) func(*flow.EpochSetup)
- func WithFirstView(view uint64) func(*flow.EpochSetup)
- func WithFrom(pid peer.ID) func(*pubsub_pb.Message)
- func WithGuarantees(guarantees ...*flow.CollectionGuarantee) func(*flow.Payload)
- func WithHeaderHeight(height uint64) func(*flow.Header)
- func WithHeight(height uint64) func(*verification.ChunkDataPackRequest)
- func WithHeightGreaterThan(height uint64) func(*verification.ChunkDataPackRequest)
- func WithInitialWeight(weight uint64) func(*flow.Identity)
- func WithKeys(identity *flow.Identity)
- func WithLock(t testing.TB, manager lockctx.Manager, lockID string, ...) error
- func WithLocks(t testing.TB, manager lockctx.Manager, lockIDs []string, ...) error
- func WithNetworkingKey(key crypto.PublicKey) func(*flow.Identity)
- func WithNextEpochProtocolState() func(entry *flow.RichEpochStateEntry)
- func WithNodeID(id flow.Identifier) func(*flow.Identity)
- func WithParticipants(participants flow.IdentitySkeletonList) func(*flow.EpochSetup)
- func WithParticipationStatus(status flow.EpochParticipationStatus) func(*flow.Identity)
- func WithPreviousResult(prevResult flow.ExecutionResult) func(*flow.ExecutionResult)
- func WithPreviousResultID(previousResultID flow.Identifier) func(*flow.ExecutionResult)
- func WithProtocolStateID(stateID flow.Identifier) func(payload *flow.Payload)
- func WithRandomPublicKeys() func(*flow.Identity)
- func WithReceipts(receipts ...*flow.ExecutionReceipt) func(*flow.Payload)
- func WithReceiptsAndNoResults(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 WithServiceEventCount(count uint16) func(*flow.Chunk)
- func WithServiceEvents(n int) func(result *flow.ExecutionResult)
- func WithSpocks(spocks []crypto.Signature) func(*flow.ExecutionReceipt)
- 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 WithTrieUpdate(trieUpdate *ledger.TrieUpdate) func(*execution_data.ChunkExecutionData)
- func WithTxResultErrorMessageExecutorID(id flow.Identifier) func(txResErrMsg *flow.TransactionResultErrorMessage)
- func WithTxResultErrorMessageIndex(index uint32) func(txResErrMsg *flow.TransactionResultErrorMessage)
- func WithTxResultErrorMessageTxID(id flow.Identifier) func(txResErrMsg *flow.TransactionResultErrorMessage)
- func WithTxResultErrorMessageTxMsg(message string) func(txResErrMsg *flow.TransactionResultErrorMessage)
- func WithValidDKG() func(*flow.RichEpochStateEntry)
- func WithVoteBlockID(blockID flow.Identifier) func(*hotstuff.Vote)
- func WithVoteSignerID(signerID flow.Identifier) func(*hotstuff.Vote)
- func WithVoteView(view uint64) func(*hotstuff.Vote)
- 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) AddBlocksWithSeals(n int, counter uint64) *EpochBuilder
- 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 EventGeneratorOption
- type EventOption
- type Events
- type Identifiers
- type LoggerHook
- type MalleabilityChecker
- type MalleabilityCheckerOpt
- type MockEntity
- type RPCFixtureOpt
- func WithGrafts(grafts ...*pubsub_pb.ControlGraft) RPCFixtureOpt
- func WithIHaves(iHaves ...*pubsub_pb.ControlIHave) RPCFixtureOpt
- func WithIWants(iWants ...*pubsub_pb.ControlIWant) RPCFixtureOpt
- func WithPrunes(prunes ...*pubsub_pb.ControlPrune) RPCFixtureOpt
- func WithPubsubMessages(msgs ...*pubsub_pb.Message) RPCFixtureOpt
- type SkipBenchmarkReason
- type SkipReason
- type StorageLockAcquisitionError
- type TestTime
- type UpdatableIDProvider
- func (p *UpdatableIDProvider) ByNodeID(flowID flow.Identifier) (*flow.Identity, bool)
- func (p *UpdatableIDProvider) ByPeerID(peerID peer.ID) (*flow.Identity, bool)
- func (p *UpdatableIDProvider) Identifiers() flow.IdentifierList
- func (p *UpdatableIDProvider) Identities(filter flow.IdentityFilter[flow.Identity]) flow.IdentityList
- func (p *UpdatableIDProvider) SetIdentities(identities flow.IdentityList)
Constants ¶
const (
DefaultAddress = "localhost:0"
)
const GenesisStateCommitmentHex = "b8bb1b56c944902e5e0877735e2e08779a3a6385c714169473ea723a47caba83"
Pre-calculated state commitment with root account with the above private key
const ServiceAccountPrivateKeyHashAlgo = hash.SHA2_256
const ServiceAccountPrivateKeyHex = "8ae3d0461cfed6d6f49bfc25fa899351c39d1bd21fdba8c87595b6c49bb4cc43"
const ServiceAccountPrivateKeySignAlgo = crypto.ECDSAP256
Variables ¶
var Block blockFactory
var ClusterBlock clusterBlockFactory
var EpochCommitFixtureCCF = func() []byte { b, err := ccf.Encode(createEpochCommitEvent()) if err != nil { panic(err) } _, err = ccf.Decode(nil, b) if err != nil { panic(err) } return b }()
var Event eventFactory
var EventGenerator eventGeneratorFactory
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 MatchInvalidServiceEventError = mock.MatchedBy(func(err error) bool { return protocol.IsInvalidServiceEventError(err) })
MatchInvalidServiceEventError matches an error that is an InvalidServiceEventError.
var ProtocolStateVersionUpgradeFixtureCCF = func() []byte { b, err := ccf.Encode(createProtocolStateVersionUpgradeEvent()) if err != nil { panic(err) } _, err = ccf.Decode(nil, b) if err != nil { panic(err) } return b }()
var Seal sealFactory
var ServiceAccountPrivateKey flow.AccountPrivateKey
var ServiceAccountPublicKey flow.AccountPublicKey
Functions ¶
func AccountFixture ¶ added in v0.23.5
AccountFixture returns a randomly generated account.
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 AddCollectionsToBlock ¶ added in v0.33.19
func AddCollectionsToBlock(block *flow.Block, collections []*flow.Collection)
func AddVersionBeacon ¶ added in v0.31.0
func AddVersionBeacon(t *testing.T, beacon *flow.VersionBeacon, state protocol.FollowerState)
AddVersionBeacon adds blocks sequence with given VersionBeacon so this service events takes effect in Flow protocol. This means execution result where event was emitted is sealed, and the seal is finalized by a valid block. This assumes state is bootstrapped with a root block, as it does NOT produce results for final block of the state Root <- A <- B(result(A(VB))) <- C(seal(B))
func AddressFixture ¶
func AllowAllPeerFilter ¶ added in v0.27.0
func AlterTransactionForCluster ¶
func AlterTransactionForCluster(tx flow.TransactionBody, clusters flow.ClusterList, target flow.IdentitySkeletonList, 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 AreNumericallyClose ¶ added in v0.33.1
AreNumericallyClose returns true if the two floats are within epsilon of each other. The epsilon is calculated as:
epsilon = max(|a|, |b|) * epsilon
Example:
AreNumericallyClose(1.0, 1.1, 0.1) // true since 1.0 * 0.1 = 0.1 < 0.1 AreNumericallyClose(1.0, 1.1, 0.01) // false since 1.0 * 0.01 = 0.01 < 0.1 AreNumericallyClose(1.0, 1.1, 0.11) // false since 1.1 * 0.11 = 0.121 > 0.1
Args: a: the first float b: the second float epsilon: the epsilon value Returns: true if the two floats are within epsilon of each other false otherwise
func AsSlashable ¶ added in v0.29.0
AsSlashable returns the input message T, wrapped as a flow.Slashable instance with a random origin ID.
func AssertClosesBefore ¶
func AssertClosesBefore(t assert.TestingT, done <-chan struct{}, duration time.Duration, msgAndArgs ...interface{})
AssertClosesBefore asserts that the given channel closes before the duration expires.
func AssertEqualBlockSequences ¶ added in v0.43.0
AssertEqualBlockSequences is given a sequence of Blocks and a sequence of Proposals. It asserts that both sequences are of the same length, and that each proposal is for the block at the same index (via block hash). Used as a convenience function for Sealing Segment tests due to differences with nils vs empty slices.
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 AssertFloatEqual ¶ added in v0.26.0
func AssertNotClosesBefore ¶ added in v0.23.0
func AssertNotClosesBefore(t assert.TestingT, done <-chan struct{}, duration time.Duration, msgAndArgs ...interface{})
AssertNotClosesBefore asserts that the given channel does not close before the duration expires.
func AssertReturnsBefore ¶
func AssertReturnsBefore(t *testing.T, f func(), duration time.Duration, msgAndArgs ...interface{}) bool
AssertReturnsBefore asserts that the given function returns before the duration expires.
func AssertSnapshotsEqual ¶ added in v0.15.0
func AttestationFixture ¶ added in v0.26.1
func AttestationFixture() *flow.Attestation
func BatchFixture ¶
func BatchListFixture ¶
func BlockEventsFixture ¶ added in v0.23.7
func BlockEventsFixture( header *flow.Header, n int, ) flow.BlockEvents
BlockEventsFixture returns a block events model populated with random events of length n.
func BlockExecutionDatEntityFixture ¶ added in v0.30.4
func BlockExecutionDatEntityFixture(opts ...func(*execution_data.BlockExecutionData)) *execution_data.BlockExecutionDataEntity
func BlockExecutionDatEntityListFixture ¶ added in v0.30.4
func BlockExecutionDatEntityListFixture(n int) []*execution_data.BlockExecutionDataEntity
func BlockExecutionDataFixture ¶ added in v0.30.4
func BlockExecutionDataFixture(opts ...func(*execution_data.BlockExecutionData)) *execution_data.BlockExecutionData
func BlockFixture ¶
BlockFixture initializes and returns a new *flow.Block instance.
func BlockFixtures ¶ added in v0.13.0
func BlockHeaderWithHeight ¶ added in v0.33.21
func BlockHeaderWithParentWithSoRFixture ¶ added in v0.32.0
func BlockResponseFixture ¶
func BlockResponseFixture(count int) *flow.BlockResponse
func BlockSealsFixture ¶
func BlockWithGuaranteesFixture ¶ added in v0.17.6
func BlockWithGuaranteesFixture(guarantees []*flow.CollectionGuarantee) *flow.Block
func BlockWithParentAndPayload ¶ added in v0.43.0
BlockWithParentAndPayload creates a new block that is valid with respect to the given parent block and with given payload.
func BlockWithParentAndPayloadAndUniqueView ¶ added in v0.43.0
func BlockWithParentAndPayloadAndUniqueView(parent *flow.Header, payload flow.Payload, forbiddenViews map[uint64]struct{}) *flow.Block
BlockWithParentAndPayloadAndUniqueView creates a child block of the given parent, where the block to be constructed will contain the iven payload. We provide a set of views that are _not_ allowed to be used for the new block. A typical usage scenario is to create blocks of different forks, without accidentally creating two blocks with the same view. CAUTION:
- modifies the set `forbiddenViews` by adding the view of the newly created block.
- To generate the child's view, we randomly select a small increment and add it to the parent's view. If the set of views covers all possible increments, this function will panic
func BlockWithParentAndProposerFixture ¶ added in v0.10.0
func BlockWithParentAndSeals ¶ added in v0.26.2
func BlockWithParentAndUniqueView ¶ added in v0.43.0
func BlockWithParentAndUniqueView(parent *flow.Header, forbiddenViews map[uint64]struct{}) *flow.Block
BlockWithParentAndUniqueView creates a child block of the given parent. We provide a set of views that are _not_ allowed to be used for the new block. A typical usage scenario is to create blocks of different forks, without accidentally creating two blocks with the same view. CAUTION:
- modifies the set `forbiddenViews` by adding the view of the newly created block.
- To generate the child's view, we randomly select a small increment and add it to the parent's view. If the set of views covers all possible increments, this function will panic
func BlockWithParentProtocolState ¶ added in v0.33.30
func BlockWithParentProtocolStateAndUniqueView ¶ added in v0.43.0
func BlockWithParentProtocolStateAndUniqueView(parent *flow.Block, forbiddenViews map[uint64]struct{}) *flow.Block
BlockWithParentProtocolStateAndUniqueView creates a child block of the given parent, such that the child's protocol state is the same as the parent's. We provide a set of views that are _not_ allowed to be used for the new block. A typical usage scenario is to create blocks of different forks, without accidentally creating two blocks with the same view. CAUTION:
- modifies the set `forbiddenViews` by adding the view of the newly created block.
- To generate the child's view, we randomly select a small increment and add it to the parent's view. If the set of views covers all possible increments, this function will panic
func BlockchainFixture ¶ added in v0.32.1
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 BootstrapFixtureWithChainID ¶ added in v0.30.7
func BootstrapFixtureWithSetupAndCommit ¶ added in v0.43.0
func BootstrapFixtureWithSetupAndCommit( header flow.HeaderBody, setup *flow.EpochSetup, commit *flow.EpochCommit, ) (*flow.Block, *flow.ExecutionResult, *flow.Seal)
BootstrapFixtureWithSetupAndCommit generates all the artifacts necessary to bootstrap the protocol state using the provided epoch setup and commit.
func BytesToCdcUInt8 ¶ added in v0.43.0
BytesToCdcUInt8 converts a Go []byte to a Cadence []UInt8 with equal content.
func CertifiedByChild ¶ added in v0.43.0
func CertifyBlock ¶ added in v0.30.0
func CertifyBlock(header *flow.Header) *flow.QuorumCertificate
CertifyBlock returns a quorum certificate for the given block header
func ChainBlockFixtureWithRoot ¶ added in v0.33.19
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(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 ChunkDataPackRequestInfoFixture ¶ added in v0.43.0
func ChunkDataPackRequestInfoFixture() *verification.ChunkDataPackRequestInfo
func ChunkDataPackRequestListFixture ¶ added in v0.17.0
func ChunkDataPackRequestListFixture( n int, opts ...func(*verification.ChunkDataPackRequest), ) verification.ChunkDataPackRequestList
ChunkDataPackRequestListFixture creates and returns a list of chunk data pack requests fixtures.
func ChunkDataPacksFixture ¶ added in v0.21.0
func ChunkDataPacksFixture( count int, opts ...func(*flow.ChunkDataPack), ) []*flow.ChunkDataPack
func ChunkDataPacksFixtureAndResult ¶ added in v0.38.0
func ChunkDataPacksFixtureAndResult() ([]*flow.ChunkDataPack, *flow.ExecutionResult)
func ChunkDataResponseMessageListFixture ¶ added in v0.23.2
func ChunkDataResponseMessageListFixture(chunkIDs flow.IdentifierList) []*messages.ChunkDataResponse
ChunkDataResponseMessageListFixture creates a list of chunk data response messages each with a single-transaction collection, and random chunk ID.
func ChunkDataResponseMsgFixture ¶ added in v0.23.2
func ChunkDataResponseMsgFixture( chunkID flow.Identifier, opts ...func(*messages.ChunkDataResponse), ) *messages.ChunkDataResponse
ChunkDataResponseMsgFixture creates a chunk data response message with a single-transaction collection, and random chunk ID. Use options to customize the response.
func ChunkExecutionDataFixture ¶ added in v0.30.4
func ChunkExecutionDataFixture(t *testing.T, minSize int, opts ...func(*execution_data.ChunkExecutionData)) *execution_data.ChunkExecutionData
func ChunkFixture ¶
func ChunkFixture( blockID flow.Identifier, collectionIndex uint, startState flow.StateCommitment, opts ...func(*flow.Chunk), ) *flow.Chunk
func ChunkListFixture ¶ added in v0.14.8
func ChunkListFixture(n uint, blockID flow.Identifier, startState flow.StateCommitment, opts ...func(*flow.Chunk)) 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, blockHeight uint64, result *flow.ExecutionResult, n int, ) verification.ChunkStatusList
ChunkStatusListFixture receives an execution result, samples `n` chunks out of it and creates a chunk status for them. It returns the list of sampled chunk statuses for the result.
func ChunkStatusListToChunkLocatorFixture ¶ added in v0.17.0
func ChunkStatusListToChunkLocatorFixture(statuses []*verification.ChunkStatus) chunks.LocatorMap
ChunkStatusListToChunkLocatorFixture extracts chunk locators from a list of chunk statuses.
func ClosedChannel ¶ added in v0.29.0
func ClosedChannel() <-chan struct{}
ClosedChannel returns a closed channel.
func ClusterAssignment ¶
func ClusterAssignment(n uint, nodes flow.IdentitySkeletonList) flow.AssignmentList
ClusterAssignment creates an assignment list with n clusters and with nodes evenly distributed among clusters.
func ClusterBlockFixtures ¶ added in v0.43.0
func ClusterBlockResponseFixture ¶
func ClusterBlockResponseFixture(count int) *cluster.BlockResponse
func ClusterList ¶ added in v0.16.0
func ClusterList(n uint, nodes flow.IdentitySkeletonList) flow.ClusterList
func ClusterPayloadFixture ¶
func ClusterProposalFixture ¶ added in v0.43.0
func ClusterProposalFromBlock ¶ added in v0.26.0
func CollectionFixture ¶
func CollectionFixture(n int, options ...func(*flow.Collection)) flow.Collection
func CollectionFromTransactions ¶ added in v0.43.0
func CollectionFromTransactions(transactions ...*flow.TransactionBody) flow.Collection
CollectionFromTransactions creates a new collection from the list of transactions.
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, options ...func(*flow.Collection)) []*flow.Collection
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 CrashTest ¶ added in v0.27.2
CrashTest safely tests functions that crash (as the expected behavior) by checking that running the function creates an error and an expected error message.
func CrashTestWithExpectedStatus ¶ added in v0.28.0
func CrashTestWithExpectedStatus( t *testing.T, scenario func(*testing.T), expectedErrorMsg string, expectedStatus ...int, )
CrashTestWithExpectedStatus checks for the test crashing with a specific exit code.
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 CreateSendTxHttpPayload ¶ added in v0.32.0
func CreateSendTxHttpPayload(tx flow.TransactionBody) map[string]interface{}
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 DynamicIdentityEntryFixture ¶ added in v0.43.0
func DynamicIdentityEntryFixture(opts ...func(*flow.DynamicIdentityEntry)) *flow.DynamicIdentityEntry
DynamicIdentityEntryFixture returns the DynamicIdentityEntry object. The dynamic identity entry can be customized (ie. set Ejected).
func DynamicIdentityEntryListFixture ¶ added in v0.37.1
func DynamicIdentityEntryListFixture(n int, opts ...func(*flow.DynamicIdentityEntry)) flow.DynamicIdentityEntryList
DynamicIdentityEntryListFixture returns a list of DynamicIdentityEntry objects.
func EmulatorRootKey ¶
func EmulatorRootKey() (*flow.AccountPrivateKey, error)
func EncodeDecodeDifferentVersions ¶ added in v0.39.0
EncodeDecodeDifferentVersions emulates the situation where a peer running software version A receives a message from a sender running software version B, where the format of the message may have been upgraded between the different software versions. This method works irrespective whether version A or B is the older/newer version (also allowing that both versions are the same; in this degenerate edge-case the old and new format would be the same).
This function works by encoding src using CBOR, then decoding the result into dst. Compatible fields as defined by CBOR will be copied into dst; in-compatible fields may be omitted.
func EngineMessageFixture ¶ added in v0.29.0
func EngineMessageFixtures ¶ added in v0.29.0
func EnsureEventsIndexSeq ¶ added in v0.28.2
EnsureEventsIndexSeq checks if values of given event index sequence are monotonically increasing.
func EpochCommitFixture ¶
func EpochCommitFixture(opts ...func(*flow.EpochCommit)) *flow.EpochCommit
func EpochCommitFixtureByChainID ¶ added in v0.30.0
EpochCommitFixtureByChainID returns an EpochCommit service event as a Cadence event representation and as a protocol model representation.
func EpochExtensionFixture ¶ added in v0.43.0
func EpochExtensionFixture() flow.EpochExtension
EpochExtensionFixture returns a randomly generated EpochExtensionFixture object.
func EpochProtocolStateEntryFixture ¶ added in v0.37.1
func EpochProtocolStateEntryFixture(tentativePhase flow.EpochPhase, efmTriggered bool) flow.MinEpochStateEntry
EpochProtocolStateEntryFixture returns a flow.MinEpochStateEntry fixture.
- PreviousEpoch is always nil
- tentativePhase defines what service events should be defined for the NextEpoch
- efmTriggered defines whether the EpochFallbackTriggered flag should be set.
func EpochRecoverFixture ¶ added in v0.37.1
func EpochRecoverFixture(opts ...func(setup *flow.EpochSetup)) *flow.EpochRecover
EpochRecoverFixture creates a valid EpochRecover with default properties for testing. The default properties for setup part can be overwritten with optional parameter functions. Commit part will be adjusted accordingly.
func EpochRecoverFixtureByChainID ¶ added in v0.37.1
EpochRecoverFixtureByChainID returns an EpochRecover service event as a Cadence event representation and as a protocol model representation.
func EpochRecoverFixtureCCF ¶ added in v0.37.1
func EpochSetupCCFWithNonHexRandomSource ¶ added in v0.33.1
func EpochSetupCCFWithNonHexRandomSource() []byte
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 EpochSetupFixtureByChainID ¶ added in v0.30.0
EpochSetupFixtureByChainID returns an EpochSetup service event as a Cadence event representation and as a protocol model representation.
func EpochSetupFixtureCCF ¶ added in v0.31.2
func EpochSetupRandomSourceFixture ¶ added in v0.33.1
func EpochSetupRandomSourceFixture() []byte
func EpochStateContainerFixture ¶ added in v0.43.0
func EpochStateContainerFixture() *flow.EpochStateContainer
EpochStateContainerFixture returns a randomly generated EpochStateContainer object.
func EpochStateFixture ¶ added in v0.33.30
func EpochStateFixture(options ...func(*flow.RichEpochStateEntry)) *flow.RichEpochStateEntry
EpochStateFixture creates a fixture with correctly structured data. The returned Identity Table represents the common situation during the staking phase of Epoch N+1:
- we are currently in Epoch N
- previous epoch N-1 is known (specifically EpochSetup and EpochCommit events)
- network is currently in the staking phase to setup the next epoch, hence no service events for the next epoch exist
In particular, the following consistency requirements hold:
- Epoch setup and commit counters are set to match.
- Identities are constructed from setup events.
- Identities are sorted in canonical order.
func EventFixture ¶
func EventFixture( opts ...EventOption, ) flow.Event
EventFixture returns a single event
func EventsFixture ¶ added in v0.31.14
func ExecutableBlockFixture ¶
func ExecutableBlockFixture( collectionsSignerIDs [][]flow.Identifier, startState *flow.StateCommitment, ) *entity.ExecutableBlock
func ExecutableBlockFixtureWithParent ¶
func ExecutableBlockFixtureWithParent( collectionsSignerIDs [][]flow.Identifier, parent *flow.Header, startState *flow.StateCommitment, ) *entity.ExecutableBlock
func ExecutableBlockFromTransactions ¶ added in v0.19.0
func ExecutableBlockFromTransactions( chain flow.ChainID, 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 FailOnIrrecoverableError ¶ added in v0.29.0
FailOnIrrecoverableError waits for either the done signal, or an error to be sent over the error channel. If an error is observed, it is logged and the test is failed. Must be invoked as a goroutine.
func FinalizedProtocolStateWithParticipants ¶
func FinalizedProtocolStateWithParticipants(participants flow.IdentityList) ( *flow.Block, *mockprotocol.Snapshot, *mockprotocol.State, *mockprotocol.Snapshot)
FinalizedProtocolStateWithParticipants returns a protocol state with finalized participants
func FixedReferenceBlockID ¶ added in v0.26.1
func FixedReferenceBlockID() flow.Identifier
func FullBlockFixture ¶ added in v0.14.0
func GenerateRandomStringWithLen ¶ added in v0.28.0
GenerateRandomStringWithLen returns a string of random alpha characters of the provided length
func GenesisStateCommitmentByChainID ¶ added in v0.30.7
func GenesisStateCommitmentByChainID(chainID flow.ChainID) flow.StateCommitment
this is done by printing the state commitment in TestBootstrapLedger test with different chain ID
func GetFlowProtocolEventID ¶ added in v0.30.0
func GetFlowProtocolEventID( t *testing.T, channel channels.Channel, event interface{}, ) flow.Identifier
GetFlowProtocolEventID returns the event ID for the event provided.
func GetPRG ¶ added in v0.30.0
returns a deterministic math/rand PRG that can be used for deterministic randomness in tests only. The PRG seed is logged in case the test iteration needs to be reproduced.
func GossipSubMessageFixture ¶ added in v0.33.1
GossipSubMessageFixture returns a gossip sub message fixture for the specified topic.
func GossipSubMessageFixtures ¶ added in v0.33.1
func GossipSubMessageFixtures(n int, topic string, opts ...func(*pubsub_pb.Message)) []*pubsub_pb.Message
GossipSubMessageFixtures returns a list of gossipsub message fixtures.
func HashFixture ¶
func HeaderBodyFixture ¶ added in v0.43.0
func HeaderBodyFixture(opts ...func(header flow.HeaderBody)) flow.HeaderBody
func HeaderBodyWithParentFixture ¶ added in v0.43.0
func HeaderBodyWithParentFixture(parent *flow.Header) flow.HeaderBody
func HeaderWithView ¶ added in v0.23.7
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.IdentifierList
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 IdentityWithNetworkingKeyFixture ¶ added in v0.22.4
func IdentityWithNetworkingKeyFixture(opts ...func(*flow.Identity)) ( *flow.Identity, crypto.PrivateKey, )
IdentityWithNetworkingKeyFixture returns a node identity and networking private key
func IndexFixture ¶ added in v0.14.0
func InsertAndFinalize ¶ added in v0.29.0
InsertAndFinalize inserts, then finalizes, the input block.
func InterfaceToCdcValues ¶ added in v0.43.0
InterfaceToCdcValues decodes jsoncdc encoded values from interface -> cadence value.
func InvalidAddressFixture ¶ added in v0.11.0
func InvalidFormatSignature ¶ added in v0.12.0
func InvalidFormatSignature() flow.TransactionSignature
func IsServiceEvent ¶ added in v0.28.2
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 LibP2PResourceLimitOverrideFixture ¶ added in v0.33.1
func LibP2PResourceLimitOverrideFixture() p2pconfig.ResourceManagerOverrideLimit
LibP2PResourceLimitOverrideFixture returns a random resource limit override for testing. The values are not guaranteed to be valid between 0 and 1000. Returns:
- p2pconf.ResourceManagerOverrideLimit: a random resource limit override.
func LightTransactionResultsFixture ¶ added in v0.32.0
func LightTransactionResultsFixture(n int) []flow.LightTransactionResult
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 LoggerForTest ¶ added in v0.28.0
func LoggerWithName ¶ added in v0.27.3
func LoggerWithWriterAndLevel ¶ added in v0.25.0
func MachineAccountFixture ¶ added in v0.22.0
func MakeOwnerReg ¶ added in v0.33.1
func MakeOwnerReg(key string, value string) flow.RegisterEntry
func MatchEpochExtension ¶ added in v0.37.1
MatchEpochExtension matches an epoch extension argument passed to a mocked component.
func MustDecodePublicKeyHex ¶ added in v0.19.0
func MustDecodePublicKeyHex(algo crypto.SigningAlgorithm, keyHex string) crypto.PublicKey
func MustDecodeSignatureHex ¶ added in v0.19.0
func NetworkCodec ¶ added in v0.27.0
NetworkCodec returns cbor codec.
func NetworkTopology ¶ added in v0.28.0
NetworkTopology returns the default topology for testing purposes.
func NetworkingKeys ¶
func NetworkingKeys(n int) []crypto.PrivateKey
func NetworkingPrivKeyFixture ¶ added in v0.23.0
func NetworkingPrivKeyFixture() crypto.PrivateKey
NetworkingPrivKeyFixture returns random ECDSAP256 private key
func NewCertifiedBlock ¶ added in v0.43.0
func NewCertifiedBlock(block *flow.Block) *flow.CertifiedBlock
func NewFlowClusterQCClusterStructType ¶ added in v0.33.30
func NewFlowClusterQCClusterStructType() *cadence.StructType
func NewNodeVersionBeaconSemverStructType ¶ added in v0.32.0
func NewNodeVersionBeaconSemverStructType() *cadence.StructType
func NewNodeVersionBeaconVersionBeaconEventType ¶ added in v0.32.0
func NewNodeVersionBeaconVersionBoundaryStructType ¶ added in v0.32.0
func NewNodeVersionBeaconVersionBoundaryStructType() *cadence.StructType
func NewProtocolStateVersionUpgradeEventType ¶ added in v0.33.30
func NewSealingConfigs ¶ added in v0.26.13
func NewSealingConfigs(val uint) module.SealingConfigsSetter
func NodeConfigFixture ¶ added in v0.25.0
func NodeConfigFixture(opts ...func(*flow.Identity)) bootstrap.NodeConfig
func NodeInfoFixture ¶ added in v0.16.1
func NodeInfoFromIdentity ¶ added in v0.43.0
NodeInfoFromIdentity converts an identity to a public NodeInfo WARNING: the function replaces the staking key from the identity by a freshly generated one.
func NodeInfosFixture ¶ added in v0.16.1
func NodeMachineAccountInfoFixture ¶ added in v0.22.0
func NodeMachineAccountInfoFixture() bootstrap.NodeMachineAccountInfo
func NoopTxScript ¶
func NoopTxScript() []byte
NoopTxScript returns a Cadence script for a no-op transaction.
func P2PRPCFixture ¶ added in v0.32.0
func P2PRPCFixture(opts ...RPCFixtureOpt) *pubsub.RPC
P2PRPCFixture returns a pubsub RPC fixture. Currently, this fixture only sets the ControlMessage field.
func P2PRPCGraftFixture ¶ added in v0.32.0
func P2PRPCGraftFixture(topic *string) *pubsub_pb.ControlGraft
P2PRPCGraftFixture returns a control message rpc Graft fixture.
func P2PRPCGraftFixtures ¶ added in v0.32.0
func P2PRPCGraftFixtures(topics ...string) []*pubsub_pb.ControlGraft
P2PRPCGraftFixtures returns n number of control message rpc Graft fixtures.
func P2PRPCIHaveFixture ¶ added in v0.32.0
func P2PRPCIHaveFixture(topic *string, messageIds ...string) *pubsub_pb.ControlIHave
P2PRPCIHaveFixture returns a control message rpc iHave fixture.
func P2PRPCIHaveFixtures ¶ added in v0.32.0
func P2PRPCIHaveFixtures(m int, topics ...string) []*pubsub_pb.ControlIHave
P2PRPCIHaveFixtures returns n number of control message where n = len(topics) rpc iHave fixtures with m number of message ids each.
func P2PRPCIWantFixture ¶ added in v0.32.0
func P2PRPCIWantFixture(messageIds ...string) *pubsub_pb.ControlIWant
P2PRPCIWantFixture returns a control message rpc iWant fixture.
func P2PRPCIWantFixtures ¶ added in v0.32.0
func P2PRPCIWantFixtures(n, m int) []*pubsub_pb.ControlIWant
P2PRPCIWantFixtures returns n number of control message rpc iWant fixtures with m number of message ids each.
func P2PRPCPruneFixture ¶ added in v0.32.0
func P2PRPCPruneFixture(topic *string) *pubsub_pb.ControlPrune
P2PRPCPruneFixture returns a control message rpc Prune fixture.
func P2PRPCPruneFixtures ¶ added in v0.32.0
func P2PRPCPruneFixtures(topics ...string) []*pubsub_pb.ControlPrune
P2PRPCPruneFixtures returns n number of control message rpc Prune fixtures.
func PeerIDFromFlowID ¶ added in v0.27.0
func PeerIdFixture ¶ added in v0.33.1
PeerIdFixture creates a random and unique peer ID (libp2p node ID).
func PeerIdFixtures ¶ added in v0.33.1
PeerIdFixtures creates random and unique peer IDs (libp2p node IDs).
func PrintHeapInfo ¶ added in v0.23.9
PrintHeapInfo prints heap object allocation through given logger.
func PrivateKeyFixture ¶ added in v0.22.0
func PrivateKeyFixture(algo crypto.SigningAlgorithm) crypto.PrivateKey
PrivateKeyFixture returns a random private key with specified signature algorithm
func PrivateKeyFixtureByIdentifier ¶ added in v0.23.7
func PrivateKeyFixtureByIdentifier( algo crypto.SigningAlgorithm, seedLength int, id flow.Identifier, ) crypto.PrivateKey
PrivateKeyFixtureByIdentifier returns a private key for a given node. given the same identifier, it will always return the same private key
func PrivateNodeInfoFixture ¶ added in v0.33.30
func PrivateNodeInfosFixture ¶ added in v0.20.0
func PrivateNodeInfosFromIdentityList ¶ added in v0.33.30
func PrivateNodeInfosFromIdentityList(il flow.IdentityList) []bootstrap.NodeInfo
func ProposalChainFixtureFrom ¶ added in v0.43.0
ProposalChainFixtureFrom creates a chain of blocks and wraps each one in a Proposal.
func ProposalFixture ¶
func ProposalFixtures ¶ added in v0.43.0
func ProposalHeaderFromHeader ¶ added in v0.43.0
func ProposalHeaderFromHeader(header *flow.Header) *flow.ProposalHeader
func ProposalKeyFixture ¶
func ProposalKeyFixture() flow.ProposalKey
func ProtocolStateVersionUpgradeFixture ¶ added in v0.33.30
func ProtocolStateVersionUpgradeFixture() *flow.ProtocolStateVersionUpgrade
func ProtocolStateVersionUpgradeFixtureByChainID ¶ added in v0.33.30
func PtrTo ¶ added in v0.39.0
func PtrTo[T any](target T) *T
PtrTo returns a pointer to the input. Useful for concisely constructing a reference-typed argument to a function or similar.
func PublicKeysFixture ¶ added in v0.17.0
func PublicKeysFixture(n int, algo crypto.SigningAlgorithm) []crypto.PublicKey
func QCSigDataFixture ¶ added in v0.23.9
func QCSigDataFixture() []byte
func QCSigDataWithSoRFixture ¶ added in v0.32.0
func QCWithBlockID ¶ added in v0.15.0
func QCWithBlockID(blockID flow.Identifier) func(*flow.QuorumCertificate)
func QCWithRootBlockID ¶ added in v0.29.0
func QCWithRootBlockID(blockID flow.Identifier) func(*flow.QuorumCertificate)
func QCWithSignerIndices ¶ added in v0.26.1
func QCWithSignerIndices(signerIndices []byte) func(*flow.QuorumCertificate)
func QuorumCertificateFixture ¶
func QuorumCertificateFixture(opts ...func(*flow.QuorumCertificate)) *flow.QuorumCertificate
func QuorumCertificateWithSignerIDsFixture ¶ added in v0.26.1
func QuorumCertificateWithSignerIDsFixture(opts ...func(*flow.QuorumCertificateWithSignerIDs)) *flow.QuorumCertificateWithSignerIDs
func QuorumCertificatesFixtures ¶ added in v0.17.1
func QuorumCertificatesFixtures( n uint, opts ...func(*flow.QuorumCertificate), ) []*flow.QuorumCertificate
func QuorumCertificatesFromAssignments ¶ added in v0.26.1
func QuorumCertificatesFromAssignments(assignment flow.AssignmentList) []*flow.QuorumCertificateWithSignerIDs
func QuorumCertificatesWithSignerIDsFixtures ¶ added in v0.26.1
func QuorumCertificatesWithSignerIDsFixtures( n uint, opts ...func(*flow.QuorumCertificateWithSignerIDs), ) []*flow.QuorumCertificateWithSignerIDs
func RandomAddressFixture ¶ added in v0.11.0
func RandomAddressFixtureForChain ¶ added in v0.33.1
func RandomBeaconPriv ¶ added in v0.23.2
func RandomBeaconPriv() *encodable.RandomBeaconPrivKey
func RandomByteSlice ¶ added in v0.32.0
RandomByteSlice is a test helper that generates a cryptographically secure random byte slice of size n.
func RandomBytes ¶
func RandomSDKAddressFixture ¶ added in v0.22.0
func RandomSourcesFixture ¶ added in v0.32.0
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 ReceiptAndSealForBlock(block *flow.Block, serviceEvents ...flow.ServiceEvent) (*flow.ExecutionReceipt, *flow.Seal)
ReceiptAndSealForBlock returns a receipt with service events and a seal for them for a given block.
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 RechainBlocks ¶ added in v0.33.19
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 RegisterEntryFixture ¶ added in v0.33.1
func RegisterEntryFixture() flow.RegisterEntry
func RegisterIDFixture ¶ added in v0.32.10
func RegisterIDFixture() flow.RegisterID
RegisterIDFixture returns a RegisterID with a fixed key and owner
func RequireCloseBefore ¶ added in v0.12.0
RequireCloseBefore requires that the given channel returns before the duration expires.
func RequireClosed ¶ added in v0.21.0
RequireClosed is a test helper function that fails the test if channel `ch` is not closed.
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 RequireEntityNonMalleable ¶ added in v0.43.0
func RequireEntityNonMalleable(t *testing.T, entity flow.IDEntity, ops ...MalleabilityCheckerOpt)
RequireEntityNonMalleable is RequireNonMalleable with the constraint that models implement flow.IDEntity and the content hash function is the ID() function. Non-malleability is a required property for any entity that implements the flow.IDEntity interface. This is especially important for entities that contain signatures and are transmitted over the network. ID is used by the protocol to insure entity integrity when transmitted over the network. ID must therefore be a binding cryptographic commitment to an entity. This function consumes the entity and modifies its fields randomly to ensure that the ID changes after each modification. Generally speaking each type that implements flow.IDEntity method should be tested with this function.
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 RequireNonMalleable ¶ added in v0.43.0
func RequireNonMalleable(t *testing.T, model any, hashModel func() flow.Identifier, ops ...MalleabilityCheckerOpt)
RequireNonMalleable is a sanity check that the model is not malleable with respect to a content hash over the model (hashModel). Non-malleability in this sense means that it is computationally hard to build a different model with the same hash. Hence, changing *any* field of a non-malleable model should change the hash, which we check here. Note that this is sanity check of non-malleability and that passing this test does not guarantee non-malleability. ATTENTION: We put only one requirement for data types, that is all fields have to be exported so we can modify them.
func RequireNotClosed ¶ added in v0.21.0
RequireNotClosed is a test helper function that fails the test if channel `ch` is closed.
func RequireNumericallyClose ¶ added in v0.33.1
func RequireNumericallyClose(t testing.TB, a, b float64, epsilon float64, msgAndArgs ...interface{})
RequireNumericallyClose is a wrapper around require.Equal that allows for a small epsilon difference between two floats. This is useful when comparing floats that are the result of a computation. For example, when comparing the result of a computation with a constant. The epsilon is calculated as:
epsilon = max(|a|, |b|) * epsilon
Example:
RequireNumericallyClose(t, 1.0, 1.1, 0.1) // passes since 1.0 * 0.1 = 0.1 < 0.1 RequireNumericallyClose(t, 1.0, 1.1, 0.01) // fails since 1.0 * 0.01 = 0.01 < 0.1 RequireNumericallyClose(t, 1.0, 1.1, 0.11) // fails since 1.1 * 0.11 = 0.121 > 0.1
Args:
t: the testing.TB instance a: the first float b: the second float
func RequireReturnsBefore ¶
RequireReturnsBefore requires that the given function returns before the duration expires.
func ResultApprovalFixture ¶
func ResultApprovalFixture(opts ...func(*flow.ResultApproval)) *flow.ResultApproval
func RootEpochProtocolStateFixture ¶ added in v0.33.30
func RootEpochProtocolStateFixture() *flow.RichEpochStateEntry
RootEpochProtocolStateFixture creates a fixture with correctly structured Epoch sub-state. The epoch substate is part of the overall protocol state (KV store). This can be useful for testing bootstrap when there is no previous epoch.
func RootSnapshotFixture ¶ added in v0.15.0
func RootSnapshotFixture( participants flow.IdentityList, opts ...func(*flow.Block), ) *inmem.Snapshot
RootSnapshotFixture returns a snapshot representing a root chain state, for example one as returned from BootstrapFixture.
func RootSnapshotFixtureWithChainID ¶ added in v0.30.7
func RunWithBadgerDB ¶
func RunWithBadgerDBAndPebbleDB ¶ added in v0.40.0
func RunWithPebbleDB ¶ added in v0.38.0
func RunWithTempDir ¶
func RunWithTypedBadgerDB ¶ added in v0.22.4
func RunWithTypedBadgerDB(t testing.TB, create func(badger.Options) (*badger.DB, error), f func(*badger.DB))
RunWithTypedBadgerDB creates a Badger DB that is passed to f and closed after f returns. The extra create parameter allows passing in a database constructor function which instantiates a database with a particular type marker, for testing storage modules which require a backed with a particular type.
func RunWithTypedPebbleDB ¶ added in v0.38.0
func SealBlock ¶ added in v0.15.0
func SealBlock(t *testing.T, st protocol.ParticipantState, mutableProtocolState protocol.MutableProtocolState, block *flow.Block, receipt *flow.ExecutionReceipt, seal *flow.Seal) (br *flow.Block, bs *flow.Block)
SealBlock seals a block B by building two blocks on it, the first containing a receipt for the block (BR), the second (BS) containing a seal for the block. B <- BR(Result_B) <- BS(Seal_B) Returns the two generated blocks.
func SeedFixtures ¶
SeedFixtures returns a list of m random []byte, each having length n
func ServiceEventsFixture ¶ added in v0.21.0
func ServiceEventsFixture(n int) flow.ServiceEventList
func SetupWithCounter ¶
func SetupWithCounter(counter uint64) func(*flow.EpochSetup)
func SignatureFixture ¶
func SignaturesFixture ¶
func SignerIndicesByIndices ¶ added in v0.26.1
func SignerIndicesFixture ¶ added in v0.26.1
func SkipBenchmarkUnless ¶ added in v0.26.0
func SkipBenchmarkUnless(b *testing.B, reason SkipBenchmarkReason, message string)
func SkipUnless ¶ added in v0.23.9
func SkipUnless(t *testing.T, reason SkipReason, message string)
func SnapshotClusterByIndex ¶ added in v0.26.2
func SnapshotFromBootstrapState ¶ added in v0.43.0
func SnapshotFromBootstrapState(root *flow.Block, result *flow.ExecutionResult, seal *flow.Seal, qc *flow.QuorumCertificate) (*inmem.Snapshot, error)
SnapshotFromBootstrapState generates a protocol.Snapshot representing a root bootstrap state. This is used to bootstrap the protocol state for genesis or post-spork states.
func StakingKeys ¶
func StakingKeys(n int) []crypto.PrivateKey
func StakingPrivKeyByIdentifier ¶ added in v0.23.7
func StakingPrivKeyByIdentifier(id flow.Identifier) crypto.PrivateKey
func StakingPrivKeyFixture ¶ added in v0.23.0
func StakingPrivKeyFixture() crypto.PrivateKey
StakingPrivKeyFixture returns a random BLS12381 private keyf
func StateCommitmentFixture ¶
func StateCommitmentFixture() flow.StateCommitment
func StateCommitmentPointerFixture ¶ added in v0.17.0
func StateCommitmentPointerFixture() *flow.StateCommitment
func StateInteractionsFixture ¶ added in v0.11.0
func StateInteractionsFixture() *snapshot.ExecutionSnapshot
func StateSnapshotForKnownBlock ¶ added in v0.14.0
func StateSnapshotForUnknownBlock ¶ added in v0.14.0
func TempBadgerDB ¶
func TempPebbleDB ¶ added in v0.38.0
func TempPebbleDBWithOpts ¶ added in v0.32.0
func TempPebblePath ¶ added in v0.32.0
func TransactionBodyFixture ¶
func TransactionBodyFixture(opts ...func(*flow.TransactionBody)) flow.TransactionBody
DEPRECATED: please use TransactionFixture instead
func TransactionBodyListFixture ¶ added in v0.23.9
func TransactionBodyListFixture(n int) []flow.TransactionBody
func TransactionDSLFixture ¶
func TransactionDSLFixture(chain flow.Chain) dsl.Transaction
func TransactionFixture ¶
func TransactionFixture(opts ...func(*flow.TransactionBody)) flow.TransactionBody
func TransactionForCluster ¶
func TransactionForCluster(clusters flow.ClusterList, target flow.IdentitySkeletonList) flow.TransactionBody
TransactionForCluster generates a transaction that will be assigned to the target cluster ID.
func TransactionResultErrorMessageFixture ¶ added in v0.43.0
func TransactionResultErrorMessageFixture(opts ...func(*flow.TransactionResultErrorMessage)) flow.TransactionResultErrorMessage
TransactionResultErrorMessageFixture creates a fixture tx result error message with random generated tx ID and executor ID for test purpose.
func TransactionResultErrorMessagesFixture ¶ added in v0.43.0
func TransactionResultErrorMessagesFixture(n int) []flow.TransactionResultErrorMessage
TransactionResultErrorMessagesFixture creates a fixture collection of tx result error messages with n elements.
func TransactionResultsFixture ¶ added in v0.26.0
func TransactionResultsFixture(n int) []flow.TransactionResult
func TransactionSignatureFixture ¶
func TransactionSignatureFixture() flow.TransactionSignature
func TypedBadgerDB ¶ added in v0.22.4
func TypedPebbleDB ¶ added in v0.38.0
func Uint64InRange ¶ added in v0.29.0
Uint64InRange returns a uint64 value drawn from the uniform random distribution [min,max].
func UnsignedExecutionReceiptFixture ¶ added in v0.43.0
func UnsignedExecutionReceiptFixture(opts ...func(*flow.UnsignedExecutionReceipt)) *flow.UnsignedExecutionReceipt
func VerifiableChunkDataFixture ¶
func VerifiableChunkDataFixture(chunkIndex uint64, opts ...func(*flow.HeaderBody)) (*verification.VerifiableChunkData, *flow.Block)
VerifiableChunkDataFixture returns a complete verifiable chunk with an execution receipt referencing the block/collections.
func VerifyCdcArguments ¶ added in v0.33.30
VerifyCdcArguments verifies that the actual slice of Go values match the expected set of Cadence values.
func VersionBeaconFixture ¶ added in v0.30.5
func VersionBeaconFixture(options ...func(*flow.VersionBeacon)) *flow.VersionBeacon
func VersionBeaconFixtureByChainID ¶ added in v0.30.5
VersionBeaconFixtureByChainID returns a VersionTable service event as a Cadence event representation and as a protocol model representation.
func ViewBasedActivatorFixture ¶ added in v0.43.0
func ViewBasedActivatorFixture() *protocol.ViewBasedActivator[uint64]
ViewBasedActivatorFixture returns a ViewBasedActivator with randomly generated Data and ActivationView.
func VoteForBlockFixture ¶ added in v0.23.9
func VoteWithBeaconSig ¶ added in v0.23.9
func VoteWithStakingSig ¶ added in v0.23.9
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 to ensure an IdentityList fixtures contains all the roles required for a valid genesis block.
func WithAllRolesExcept ¶
WithAllRolesExcept is used to ensure an IdentityList fixture contains all roles except omitting a certain role, for cases where we are manually setting up nodes.
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 WithApproximateSize ¶ added in v0.28.3
func WithApproximateSize(bytes uint64) func(*messages.ChunkDataResponse)
WithApproximateSize sets the ChunkDataResponse to be approximately bytes in size.
func WithAssignments ¶ added in v0.43.0
func WithAssignments(assignments flow.AssignmentList) func(*flow.EpochSetup)
func WithAttestationBlock ¶ added in v0.14.0
func WithAttestationBlock(block *flow.Block) func(*flow.ResultApproval)
func WithBlockExecutionDataBlockID ¶ added in v0.30.4
func WithBlockExecutionDataBlockID(blockID flow.Identifier) func(*execution_data.BlockExecutionData)
func WithBlockID ¶ added in v0.11.0
func WithBlockID(id flow.Identifier) func(*flow.ResultApproval)
func WithBoundaries ¶ added in v0.31.0
func WithBoundaries(boundaries ...flow.VersionBoundary) func(*flow.VersionBeacon)
func WithChunk ¶ added in v0.11.0
func WithChunk(chunkIdx uint64) func(*flow.ResultApproval)
func WithChunkDataPackCollection ¶ added in v0.21.0
func WithChunkDataPackCollection(collection *flow.Collection) func(*flow.ChunkDataPack)
func WithChunkEvents ¶ added in v0.30.4
func WithChunkEvents(events flow.EventsList) func(*execution_data.ChunkExecutionData)
func WithChunkExecutionDatas ¶ added in v0.30.4
func WithChunkExecutionDatas(chunks ...*execution_data.ChunkExecutionData) func(*execution_data.BlockExecutionData)
func WithChunkID ¶ added in v0.23.2
func WithChunkID(chunkID flow.Identifier) func(*verification.ChunkDataPackRequest)
func WithChunkStartState ¶ added in v0.27.0
func WithChunkStartState(startState flow.StateCommitment) func(chunk *flow.Chunk)
func WithChunks ¶ added in v0.17.0
func WithChunks(n uint) func(*flow.ExecutionResult)
func WithClusterQCs ¶ added in v0.43.0
func WithClusterQCs(qcs []flow.ClusterQCVoteData) func(*flow.EpochCommit)
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 WithDKGFromParticipants ¶
func WithDKGFromParticipants(participants flow.IdentitySkeletonList) func(*flow.EpochCommit)
func WithDisagrees ¶ added in v0.17.0
func WithDisagrees(list flow.IdentifierList) func(*verification.ChunkDataPackRequest)
func WithExecutionDataID ¶ added in v0.26.2
func WithExecutionDataID(id flow.Identifier) func(result *flow.ExecutionResult)
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 WithExecutionResults ¶ added in v0.23.2
func WithExecutionResults(results ...*flow.ExecutionResult) func(*flow.Payload)
WithExecutionResults will add execution results to payload
func WithExecutorID ¶ added in v0.11.0
func WithExecutorID(executorID flow.Identifier) func(*flow.ExecutionReceipt)
func WithFinalState ¶ added in v0.30.7
func WithFinalState(commit flow.StateCommitment) func(*flow.ExecutionResult)
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 WithInitialWeight ¶ added in v0.33.30
WithInitialWeight sets the initial weight on an identity fixture.
func WithLock ¶ added in v0.43.0
func WithLock(t testing.TB, manager lockctx.Manager, lockID string, fn func(lctx lockctx.Context) error) error
WithLock creates a lock context from the given manager, acquires the given lock, then executes the function `fn`. Error returns:
- Errors produced by the injected function `fn` are directly propagated to the caller.
- Errors during lock acquisition are wrapped in a StorageLockAcquisitionError.
func WithLocks ¶
func WithLocks(t testing.TB, manager lockctx.Manager, lockIDs []string, fn func(lctx lockctx.Context) error) error
WithLocks creates a lock context from the given manager, acquires the given locks, then executes the function `fn`. The test will fail if we are unable to acquire any of the locks or if `fn` returns any non-nil error. Error returns:
- Errors produced by the injected function `fn` are directly propagated to the caller.
- Errors during lock acquisition are wrapped in a StorageLockAcquisitionError.
func WithNetworkingKey ¶ added in v0.13.0
WithNetworkingKey sets the networking public key of identity fixture.
func WithNextEpochProtocolState ¶ added in v0.33.30
func WithNextEpochProtocolState() func(entry *flow.RichEpochStateEntry)
WithNextEpochProtocolState creates a fixture with correctly structured data for next epoch. The resulting Identity Table represents the common situation during the epoch commit phase for Epoch N+1:
- We are currently in Epoch N.
- The previous epoch N-1 is known (specifically EpochSetup and EpochCommit events).
- The network has completed the epoch setup phase, i.e. published the EpochSetup and EpochCommit events for epoch N+1.
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.IdentitySkeletonList) func(*flow.EpochSetup)
func WithParticipationStatus ¶ added in v0.33.30
func WithParticipationStatus(status flow.EpochParticipationStatus) func(*flow.Identity)
WithParticipationStatus sets the epoch participation status on an identity fixture.
func WithPreviousResult ¶ added in v0.11.0
func WithPreviousResult(prevResult flow.ExecutionResult) func(*flow.ExecutionResult)
func WithPreviousResultID ¶ added in v0.43.0
func WithPreviousResultID(previousResultID flow.Identifier) func(*flow.ExecutionResult)
func WithProtocolStateID ¶ added in v0.33.30
func WithProtocolStateID(stateID flow.Identifier) func(payload *flow.Payload)
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 WithReceiptsAndNoResults ¶ added in v0.23.2
func WithReceiptsAndNoResults(receipts ...*flow.ExecutionReceipt) func(*flow.Payload)
WithReceiptsAndNoResults will add receipt to payload only
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 WithServiceEventCount ¶ added in v0.39.0
func WithServiceEvents ¶
func WithServiceEvents(n int) func(result *flow.ExecutionResult)
func WithSpocks ¶ added in v0.32.0
func WithSpocks(spocks []crypto.Signature) func(*flow.ExecutionReceipt)
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 WithTrieUpdate ¶ added in v0.31.14
func WithTrieUpdate(trieUpdate *ledger.TrieUpdate) func(*execution_data.ChunkExecutionData)
func WithTxResultErrorMessageExecutorID ¶ added in v0.43.0
func WithTxResultErrorMessageExecutorID(id flow.Identifier) func(txResErrMsg *flow.TransactionResultErrorMessage)
func WithTxResultErrorMessageIndex ¶ added in v0.43.0
func WithTxResultErrorMessageIndex(index uint32) func(txResErrMsg *flow.TransactionResultErrorMessage)
func WithTxResultErrorMessageTxID ¶ added in v0.43.0
func WithTxResultErrorMessageTxID(id flow.Identifier) func(txResErrMsg *flow.TransactionResultErrorMessage)
func WithTxResultErrorMessageTxMsg ¶ added in v0.43.0
func WithTxResultErrorMessageTxMsg(message string) func(txResErrMsg *flow.TransactionResultErrorMessage)
func WithValidDKG ¶ added in v0.33.30
func WithValidDKG() func(*flow.RichEpochStateEntry)
WithValidDKG updated protocol state with correctly structured data for DKG.
func WithVoteBlockID ¶ added in v0.23.9
func WithVoteBlockID(blockID flow.Identifier) func(*hotstuff.Vote)
func WithVoteSignerID ¶ added in v0.23.9
func WithVoteSignerID(signerID flow.Identifier) func(*hotstuff.Vote)
func WithVoteView ¶ added in v0.23.9
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 KVStoreReader *protocol.KVStoreReader ProtocolStateVersion uint64 // 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 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
ValidSubgraphFixture 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, mutator protocol.MutableProtocolState, states ...protocol.FollowerState) *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) AddBlocksWithSeals ¶ added in v0.25.0
func (builder *EpochBuilder) AddBlocksWithSeals(n int, counter uint64) *EpochBuilder
AddBlocksWithSeals for the n number of blocks specified this func will add a seal for the second highest block in the state and a receipt for the highest block in state to the given block before adding it to the state. NOTE: This func should only be used after BuildEpoch to extend the commit phase
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 +------------+ +------------+ +-----------+ +-----------+ +----------+ +----------+ +----------+ | ER(P-1) |->| ER(P) |->| ER(A) |->| ER(B) |->| ER(C) |->| ER(D) |->| ER(E) | | S(ER(P-2)) | | S(ER(P-1)) | | S(ER(P)) | | S(ER(A)) | | S(ER(B)) | | S(ER(C)) | | S(ER(D)) | +------------+ +------------+ +-----------+ +-----------+ +----------+ +----------+ +----------+ | | 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, processing D causes the EpochSetup to become activated.
F contains a seal for block D containing the EpochCommit service event. processing F 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 CommittedFinal uint64 // final height of the 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) FinalHeight ¶ added in v0.30.0
func (epoch EpochHeights) FinalHeight() uint64
FinalHeight returns the height of the first block in the epoch.
func (EpochHeights) FirstHeight ¶ added in v0.30.0
func (epoch EpochHeights) FirstHeight() uint64
FirstHeight returns the height of the first block in the epoch.
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 EventGeneratorOption ¶ added in v0.43.0
type EventGeneratorOption func(*Events)
EventGeneratorOption configures an Events generator.
type EventOption ¶ added in v0.43.0
EventOption configures a flow.Event fields.
type Events ¶ added in v0.43.0
type Events struct {
// contains filtered or unexported fields
}
Events generates mock Flow events with incremental count and optional encoding.
func NewEventGenerator ¶ added in v0.43.0
func NewEventGenerator(opts ...EventGeneratorOption) *Events
NewEventGenerator creates a new Events generator.
type Identifiers ¶ added in v0.43.0
type Identifiers struct {
// contains filtered or unexported fields
}
func IdentifierGenerator ¶ added in v0.43.0
func IdentifierGenerator() *Identifiers
func (*Identifiers) New ¶ added in v0.43.0
func (g *Identifiers) New() flow.Identifier
type LoggerHook ¶ added in v0.22.0
type LoggerHook struct {
// contains filtered or unexported fields
}
LoggerHook implements the zerolog.Hook interface and can be used to capture logs for testing purposes.
func HookedLogger ¶ added in v0.22.0
func HookedLogger() (zerolog.Logger, LoggerHook)
func NewLoggerHook ¶ added in v0.22.0
func NewLoggerHook() LoggerHook
func (LoggerHook) Logs ¶ added in v0.22.0
func (hook LoggerHook) Logs() string
Logs returns the logs as a string
type MalleabilityChecker ¶ added in v0.43.0
type MalleabilityChecker struct {
// contains filtered or unexported fields
}
MalleabilityChecker is a customizable checker to test whether an entity is malleable. If a structure implements flow.IDEntity interface, *any* change to the data structure has to change the ID of the entity as well. The MalleabilityChecker performs a recursive check of all fields of the entity and ensures that changing any field will change the ID of the entity. By default, the MalleabilityChecker uses pre-defined generators for each basic golang type, which return a random value, to modify the entity's field values. However, the MalleabilityChecker can be customized, by providing custom generators for specific types or specific fields.
The caller can provide a loosely instantiated entity struct, which serves as a template for further modification. If checker encounters a field that is nil, it will insert a randomized instance into field and continue the check. If checker encounters a nil/empty slice or map, it will create a new instance of the slice/map, insert a value and continue the check. In rare cases, a type may have a different ID computation depending on whether a field is nil. In such cases, we can use the WithPinnedField option to skip malleability checks on this field.
This checker heavily relies on generation of random values for the fields based on their type. All types are split into three categories:
- structures, primitives, slices, arrays, maps (generateRandomReflectValue)
- interfaces (generateInterfaceFlowValue)
Checker knows how to deal with each of the categories and generate random values for them. There are two ways to handle types not natively recognized by the MalleabilityChecker:
- User can provide a custom type generator for the type using WithTypeGenerator option.
- User can provide a custom generator for the field using WithFieldGenerator option.
It is recommended to use the first option if type is used in multiple places and general enough. Matching by type (instead of field name) is less selective, by covering all fields of the given type. Field generator is very useful for cases where the field is context-sensitive, and we cannot generate a completely random value.
func NewMalleabilityChecker ¶ added in v0.43.0
func NewMalleabilityChecker(ops ...MalleabilityCheckerOpt) *MalleabilityChecker
NewMalleabilityChecker creates a new instance of the MalleabilityChecker with the given options.
func (*MalleabilityChecker) Check ¶ added in v0.43.0
func (mc *MalleabilityChecker) Check(model any, hashModel func() flow.Identifier) error
Check is a method that performs the malleability check on the input model. The caller provides a loosely instantiated model, which serves as a template for further modification. The malleability check is recursively applied to all fields of the model. If one of the fields is nil or an empty slice/map, the checker will create a new instance of the field and continue the check. In rare cases, a type may have a different ID computation depending on whether a field is nil, in such case, we can use field pinning to prevent the checker from changing the field. It returns an error if the model is malleable, otherwise it returns nil. No errors are expected during normal operations.
func (*MalleabilityChecker) CheckEntity ¶ added in v0.43.0
func (mc *MalleabilityChecker) CheckEntity(entity flow.IDEntity) error
CheckEntity is Check with the constraint that models implement flow.IDEntity and the content hash function is the ID() function. It returns an error if the entity is malleable, otherwise it returns nil. No errors are expected during normal operations.
type MalleabilityCheckerOpt ¶ added in v0.43.0
type MalleabilityCheckerOpt func(*MalleabilityChecker)
MalleabilityCheckerOpt is a functional option for the MalleabilityChecker which allows to modify behavior of the checker.
func WithFieldGenerator ¶ added in v0.43.0
func WithFieldGenerator[T any](field string, generator func() T) MalleabilityCheckerOpt
WithFieldGenerator allows to override the default behavior of the checker for the given field, meaning if a field with given path is encountered, the MalleabilityChecker will use the provided generator instead of a random value. An example usage would be:
type BarType struct { Baz string } type FooType struct { Bar BarType } ... WithFieldGenerator("Bar.Baz", func() string { return randomString()})
func WithPinnedField ¶ added in v0.43.0
func WithPinnedField(field string) MalleabilityCheckerOpt
WithPinnedField allows to skip malleability checks for the given field. If a field with given path is encountered, the MalleabilityChecker will skip the check for this field. Pinning is mutually exclusive with field generators, meaning if a field is pinned, the checker will not overwrite the field with a random value, even if a field generator is provided. This is useful when the ID computation varies depending on specific values of some field (typically used for temporary downwards compatibility - new fields are added as temporary optional). An example usage would be:
type BarType struct { Baz string } type FooType struct { Bar BarType } ... WithPinnedField("Bar.Baz")
func WithTypeGenerator ¶ added in v0.43.0
func WithTypeGenerator[T any](generator func() T) MalleabilityCheckerOpt
WithTypeGenerator allows to override the default behavior of the checker for the given type, meaning if a field of the given type is encountered, the MalleabilityChecker will use the provided generator instead of a random value. An example usage would be:
type BarType struct { Baz string } type FooType struct { Bar []BarType } ... WithTypeGenerator(func() BarType { return randomBar()})
ATTENTION: In order for the MalleabilityChecker to work properly, two calls of the generator should produce two different values.
type MockEntity ¶ added in v0.23.9
type MockEntity struct { Identifier flow.Identifier Nonce uint64 }
MockEntity is a simple struct used for testing mempools constrained to Identifier-typed keys. The Identifier field is the key used to store the entity in the mempool. The Nonce field can be used to simulate modifying the entity value stored in the mempool, for example via `Adjust`/`AdjustWithInit` methods. This allows for controlled testing of how mempools handle entity storage and updates.
func EntityListFixture ¶ added in v0.23.9
func EntityListFixture(n uint) []*MockEntity
func MockEntityFixture ¶ added in v0.23.9
func MockEntityFixture() *MockEntity
type RPCFixtureOpt ¶ added in v0.32.0
func WithGrafts ¶ added in v0.32.0
func WithGrafts(grafts ...*pubsub_pb.ControlGraft) RPCFixtureOpt
WithGrafts sets the grafts on the rpc control message.
func WithIHaves ¶ added in v0.32.0
func WithIHaves(iHaves ...*pubsub_pb.ControlIHave) RPCFixtureOpt
WithIHaves sets the iHaves on the rpc control message.
func WithIWants ¶ added in v0.32.0
func WithIWants(iWants ...*pubsub_pb.ControlIWant) RPCFixtureOpt
WithIWants sets the iWants on the rpc control message.
func WithPrunes ¶ added in v0.32.0
func WithPrunes(prunes ...*pubsub_pb.ControlPrune) RPCFixtureOpt
WithPrunes sets the prunes on the rpc control message.
func WithPubsubMessages ¶ added in v0.33.1
func WithPubsubMessages(msgs ...*pubsub_pb.Message) RPCFixtureOpt
type SkipBenchmarkReason ¶ added in v0.26.0
type SkipBenchmarkReason int
const (
BENCHMARK_EXPERIMENT SkipBenchmarkReason = iota + 1
)
func (SkipBenchmarkReason) String ¶ added in v0.26.0
func (s SkipBenchmarkReason) String() string
type SkipReason ¶ added in v0.23.9
type SkipReason int
const ( TEST_FLAKY SkipReason = iota + 1 // flaky TEST_TODO // not fully implemented or broken and needs to be fixed TEST_REQUIRES_GCP_ACCESS // requires the environment to be configured with GCP credentials TEST_DEPRECATED // uses code that has been deprecated / disabled TEST_LONG_RUNNING // long running TEST_RESOURCE_INTENSIVE // resource intensive test )
func ParseSkipReason ¶ added in v0.26.0
func ParseSkipReason(output string) (SkipReason, bool)
func (SkipReason) MarshalJSON ¶ added in v0.26.0
func (s SkipReason) MarshalJSON() ([]byte, error)
func (SkipReason) String ¶ added in v0.23.9
func (s SkipReason) String() string
type StorageLockAcquisitionError ¶
type StorageLockAcquisitionError struct {
// contains filtered or unexported fields
}
StorageLockAcquisitionError indicates that acquiring a storage lock failed.
func (StorageLockAcquisitionError) Error ¶
func (e StorageLockAcquisitionError) Error() string
func (StorageLockAcquisitionError) Unwrap ¶
func (e StorageLockAcquisitionError) Unwrap() error
type TestTime ¶ added in v0.29.0
type TestTime struct {
// contains filtered or unexported fields
}
TestTime is a fake time used for testing.
type UpdatableIDProvider ¶ added in v0.32.0
type UpdatableIDProvider struct {
// contains filtered or unexported fields
}
UpdatableIDProvider implements an IdentityProvider which can be manually updated by setting the IdentityList to a new value. It also implements an IdentifierProvider which provides the identifiers of the IdentityList. This is mainly used to simulate epoch transitions in tests.
func NewUpdatableIDProvider ¶ added in v0.32.0
func NewUpdatableIDProvider(identities flow.IdentityList) *UpdatableIDProvider
func (*UpdatableIDProvider) ByNodeID ¶ added in v0.32.0
func (p *UpdatableIDProvider) ByNodeID(flowID flow.Identifier) (*flow.Identity, bool)
func (*UpdatableIDProvider) Identifiers ¶ added in v0.32.0
func (p *UpdatableIDProvider) Identifiers() flow.IdentifierList
func (*UpdatableIDProvider) Identities ¶ added in v0.32.0
func (p *UpdatableIDProvider) Identities(filter flow.IdentityFilter[flow.Identity]) flow.IdentityList
func (*UpdatableIDProvider) SetIdentities ¶ added in v0.32.0
func (p *UpdatableIDProvider) SetIdentities(identities flow.IdentityList)
SetIdentities updates the IdentityList returned by this provider.
Source Files
¶
- block.go
- bytes.go
- chain_suite.go
- cluster.go
- cluster_block.go
- cluster_state_checker.go
- encoding.go
- entity.go
- epoch_builder.go
- equals.go
- events.go
- execution_state.go
- files.go
- fixtures.go
- fvm.go
- headers.go
- heap.go
- identifiers.go
- identities.go
- incorporated_results.go
- incorporated_results_seals.go
- irrecoverable.go
- keys.go
- lifecycle.go
- locks.go
- logging.go
- matchers.go
- math.go
- protocol_state.go
- seals.go
- service_events_fixtures.go
- timer.go
- unittest.go
- updatable_provider.go
- util.go
- utils.go
- version_beacon.go