unittest

package
v0.29.6 Latest Latest
Warning

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

Go to latest
Published: Jan 19, 2023 License: AGPL-3.0 Imports: 69 Imported by: 17

Documentation

Index

Constants

View Source
const (
	DefaultSeedFixtureLength = 64
	DefaultAddress           = "localhost:0"
)
View Source
const GenesisStateCommitmentHex = "48bc690ac7ebf7cdb41df24c6f8ba011b206408623b6d56b3723910664cdb5aa"

Pre-calculated state commitment with root account with the above private key

View Source
const ServiceAccountPrivateKeyHashAlgo = hash.SHA2_256
View Source
const ServiceAccountPrivateKeyHex = "8ae3d0461cfed6d6f49bfc25fa899351c39d1bd21fdba8c87595b6c49bb4cc43"
View Source
const ServiceAccountPrivateKeySignAlgo = crypto.ECDSAP256

Variables

View Source
var GenesisStateCommitment flow.StateCommitment
View Source
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
}()
View Source
var IncorporatedResult incorporatedResultFactory
View Source
var IncorporatedResultSeal incorporatedResultSealFactory
View Source
var Seal sealFactory
View Source
var ServiceAccountPrivateKey flow.AccountPrivateKey
View Source
var ServiceAccountPublicKey flow.AccountPublicKey

Functions

func AccountFixture

func AccountFixture() (*flow.Account, error)

AccountFixture returns a randomly generated account.

func AccountKeyDefaultFixture

func AccountKeyDefaultFixture() (*flow.AccountPrivateKey, error)

AccountKeyDefaultFixture returns a randomly generated ECDSA/SHA3 account key.

func AccountKeyFixture

func AccountKeyFixture(
	seedLength int,
	signingAlgo crypto.SigningAlgorithm,
	hashAlgo hash.HashingAlgorithm,
) (*flow.AccountPrivateKey, error)

AccountKeyFixture returns a randomly generated account key.

func AddressFixture

func AddressFixture() flow.Address

func AllowAllPeerFilter

func AllowAllPeerFilter() func(peer.ID) error

func AlterTransactionForCluster

func AlterTransactionForCluster(tx flow.TransactionBody, clusters flow.ClusterList, target flow.IdentityList, after func(tx *flow.TransactionBody)) flow.TransactionBody

AlterTransactionForCluster modifies a transaction nonce until it is assigned to the target cluster.

The `after` function is run after each modification to allow for any content dependent changes to the transaction (eg. signing it).

func ApprovalFor

func ApprovalFor(result *flow.ExecutionResult, chunkIdx uint64, approverID flow.Identifier) *flow.ResultApproval

func AsSlashable

func AsSlashable[T any](msg *T) flow.Slashable[T]

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 AssertEqualBlocksLenAndOrder

func AssertEqualBlocksLenAndOrder(t *testing.T, expectedBlocks, actualSegmentBlocks []*flow.Block)

AssertEqualBlocksLenAndOrder asserts that both a segment of blocks have the same len and blocks are in the same order

func AssertErrSubstringMatch

func AssertErrSubstringMatch(t testing.TB, expected, actual error)

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

func AssertFloatEqual(t *testing.T, expected, actual float64, message string)

func AssertNotClosesBefore

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{})

AssertReturnsBefore asserts that the given function returns before the duration expires.

func AssertSnapshotsEqual

func AssertSnapshotsEqual(t *testing.T, snap1, snap2 protocol.Snapshot)

func AttestationFixture

func AttestationFixture() *flow.Attestation

func BadgerDB

func BadgerDB(t testing.TB, dir string) *badger.DB

func BatchFixture

func BatchFixture() chainsync.Batch

func BatchListFixture

func BatchListFixture(n int) []chainsync.Batch

func BlockEventsFixture

func BlockEventsFixture(header *flow.Header, n int) flow.BlockEvents

BlockEventsFixture returns a block events model populated with random events of length n.

func BlockFixture

func BlockFixture() flow.Block

func BlockFixtures

func BlockFixtures(number int) []*flow.Block

func BlockHeaderFixture

func BlockHeaderFixture(opts ...func(header *flow.Header)) *flow.Header

func BlockHeaderFixtureOnChain

func BlockHeaderFixtureOnChain(chainID flow.ChainID, opts ...func(header *flow.Header)) *flow.Header

func BlockHeaderWithParentFixture

func BlockHeaderWithParentFixture(parent *flow.Header) *flow.Header

func BlockSealsFixture

func BlockSealsFixture(n int) []*flow.Seal

func BlockWithGuaranteesFixture

func BlockWithGuaranteesFixture(guarantees []*flow.CollectionGuarantee) *flow.Block

func BlockWithParentAndProposerFixture

func BlockWithParentAndProposerFixture(parent *flow.Header, proposer flow.Identifier, participantCount int) flow.Block

func BlockWithParentAndSeals

func BlockWithParentAndSeals(parent *flow.Header, seals []*flow.Header) *flow.Block

func BlockWithParentFixture

func BlockWithParentFixture(parent *flow.Header) *flow.Block

func BootstrapExecutionResultFixture

func BootstrapExecutionResultFixture(block *flow.Block, commit flow.StateCommitment) *flow.ExecutionResult

