test

package module
v0.0.0-...-a969d0f Latest Latest
Warning

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

Go to latest
Published: Oct 15, 2025 License: Unlicense Imports: 26 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CDCToDKGIDMapping

func CDCToDKGIDMapping(cdc cadence.Value) map[string]int

CDCToDKGIDMapping converts an ID mapping (map from node IDs to DKG indexes) from a Cadence dictionary representation to a Go map representation.

func CDCToString

func CDCToString(v cadence.Value) string

CDCToString converts a cadence.String to a Go string.

func CadenceArrayFrom

func CadenceArrayFrom[T any](slice []T, convert func(T) cadence.Value) cadence.Array

CadenceArrayFrom constructs a Cadence array from a Go slice, converting each individual element with the convert function.

func CadenceArrayTo

func CadenceArrayTo[T any](arr cadence.Value, convert func(cadence.Value) T) []T

CadenceArrayTo converts a Cadence array to a Go slice, converting each individual element with the convert function

func CadenceBool

func CadenceBool(value bool) cadence.Bool

CadenceBool returns a bool value from a bool

func CadenceString

func CadenceString(value string) cadence.Value

CadenceString returns a string value from a string representation

func CadenceUFix64

func CadenceUFix64(value string) cadence.Value

CadenceUFix64 returns a UFix64 value from a string representation

func CadenceUInt64

func CadenceUInt64(value uint64) cadence.Value

CadenceUInt64 returns a UInt64 value from a uint64

func CadenceUInt8

func CadenceUInt8(value uint8) cadence.Value

CadenceUInt8 returns a UInt8 value from a uint8

func DKGIDMappingToCDC

func DKGIDMappingToCDC(idMapping map[string]int) cadence.Dictionary

DKGIDMappingToCDC converts an ID mapping (map from node IDs to DKG indexes) from a Go map representation to a Cadence dictionary representation.

func DKGPubKeyFixture

func DKGPubKeyFixture() string

DKGPubKeyFixture constructs a fixture for a DKG public key string as accepted by FlowDKG (any hex-encoded 96-byte bytes).

func DKGPubKeyFixtureCDC

func DKGPubKeyFixtureCDC() cadence.String

DKGPubKeyFixtureCDC returns a Cadence string-typed version of DKGPubKeyFixture.

func DKGPubKeysFixture

func DKGPubKeysFixture(n int) []string

DKGPubKeysFixture constructs a fixture for a DKG public key string list as accepted by FlowDKG (any list of hex-encoded 96-byte bytes).

func DKGPubKeysFixtureCDC

func DKGPubKeysFixtureCDC(n int) cadence.Array

DKGPubKeysFixtureCDC returns a Cadence array-typed version of DKGPubKeysFixture.

func StringToCDC

func StringToCDC(s string) cadence.Value

StringToCDC converts a Go string to a cadence.String.

func Submit

func Submit(
	t *testing.T,
	b emulator.Emulator,
	tx *flow.Transaction,
	shouldRevert bool,
	expectedErrs ...error,
) *types.TransactionResult

Submit submits a transaction and checks if it fails or not, based on shouldRevert specification. If shouldRevert is true this function will ensures that the transaction error contains each of the expected errors.

func UnwrapOptional

func UnwrapOptional[T cadence.Value](optional cadence.Value) T

UnwrapOptional unwraps a Cadence optional of type T?, and returns the underlying value of type T.

Types

type CandidateNodes

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

type Cluster

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

Used to verify the values of the clusters in the smart contract

type ConfigMetadata

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

Used to verify the configurable Epoch metadata in tests

type DelegatorIDs

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

Struct for each delegator that specifies their node ID and delegator ID

type EpochCommit

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

Used to verify the EpochCommit event fields in tests

type EpochCommitEvent

type EpochCommitEvent flow.Event

func (EpochCommitEvent) Counter

func (evt EpochCommitEvent) Counter() cadence.UInt64

type EpochMetadata

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

Used to verify epoch metadata in tests

type EpochRecover

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

EpochRecover used to verify EpochRecover event fields in tests.

type EpochRecoverEvent

type EpochRecoverEvent flow.Event

func (EpochRecoverEvent) ClusterQCVoteData

func (evt EpochRecoverEvent) ClusterQCVoteData() cadence.Array

ClusterQCVoteData returns clusterQCVoteData field in EpochRecover event.

func (EpochRecoverEvent) CollectorClusters

func (evt EpochRecoverEvent) CollectorClusters() cadence.Array

CollectorClusters returns clusterAssignments field in EpochRecover event.

func (EpochRecoverEvent) Counter

func (evt EpochRecoverEvent) Counter() cadence.UInt64

Counter returns counter field in EpochRecover event.

func (EpochRecoverEvent) DKGFinalViews

func (evt EpochRecoverEvent) DKGFinalViews() (cadence.UInt64, cadence.UInt64, cadence.UInt64)

DKGFinalViews returns dkgFinalViews field in EpochRecover event.

func (EpochRecoverEvent) DKGGroupKey

