test

package
v0.1.4 Latest Latest
Warning

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

Go to latest
Published: Aug 7, 2023 License: MIT Imports: 37 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultSettings = settings.Settings{
	AcceptingContracts:  true,
	MaxContractDuration: blocksPerMonth * 3,
	WindowSize:          144,
	MaxCollateral:       types.Siacoins(5000),

	ContractPrice: types.Siacoins(1).Div64(4),

	BaseRPCPrice:      types.NewCurrency64(100),
	SectorAccessPrice: types.NewCurrency64(100),

	CollateralMultiplier: 2.0,
	StoragePrice:         types.Siacoins(100).Div64(1e12).Div64(blocksPerMonth),
	EgressPrice:          types.Siacoins(100).Div64(1e12),
	IngressPrice:         types.Siacoins(100).Div64(1e12),

	PriceTableValidity: 30 * time.Second,

	AccountExpiry:     30 * 24 * time.Hour,
	MaxAccountBalance: types.Siacoins(10),
	SectorCacheSize:   64,
}

DefaultSettings returns the default settings for the test host

Functions

func NewTestingPair

func NewTestingPair(dir string, log *zap.Logger) (*Renter, *Host, error)

NewTestingPair creates a new renter and host pair, connects them to each other, and funds both wallets.

Types

type Consensus

type Consensus interface {
	AcceptBlock(types.Block) error
}

Consensus defines a minimal interface needed by the miner to interact with the consensus set

type Host

type Host struct {
	*Node
	// contains filtered or unexported fields
}

A Host is an ephemeral host that can be used for testing.

func NewHost

func NewHost(privKey types.PrivateKey, dir string, node *Node, log *zap.Logger) (*Host, error)

NewHost initializes a new test host

func (*Host) AddVolume

func (h *Host) AddVolume(path string, size uint64) error

AddVolume adds a new volume to the host

func (*Host) Close

func (h *Host) Close() error

Close shutsdown the host

func (*Host) Contracts

func (h *Host) Contracts() *contracts.ContractManager

Contracts returns the host's contract manager

func (*Host) PublicKey

func (h *Host) PublicKey() types.PublicKey

PublicKey returns the host's public key

func (*Host) RHPv2Addr

func (h *Host) RHPv2Addr() string

RHPv2Addr returns the address of the RHPv2 listener

func (*Host) RHPv2Settings

func (h *Host) RHPv2Settings() (crhpv2.HostSettings, error)

RHPv2Settings returns the host's current RHPv2 settings

func (*Host) RHPv3Addr

func (h *Host) RHPv3Addr() string

RHPv3Addr returns the address of the RHPv3 listener

func (*Host) RHPv3PriceTable

func (h *Host) RHPv3PriceTable() (crhpv3.HostPriceTable, error)

RHPv3PriceTable returns the host's current RHPv3 price table

func (*Host) RHPv3WSAddr

func (h *Host) RHPv3WSAddr() string

RHPv3WSAddr returns the address of the RHPv3 WebSocket listener

func (*Host) Storage

func (h *Host) Storage() *storage.VolumeManager

Storage returns the host's storage manager

func (*Host) UpdateSettings

func (h *Host) UpdateSettings(settings settings.Settings) error

UpdateSettings updates the host's configuration

func (*Host) WalletAddress

func (h *Host) WalletAddress() types.Address

WalletAddress returns the host's wallet address

type Miner

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

A Miner is a CPU miner that can mine blocks, sending the reward to a specified address.

func NewMiner

func NewMiner(consensus Consensus) *Miner

NewMiner initializes a new CPU miner

func (*Miner) Mine

func (m *Miner) Mine(addr types.Address, n int) error

Mine mines n blocks, sending the reward to addr

func (*Miner) ProcessConsensusChange

func (m *Miner) ProcessConsensusChange(cc modules.ConsensusChange)

ProcessConsensusChange implements modules.ConsensusSetSubscriber.

func (*Miner) ReceiveUpdatedUnconfirmedTransactions

func (m *Miner) ReceiveUpdatedUnconfirmedTransactions(diff *modules.TransactionPoolDiff)

ReceiveUpdatedUnconfirmedTransactions implements modules.TransactionPoolSubscriber

type Node

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

A Node is a base Sia node that can be extended by a Renter or Host

func NewNode

func NewNode(dir string) (*Node, error)

NewNode creates a new Sia node and wallet with the given key

func (*Node) ChainManager