func BootstrapFixture

func BootstrapFixture(participants flow.IdentityList, opts ...func(*flow.Block)) (*flow.Block, *flow.ExecutionResult, *flow.Seal)

BootstrapFixture generates all the artifacts necessary to bootstrap the protocol state.

func ChainFixture

func ChainFixture(nonGenesisCount int) ([]*flow.Block, *flow.ExecutionResult, *flow.Seal)

ChainFixture creates a list of blocks that forms a chain

func ChainFixtureFrom

func ChainFixtureFrom(count int, parent *flow.Header) []*flow.Block

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

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 ChunkDataPackRequestListFixture

func ChunkDataPackRequestListFixture(n int, opts ...func(*verification.ChunkDataPackRequest)) verification.ChunkDataPackRequestList

ChunkDataPackRequestListFixture creates and returns a list of chunk data pack requests fixtures.

func ChunkDataPacksFixture

func ChunkDataPacksFixture(count int, opts ...func(*flow.ChunkDataPack)) []*flow.ChunkDataPack

func ChunkDataResponseMessageListFixture

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

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 ChunkFixture

func ChunkFixture(blockID flow.Identifier, collectionIndex uint, opts ...func(*flow.Chunk)) *flow.Chunk

func ChunkListFixture

func ChunkListFixture(n uint, blockID flow.Identifier) flow.ChunkList

func ChunkLocatorFixture

func ChunkLocatorFixture(resultID flow.Identifier, index uint64) *chunks.Locator

func ChunkLocatorListFixture

func ChunkLocatorListFixture(n uint) chunks.LocatorList

func ChunkStatusListFixture

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

func ChunkStatusListToChunkLocatorFixture(statuses []*verification.ChunkStatus) chunks.LocatorMap

ChunkStatusListToChunkLocatorFixture extracts chunk locators from a list of chunk statuses.

func CidFixture

func CidFixture() cid.Cid

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 ClusterBlockFixture() cluster.Block

func ClusterBlockWithParent

func ClusterBlockWithParent(parent *cluster.Block) cluster.Block

ClusterBlockWithParent creates a new cluster consensus block that is valid with respect to the given parent block.

func ClusterList

func ClusterList(n uint, nodes flow.IdentityList) flow.ClusterList

func ClusterPayloadFixture

func ClusterPayloadFixture(n int) *cluster.Payload

func ClusterProposalFromBlock

func ClusterProposalFromBlock(block *cluster.Block) *messages.ClusterBlockProposal

func CollectionFixture

func CollectionFixture(n int, options ...func(*flow.Collection)) flow.Collection

func CollectionGuaranteeFixture

func CollectionGuaranteeFixture(options ...func(*flow.CollectionGuarantee)) *flow.CollectionGuarantee

func CollectionGuaranteesFixture

func CollectionGuaranteesFixture(n int, options ...func(*flow.CollectionGuarantee)) []*flow.CollectionGuarantee

func CollectionGuaranteesWithCollectionIDFixture

func CollectionGuaranteesWithCollectionIDFixture(collections []*flow.Collection) []*flow.CollectionGuarantee

func CollectionListFixture

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

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

func Concurrently(n int, f func(int))

func CrashTest

func CrashTest(t *testing.T, scenario func(*testing.T), expectedErrorMsg string)

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

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 DKGBroadcastMessageFixture

func DKGBroadcastMessageFixture() *messages.BroadcastDKGMessage

DKGBroadcastMessageFixture creates a single DKG broadcast message with random fields

func DKGMessageFixture

func DKGMessageFixture() *messages.DKGMessage

DKGMessageFixture creates a single DKG message with random fields

func DKGParticipantLookup

func DKGParticipantLookup(participants flow.IdentityList) map[flow.Identifier]flow.DKGParticipant

func EmulatorRootKey

func EmulatorRootKey() (*flow.AccountPrivateKey, error)

func EngineMessageFixture

func EngineMessageFixture() *engine.Message

func EngineMessageFixtures

func EngineMessageFixtures(count int) []*engine.Message

func EnsureEventsIndexSeq

func EnsureEventsIndexSeq(t *testing.T, events []flow.Event, chainID flow.ChainID)

EnsureEventsIndexSeq checks if values of given event index sequence are monotonically increasing.

func EntityWithID

func EntityWithID(expectedID flow.Identifier) interface{}

func EpochCommitFixture

func EpochCommitFixture(opts ...func(*flow.EpochCommit)) *flow.EpochCommit

func EpochSetupFixture

func EpochSetupFixture(opts ...func(setup *flow.EpochSetup)) *flow.EpochSetup

EpochSetupFixture creates a valid EpochSetup with default properties for testing. The default properties can be overwritten with optional parameter functions.

func EpochStatusFixture

func EpochStatusFixture() *flow.EpochStatus

func EventFixture

func EventFixture(eType flow.EventType, transactionIndex uint32, eventIndex uint32, txID flow.Identifier, _ int) flow.Event

EventFixture returns an event

func ExecutableBlockFixture

func ExecutableBlockFixture(collectionsSignerIDs [][]flow.Identifier) *entity.ExecutableBlock

func ExecutableBlockFixtureWithParent

