Documentation ¶
Index ¶
- Constants
- func ApplyTestMessage(st state.Tree, store vm.Storage, msg *types.UnsignedMessage, bh abi.ChainEpoch) (*consensus.ApplicationResult, error)
- func ApplyTestMessageWithActors(actors vm.ActorCodeLoader, st state.Tree, store vm.Storage, ...) (*consensus.ApplicationResult, error)
- func ApplyTestMessageWithGas(actors vm.ActorCodeLoader, st state.Tree, store vm.Storage, ...) (*consensus.ApplicationResult, error)
- func AutoSealInterval(autoSealInterval string) func(*TestDaemon)
- func CmdTimeout(t time.Duration) func(*TestDaemon)
- func ContainerDir(dir string) func(*TestDaemon)
- func CreateAndApplyTestMessage(t *testing.T, st state.Tree, vms vm.Storage, to address.Address, ...) (*consensus.ApplicationResult, error)
- func CreateAndApplyTestMessageFrom(t *testing.T, st state.Tree, vms vm.Storage, from address.Address, ...) (*consensus.ApplicationResult, error)
- func DefaultAddress(defaultAddr address.Address) func(*TestDaemon)
- func GenesisFile(a string) func(*TestDaemon)
- func GenesisFilePath() string
- func GetFilecoinBinary() (string, error)
- func GetFreePort() (int, error)
- func InitArgs(a ...string) func(*TestDaemon)
- func IsRelay(td *TestDaemon)
- func KeyFile(kf string) func(*TestDaemon)
- func MakeCommitment() []byte
- func MakeCommitments() types.Commitments
- func MakeRandomBytes(size int) []byte
- func MustGetFilecoinBinary() string
- func NewFakeHost() host.Host
- func NewFakeProcessor() *consensus.DefaultProcessor
- func RandPeerID() (peer.ID, error)
- func RequireInitAccountActor(ctx context.Context, t *testing.T, st state.Tree, vms vm.Storage, ...) (*actor.Actor, address.Address)
- func RequireIntPeerID(t *testing.T, i int64) peer.ID
- func RequireLookupActor(ctx context.Context, t *testing.T, st state.Tree, vms vm.Storage, ...) (*actor.Actor, address.Address)
- func RequireMakeStateTree(t *testing.T, cst cbor.IpldStore, acts map[address.Address]*actor.Actor) (cid.Cid, *state.State)
- func RequireNewFakeActor(t *testing.T, vms vm.Storage, addr address.Address, codeCid cid.Cid) *actor.Actor
- func RequireNewFakeActorWithTokens(t *testing.T, vms vm.Storage, addr address.Address, codeCid cid.Cid, ...) *actor.Actor
- func RequireNewInitActor(t *testing.T, vms vm.Storage) *actor.Actor
- func RequireNewMinerActor(ctx context.Context, t *testing.T, st state.Tree, vms vm.Storage, ...) (*actor.Actor, address.Address)
- func RequireRandomPeerID(t *testing.T) peer.ID
- func RequireSignedTestBlockFromTipSet(t *testing.T, baseTipSet block.TipSet, stateRootCid cid.Cid, ...) *block.Block
- func RunInit(td *TestDaemon, opts ...string) ([]byte, error)
- func RunSuccessFirstLine(td *TestDaemon, args ...string) string
- func RunSuccessLines(td *TestDaemon, args ...string) []string
- func ShouldInit(i bool) func(*TestDaemon)
- func VMStorage() vm.Storage
- func WaitForIt(count int, delay time.Duration, cb func() (bool, error)) error
- func WaitTimeout(wg *sync.WaitGroup, timeout time.Duration) bool
- func WithMiner(m address.Address) func(*TestDaemon)
- type CmdOutput
- func (o *CmdOutput) AssertFail(err string) *CmdOutput
- func (o *CmdOutput) AssertSuccess() *CmdOutput
- func (o *CmdOutput) ReadStderr() string
- func (o *CmdOutput) ReadStdout() string
- func (o *CmdOutput) ReadStdoutTrimNewlines() string
- func (o *CmdOutput) SetInvocationError(executionErr error)
- func (o *CmdOutput) SetStatus(status int)
- func (o *CmdOutput) Status() (int, error)
- func (o *CmdOutput) Stderr() []byte
- func (o *CmdOutput) Stdout() []byte
- type FakeBlockValidator
- func (fbv *FakeBlockValidator) ValidateMessagesSyntax(ctx context.Context, messages []*types.SignedMessage) error
- func (fbv *FakeBlockValidator) ValidateReceiptsSyntax(ctx context.Context, receipts []vm.MessageReceipt) error
- func (fbv *FakeBlockValidator) ValidateSemantic(ctx context.Context, child *block.Block, parents block.TipSet) error
- func (fbv *FakeBlockValidator) ValidateSyntax(ctx context.Context, blk *block.Block) error
- func (fbv *FakeBlockValidator) ValidateUnsignedMessagesSyntax(ctx context.Context, messages []*types.UnsignedMessage) error
- type FakeDialer
- func (fd *FakeDialer) ClosePeer(peer.ID) error
- func (fd *FakeDialer) Connectedness(peer.ID) inet.Connectedness
- func (fd *FakeDialer) Conns() []inet.Conn
- func (fd *FakeDialer) ConnsToPeer(peer.ID) []inet.Conn
- func (fd *FakeDialer) DialPeer(context.Context, peer.ID) (inet.Conn, error)
- func (fd *FakeDialer) LocalPeer() peer.ID
- func (fd *FakeDialer) Notify(inet.Notifiee)
- func (fd *FakeDialer) Peers() []peer.ID
- func (fd *FakeDialer) Peerstore() peerstore.Peerstore
- func (fd *FakeDialer) StopNotify(inet.Notifiee)
- type FakeHost
- func (fh *FakeHost) Addrs() []ma.Multiaddr
- func (fh *FakeHost) Close() error
- func (fh *FakeHost) ConnManager() connmgr.ConnManager
- func (fh *FakeHost) Connect(ctx context.Context, pi peer.AddrInfo) error
- func (fh *FakeHost) EventBus() event.Bus
- func (fh *FakeHost) ID() peer.ID
- func (fh *FakeHost) Mux() protocol.Switch
- func (fh *FakeHost) Network() inet.Network
- func (fh *FakeHost) NewStream(context.Context, peer.ID, ...protocol.ID) (inet.Stream, error)
- func (fh *FakeHost) Peerstore() peerstore.Peerstore
- func (fh *FakeHost) RemoveStreamHandler(protocol.ID)
- func (fh *FakeHost) SetStreamHandler(protocol.ID, inet.StreamHandler)
- func (fh *FakeHost) SetStreamHandlerMatch(protocol.ID, func(string) bool, inet.StreamHandler)
- type FakeWorkerPorcelainAPI
- func (t *FakeWorkerPorcelainAPI) BlockTime() time.Duration
- func (t *FakeWorkerPorcelainAPI) FaultsStateView(_ block.TipSetKey) (consensus.FaultStateView, error)
- func (t *FakeWorkerPorcelainAPI) PowerStateView(_ block.TipSetKey) (consensus.PowerStateView, error)
- func (t *FakeWorkerPorcelainAPI) SampleChainRandomness(ctx context.Context, head block.TipSetKey, tag acrypto.DomainSeparationTag, ...) (abi.Randomness, error)
- type MockMessagePoolValidator
- type StubBlockValidator
- func (mbv *StubBlockValidator) StubSemanticValidationForBlock(child *block.Block, err error)
- func (mbv *StubBlockValidator) StubSyntaxValidationForBlock(blk *block.Block, err error)
- func (mbv *StubBlockValidator) ValidateSemantic(ctx context.Context, child *block.Block, parents *block.TipSet, _ uint64) error
- func (mbv *StubBlockValidator) ValidateSyntax(ctx context.Context, blk *block.Block) error
- type TestDaemon
- func (td *TestDaemon) CmdAddr() (ma.Multiaddr, error)
- func (td *TestDaemon) Config() *config.Config
- func (td *TestDaemon) ConnectSuccess(remote *TestDaemon) *CmdOutput
- func (td *TestDaemon) CreateAddress() string
- func (td *TestDaemon) CreateStorageMinerAddr(peer *TestDaemon, fromAddr address.Address) address.Address
- func (td *TestDaemon) GetAddresses() []string
- func (td *TestDaemon) GetChainHead() []block.Block
- func (td *TestDaemon) GetDefaultAddress() string
- func (td *TestDaemon) GetID() string
- func (td *TestDaemon) GetMinerAddress() address.Address
- func (td *TestDaemon) MakeMoney(rewards int, peers ...*TestDaemon)
- func (td *TestDaemon) MineAndPropagate(wait time.Duration, peers ...*TestDaemon)
- func (td *TestDaemon) MinerSetPrice(minerAddr address.Address, fromAddr address.Address, price string, ...) cid.Cid
- func (td *TestDaemon) MustHaveChainHeadBy(wait time.Duration, peers []*TestDaemon)
- func (td *TestDaemon) MustUnmarshalChain(input string) [][]block.Block
- func (td *TestDaemon) ReadStderr() string
- func (td *TestDaemon) ReadStdout() string
- func (td *TestDaemon) RepoDir() string
- func (td *TestDaemon) Restart() *TestDaemon
- func (td *TestDaemon) Run(args ...string) *CmdOutput
- func (td *TestDaemon) RunFail(err string, args ...string) *CmdOutput
- func (td *TestDaemon) RunSuccess(args ...string) *CmdOutput
- func (td *TestDaemon) RunWithStdin(stdin io.Reader, args ...string) *CmdOutput
- func (td *TestDaemon) SectorDir() string
- func (td *TestDaemon) Shutdown()
- func (td *TestDaemon) ShutdownEasy()
- func (td *TestDaemon) ShutdownSuccess()
- func (td *TestDaemon) Start() *TestDaemon
- func (td *TestDaemon) Stop() *TestDaemon
- func (td *TestDaemon) UpdatePeerID()
- func (td *TestDaemon) WaitForAPI() error
- func (td *TestDaemon) WaitForMessageRequireSuccess(msgCid cid.Cid) *vm.MessageReceipt
- type TestFetcher
- func (f *TestFetcher) AddSourceBlocks(blocks ...*block.Block)
- func (f *TestFetcher) FetchTipSetHeaders(ctx context.Context, tsKey block.TipSetKey, from peer.ID, ...) ([]block.TipSet, error)
- func (f *TestFetcher) FetchTipSets(ctx context.Context, tsKey block.TipSetKey, from peer.ID, ...) ([]block.TipSet, error)
- func (f *TestFetcher) GetBlocks(ctx context.Context, cids []cid.Cid) ([]*block.Block, error)
Constants ¶
const BlockTimeTest = time.Second
BlockTimeTest is the block time used by workers during testing.
const ( // DefaultDaemonCmdTimeout is the default timeout for executing commands. DefaultDaemonCmdTimeout = 1 * time.Minute )
Variables ¶
This section is empty.
Functions ¶
func ApplyTestMessage ¶
func ApplyTestMessage(st state.Tree, store vm.Storage, msg *types.UnsignedMessage, bh abi.ChainEpoch) (*consensus.ApplicationResult, error)
ApplyTestMessage sends a message directly to the vm, bypassing message validation
func ApplyTestMessageWithActors ¶
func ApplyTestMessageWithActors(actors vm.ActorCodeLoader, st state.Tree, store vm.Storage, msg *types.UnsignedMessage, bh abi.ChainEpoch) (*consensus.ApplicationResult, error)
ApplyTestMessageWithActors sends a message directly to the vm with a given set of builtin actors
func ApplyTestMessageWithGas ¶
func ApplyTestMessageWithGas(actors vm.ActorCodeLoader, st state.Tree, store vm.Storage, msg *types.UnsignedMessage, bh abi.ChainEpoch, minerOwner address.Address) (*consensus.ApplicationResult, error)
ApplyTestMessageWithGas uses the FakeBlockRewarder but the default SignedMessageValidator
func AutoSealInterval ¶
func AutoSealInterval(autoSealInterval string) func(*TestDaemon)
AutoSealInterval specifies an interval for automatically sealing
func CmdTimeout ¶
func CmdTimeout(t time.Duration) func(*TestDaemon)
CmdTimeout allows setting the `cmdTimeout` config option on the daemon.
func ContainerDir ¶
func ContainerDir(dir string) func(*TestDaemon)
ContainerDir sets the `containerDir` path for the daemon.
func CreateAndApplyTestMessage ¶
func CreateAndApplyTestMessage(t *testing.T, st state.Tree, vms vm.Storage, to address.Address, val, bh uint64, method abi.MethodNum, ancestors []block.TipSet, params ...interface{}) (*consensus.ApplicationResult, error)
CreateAndApplyTestMessage wraps the given parameters in a message and calls CreateAndApplyTestMessageFrom sending the message from address.TestAddress
func CreateAndApplyTestMessageFrom ¶
func CreateAndApplyTestMessageFrom(t *testing.T, st state.Tree, vms vm.Storage, from address.Address, to address.Address, val, bh uint64, method abi.MethodNum, ancestors []block.TipSet, params ...interface{}) (*consensus.ApplicationResult, error)
CreateAndApplyTestMessageFrom wraps the given parameters in a message and calls ApplyTestMessage.
func DefaultAddress ¶
func DefaultAddress(defaultAddr address.Address) func(*TestDaemon)
DefaultAddress specifies a key file for this daemon to add to their wallet during init
func GenesisFile ¶
func GenesisFile(a string) func(*TestDaemon)
GenesisFile allows setting the `genesisFile` config option on the daemon.
func GenesisFilePath ¶
func GenesisFilePath() string
GenesisFilePath returns the path to the test genesis
func GetFilecoinBinary ¶
GetFilecoinBinary returns the path where the filecoin binary will be if it has been built
func GetFreePort ¶
GetFreePort gets a free port from the kernel Credit: https://github.com/phayes/freeport
func InitArgs ¶
func InitArgs(a ...string) func(*TestDaemon)
InitArgs allows setting additional arguments to repo initialization
func KeyFile ¶
func KeyFile(kf string) func(*TestDaemon)
KeyFile specifies a key file for this daemon to add to their wallet during init
func MakeCommitments ¶
func MakeCommitments() types.Commitments
MakeCommitments creates three random commitments for constructing a types.Commitments.
func MakeRandomBytes ¶
MakeRandomBytes generates a randomized byte slice of size 'size'
func MustGetFilecoinBinary ¶
func MustGetFilecoinBinary() string
MustGetFilecoinBinary returns the path where the filecoin binary will be if it has been built and panics otherwise.
func NewFakeHost ¶
NewFakeHost constructs a FakeHost with no other parameters needed
func NewFakeProcessor ¶
func NewFakeProcessor() *consensus.DefaultProcessor
NewFakeProcessor creates a processor with a test validator and test rewarder
func RandPeerID ¶
RandPeerID is a libp2p random peer ID generator. These peer.ID generators were copied from libp2p/go-testutil. We didn't bring in the whole repo as a dependency because we only need this small bit. However if we find ourselves using more and more pieces we should just take a dependency on it.
func RequireInitAccountActor ¶
func RequireInitAccountActor(ctx context.Context, t *testing.T, st state.Tree, vms vm.Storage, addr address.Address, balance types.AttoFIL) (*actor.Actor, address.Address)
RequireInitAccountActor initializes an account actor
func RequireIntPeerID ¶
RequireIntPeerID takes in an integer and creates a unique peer id for it.
func RequireLookupActor ¶
func RequireLookupActor(ctx context.Context, t *testing.T, st state.Tree, vms vm.Storage, actorAddr address.Address) (*actor.Actor, address.Address)
RequireLookupActor converts the given address to an id address before looking up the actor in the state tree
func RequireMakeStateTree ¶
func RequireMakeStateTree(t *testing.T, cst cbor.IpldStore, acts map[address.Address]*actor.Actor) (cid.Cid, *state.State)
RequireMakeStateTree takes a map of addresses to actors and stores them on the state tree, requiring that all its steps succeed.
func RequireNewFakeActor ¶
func RequireNewFakeActor(t *testing.T, vms vm.Storage, addr address.Address, codeCid cid.Cid) *actor.Actor
RequireNewFakeActor instantiates and returns a new fake actor and requires that its steps succeed.
func RequireNewFakeActorWithTokens ¶
func RequireNewFakeActorWithTokens(t *testing.T, vms vm.Storage, addr address.Address, codeCid cid.Cid, amt types.AttoFIL) *actor.Actor
RequireNewFakeActorWithTokens instantiates and returns a new fake actor and requires that its steps succeed.
func RequireNewInitActor ¶
RequireNewInitActor instantiates and returns a new init actor
func RequireNewMinerActor ¶
func RequireNewMinerActor(ctx context.Context, t *testing.T, st state.Tree, vms vm.Storage, owner address.Address, pledge uint64, pid peer.ID, coll types.AttoFIL) (*actor.Actor, address.Address)
RequireNewMinerActor creates a new miner actor with the given owner, pledge, and collateral, and requires that its steps succeed.
func RequireRandomPeerID ¶
RequireRandomPeerID returns a new libp2p peer ID or panics.
func RequireSignedTestBlockFromTipSet ¶
func RequireSignedTestBlockFromTipSet(t *testing.T, baseTipSet block.TipSet, stateRootCid cid.Cid, receiptRootCid cid.Cid, height abi.ChainEpoch, minerAddr address.Address, minerWorker address.Address, signer types.Signer) *block.Block
RequireSignedTestBlockFromTipSet creates a block with a valid signature by the passed in miner work and a Miner field set to the minerAddr.
func RunInit ¶
func RunInit(td *TestDaemon, opts ...string) ([]byte, error)
RunInit is the equivalent of executing `go-filecoin init`.
func RunSuccessFirstLine ¶
func RunSuccessFirstLine(td *TestDaemon, args ...string) string
RunSuccessFirstLine executes the given command, asserts success and returns the first line of stdout.
func RunSuccessLines ¶
func RunSuccessLines(td *TestDaemon, args ...string) []string
RunSuccessLines executes the given command, asserts success and returns an array of lines of the stdout.
func ShouldInit ¶
func ShouldInit(i bool) func(*TestDaemon)
ShouldInit allows setting the `init` config option on the daemon. If set, `go-filecoin init` is run before starting up the daemon.
func WaitTimeout ¶
WaitTimeout waits for the waitgroup for the specified max timeout. Returns true if waiting timed out.
func WithMiner ¶
func WithMiner(m address.Address) func(*TestDaemon)
WithMiner allows setting the --with-miner flag on init.
Types ¶
type CmdOutput ¶
type CmdOutput struct { // Args is the command and argument sequence executed. Args []string // contains filtered or unexported fields }
CmdOutput collects the output from a CLI command issued to a process.
func ReadOutput ¶
ReadOutput reads the `stdout` and `stderr` streams completely and returns a new Output object.
func (*CmdOutput) AssertFail ¶
AssertFail asserts that the output represents a failed execution, with the error matching the passed in error.
func (*CmdOutput) AssertSuccess ¶
AssertSuccess asserts that the output represents a successful execution.
func (*CmdOutput) ReadStderr ¶
ReadStderr returns a string representation of the stderr output.
func (*CmdOutput) ReadStdout ¶
ReadStdout returns a string representation of the stdout output.
func (*CmdOutput) ReadStdoutTrimNewlines ¶
ReadStdoutTrimNewlines returns a string representation of stdout, with trailing line breaks removed.
func (*CmdOutput) SetInvocationError ¶
SetInvocationError sets the error for an unsuccessful invocation. May not be called if a status code has been set (probably indicating a usage error).
func (*CmdOutput) SetStatus ¶
SetStatus sets the status code for a successful invocation. May not be called if a status code has been set (probably indicating a usage error).
func (*CmdOutput) Status ¶
Status returns the status code and any error value from execution. The status code and any output streams are valid only if error is nil.
type FakeBlockValidator ¶
type FakeBlockValidator struct{}
FakeBlockValidator passes everything as valid
func NewFakeBlockValidator ¶
func NewFakeBlockValidator() *FakeBlockValidator
NewFakeBlockValidator createas a FakeBlockValidator that passes everything as valid.
func (*FakeBlockValidator) ValidateMessagesSyntax ¶
func (fbv *FakeBlockValidator) ValidateMessagesSyntax(ctx context.Context, messages []*types.SignedMessage) error
ValidateMessagesSyntax does nothing
func (*FakeBlockValidator) ValidateReceiptsSyntax ¶
func (fbv *FakeBlockValidator) ValidateReceiptsSyntax(ctx context.Context, receipts []vm.MessageReceipt) error
ValidateReceiptsSyntax does nothing
func (*FakeBlockValidator) ValidateSemantic ¶
func (fbv *FakeBlockValidator) ValidateSemantic(ctx context.Context, child *block.Block, parents block.TipSet) error
ValidateSemantic does nothing.
func (*FakeBlockValidator) ValidateSyntax ¶
ValidateSyntax does nothing.
func (*FakeBlockValidator) ValidateUnsignedMessagesSyntax ¶
func (fbv *FakeBlockValidator) ValidateUnsignedMessagesSyntax(ctx context.Context, messages []*types.UnsignedMessage) error
ValidateUnsignedMessagesSyntax does nothing
type FakeDialer ¶
FakeDialer is a test inet.Dialer
func (*FakeDialer) Connectedness ¶
func (fd *FakeDialer) Connectedness(peer.ID) inet.Connectedness
func (*FakeDialer) Conns ¶
func (fd *FakeDialer) Conns() []inet.Conn
func (*FakeDialer) ConnsToPeer ¶
func (fd *FakeDialer) ConnsToPeer(peer.ID) []inet.Conn
func (*FakeDialer) LocalPeer ¶
func (fd *FakeDialer) LocalPeer() peer.ID
func (*FakeDialer) Notify ¶
func (fd *FakeDialer) Notify(inet.Notifiee)
func (*FakeDialer) Peers ¶
func (fd *FakeDialer) Peers() []peer.ID
Peers returns a fake inet.Dialer PeersImpl
func (*FakeDialer) Peerstore ¶
func (fd *FakeDialer) Peerstore() peerstore.Peerstore
func (*FakeDialer) StopNotify ¶
func (fd *FakeDialer) StopNotify(inet.Notifiee)
type FakeHost ¶
FakeHost is a test host.Host
func (*FakeHost) ConnManager ¶
func (fh *FakeHost) ConnManager() connmgr.ConnManager
func (*FakeHost) NewStream ¶
NewStream is required for the host.Host interface; returns a new FakeStream.
func (*FakeHost) RemoveStreamHandler ¶
func (*FakeHost) SetStreamHandler ¶
func (fh *FakeHost) SetStreamHandler(protocol.ID, inet.StreamHandler)
func (*FakeHost) SetStreamHandlerMatch ¶
type FakeWorkerPorcelainAPI ¶
type FakeWorkerPorcelainAPI struct {
// contains filtered or unexported fields
}
FakeWorkerPorcelainAPI implements the WorkerPorcelainAPI>
func NewDefaultFakeWorkerPorcelainAPI ¶
func NewDefaultFakeWorkerPorcelainAPI(signer address.Address, rnd consensus.ChainRandomness) *FakeWorkerPorcelainAPI
NewDefaultFakeWorkerPorcelainAPI returns a FakeWorkerPorcelainAPI.
func NewFakeWorkerPorcelainAPI ¶
func NewFakeWorkerPorcelainAPI(rnd consensus.ChainRandomness, totalPower uint64, minerToWorker map[address.Address]address.Address) *FakeWorkerPorcelainAPI
NewFakeWorkerPorcelainAPI produces an api suitable to use as the worker's porcelain api.
func (*FakeWorkerPorcelainAPI) BlockTime ¶
func (t *FakeWorkerPorcelainAPI) BlockTime() time.Duration
BlockTime returns the blocktime FakeWorkerPorcelainAPI is configured with.
func (*FakeWorkerPorcelainAPI) FaultsStateView ¶
func (t *FakeWorkerPorcelainAPI) FaultsStateView(_ block.TipSetKey) (consensus.FaultStateView, error)
func (*FakeWorkerPorcelainAPI) PowerStateView ¶
func (t *FakeWorkerPorcelainAPI) PowerStateView(_ block.TipSetKey) (consensus.PowerStateView, error)
PowerStateView returns the state view.
func (*FakeWorkerPorcelainAPI) SampleChainRandomness ¶
func (t *FakeWorkerPorcelainAPI) SampleChainRandomness(ctx context.Context, head block.TipSetKey, tag acrypto.DomainSeparationTag, epoch abi.ChainEpoch, entropy []byte) (abi.Randomness, error)
type MockMessagePoolValidator ¶
type MockMessagePoolValidator struct {
Valid bool
}
MockMessagePoolValidator is a mock validator
func NewMockMessagePoolValidator ¶
func NewMockMessagePoolValidator() *MockMessagePoolValidator
NewMockMessagePoolValidator creates a MockMessagePoolValidator
func (*MockMessagePoolValidator) ValidateSignedMessageSyntax ¶
func (v *MockMessagePoolValidator) ValidateSignedMessageSyntax(ctx context.Context, msg *types.SignedMessage) error
Validate returns true if the mock validator is set to validate the message
type StubBlockValidator ¶
type StubBlockValidator struct {
// contains filtered or unexported fields
}
StubBlockValidator is a mockable block validator.
func NewStubBlockValidator ¶
func NewStubBlockValidator() *StubBlockValidator
NewStubBlockValidator creates a StubBlockValidator that allows errors to configured for blocks passed to the Validate* methods.
func (*StubBlockValidator) StubSemanticValidationForBlock ¶
func (mbv *StubBlockValidator) StubSemanticValidationForBlock(child *block.Block, err error)
StubSemanticValidationForBlock stubs an error when the ValidateSemantic is called on the with the given child block.
func (*StubBlockValidator) StubSyntaxValidationForBlock ¶
func (mbv *StubBlockValidator) StubSyntaxValidationForBlock(blk *block.Block, err error)
StubSyntaxValidationForBlock stubs an error when the ValidateSyntax is called on the with the given block.
func (*StubBlockValidator) ValidateSemantic ¶
func (mbv *StubBlockValidator) ValidateSemantic(ctx context.Context, child *block.Block, parents *block.TipSet, _ uint64) error
ValidateSemantic returns nil or error for stubbed block `child`.
func (*StubBlockValidator) ValidateSyntax ¶
ValidateSyntax return nil or error for stubbed block `blk`.
type TestDaemon ¶
type TestDaemon struct { Stdin io.Writer Stdout io.Reader Stderr io.Reader // contains filtered or unexported fields }
TestDaemon is used to manage a Filecoin daemon instance for testing purposes.
func NewDaemon ¶
func NewDaemon(t *testing.T, options ...func(*TestDaemon)) *TestDaemon
NewDaemon creates a new `TestDaemon`, using the passed in configuration options.
func (*TestDaemon) CmdAddr ¶
func (td *TestDaemon) CmdAddr() (ma.Multiaddr, error)
CmdAddr returns the command address of the test daemon (if it is running).
func (*TestDaemon) Config ¶
func (td *TestDaemon) Config() *config.Config
Config is a helper to read out the config of the daemon.
func (*TestDaemon) ConnectSuccess ¶
func (td *TestDaemon) ConnectSuccess(remote *TestDaemon) *CmdOutput
ConnectSuccess connects the daemon to another daemon, asserting that the operation was successful.
func (*TestDaemon) CreateAddress ¶
func (td *TestDaemon) CreateAddress() string
CreateAddress adds a new address to the daemons wallet and returns it. equivalent to:
`go-filecoin address new`
func (*TestDaemon) CreateStorageMinerAddr ¶
func (td *TestDaemon) CreateStorageMinerAddr(peer *TestDaemon, fromAddr address.Address) address.Address
CreateStorageMinerAddr issues a new message to the network, mines the message and returns the address of the new miner equivalent to:
`go-filecoin miner create --from $TEST_ACCOUNT 20`
func (*TestDaemon) GetAddresses ¶
func (td *TestDaemon) GetAddresses() []string
GetAddresses returns all of the addresses of the daemon.
func (*TestDaemon) GetChainHead ¶
func (td *TestDaemon) GetChainHead() []block.Block
GetChainHead returns the blocks in the head tipset from `td`
func (*TestDaemon) GetDefaultAddress ¶
func (td *TestDaemon) GetDefaultAddress() string
GetDefaultAddress returns the default sender address for this daemon.
func (*TestDaemon) GetMinerAddress ¶
func (td *TestDaemon) GetMinerAddress() address.Address
GetMinerAddress returns the miner address for this daemon.
func (*TestDaemon) MakeMoney ¶
func (td *TestDaemon) MakeMoney(rewards int, peers ...*TestDaemon)
MakeMoney mines a block and ensures that the block has been propagated to all peers.
func (*TestDaemon) MineAndPropagate ¶
func (td *TestDaemon) MineAndPropagate(wait time.Duration, peers ...*TestDaemon)
MineAndPropagate mines a block and ensure the block has propagated to all `peers` by comparing the current head block of `td` with the head block of each peer in `peers`
func (*TestDaemon) MinerSetPrice ¶
func (td *TestDaemon) MinerSetPrice(minerAddr address.Address, fromAddr address.Address, price string, expiry string) cid.Cid
MinerSetPrice creates an ask for a CURRENTLY MINING test daemon and waits for it to appears on chain. It returns the cid of the AddAsk message so other daemons can `message wait` for it.
func (*TestDaemon) MustHaveChainHeadBy ¶
func (td *TestDaemon) MustHaveChainHeadBy(wait time.Duration, peers []*TestDaemon)
MustHaveChainHeadBy ensures all `peers` have the same chain head as `td`, by duration `wait`
func (*TestDaemon) MustUnmarshalChain ¶
func (td *TestDaemon) MustUnmarshalChain(input string) [][]block.Block
MustUnmarshalChain unmarshals the chain from `input` into a slice of blocks
func (*TestDaemon) ReadStderr ¶
func (td *TestDaemon) ReadStderr() string
ReadStderr returns a string representation of the stderr of the daemon.
func (*TestDaemon) ReadStdout ¶
func (td *TestDaemon) ReadStdout() string
ReadStdout returns a string representation of the stdout of the daemon.
func (*TestDaemon) RepoDir ¶
func (td *TestDaemon) RepoDir() string
RepoDir returns the repo directory of the test daemon.
func (*TestDaemon) Restart ¶
func (td *TestDaemon) Restart() *TestDaemon
Restart restarts the daemon
func (*TestDaemon) Run ¶
func (td *TestDaemon) Run(args ...string) *CmdOutput
Run executes the given command against the test daemon.
func (*TestDaemon) RunFail ¶
func (td *TestDaemon) RunFail(err string, args ...string) *CmdOutput
RunFail is like Run, but asserts that the command exited with an error matching the passed in error.
func (*TestDaemon) RunSuccess ¶
func (td *TestDaemon) RunSuccess(args ...string) *CmdOutput
RunSuccess is like Run, but asserts that the command exited successfully.
func (*TestDaemon) RunWithStdin ¶
func (td *TestDaemon) RunWithStdin(stdin io.Reader, args ...string) *CmdOutput
RunWithStdin executes the given command against the test daemon, allowing to control stdin of the process.
func (*TestDaemon) SectorDir ¶
func (td *TestDaemon) SectorDir() string
SectorDir returns the sector root directory of the test daemon.
func (*TestDaemon) Shutdown ¶
func (td *TestDaemon) Shutdown()
Shutdown stops the daemon and deletes the repository.
func (*TestDaemon) ShutdownEasy ¶
func (td *TestDaemon) ShutdownEasy()
ShutdownEasy stops the daemon using `SIGINT`.
func (*TestDaemon) ShutdownSuccess ¶
func (td *TestDaemon) ShutdownSuccess()
ShutdownSuccess stops the daemon, asserting that it exited successfully.
func (*TestDaemon) UpdatePeerID ¶
func (td *TestDaemon) UpdatePeerID()
UpdatePeerID updates a currently mining miner's peer ID
func (*TestDaemon) WaitForAPI ¶
func (td *TestDaemon) WaitForAPI() error
WaitForAPI polls if the API on the daemon is available, and blocks until it is.
func (*TestDaemon) WaitForMessageRequireSuccess ¶
func (td *TestDaemon) WaitForMessageRequireSuccess(msgCid cid.Cid) *vm.MessageReceipt
WaitForMessageRequireSuccess accepts a message cid and blocks until a message with matching cid is included in a block. The receipt is then inspected to ensure that the corresponding message receipt had a 0 exit code.
type TestFetcher ¶
type TestFetcher struct {
// contains filtered or unexported fields
}
TestFetcher is an object with the same method set as Fetcher plus a method for adding blocks to the source. It is used to implement an object that behaves like Fetcher but does not go to the network for use in tests.
func NewTestFetcher ¶
func NewTestFetcher() *TestFetcher
NewTestFetcher returns a TestFetcher with no source blocks.
func (*TestFetcher) AddSourceBlocks ¶
func (f *TestFetcher) AddSourceBlocks(blocks ...*block.Block)
AddSourceBlocks adds the input blocks to the fetcher source.
func (*TestFetcher) FetchTipSetHeaders ¶
func (f *TestFetcher) FetchTipSetHeaders(ctx context.Context, tsKey block.TipSetKey, from peer.ID, done func(t block.TipSet) (bool, error)) ([]block.TipSet, error)
FetchTipSetHeaders fetches the tipset at `tsKey` but not messages