test

package
v1.0.4 Latest Latest
Warning

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

Go to latest
Published: Mar 27, 2024 License: MIT Imports: 39 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: 2 * time.Minute,

	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 NewEmptyHost added in v1.0.0

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

NewEmptyHost initializes a new test host

func NewHost

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

NewHost initializes a new test host

func (*Host) Accounts added in v0.2.0

func (h *Host) Accounts() *accounts.AccountManager

Accounts returns the host's account manager

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) RHP2Addr added in v0.2.0

func (h *Host) RHP2Addr() string

RHP2Addr returns the address of the rhp2 listener

func (*Host) RHP2Settings added in v0.2.0

func (h *Host) RHP2Settings() (crhp2.HostSettings, error)

RHP2Settings returns the host's current rhp2 settings

func (*Host) RHP3Addr added in v0.2.0

func (h *Host) RHP3Addr() string

RHP3Addr returns the address of the rhp3 listener

func (*Host) RHP3PriceTable added in v0.2.0

func (h *Host) RHP3PriceTable() (crhp3.HostPriceTable, error)

RHP3PriceTable returns the host's current rhp3 price table

func (*Host) RHP3WSAddr added in v0.2.0

func (h *Host) RHP3WSAddr() string

RHP3WSAddr returns the address of the rhp3 WebSocket listener

func (*Host) Settings added in v1.0.0

func (h *Host) Settings() *settings.ConfigManager

Settings returns the host's settings manager

func (*Host) Storage

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

Storage returns the host's storage manager

func (*Host) Store added in v0.2.0

func (h *Host) Store() *sqlite.Store

Store returns the host's database

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() *chain.TransactionPool

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) (crhp2.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) (*rhp2.RHP2Session, 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) (*rhp3.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) (crhp2.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 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
v2
v3

Jump to

Keyboard shortcuts

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