func ExecutableBlockFixtureWithParent(collectionsSignerIDs [][]flow.Identifier, parent *flow.Header) *entity.ExecutableBlock

func ExecutableBlockFromTransactions

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

func ExecutionResultListFixture(n int, opts ...func(*flow.ExecutionResult)) []*flow.ExecutionResult

func ExpectPanic

func ExpectPanic(expectedMsg string, t *testing.T)

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

func FixedReferenceBlockID() flow.Identifier

func FullBlockFixture

func FullBlockFixture() flow.Block

func GenerateRandomStringWithLen

func GenerateRandomStringWithLen(commentLen uint) string

GenerateRandomStringWithLen returns a string of random alpha characters of the provided length

func GenesisFixture

func GenesisFixture() *flow.Block

func GetFlowProtocolEventID

func GetFlowProtocolEventID(t *testing.T, channel channels.Channel, event interface{}) flow.Identifier

GetFlowProtocolEventID returns the event ID for the event provided.

func HashFixture

func HashFixture(size int) hash.Hash

func HeaderWithView

func HeaderWithView(view uint64) func(*flow.Header)

func HeadersFromMap

func HeadersFromMap(headerDB map[flow.Identifier]*flow.Header) *storage.Headers

HeadersFromMap creates a storage header mock that backed by a given map

func IDEqual

func IDEqual(t *testing.T, id1, id2 flow.Identifier)

func IDsEqual

func IDsEqual(t *testing.T, id1, id2 []flow.Identifier)

func IPPort

func IPPort(port string) string

func IdentifierFixture

func IdentifierFixture() flow.Identifier

func IdentifierListFixture

func IdentifierListFixture(n int) flow.IdentifierList

func IdentityFixture

func IdentityFixture(opts ...func(*flow.Identity)) *flow.Identity

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

func IdentityWithNetworkingKeyFixture(opts ...func(*flow.Identity)) (*flow.Identity, crypto.PrivateKey)

IdentityWithNetworkingKeyFixture returns a node identity and networking private key

func IndexFixture

func IndexFixture() *flow.Index

func InvalidAddressFixture

func InvalidAddressFixture() flow.Address

func InvalidFormatSignature

func InvalidFormatSignature() flow.TransactionSignature

func IsServiceEvent

func IsServiceEvent(event flow.Event, chainID flow.ChainID) bool

func KeyFixture

func KeyFixture(algo crypto.SigningAlgorithm) crypto.PrivateKey

func KeysFixture

func KeysFixture(n int, algo crypto.SigningAlgorithm) []crypto.PrivateKey

func LogVerbose

func LogVerbose()

func Logger

func Logger() zerolog.Logger

Logger returns a zerolog use -vv flag to print debugging logs for tests

func LoggerForTest

func LoggerForTest(t *testing.T, level zerolog.Level) zerolog.Logger

go:noinline

func LoggerWithLevel

func LoggerWithLevel(level zerolog.Level) zerolog.Logger

func LoggerWithName

func LoggerWithName(mod string) zerolog.Logger

func LoggerWithWriterAndLevel

func LoggerWithWriterAndLevel(writer io.Writer, level zerolog.Level) zerolog.Logger

func MachineAccountFixture

func MachineAccountFixture(t *testing.T) (bootstrap.NodeMachineAccountInfo, *sdk.Account)

func MustDecodePublicKeyHex

func MustDecodePublicKeyHex(algo crypto.SigningAlgorithm, keyHex string) crypto.PublicKey

func MustDecodeSignatureHex

func MustDecodeSignatureHex(sigHex string) crypto.Signature

func NetworkCodec

func NetworkCodec() network.Codec

NetworkCodec returns cbor codec.

func NetworkSlashingViolationsConsumer

func NetworkSlashingViolationsConsumer(logger zerolog.Logger, metrics module.NetworkSecurityMetrics) slashing.ViolationsConsumer

NetworkSlashingViolationsConsumer returns a slashing violations consumer for network middleware

func NetworkTopology

func NetworkTopology() network.Topology

NetworkTopology returns the default topology for testing purposes.

func NetworkingKeys

func NetworkingKeys(n int) []crypto.PrivateKey

func NetworkingPrivKeyFixture

func NetworkingPrivKeyFixture() crypto.PrivateKey

NetworkingPrivKeyFixture returns random ECDSAP256 private key

func NewSealingConfigs

func NewSealingConfigs(val uint) module.SealingConfigsSetter

func NodeConfigFixture

func NodeConfigFixture(opts ...func(*flow.Identity)) bootstrap.NodeConfig

func NodeInfoFixture

func NodeInfoFixture(opts ...func(*flow.Identity)) bootstrap.NodeInfo

func NodeInfosFixture

func NodeInfosFixture(n int, opts ...func(*flow.Identity)) []bootstrap.NodeInfo

func NodeMachineAccountInfoFixture

func NodeMachineAccountInfoFixture() bootstrap.NodeMachineAccountInfo

func NoopTxScript

func NoopTxScript() []byte

NoopTxScript returns a Cadence script for a no-op transaction.

func PayloadFixture

func PayloadFixture(options ...func(*flow.Payload)) flow.Payload

func PeerIDFromFlowID