func (evt EpochRecoverEvent) DKGGroupKey() cadence.Array

DKGGroupKey returns dkgGroupKey field in EpochRecover event.

func (EpochRecoverEvent) DKGPubKeys

func (evt EpochRecoverEvent) DKGPubKeys() cadence.Array

DKGPubKeys returns dkgPubKeys field in EpochRecover event.

func (EpochRecoverEvent) FinalView

func (evt EpochRecoverEvent) FinalView() cadence.UInt64

FinalView returns finalView field in EpochRecover event.

func (EpochRecoverEvent) FirstView

func (evt EpochRecoverEvent) FirstView() cadence.UInt64

FirstView returns firstView field in EpochRecover event.

func (EpochRecoverEvent) NodeInfo

func (evt EpochRecoverEvent) NodeInfo() cadence.Array

NodeInfo returns nodeInfo field in EpochRecover event.

func (EpochRecoverEvent) RandomSource

func (evt EpochRecoverEvent) RandomSource() cadence.String

RandomSource returns randomSource field in EpochRecover event.

func (EpochRecoverEvent) TargetDuration

func (evt EpochRecoverEvent) TargetDuration() cadence.UInt64

TargetDuration returns targetDuration field in EpochRecover event.

func (EpochRecoverEvent) TargetEndTime

func (evt EpochRecoverEvent) TargetEndTime() cadence.UInt64

TargetEndTime returns targetEndTime field in EpochRecover event.

type EpochSetup

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

Used to verify the EpochSetup event fields in tests

type EpochSetupEvent

type EpochSetupEvent flow.Event

func (EpochSetupEvent) Counter

func (evt EpochSetupEvent) Counter() cadence.UInt64

func (EpochSetupEvent) NodeInfo

func (evt EpochSetupEvent) NodeInfo() cadence.Array

type EpochStart

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

Used to verify the EpochStart event fields in tests

type EpochStartEvent

type EpochStartEvent flow.Event

func (EpochStartEvent) Counter

func (evt EpochStartEvent) Counter() cadence.UInt64

type EpochTimingConfig

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

EpochTimingConfig is used to verify timing config stored on-chain.

type EpochTotalRewardsPaid

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

Used to verify the EpochSetup event fields in tests

type EpochTotalRewardsPaidEvent

type EpochTotalRewardsPaidEvent flow.Event

func (EpochTotalRewardsPaidEvent) FeesBurned

func (evt EpochTotalRewardsPaidEvent) FeesBurned() cadence.UFix64

func (EpochTotalRewardsPaidEvent) FromFees

func (evt EpochTotalRewardsPaidEvent) FromFees() cadence.UFix64

func (EpochTotalRewardsPaidEvent) Minted

func (EpochTotalRewardsPaidEvent) Total

type MachineAccountCreatedEvent

type MachineAccountCreatedEvent interface {
	NodeID() cadence.String
	Role() cadence.UInt8
	Address() flow.Address
}

type ResultSubmission

type ResultSubmission struct {
	GroupPubKey string
	PubKeys     []string
	IDMapping   map[string]int
}

ResultSubmission is a Go structure representation the FlowDKG.ResultSubmission Cadence data structure. It is used to construct and operate on ResultSubmission objects from Cadence, in Go tests.

func GetDKGCanonicalFinalSubmission

func GetDKGCanonicalFinalSubmission(t *testing.T, b emulator.Emulator, env templates.Environment) ResultSubmission

GetDKGCanonicalFinalSubmission executes a script to retrieve the canonical final submission, if any exists.

func GetDKGFinalSubmissions

func GetDKGFinalSubmissions(t *testing.T, b emulator.Emulator, env templates.Environment) []ResultSubmission

GetDKGFinalSubmissions executes a script to retrieve all unique final submissions.

func ResultSubmissionFromCadence

func ResultSubmissionFromCadence(cdc cadence.Value) ResultSubmission

ResultSubmissionFromCadence converts a Cadence-typed ResultSubmission to the Go representation.

func (*ResultSubmission) GroupPubKeyCDC

func (rs *ResultSubmission) GroupPubKeyCDC() cadence.String

GroupPubKeyCDC returns the GroupPubKey field as a cadence String.

func (*ResultSubmission) IDMappingCDC

func (rs *ResultSubmission) IDMappingCDC() cadence.Dictionary

IDMappingCDC returns the IDMapping field as a cadence {String: Int}.

func (*ResultSubmission) PubKeysCDC

func (rs *ResultSubmission) PubKeysCDC() cadence.Array

PubKeysCDC returns the PubKeys field as a cadence [String].

type SharedAccountRegisteredEvent

type SharedAccountRegisteredEvent interface {
	Address() flow.Address
}

type StakingCollectionInfo

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

/ Used to verify staking collection info in tests

type StakingInfo

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

Used to verify staking info in tests

type UnlockedAccountRegisteredEvent

type UnlockedAccountRegisteredEvent interface {
	Address() flow.Address
}

Unlocked account Registered event

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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