testutil

package
v0.10.1 Latest Latest
Warning

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

Go to latest
Published: Jan 18, 2025 License: MIT Imports: 19 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MineBlocks added in v0.2.2

func MineBlocks(tb testing.TB, cm *chain.Manager, addr types.Address, n int)

MineBlocks mines n blocks with the reward going to the given address.

func Network

func Network() (*consensus.Network, types.Block)

Network returns a test network and genesis block.

func ServeSiaMux added in v0.4.0

func ServeSiaMux(tb testing.TB, s *rhp4.Server, log *zap.Logger) string

ServeSiaMux starts a RHP4 host listening on a random port and returns the address.

func V2Network added in v0.2.4

func V2Network() (*consensus.Network, types.Block)

V2Network returns a test network and genesis block with early V2 hardforks

Types

type EphemeralContractor added in v0.4.0

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

An EphemeralContractor is an in-memory minimal rhp4.Contractor for testing.

func NewEphemeralContractor added in v0.4.0

func NewEphemeralContractor(cm *chain.Manager) *EphemeralContractor

NewEphemeralContractor creates an EphemeralContractor for testing.

func (*EphemeralContractor) AccountBalance added in v0.4.0

func (ec *EphemeralContractor) AccountBalance(account proto4.Account) (types.Currency, error)

AccountBalance returns the balance of an account.

func (*EphemeralContractor) AddV2Contract added in v0.4.0

func (ec *EphemeralContractor) AddV2Contract(formationSet rhp4.TransactionSet, _ proto4.Usage) error

AddV2Contract adds a new contract to the host.

func (*EphemeralContractor) CreditAccountsWithContract added in v0.4.0

func (ec *EphemeralContractor) CreditAccountsWithContract(deposits []proto4.AccountDeposit, contractID types.FileContractID, revision types.V2FileContract, _ proto4.Usage) ([]types.Currency, error)

CreditAccountsWithContract credits accounts with the given deposits and revises the contract revision. The contract must be locked before calling this method.

func (*EphemeralContractor) DebitAccount added in v0.4.0

func (ec *EphemeralContractor) DebitAccount(account proto4.Account, usage proto4.Usage) error

DebitAccount debits an account by the given amount.

func (*EphemeralContractor) LockV2Contract added in v0.4.0

func (ec *EphemeralContractor) LockV2Contract(contractID types.FileContractID) (rhp4.RevisionState, func(), error)

LockV2Contract locks a contract and returns its current state.

func (*EphemeralContractor) RenewV2Contract added in v0.4.0

func (ec *EphemeralContractor) RenewV2Contract(renewalSet rhp4.TransactionSet, _ proto4.Usage) error

RenewV2Contract finalizes an existing contract and adds the renewed contract to the host. The existing contract must be locked before calling this method.

func (*EphemeralContractor) ReviseV2Contract added in v0.4.0

func (ec *EphemeralContractor) ReviseV2Contract(contractID types.FileContractID, revision types.V2FileContract, roots []types.Hash256, _ proto4.Usage) error

ReviseV2Contract atomically revises a contract and updates its sector roots and usage.

func (*EphemeralContractor) Tip added in v0.4.0

Tip returns the current chain tip.

func (*EphemeralContractor) UpdateChainState added in v0.4.0

func (ec *EphemeralContractor) UpdateChainState(reverted []chain.RevertUpdate, applied []chain.ApplyUpdate) error

UpdateChainState updates the EphemeralContractor's state based on the reverted and applied chain updates.

func (*EphemeralContractor) V2FileContractElement added in v0.6.0

func (ec *EphemeralContractor) V2FileContractElement(contractID types.FileContractID) (types.ChainIndex, types.V2FileContractElement, error)

V2FileContractElement returns the contract state element for the given contract ID.

type EphemeralPeerStore added in v0.8.0

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

A EphemeralPeerStore is an in-memory implementation of a PeerStore.

func NewEphemeralPeerStore added in v0.8.0

func NewEphemeralPeerStore() *EphemeralPeerStore

NewEphemeralPeerStore returns a new EphemeralPeerStore.

func (*EphemeralPeerStore) AddPeer added in v0.8.0

func (ps *EphemeralPeerStore) AddPeer(addr string) error

AddPeer adds a peer to the store. If the peer already exists, nil should be returned.

func (*EphemeralPeerStore) Ban added in v0.8.0

func (ps *EphemeralPeerStore) Ban(addr string, duration time.Duration, reason string) error