func PeerIDFromFlowID(identity *flow.Identity) (peer.ID, error)

func PrintHeapInfo

func PrintHeapInfo(logger zerolog.Logger)

PrintHeapInfo prints heap object allocation through given logger.

func PrivateKeyFixture

func PrivateKeyFixture(algo crypto.SigningAlgorithm, seedLength int) crypto.PrivateKey

PrivateKeyFixture returns a random private key with specified signature algorithm and seed length

func PrivateKeyFixtureByIdentifier

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 PrivateNodeInfosFixture

func PrivateNodeInfosFixture(n int, opts ...func(*flow.Identity)) []bootstrap.NodeInfo

func ProposalFixture

func ProposalFixture() *messages.BlockProposal

func ProposalFromBlock

func ProposalFromBlock(block *flow.Block) *messages.BlockProposal

func ProposalKeyFixture

func ProposalKeyFixture() flow.ProposalKey

func PublicKeysFixture

func PublicKeysFixture(n int, algo crypto.SigningAlgorithm) []crypto.PublicKey

func QCSigDataFixture

func QCSigDataFixture() []byte

func QCWithBlockID

func QCWithBlockID(blockID flow.Identifier) func(*flow.QuorumCertificate)

func QCWithSignerIndices

func QCWithSignerIndices(signerIndices []byte) func(*flow.QuorumCertificate)

func QuorumCertificateFixture

func QuorumCertificateFixture(opts ...func(*flow.QuorumCertificate)) *flow.QuorumCertificate

func QuorumCertificateWithSignerIDsFixture

func QuorumCertificateWithSignerIDsFixture(opts ...func(*flow.QuorumCertificateWithSignerIDs)) *flow.QuorumCertificateWithSignerIDs

func QuorumCertificatesFixtures

func QuorumCertificatesFixtures(n uint, opts ...func(*flow.QuorumCertificate)) []*flow.QuorumCertificate

func QuorumCertificatesFromAssignments

func QuorumCertificatesFromAssignments(assignment flow.AssignmentList) []*flow.QuorumCertificateWithSignerIDs

func QuorumCertificatesWithSignerIDsFixtures

func QuorumCertificatesWithSignerIDsFixtures(n uint, opts ...func(*flow.QuorumCertificateWithSignerIDs)) []*flow.QuorumCertificateWithSignerIDs

func RandomAddressFixture

func RandomAddressFixture() flow.Address

func RandomBeaconPriv

func RandomBeaconPriv() *encodable.RandomBeaconPrivKey

func RandomBytes

func RandomBytes(n int) []byte

func RandomSDKAddressFixture

func RandomSDKAddressFixture() sdk.Address

func RangeFixture

func RangeFixture() chainsync.Range

func RangeListFixture

func RangeListFixture(n int) []chainsync.Range

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

func ReceiptAndSealForBlock(block *flow.Block) (*flow.ExecutionReceipt, *flow.Seal)

func ReceiptChainFor

func ReceiptChainFor(blocks []*flow.Block, result0 *flow.ExecutionResult) []*flow.ExecutionReceipt

func ReceiptForBlockExecutorFixture

func ReceiptForBlockExecutorFixture(block *flow.Block, executor flow.Identifier) *flow.ExecutionReceipt

func ReceiptForBlockFixture

func ReceiptForBlockFixture(block *flow.Block) *flow.ExecutionReceipt

func ReceiptsForBlockFixture

func ReceiptsForBlockFixture(block *flow.Block, ids []flow.Identifier) []*flow.ExecutionReceipt

func ReconnectBlocksAndReceipts

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 RequireCloseBefore

func RequireCloseBefore(t testing.TB, c <-chan struct{}, duration time.Duration, message string)

RequireCloseBefore requires that the given channel returns before the duration expires.

func RequireClosed

func RequireClosed(t *testing.T, ch <-chan struct{}, message string)

RequireClosed is a test helper function that fails the test if channel `ch` is not closed.

func RequireComponentsDoneBefore

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

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

func RequireConcurrentCallsReturnBefore(t *testing.T, f func(), count int, duration time.Duration, message string)

RequireConcurrentCallsReturnBefore is a test helper that runs function `f` count-many times concurrently, and requires all invocations to return within duration.

func RequireFileEmpty

func RequireFileEmpty(t *testing.T, path string)

func RequireNeverClosedWithin

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

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 RequireNotClosed

func RequireNotClosed(t *testing.T, ch <-chan struct{}, message string)

RequireNotClosed is a test helper function that fails the test if channel `ch` is closed.

func RequireReturnsBefore

func RequireReturnsBefore(t testing.TB, f func(), duration time.Duration, message string)

RequireReturnsBefore requires that the given function returns before the duration expires.

func ResultApprovalFixture

func ResultApprovalFixture(opts ...func(*flow.ResultApproval)) *flow.ResultApproval

func RootSnapshotFixture

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 RunWithBadgerDB

func RunWithBadgerDB(t testing.TB, f func(*badger.DB))

func RunWithTempDir

func RunWithTempDir(t testing.TB, f func(string))

func RunWithTypedBadgerDB

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 SealBlock