func (n *Node) ChainManager() *chain.Manager

ChainManager returns the chain manager

func (*Node) Close

func (n *Node) Close() error

Close closes the node

func (*Node) ConnectPeer

func (n *Node) ConnectPeer(addr string) error

ConnectPeer connects the host's gateway to a peer

func (*Node) GatewayAddr

func (n *Node) GatewayAddr() string

GatewayAddr returns the address of the gateway

func (*Node) MineBlocks

func (n *Node) MineBlocks(address types.Address, count int) error

MineBlocks mines n blocks sending the reward to address

func (*Node) TPool

func (n *Node) TPool() *TXPool

TPool returns the transaction pool

func (*Node) TipState

func (n *Node) TipState() consensus.State

TipState returns the current consensus state.

type Renter

type Renter struct {
	*Node
	// contains filtered or unexported fields
}

A Renter is an ephemeral renter that can be used for testing

func NewRenter

func NewRenter(privKey types.PrivateKey, dir string, node *Node, log *zap.Logger) (*Renter, error)

NewRenter creates a new renter for testing

func (*Renter) Close

func (r *Renter) Close() error

Close shutsdown the renter

func (*Renter) FormContract

func (r *Renter) FormContract(ctx context.Context, hostAddr string, hostKey types.PublicKey, renterPayout, hostCollateral types.Currency, duration uint64) (rhpv2.ContractRevision, error)

FormContract forms a contract with the host

func (*Renter) NewRHP2Session

func (r *Renter) NewRHP2Session(ctx context.Context, hostAddr string, hostKey types.PublicKey, contractID types.FileContractID) (*worker.Session, error)

NewRHP2Session creates a new session, locks a contract, and retrieves the host's settings

func (*Renter) NewRHP3Session

func (r *Renter) NewRHP3Session(ctx context.Context, hostAddr string, hostKey types.PublicKey) (*rhpv3.Session, error)

NewRHP3Session creates a new session

func (*Renter) PrivateKey

func (r *Renter) PrivateKey() types.PrivateKey

PrivateKey returns the renter's private key

func (*Renter) PublicKey

func (r *Renter) PublicKey() types.PublicKey

PublicKey returns the renter's public key

func (*Renter) Settings

func (r *Renter) Settings(ctx context.Context, hostAddr string, hostKey types.PublicKey) (rhpv2.HostSettings, error)

Settings returns the host's current settings

func (*Renter) Wallet

func (r *Renter) Wallet() *wallet.SingleAddressWallet

Wallet returns the renter's wallet

func (*Renter) WalletAddress

func (r *Renter) WalletAddress() types.Address

WalletAddress returns the renter's wallet address

type TXPool

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

TXPool wraps a siad transaction pool with core types.

func (TXPool) AcceptTransactionSet

func (tp TXPool) AcceptTransactionSet(txns []types.Transaction) error

AcceptTransactionSet adds a transaction set to the pool.

func (TXPool) RecommendedFee

func (tp TXPool) RecommendedFee() (fee types.Currency)

RecommendedFee returns the recommended fee for a transaction.

func (TXPool) Subscribe

func (tp TXPool) Subscribe(subscriber modules.TransactionPoolSubscriber)

Subscribe subscribes to the transaction pool.

func (TXPool) Transactions

func (tp TXPool) Transactions() []types.Transaction

Transactions returns all transactions in the pool.

func (TXPool) UnconfirmedParents

func (tp TXPool) UnconfirmedParents(txn types.Transaction) ([]types.Transaction, error)

UnconfirmedParents returns the parents of a transaction in the pool.

type Wallet

type Wallet struct {
	*Node
	*wallet.SingleAddressWallet
	// contains filtered or unexported fields
}

A Wallet is an ephemeral wallet that can be used for testing.

func NewWallet

func NewWallet(privKey types.PrivateKey, dir string, log *zap.Logger) (*Wallet, error)

NewWallet initializes a new test wallet.

func (*Wallet) Close

func (w *Wallet) Close() error

Close closes the wallet.

func (*Wallet) SendSiacoins

func (w *Wallet) SendSiacoins(outputs []types.SiacoinOutput) (txn types.Transaction, err error)

SendSiacoins helper func to send siacoins from a wallet.

func (*Wallet) Store

func (w *Wallet) Store() *sqlite.Store

Store returns the wallet's store.

Directories

Path Synopsis
rhp
v3

Jump to

Keyboard shortcuts

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