Documentation ¶
Index ¶
- Constants
- Variables
- func AccountKeyFixture() (*flow.AccountPrivateKey, error)
- func AddressFixture() flow.Address
- func AlterTransactionForCluster(tx flow.TransactionBody, clusters flow.ClusterList, target flow.IdentityList, ...) flow.TransactionBody
- func AssertClosesBefore(t *testing.T, done <-chan struct{}, duration time.Duration)
- func AssertErrSubstringMatch(t testing.TB, expected, actual error)
- func AssertReturnsBefore(t *testing.T, f func(), duration time.Duration)
- func BadgerDB(t testing.TB, dir string) *badger.DB
- func BatchFixture() flow.Batch
- func BatchListFixture(n int) []flow.Batch
- func BlockFixture() flow.Block
- func BlockHeaderFixture() flow.Header
- func BlockHeaderFixtureOnChain(chainID flow.ChainID) flow.Header
- func BlockHeaderWithParentFixture(parent *flow.Header) flow.Header
- func BlockSealsFixture(n int) []*flow.Seal
- func BlockWithParentFixture(parent *flow.Header) flow.Block
- func BootstrapExecutionResultFixture(block *flow.Block, commit flow.StateCommitment) *flow.ExecutionResult
- func BootstrapFixture(participants flow.IdentityList, opts ...func(*flow.Block)) (*flow.Block, *flow.ExecutionResult, *flow.Seal)
- func ChunkDataPackFixture(identifier flow.Identifier) *flow.ChunkDataPack
- func ChunkFixture(blockID flow.Identifier) *flow.Chunk
- func ChunksFixture(n uint, blockID flow.Identifier) []*flow.Chunk
- func ClusterAssignment(n uint, nodes flow.IdentityList) flow.AssignmentList
- func ClusterBlockFixture() cluster.Block
- func ClusterBlockWithParent(parent *cluster.Block) cluster.Block
- func ClusterPayloadFixture(n int) *cluster.Payload
- func CollectionFixture(n int) flow.Collection
- func CollectionGuaranteeFixture(options ...func(*flow.CollectionGuarantee)) *flow.CollectionGuarantee
- func CollectionGuaranteesFixture(n int, options ...func(*flow.CollectionGuarantee)) []*flow.CollectionGuarantee
- func CommitWithCounter(counter uint64) func(*flow.EpochCommit)
- func CompleteCollectionFixture() *entity.CompleteCollection
- func CompleteIdentitySet(identities ...*flow.Identity) flow.IdentityList
- func CreateNParticipantsWithMyRole(myRole flow.Role, otherRoles ...flow.Role) (flow.IdentityList, flow.Identifier, *module.Local)
- func EmulatorRootKey() (*flow.AccountPrivateKey, error)
- func EpochCommitFixture(opts ...func(*flow.EpochCommit)) *flow.EpochCommit
- func EpochSetupFixture(opts ...func(setup *flow.EpochSetup)) *flow.EpochSetup
- func EventFixture(eType flow.EventType, transactionIndex uint32, eventIndex uint32, ...) flow.Event
- func ExecutableBlockFixture(collectionsSignerIDs [][]flow.Identifier) *entity.ExecutableBlock
- func ExecutableBlockFixtureWithParent(collectionsSignerIDs [][]flow.Identifier, parent *flow.Header) *entity.ExecutableBlock
- func ExecutionReceiptFixture() *flow.ExecutionReceipt
- func ExecutionResultFixture() *flow.ExecutionResult
- func ExpectPanic(expectedMsg string, t *testing.T)
- func FinalizedProtocolStateWithParticipants(participants flow.IdentityList) (*flow.Block, *protocol.Snapshot, *protocol.State)
- func GenesisFixture(identities flow.IdentityList) *flow.Block
- func HashFixture(size int) hash.Hash
- func HeadersFromMap(headerDB map[flow.Identifier]*flow.Header) *storage.Headers
- func IdentifierFixture() flow.Identifier
- func IdentifierListFixture(n int) []flow.Identifier
- func IdentityFixture(opts ...func(*flow.Identity)) *flow.Identity
- func IdentityListFixture(n int, opts ...func(*flow.Identity)) flow.IdentityList
- func KeyFixture(algo crypto.SigningAlgorithm) crypto.PrivateKey
- func NetworkingKey() (crypto.PrivateKey, error)
- func NetworkingKeys(n int) ([]crypto.PrivateKey, error)
- func NoopTxScript() []byte
- func PayloadFixture(options ...func(*flow.Payload)) *flow.Payload
- func PendingFromBlock(block *flow.Block) *flow.PendingBlock
- func ProposalFixture() *messages.BlockProposal
- func ProposalFromBlock(block *flow.Block) *messages.BlockProposal
- func ProposalKeyFixture() flow.ProposalKey
- func QuorumCertificateFixture() *flow.QuorumCertificate
- func RandomBytes(n int) []byte
- func RangeFixture() flow.Range
- func RangeListFixture(n int) []flow.Range
- func ReadyDoneify(toMock interface{})
- func RegisterNetwork() (*module.Network, *network.Conduit)
- func RequireReturnsBefore(t testing.TB, f func(), duration time.Duration, message string)
- func ResultApprovalFixture(opts ...func(*flow.ResultApproval)) *flow.ResultApproval
- func ResultForBlockFixture(block *flow.Block) *flow.ExecutionResult
- func RunWithBadgerDB(t testing.TB, f func(*badger.DB))
- func RunWithTempDir(t testing.TB, f func(string))
- func SealFixture(opts ...func(*flow.Seal)) *flow.Seal
- func SealFromResult(result *flow.ExecutionResult) func(*flow.Seal)
- func SealWithBlockID(blockID flow.Identifier) func(*flow.Seal)
- func SeedFixture(n int) []byte
- func SeedFixtures(m int, n int) [][]byte
- func SetupWithCounter(counter uint64) func(*flow.EpochSetup)
- func SignatureFixture() crypto.Signature
- func SignaturesFixture(n int) []crypto.Signature
- func StakingKey() (crypto.PrivateKey, error)
- func StakingKeys(n int) ([]crypto.PrivateKey, error)
- func StateCommitmentFixture() flow.StateCommitment
- func StateDeltaFixture() *messages.ExecutionStateDelta
- func StateDeltaWithParentFixture(parent *flow.Header) *messages.ExecutionStateDelta
- func TempBadgerDB(t testing.TB) (*badger.DB, string)
- func TempDir(t testing.TB) string
- func TransactionBodyFixture(opts ...func(*flow.TransactionBody)) flow.TransactionBody
- func TransactionDSLFixture(chain flow.Chain) dsl.Transaction
- func TransactionFixture(n ...func(t *flow.Transaction)) flow.Transaction
- func TransactionForCluster(clusters flow.ClusterList, target flow.IdentityList) flow.TransactionBody
- func TransactionSignatureFixture() flow.TransactionSignature
- func VerifiableChunkDataFixture(chunkIndex uint64) *verification.VerifiableChunkData
- func VoteFixture() *hotstuff.Vote
- func WithAllRoles() func(*flow.Identity)
- func WithAllRolesExcept(except ...flow.Role) func(*flow.Identity)
- func WithCollRef(refID flow.Identifier) func(*flow.CollectionGuarantee)
- func WithDKGFromParticipants(participants flow.IdentityList) func(*flow.EpochCommit)
- func WithExecutionResultID(id flow.Identifier) func(*flow.ResultApproval)
- func WithFinalView(view uint64) func(*flow.EpochSetup)
- func WithNodeID(b byte) func(*flow.Identity)
- func WithParticipants(participants flow.IdentityList) func(*flow.EpochSetup)
- func WithRandomPublicKeys() func(*flow.Identity)
- func WithReferenceBlock(id flow.Identifier) func(tx *flow.TransactionBody)
- func WithRole(role flow.Role) func(*flow.Identity)
- func WithServiceEvents(events ...flow.ServiceEvent) func(*flow.Seal)
- func WithStake(stake uint64) func(*flow.Identity)
- func WithTransactionDSL(txDSL dsl.Transaction) func(tx *flow.TransactionBody)
- func WithoutSeals(payload *flow.Payload)
- 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
Constants ¶
const GenesisStateCommitmentHex = "71496a154529a087d899b2cc54d477b5d2710b431d950609f1f7fcf593a8413b"
Pre-calculated state commitment with root account with the above private key
const ServiceAccountPrivateKeyHex = "e3a08ae3d0461cfed6d6f49bfc25fa899351c39d1bd21fdba8c87595b6c49bb4cc430201"
Variables ¶
var GenesisStateCommitment flow.StateCommitment
var GenesisTokenSupply = func() cadence.UFix64 { value, err := cadence.NewUFix64("10000000.00000000") if err != nil { panic(fmt.Errorf("invalid genesis token supply: %w", err)) } return value }()
var ServiceAccountPrivateKey flow.AccountPrivateKey
var ServiceAccountPublicKey flow.AccountPublicKey
Functions ¶
func AccountKeyFixture ¶
func AccountKeyFixture() (*flow.AccountPrivateKey, error)
AccountKeyFixture returns a randomly generated ECDSA/SHA3 account key.
func AddressFixture ¶
func AlterTransactionForCluster ¶
func AlterTransactionForCluster(tx flow.TransactionBody, clusters flow.ClusterList, target flow.IdentityList, after func(tx *flow.TransactionBody)) flow.TransactionBody
AlterTransactionForCluster modifies a transaction nonce until it is assigned to the target cluster.
The `after` function is run after each modification to allow for any content dependent changes to the transaction (eg. signing it).
func AssertClosesBefore ¶
AssertClosesBefore asserts that the given channel closes before the duration expires.
func AssertErrSubstringMatch ¶
AssertErrSubstringMatch asserts that two errors match with substring checking on the Error method (`expected` must be a substring of `actual`, to account for the actual error being wrapped). Fails the test if either error is nil.
NOTE: This should only be used in cases where `errors.Is` cannot be, like when errors are transmitted over the network without type information.
func AssertReturnsBefore ¶
AssertReturnsBefore asserts that the given function returns before the duration expires.
func BatchFixture ¶
func BatchListFixture ¶
func BlockFixture ¶
func BlockHeaderFixture ¶
func BlockSealsFixture ¶
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 ChunkDataPackFixture ¶
func ChunkDataPackFixture(identifier flow.Identifier) *flow.ChunkDataPack
func ChunkFixture ¶
func ChunkFixture(blockID flow.Identifier) *flow.Chunk
func ChunksFixture ¶ added in v0.9.6
func ChunksFixture(n uint, blockID flow.Identifier) []*flow.Chunk
func ClusterAssignment ¶
func ClusterAssignment(n uint, nodes flow.IdentityList) flow.AssignmentList
ClusterAssignment creates an assignment list with n clusters and with nodes evenly distributed among clusters.
func ClusterBlockFixture ¶
func ClusterBlockWithParent ¶
ClusterBlockWithParent creates a new cluster consensus block that is valid with respect to the given parent block.
func ClusterPayloadFixture ¶
func CollectionFixture ¶
func CollectionFixture(n int) flow.Collection
func CollectionGuaranteeFixture ¶
func CollectionGuaranteeFixture(options ...func(*flow.CollectionGuarantee)) *flow.CollectionGuarantee
func CollectionGuaranteesFixture ¶
func CollectionGuaranteesFixture(n int, options ...func(*flow.CollectionGuarantee)) []*flow.CollectionGuarantee
func CommitWithCounter ¶
func CommitWithCounter(counter uint64) func(*flow.EpochCommit)
func CompleteCollectionFixture ¶
func CompleteCollectionFixture() *entity.CompleteCollection
func CompleteIdentitySet ¶
func CompleteIdentitySet(identities ...*flow.Identity) flow.IdentityList
CompleteIdentitySet takes a number of identities and completes the missing roles.
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 EmulatorRootKey ¶
func EmulatorRootKey() (*flow.AccountPrivateKey, error)
func EpochCommitFixture ¶
func EpochCommitFixture(opts ...func(*flow.EpochCommit)) *flow.EpochCommit
func EpochSetupFixture ¶
func EpochSetupFixture(opts ...func(setup *flow.EpochSetup)) *flow.EpochSetup
func EventFixture ¶
func EventFixture(eType flow.EventType, transactionIndex uint32, eventIndex uint32, txID flow.Identifier) flow.Event
EventFixture returns an event
func ExecutableBlockFixture ¶
func ExecutableBlockFixture(collectionsSignerIDs [][]flow.Identifier) *entity.ExecutableBlock
func ExecutableBlockFixtureWithParent ¶
func ExecutableBlockFixtureWithParent(collectionsSignerIDs [][]flow.Identifier, parent *flow.Header) *entity.ExecutableBlock
func ExecutionReceiptFixture ¶
func ExecutionReceiptFixture() *flow.ExecutionReceipt
func ExecutionResultFixture ¶
func ExecutionResultFixture() *flow.ExecutionResult
func ExpectPanic ¶
func FinalizedProtocolStateWithParticipants ¶
func FinalizedProtocolStateWithParticipants(participants flow.IdentityList) ( *flow.Block, *protocol.Snapshot, *protocol.State)
FinalizedProtocolStateWithParticipants returns a protocol state with finalized participants
func GenesisFixture ¶
func GenesisFixture(identities flow.IdentityList) *flow.Block
func HashFixture ¶
func HeadersFromMap ¶
HeadersFromMap creates a storage header mock that backed by a given map
func IdentifierFixture ¶
func IdentifierFixture() flow.Identifier
func IdentifierListFixture ¶
func IdentifierListFixture(n int) []flow.Identifier
func IdentityFixture ¶
IdentityFixture returns a node identity.
func IdentityListFixture ¶
func IdentityListFixture(n int, opts ...func(*flow.Identity)) flow.IdentityList
IdentityListFixture returns a list of node identity objects. The identities can be customized (ie. set their role) by passing in a function that modifies the input identities as required.
func KeyFixture ¶
func KeyFixture(algo crypto.SigningAlgorithm) crypto.PrivateKey
func NetworkingKey ¶
func NetworkingKey() (crypto.PrivateKey, error)
func NetworkingKeys ¶
func NetworkingKeys(n int) ([]crypto.PrivateKey, error)
func NoopTxScript ¶
func NoopTxScript() []byte
NoopTxScript returns a Cadence script for a no-op transaction.
func PendingFromBlock ¶
func PendingFromBlock(block *flow.Block) *flow.PendingBlock
func ProposalFixture ¶
func ProposalFixture() *messages.BlockProposal
func ProposalFromBlock ¶
func ProposalFromBlock(block *flow.Block) *messages.BlockProposal
func ProposalKeyFixture ¶
func ProposalKeyFixture() flow.ProposalKey
func QuorumCertificateFixture ¶
func QuorumCertificateFixture() *flow.QuorumCertificate
func RandomBytes ¶
func RangeFixture ¶
func RangeListFixture ¶
func ReadyDoneify ¶
func ReadyDoneify(toMock interface{})
ReadyDoneify sets up a generated mock to respond to Ready and Done lifecycle methods. Any mock type generated by mockery can be used.
func RegisterNetwork ¶
RegisterNetwork returns a mocked network and conduit
func RequireReturnsBefore ¶
RequireReturnBefore requires that the given function returns before the duration expires.
func ResultApprovalFixture ¶
func ResultApprovalFixture(opts ...func(*flow.ResultApproval)) *flow.ResultApproval
func ResultForBlockFixture ¶ added in v0.9.6
func ResultForBlockFixture(block *flow.Block) *flow.ExecutionResult
func RunWithBadgerDB ¶
func RunWithTempDir ¶
func SealFromResult ¶
func SealFromResult(result *flow.ExecutionResult) func(*flow.Seal)
func SealWithBlockID ¶
func SealWithBlockID(blockID flow.Identifier) func(*flow.Seal)
func SeedFixtures ¶
SeedFixtures returns a list of m random []byte, each having length n
func SetupWithCounter ¶
func SetupWithCounter(counter uint64) func(*flow.EpochSetup)
func SignatureFixture ¶
func SignaturesFixture ¶
func StakingKey ¶
func StakingKey() (crypto.PrivateKey, error)
func StakingKeys ¶
func StakingKeys(n int) ([]crypto.PrivateKey, error)
func StateCommitmentFixture ¶
func StateCommitmentFixture() flow.StateCommitment
func StateDeltaFixture ¶
func StateDeltaFixture() *messages.ExecutionStateDelta
func StateDeltaWithParentFixture ¶
func StateDeltaWithParentFixture(parent *flow.Header) *messages.ExecutionStateDelta
func TempBadgerDB ¶
func TransactionBodyFixture ¶
func TransactionBodyFixture(opts ...func(*flow.TransactionBody)) flow.TransactionBody
func TransactionDSLFixture ¶
func TransactionDSLFixture(chain flow.Chain) dsl.Transaction
func TransactionFixture ¶
func TransactionFixture(n ...func(t *flow.Transaction)) flow.Transaction
func TransactionForCluster ¶
func TransactionForCluster(clusters flow.ClusterList, target flow.IdentityList) flow.TransactionBody
TransactionForCluster generates a transaction that will be assigned to the target cluster ID.
func TransactionSignatureFixture ¶
func TransactionSignatureFixture() flow.TransactionSignature
func VerifiableChunkDataFixture ¶
func VerifiableChunkDataFixture(chunkIndex uint64) *verification.VerifiableChunkData
VerifiableChunkDataFixture returns a complete verifiable chunk with an execution receipt referencing the block/collections.
func VoteFixture ¶
func WithAllRoles ¶
WithAllRoles can be used used to ensure an IdentityList fixtures contains all the roles required for a valid genesis block.
func WithAllRolesExcept ¶
Same as above, but omitting a certain role for cases where we are manually setting up nodes or a particular role.
func WithCollRef ¶
func WithCollRef(refID flow.Identifier) func(*flow.CollectionGuarantee)
func WithDKGFromParticipants ¶
func WithDKGFromParticipants(participants flow.IdentityList) func(*flow.EpochCommit)
func WithExecutionResultID ¶
func WithExecutionResultID(id flow.Identifier) func(*flow.ResultApproval)
func WithFinalView ¶
func WithFinalView(view uint64) func(*flow.EpochSetup)
func WithNodeID ¶
WithNodeID adds a node ID with the given first byte to an identity.
func WithParticipants ¶
func WithParticipants(participants flow.IdentityList) func(*flow.EpochSetup)
func WithRandomPublicKeys ¶
WithRandomPublicKeys adds random public keys to an identity.
func WithReferenceBlock ¶
func WithReferenceBlock(id flow.Identifier) func(tx *flow.TransactionBody)
func WithServiceEvents ¶
func WithServiceEvents(events ...flow.ServiceEvent) func(*flow.Seal)
func WithTransactionDSL ¶
func WithTransactionDSL(txDSL dsl.Transaction) func(tx *flow.TransactionBody)
func WithoutSeals ¶
Types ¶
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.