func SealBlock(t *testing.T, st protocol.MutableState, block *flow.Block, receipt *flow.ExecutionReceipt, seal *flow.Seal) *flow.Header

SealBlock seals a block by building two blocks on it, the first containing a receipt for the block, the second containing a seal for the block. Returns the block containing the seal.

func SeedFixture

func SeedFixture(n int) []byte

SeedFixture returns a random []byte with length n

func SeedFixtures

func SeedFixtures(m int, n int) [][]byte

SeedFixtures returns a list of m random []byte, each having length n

func ServiceEventsFixture

func ServiceEventsFixture(n int) flow.ServiceEventList

func SetupWithCounter

func SetupWithCounter(counter uint64) func(*flow.EpochSetup)

func SignatureFixture

func SignatureFixture() crypto.Signature

func SignaturesFixture

func SignaturesFixture(n int) []crypto.Signature

func SignerIndicesByIndices

func SignerIndicesByIndices(n int, indices []int) []byte

func SignerIndicesFixture

func SignerIndicesFixture(n int) []byte

func SkipBenchmarkUnless

func SkipBenchmarkUnless(b *testing.B, reason SkipBenchmarkReason, message string)

func SkipUnless

func SkipUnless(t *testing.T, reason SkipReason, message string)

func SnapshotClusterByIndex

func SnapshotClusterByIndex(snapshot *inmem.Snapshot, clusterIndex uint) (protocol.Cluster, error)

func StakingKeys

func StakingKeys(n int) []crypto.PrivateKey

func StakingPrivKeyByIdentifier

func StakingPrivKeyByIdentifier(id flow.Identifier) crypto.PrivateKey

func StakingPrivKeyFixture

func StakingPrivKeyFixture() crypto.PrivateKey

StakingPrivKeyFixture returns a random BLS12381 private keyf

func StateCommitmentFixture

func StateCommitmentFixture() flow.StateCommitment

func StateCommitmentPointerFixture

func StateCommitmentPointerFixture() *flow.StateCommitment

func StateDeltaFixture

func StateDeltaFixture() *messages.ExecutionStateDelta

func StateDeltaWithParentFixture

func StateDeltaWithParentFixture(parent *flow.Header) *messages.ExecutionStateDelta

func StateInteractionsFixture

func StateInteractionsFixture() *delta.Snapshot

func StateSnapshotForKnownBlock

func StateSnapshotForKnownBlock(block *flow.Header, identities map[flow.Identifier]*flow.Identity) *protocol.Snapshot

func StateSnapshotForUnknownBlock

func StateSnapshotForUnknownBlock() *protocol.Snapshot

func TempBadgerDB

func TempBadgerDB(t testing.TB) (*badger.DB, string)

func TempDir

func TempDir(t testing.TB) string

func TransactionBodyFixture

func TransactionBodyFixture(opts ...func(*flow.TransactionBody)) flow.TransactionBody

func TransactionBodyListFixture

func TransactionBodyListFixture(n int) []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 TransactionResultsFixture

func TransactionResultsFixture(n int) []flow.TransactionResult

func TransactionSignatureFixture

func TransactionSignatureFixture() flow.TransactionSignature

func TypedBadgerDB

func TypedBadgerDB(t testing.TB, dir string, create func(badger.Options) (*badger.DB, error)) *badger.DB

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 VoteFixture(opts ...func(vote *hotstuff.Vote)) *hotstuff.Vote

func VoteForBlockFixture

func VoteForBlockFixture(block *hotstuff.Block, opts ...func(vote *hotstuff.Vote)) *hotstuff.Vote

func VoteWithBeaconSig

func VoteWithBeaconSig() func(*hotstuff.Vote)

func VoteWithStakingSig

func VoteWithStakingSig() func(*hotstuff.Vote)

func WithAddress

func WithAddress(address string) func(*flow.Identity)

WithAddress sets the network address of identity fixture.

func WithAllRoles

func WithAllRoles() func(*flow.Identity)

WithAllRoles can be used used to ensure an IdentityList fixtures contains all the roles required for a valid genesis block.

func WithAllRolesExcept

func WithAllRolesExcept(except ...flow.Role) func(*flow.Identity)

Same as above, but omitting a certain role for cases where we are manually setting up nodes or a particular role.

func WithAllTheFixins

func WithAllTheFixins(payload *flow.Payload)

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

func WithApproverID(approverID flow.Identifier) func(*flow.ResultApproval)

func WithApproximateSize

func WithApproximateSize(bytes uint64) func(*messages.ChunkDataResponse)

WithApproximateSize sets the ChunkDataResponse to be approximately bytes in size.

func WithAttestationBlock

func WithAttestationBlock(block *flow.Block) func(*flow.ResultApproval)

func WithBlock

func WithBlock(block *flow.Block) func(*flow.ExecutionResult)

func WithBlockID

func WithBlockID(id flow.Identifier) func(*flow.ResultApproval)

func WithChunk

func WithChunk(chunkIdx uint64) func(*flow.ResultApproval)

func WithChunkDataPackCollection

func WithChunkDataPackCollection(collection *flow.Collection) func(*flow.ChunkDataPack)

func WithChunkID

func WithChunkID(chunkID flow.Identifier) func(*verification.ChunkDataPackRequest)

func WithChunkStartState

