Documentation
¶
Overview ¶
Package test provides shared test helpers.
Index ¶
- func GoSDK(t *testing.T, root string) string
- func MetricSamples(t *testing.T, registry prometheus.Gatherer, name string, ...) []*dto.Metric
- func MetricSum(t *testing.T, registry prometheus.Gatherer, name string, ...) float64
- func PythonSDK(t *testing.T, root string) (python, export string)
- func WriteConfig(t testing.TB, path, config string)
- func WriteFixedKeystore(t testing.TB) (keystorePath, passwordPath string)
- func WriteKeystore(t testing.TB, private *ecdsa.PrivateKey) (keystorePath, passwordPath string)
- type ChainCall
- type ChainRPC
- type ChainRPCStats
- type ChainState
- type RedemptionRPC
- func (f *RedemptionRPC) Header() *types.Header
- func (f *RedemptionRPC) Mine(tx *types.Transaction, success bool)
- func (f *RedemptionRPC) MineLocked(tx *types.Transaction, success bool)
- func (f *RedemptionRPC) Serve(w http.ResponseWriter, r *http.Request)
- func (f *RedemptionRPC) Transactions() []*types.Transaction
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GoSDK ¶ added in v1.0.3
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
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 ¶
WriteConfig writes a TOML fixture in the format selected by its extension.
func WriteFixedKeystore ¶
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 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 (*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 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