test

package
v1.0.7 Latest Latest
Warning

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

Go to latest
Published: Nov 13, 2026 License: MIT Imports: 26 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package test provides shared test helpers.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GoSDK added in v1.0.3

func GoSDK(t *testing.T, root string) string

GoSDK exports the pinned SDK without changing the developer's checkout. It returns an empty path when an unconfigured checkout is absent.

func MetricSamples added in v1.0.7

func MetricSamples(t *testing.T, registry prometheus.Gatherer, name string, labels map[string]string) []*dto.Metric

MetricSamples distinguishes absent series from samples whose value is zero.

func MetricSum added in v1.0.7

func MetricSum(t *testing.T, registry prometheus.Gatherer, name string, labels map[string]string) float64

MetricSum sums samples matching a label subset. Histograms return their observation count, allowing behavioral tests to verify exactly-once recording.

func PythonSDK added in v1.0.3

func PythonSDK(t *testing.T, root string) (python, export string)

PythonSDK exports the pinned SDK without changing the developer's checkout. It returns empty paths when an unconfigured checkout or interpreter is absent.

func WriteConfig

func WriteConfig(t testing.TB, path, config string)

WriteConfig writes a TOML fixture in the format selected by its extension.

func WriteFixedKeystore

func WriteFixedKeystore(t testing.TB) (keystorePath, passwordPath string)

WriteFixedKeystore preserves the scalar-one account used by transaction fixtures.

func WriteKeystore

func WriteKeystore(t testing.TB, private *ecdsa.PrivateKey) (keystorePath, passwordPath string)

WriteKeystore creates an owner-only keystore and exact-byte password file. A nil private key generates a new account. Minimal scrypt parameters are only for tests.

Types

type ChainCall added in v1.0.7

type ChainCall struct {
	To       common.Address
	Function string
}

type ChainRPC added in v1.0.7

type ChainRPC struct {
	URL        string
	Controller common.Address
	// contains filtered or unexported fields
}

Adapted from BlueClawNetwork/livepeer-node internal/test/chainrpc.go, 285eda984d7cce4e3030ef0510d63ae142534dd7, by Mike Zupper (MIT; see LICENSE). ChainRPC serves payment reads at canonical blocks. Other tests can extend this fixture without duplicating the payment RPC protocol.

func NewChainRPC added in v1.0.7

func NewChainRPC(t testing.TB) *ChainRPC

func (*ChainRPC) Reset added in v1.0.7

func (c *ChainRPC) Reset()

func (*ChainRPC) State added in v1.0.7

func (c *ChainRPC) State() ChainState

func (*ChainRPC) Stats added in v1.0.7

func (c *ChainRPC) Stats() ChainRPCStats

func (*ChainRPC) Update added in v1.0.7

func (c *ChainRPC) Update(update func(*ChainState))

type ChainRPCStats added in v1.0.7

type ChainRPCStats struct {
	RoundTrips   int
	Calls        map[string]int
	LogAddresses []common.Address
}

type ChainState added in v1.0.7

type ChainState struct {
	Number, L1Block, Timestamp                 uint64
	ChainID                                    uint64
	Hash, Parent, RoundHash                    common.Hash
	Round, CurrentRound                        uint64
	Payer, Recipient                           common.Address
	Activation, Deactivation                   uint64
	OmitL1, OmitTimestamp                      bool
	Fail                                       string
	Before                                     func(context.Context, string)
	Contracts                                  map[string]common.Address
	Results                                    map[ChainCall]string
	Logs                                       []types.Log
	LogsBloom                                  any
	Deposit, Reserve, Claimable, WithdrawRound uint64
	FailPayer                                  common.Address
}

type RedemptionRPC added in v1.0.7

type RedemptionRPC struct {
	StaleNonceValue                         uint64
	PrepareError                            string
	Wallet                                  common.Address
	Registered, WalletActive                bool
	RegisteredAccount                       common.Address
	Validity, FinalizedRound                int64
	SnapshotError, ReceiptMissingStatus     bool
	Block, Round                            int64
	Inactive, ActiveError                   bool
	ActiveRecipient                         common.Address
	OnSend                                  func(*types.Transaction)
	Mu                                      sync.Mutex
	Tickets                                 map[common.Hash]common.Hash // ticket hash -> randomness hash
	Sent                                    []*types.Transaction
	Pool                                    map[uint64]*types.Transaction
	Receipts                                map[common.Hash]*types.Receipt
	Used                                    map[common.Hash]bool
	Finalized                               bool
	ReceiptError, ReceiptMissing            bool
	StaleNonce                              bool
	FinalizedNonce                          uint64
	FinalizedNonceReads                     int
	FinalizedNonceError, FinalizedNonceNull bool
	RejectNext, LoseNextResponse            bool
	MineAfter                               int
	NonceReads                              int
	ContractCalls                           int
	GasEstimates                            int
	RejectSend                              int
	NonceBarrier                            chan struct{}
	ReceiptHeader                           *types.Header
	Server                                  *httptest.Server
}

RedemptionRPC models independent clients against one account's pending pool. All mutable RPC state is synchronized so the same scenarios run under -race.

func NewRedemptionRPC added in v1.0.7

func NewRedemptionRPC(t *testing.T) *RedemptionRPC

func (*RedemptionRPC) Header added in v1.0.7

func (f *RedemptionRPC) Header() *types.Header

Header returns the same latest execution header served by the fixture.

func (*RedemptionRPC) Mine added in v1.0.7

func (f *RedemptionRPC) Mine(tx *types.Transaction, success bool)

func (*RedemptionRPC) MineLocked added in v1.0.7

func (f *RedemptionRPC) MineLocked(tx *types.Transaction, success bool)

func (*RedemptionRPC) Serve added in v1.0.7

func (f *RedemptionRPC) Serve(w http.ResponseWriter, r *http.Request)

func (*RedemptionRPC) Transactions added in v1.0.7

func (f *RedemptionRPC) Transactions() []*types.Transaction

Jump to

Keyboard shortcuts

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