func WithChunkStartState(startState flow.StateCommitment) func(chunk *flow.Chunk)

func WithChunks

func WithChunks(n uint) func(*flow.ExecutionResult)

func WithClusterQCsFromAssignments

func WithClusterQCsFromAssignments(assignments flow.AssignmentList) func(*flow.EpochCommit)

func WithCollRef

func WithCollRef(refID flow.Identifier) func(*flow.CollectionGuarantee)

func WithCollection

func WithCollection(collection *flow.Collection) func(guarantee *flow.CollectionGuarantee)

func WithDKGFromParticipants

func WithDKGFromParticipants(participants flow.IdentityList) func(*flow.EpochCommit)

func WithDisagrees

func WithDisagrees(list flow.IdentifierList) func(*verification.ChunkDataPackRequest)

func WithEjected

func WithEjected(ejected bool) func(*flow.Identity)

func WithExecutionDataID

func WithExecutionDataID(id flow.Identifier) func(result *flow.ExecutionResult)

func WithExecutionResultBlockID

func WithExecutionResultBlockID(blockID flow.Identifier) func(*flow.ExecutionResult)

func WithExecutionResultID

func WithExecutionResultID(id flow.Identifier) func(*flow.ResultApproval)

func WithExecutionResults

func WithExecutionResults(results ...*flow.ExecutionResult) func(*flow.Payload)

WithExecutionResults will add execution results to payload

func WithExecutorID

func WithExecutorID(executorID flow.Identifier) func(*flow.ExecutionReceipt)

func WithFinalView

func WithFinalView(view uint64) func(*flow.EpochSetup)

func WithFirstView

func WithFirstView(view uint64) func(*flow.EpochSetup)

func WithGuarantees

func WithGuarantees(guarantees ...*flow.CollectionGuarantee) func(*flow.Payload)

func WithHeaderHeight

func WithHeaderHeight(height uint64) func(header *flow.Header)

func WithHeight

func WithHeight(height uint64) func(*verification.ChunkDataPackRequest)

func WithHeightGreaterThan

func WithHeightGreaterThan(height uint64) func(*verification.ChunkDataPackRequest)

func WithKeys

func WithKeys(identity *flow.Identity)

func WithNetworkingKey

func WithNetworkingKey(key crypto.PublicKey) func(*flow.Identity)

WithNetworkingKey sets the networking public key of identity fixture.

func WithNodeID

func WithNodeID(id flow.Identifier) func(*flow.Identity)

WithNodeID adds a node ID with the given first byte to an identity.

func WithParticipants

func WithParticipants(participants flow.IdentityList) func(*flow.EpochSetup)

func WithPreviousResult

func WithPreviousResult(prevResult flow.ExecutionResult) func(*flow.ExecutionResult)

func WithRandomPublicKeys

func WithRandomPublicKeys() func(*flow.Identity)

WithRandomPublicKeys adds random public keys to an identity.

func WithReceipts

func WithReceipts(receipts ...*flow.ExecutionReceipt) func(*flow.Payload)

func WithReceiptsAndNoResults

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

func WithResult(result *flow.ExecutionResult) func(*flow.ExecutionReceipt)

func WithRole

func WithRole(role flow.Role) func(*flow.Identity)

WithRole adds a role to an identity fixture.

func WithSeals

func WithSeals(seals ...*flow.Seal) func(*flow.Payload)

func WithServiceEvents

func WithServiceEvents(n int) func(result *flow.ExecutionResult)

func WithStakingPubKey

func WithStakingPubKey(pubKey crypto.PublicKey) func(*flow.Identity)

WithStakingPubKey adds a staking public key to the identity

func WithStartState

func WithStartState(startState flow.StateCommitment) func(*flow.ChunkDataPack)

func WithTransactionDSL

func WithTransactionDSL(txDSL dsl.Transaction) func(tx *flow.TransactionBody)

func WithVoteBlockID

func WithVoteBlockID(blockID flow.Identifier) func(*hotstuff.Vote)

func WithVoteSignerID

func WithVoteSignerID(signerID flow.Identifier) func(*hotstuff.Vote)

func WithVoteView

func WithVoteView(view uint64) func(*hotstuff.Vote)

func WithWeight

func WithWeight(weight uint64) func(*flow.Identity)

WithWeight sets the weight on an identity fixture.

func WithoutGuarantee

func WithoutGuarantee(payload *flow.Payload)

Types

type BaseChainSuite