Ban temporarily bans one or more IPs. The addr should either be a single IP with port (e.g. 1.2.3.4:5678) or a CIDR subnet (e.g. 1.2.3.4/16).

func (*EphemeralPeerStore) Banned added in v0.8.0

func (ps *EphemeralPeerStore) Banned(addr string) (bool, error)

Banned returns false

func (*EphemeralPeerStore) PeerInfo added in v0.8.0

func (ps *EphemeralPeerStore) PeerInfo(addr string) (syncer.PeerInfo, error)

PeerInfo returns the metadata for the specified peer or ErrPeerNotFound if the peer wasn't found in the store.

func (*EphemeralPeerStore) Peers added in v0.8.0

func (ps *EphemeralPeerStore) Peers() ([]syncer.PeerInfo, error)

Peers returns the set of known peers.

func (*EphemeralPeerStore) UpdatePeerInfo added in v0.8.0

func (ps *EphemeralPeerStore) UpdatePeerInfo(addr string, fn func(*syncer.PeerInfo)) error

UpdatePeerInfo updates the metadata for the specified peer. If the peer is not found, the error should be ErrPeerNotFound.

type EphemeralSectorStore added in v0.4.0

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

An EphemeralSectorStore is an in-memory minimal rhp4.SectorStore for testing.

func NewEphemeralSectorStore added in v0.4.0

func NewEphemeralSectorStore() *EphemeralSectorStore

NewEphemeralSectorStore creates an EphemeralSectorStore for testing.

func (*EphemeralSectorStore) HasSector added in v0.6.0

func (es *EphemeralSectorStore) HasSector(root types.Hash256) (bool, error)

HasSector checks if a sector is stored in the store.

func (*EphemeralSectorStore) ReadSector added in v0.4.0

func (es *EphemeralSectorStore) ReadSector(root types.Hash256) (*[proto4.SectorSize]byte, error)

ReadSector reads a sector from the EphemeralSectorStore.

func (*EphemeralSectorStore) StoreSector added in v0.6.0

func (es *EphemeralSectorStore) StoreSector(root types.Hash256, sector *[proto4.SectorSize]byte, expiration uint64) error

StoreSector stores a sector in the EphemeralSectorStore.

type EphemeralSettingsReporter added in v0.4.0

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

An EphemeralSettingsReporter is an in-memory minimal rhp4.SettingsReporter for testing.

func NewEphemeralSettingsReporter added in v0.4.0

func NewEphemeralSettingsReporter() *EphemeralSettingsReporter

NewEphemeralSettingsReporter creates an EphemeralSettingsReporter for testing.

func (*EphemeralSettingsReporter) RHP4Settings added in v0.4.0

func (esr *EphemeralSettingsReporter) RHP4Settings() proto4.HostSettings

RHP4Settings implements the rhp4.SettingsReporter interface.

func (*EphemeralSettingsReporter) Update added in v0.4.0

func (esr *EphemeralSettingsReporter) Update(settings proto4.HostSettings)

Update updates the settings reported by the EphemeralSettingsReporter.

type EphemeralWalletStore

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

An EphemeralWalletStore is a Store that does not persist its state to disk. It is primarily useful for testing or as a reference implementation.

func NewEphemeralWalletStore

func NewEphemeralWalletStore() *EphemeralWalletStore

NewEphemeralWalletStore returns a new EphemeralWalletStore.

func (*EphemeralWalletStore) Tip

Tip returns the last indexed tip of the wallet.

func (*EphemeralWalletStore) UnspentSiacoinElements

func (es *EphemeralWalletStore) UnspentSiacoinElements() (utxos []types.SiacoinElement, _ error)

UnspentSiacoinElements returns the wallet's unspent siacoin outputs.

func (*EphemeralWalletStore) UpdateChainState added in v0.0.4

func (es *EphemeralWalletStore) UpdateChainState(fn func(ux wallet.UpdateTx) error) error

UpdateChainState applies and reverts chain updates to the wallet.

func (*EphemeralWalletStore) WalletEventCount added in v0.0.2

func (es *EphemeralWalletStore) WalletEventCount() (uint64, error)

WalletEventCount returns the number of events relevant to the wallet.

func (*EphemeralWalletStore) WalletEvents added in v0.0.2

func (es *EphemeralWalletStore) WalletEvents(offset, limit int) ([]wallet.Event, error)

WalletEvents returns the wallet's events.

Jump to

Keyboard shortcuts

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