type BaseChainSuite struct {
	suite.Suite

	// IDENTITIES
	ConID flow.Identifier
	ExeID flow.Identifier
	VerID flow.Identifier

	Identities map[flow.Identifier]*flow.Identity
	Approvers  flow.IdentityList

	// BLOCKS
	RootBlock             flow.Block
	LatestSealedBlock     flow.Block
	LatestFinalizedBlock  *flow.Block
	UnfinalizedBlock      flow.Block
	LatestExecutionResult *flow.ExecutionResult
	Blocks                map[flow.Identifier]*flow.Block

	// PROTOCOL STATE
	State          *protocol.State
	SealedSnapshot *protocol.Snapshot
	FinalSnapshot  *protocol.Snapshot

	// MEMPOOLS and STORAGE which are injected into Matching Engine
	// mock storage.ExecutionReceipts: backed by in-memory map PersistedReceipts
	ReceiptsDB *storage.ExecutionReceipts

	ResultsDB        *storage.ExecutionResults
	PersistedResults map[flow.Identifier]*flow.ExecutionResult

	// mock mempool.IncorporatedResultSeals: backed by in-memory map PendingSeals
	SealsPL      *mempool.IncorporatedResultSeals
	PendingSeals map[flow.Identifier]*flow.IncorporatedResultSeal

	// mock BLOCK STORAGE: backed by in-memory map Blocks
	HeadersDB  *storage.Headers               // backed by map Blocks
	IndexDB    *storage.Index                 // backed by map Blocks
	PayloadsDB *storage.Payloads              // backed by map Blocks
	SealsDB    *storage.Seals                 // backed by map SealsIndex
	SealsIndex map[flow.Identifier]*flow.Seal // last valid seal for block

	// mock mempool.ReceiptsForest: used to test whether or not Matching Engine stores receipts
	ReceiptsPL *mempool.ExecutionTree

	Assigner    *module.ChunkAssigner
	Assignments map[flow.Identifier]*chunks.Assignment // index for assignments for given execution result

	PendingReceipts *mempool.PendingReceipts
}

func (*BaseChainSuite) AddSubgraphFixtureToMempools

func (bc *BaseChainSuite) AddSubgraphFixtureToMempools(subgraph subgraphFixture)

addSubgraphFixtureToMempools adds add entities in subgraph to mempools and persistent storage mocks

func (*BaseChainSuite) Extend

func (bc *BaseChainSuite) Extend(block *flow.Block)

func (*BaseChainSuite) SetupChain

func (bc *BaseChainSuite) SetupChain()

func (*BaseChainSuite) ValidSubgraphFixture

func (bc *BaseChainSuite) ValidSubgraphFixture() subgraphFixture

Generates a valid subgraph: let

  • R1 be a result which pertains to blockA
  • R2 be R1's previous result, where R2 pertains to blockB

The execution results form a valid subgraph if and only if:

blockA.ParentID == blockB.ID

type ClusterStateChecker

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

ClusterStateChecker is a test utility for checking cluster state. First, prepare it with expectations about the state, using `Expect*` functions, then use `Check` to assert the expectations.

Duplicates are checked automatically without setting any expectations.

func NewClusterStateChecker

func NewClusterStateChecker(state cluster.State) *ClusterStateChecker

NewClusterStateChecker returns a state checker for the given state.

func (*ClusterStateChecker) Assert

func (checker *ClusterStateChecker) Assert(t *testing.T)

Assert checks all assertions against the cluster state. If any assertions fail, the test will fail.

func (*ClusterStateChecker) ExpectContainsTx

func (checker *ClusterStateChecker) ExpectContainsTx(txIDs ...flow.Identifier) *ClusterStateChecker

ExpectContainsTx adds an expectation that the given transaction exists in the cluster state.

func (*ClusterStateChecker) ExpectOmitsTx

func (checker *ClusterStateChecker) ExpectOmitsTx(txIDs ...flow.Identifier) *ClusterStateChecker

ExpectOmitsTx adds an expectation that the given transaction does not exist in the cluster state.

func (*ClusterStateChecker) ExpectTxCount

func (checker *ClusterStateChecker) ExpectTxCount(n int) *ClusterStateChecker

ExpectTxCount adds an expectation for the total count of transactions in the cluster state.

type EpochBuilder

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

EpochBuilder is a testing utility for building epochs into chain state.

func NewEpochBuilder

func NewEpochBuilder(t *testing.T, states ...protocol.MutableState) *EpochBuilder

NewEpochBuilder returns a new EpochBuilder which will build epochs using the given states. At least one state must be provided. If more than one are provided they must have the same initial state.

func (*EpochBuilder) AddBlocksWithSeals

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) BuildBlocks

func (builder *EpochBuilder) BuildBlocks(n uint)

BuildBlocks builds empty blocks on top of the finalized state. It is used to build epochs that are not the minimum possible length, which is the default result from chaining BuildEpoch and CompleteEpoch.

func (*EpochBuilder) BuildEpoch

func (builder *EpochBuilder) BuildEpoch() *EpochBuilder

BuildEpoch builds and finalizes a sequence of blocks comprising a minimal full epoch (epoch N). We assume the latest finalized block is within staking phase in epoch N.

                |                                  EPOCH N                                                      |
                |                                                                                               |
P                 A               B               C               D             E             F           G

+------------+  +------------+  +-----------+  +-----------+  +----------+  +----------+  +----------+----------+
| ER(P-1)    |->| ER(P)      |->| ER(A)     |->| ER(B)     |->| ER(C)    |->| ER(D)    |->| ER(E)    | ER(F)    |
| S(ER(P-2)) |  | S(ER(P-1)) |  | S(ER(P))  |  | S(ER(A))  |  | S(ER(B)) |  | S(ER(C)) |  | S(ER(D)) | S(ER(E)) |
+------------+  +------------+  +-----------+  +-----------+  +----------+  +----------+  +----------+----------+
                                                                            |                        |
                                                                          Setup                    Commit

ER(X) := ExecutionReceipt for block X S(ER(X)) := Seal for the ExecutionResult contained in ER(X) (seals block X)

A is the latest finalized block. Every block contains a receipt for the previous block and a seal for the receipt contained in the previous block. The only exception is when A is the root block, in which case block B does not contain a receipt for block A, and block C does not contain a seal for block A. This is because the root block is sealed from genesis and we can't insert duplicate seals.

D contains a seal for block B containing the EpochSetup service event. E contains a QC for D, which causes the EpochSetup to become activated.

F contains a seal for block D containing the EpochCommit service event. G contains a QC for F, which causes the EpochCommit to become activated.

To build a sequence of epochs, we call BuildEpoch, then CompleteEpoch, and so on.

Upon building an epoch N (preparing epoch N+1), we store some information about the heights of blocks in the BUILT epoch (epoch N). These can be queried with EpochHeights.

func (*EpochBuilder) CompleteEpoch

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

func (builder *EpochBuilder) EpochHeights(counter uint64) (*EpochHeights, bool)

EpochHeights returns heights of each phase within about a built epoch.

func (*EpochBuilder) UsingCommitOpts

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

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

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

func (epoch EpochHeights) CommittedRange() []uint64

CommittedRange returns the range of all heights in the committed phase.

func (EpochHeights) Range

func (epoch EpochHeights) Range() []uint64

Range returns the range of all heights that are in this epoch.

func (EpochHeights) SetupRange

func (epoch EpochHeights) SetupRange() []uint64

SetupRange returns the range of all heights in the setup phase.

func (EpochHeights) StakingRange

func (epoch EpochHeights) StakingRange() []uint64

StakingRange returns the range of all heights in the staking phase.

type FixedStaker

type FixedStaker struct {
	Staked bool
}

func NewFixedStaker

func NewFixedStaker(initial bool) *FixedStaker

func (*FixedStaker) AmIStakedAt

func (f *FixedStaker) AmIStakedAt(_ flow.Identifier) bool

type LoggerHook

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

func HookedLogger() (zerolog.Logger, LoggerHook)

func NewLoggerHook

func NewLoggerHook() LoggerHook

func (LoggerHook) Logs

func (hook LoggerHook) Logs() string

Logs returns the logs as a string

func (LoggerHook) Run

func (hook LoggerHook) Run(_ *zerolog.Event, level zerolog.Level, msg string)

Run implements zerolog.Hook and appends the log message to the log.

type MockEntity

type MockEntity struct {
	Identifier flow.Identifier
}

MockEntity implements a bare minimum entity for sake of test.

func EntityListFixture

func EntityListFixture(n uint) []*MockEntity

func MockEntityFixture

func MockEntityFixture() *MockEntity

func MockEntityListFixture

func MockEntityListFixture(count int) []*MockEntity

func (MockEntity) Checksum

func (m MockEntity) Checksum() flow.Identifier

func (MockEntity) ID

func (m MockEntity) ID() flow.Identifier

type ProtectedMap

type ProtectedMap[K comparable, V any] struct {
	// contains filtered or unexported fields
}

ProtectedMap is a thread-safe map.

func NewProtectedMap

func NewProtectedMap[K comparable, V any]() *ProtectedMap[K, V]

NewProtectedMap returns a new ProtectedMap with the given types

func (*ProtectedMap[K, V]) Add

func (p *ProtectedMap[K, V]) Add(key K, value V)

Add adds a key-value pair to the map

func (*ProtectedMap[K, V]) ForEach

func (p *ProtectedMap[K, V]) ForEach(fn func(k K, v V) error) error

ForEach iterates over the map and calls the given function for each key-value pair. If the function returns an error, the iteration is stopped and the error is returned.

func (*ProtectedMap[K, V]) Get

func (p *ProtectedMap[K, V]) Get(key K) (V, bool)

Get returns the value for the given key and a boolean indicating if the key was found

func (*ProtectedMap[K, V]) Has

func (p *ProtectedMap[K, V]) Has(key K) bool

Has returns true if the map contains the given key

func (*ProtectedMap[K, V]) Remove

func (p *ProtectedMap[K, V]) Remove(key K)

Remove removes a key-value pair from the map

type SkipBenchmarkReason

type SkipBenchmarkReason int
const (
	BENCHMARK_EXPERIMENT SkipBenchmarkReason = iota + 1
)

func (SkipBenchmarkReason) String

func (s SkipBenchmarkReason) String() string

type SkipReason

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

func ParseSkipReason(output string) (SkipReason, bool)

func (SkipReason) MarshalJSON

func (s SkipReason) MarshalJSON() ([]byte, error)

func (SkipReason) String

func (s SkipReason) String() string

type TestTime

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

TestTime is a fake time used for testing.

func NewTestTime

func NewTestTime() *TestTime

NewTestTime returns new TestTime.

func (*TestTime) Advance

func (tt *TestTime) Advance(dur time.Duration)

Advance advances the fake time.

func (*TestTime) Now

func (tt *TestTime) Now() time.Time

Now returns the current fake time.

func (*TestTime) Since

func (tt *TestTime) Since(t time.Time) time.Duration

Since returns the fake time since the given time.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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