Documentation ¶
Index ¶
- Constants
- Variables
- func AssertFilesEqual(t *testing.T, left, right string)
- func CalcFuncSignature(funcName string) []byte
- func CircuitBreaker(t *testing.T, label string, throttle, timeout time.Duration, cb func() bool)
- func CreateImportFile(ctx context.Context, client api.FullNode, rseed int, size int) (res *api.ImportRes, path string, data []byte, err error)
- func CreateRandomCARv1(t *testing.T, rseed, size int, opts ...GeneratedDAGOpts) (carV1FilePath string, origFilePath string)
- func CreateRandomFile(t *testing.T, rseed, size int) (path string)
- func EnsembleMinimal(t *testing.T, opts ...interface{}) (*TestFullNode, *TestMiner, *Ensemble)
- func EnsembleOneTwo(t *testing.T, opts ...interface{}) (*TestFullNode, *TestMiner, *TestMiner, *Ensemble)
- func EnsembleTwoOne(t *testing.T, opts ...interface{}) (*TestFullNode, *TestFullNode, *TestMiner, *Ensemble)
- func EnsembleWithMinerAndMarketNodes(t *testing.T, opts ...interface{}) (*TestFullNode, *TestMiner, *TestMiner, *Ensemble)
- func EnsembleWorker(t *testing.T, opts ...interface{}) (*TestFullNode, *TestMiner, *TestWorker, *Ensemble)
- func EthFunctionHash(sig string) []byte
- func EthTopicHash(sig string) ethtypes.EthHash
- func Expensive(t *testing.T)
- func QuietAllLogsExcept(names ...string)
- func QuietMiningLogs()
- func RunClientTest(t *testing.T, cmds []*lcli.Command, clientNode *TestFullNode)
- func SendFunds(ctx context.Context, t *testing.T, sender *TestFullNode, ...)
- type BlockMiner
- func (bm *BlockMiner) InjectNulls(rounds abi.ChainEpoch)
- func (bm *BlockMiner) MineBlocks(ctx context.Context, blocktime time.Duration)
- func (bm *BlockMiner) MineBlocksMustPost(ctx context.Context, blocktime time.Duration)
- func (bm *BlockMiner) MineUntilBlock(ctx context.Context, fn *TestFullNode, cb func(abi.ChainEpoch))
- func (bm *BlockMiner) Pause()
- func (bm *BlockMiner) Restart()
- func (bm *BlockMiner) Stop()
- type CfgOption
- type ChainPredicate
- type Closer
- type DealHarness
- func (dh *DealHarness) DefaultStartDealParams() api.StartDealParams
- func (dh *DealHarness) ExpectDealFailure(ctx context.Context, deal *cid.Cid, errs string) error
- func (dh *DealHarness) ExtractFileFromCAR(ctx context.Context, file *os.File) string
- func (dh *DealHarness) MakeOnlineDeal(ctx context.Context, params MakeFullDealParams) (deal *cid.Cid, res *api.ImportRes, path string)
- func (dh *DealHarness) PerformRetrieval(ctx context.Context, deal *cid.Cid, root cid.Cid, carExport bool, ...) (path string)
- func (dh *DealHarness) PerformRetrievalWithOrder(ctx context.Context, deal *cid.Cid, root cid.Cid, carExport bool, ...) (path string)
- func (dh *DealHarness) RunConcurrentDeals(opts RunConcurrentDealsOpts)
- func (dh *DealHarness) StartDeal(ctx context.Context, dealParams api.StartDealParams) *cid.Cid
- func (dh *DealHarness) StartRandomDeal(ctx context.Context, params MakeFullDealParams) (deal *cid.Cid, res *api.ImportRes, path string)
- func (dh *DealHarness) StartSealingWaiting(ctx context.Context)
- func (dh *DealHarness) WaitDealPublished(ctx context.Context, deal *cid.Cid)
- func (dh *DealHarness) WaitDealSealed(ctx context.Context, deal *cid.Cid, noseal, noSealStart bool, cb func())
- func (dh *DealHarness) WaitDealSealedQuiet(ctx context.Context, deal *cid.Cid, noseal, noSealStart bool, cb func())
- type EVM
- func (e *EVM) AssertAddressBalanceConsistent(ctx context.Context, addr address.Address) big.Int
- func (e *EVM) ComputeContractAddress(deployer ethtypes.EthAddress, nonce uint64) ethtypes.EthAddress
- func (e *EVM) DeployContract(ctx context.Context, sender address.Address, bytecode []byte) eam.CreateReturn
- func (e *EVM) DeployContractFromFilename(ctx context.Context, binFilename string) (address.Address, address.Address)
- func (e *EVM) DeployContractFromFilenameWithValue(ctx context.Context, binFilename string, value big.Int) (address.Address, address.Address)
- func (e *EVM) DeployContractWithValue(ctx context.Context, sender address.Address, bytecode []byte, value big.Int) eam.CreateReturn
- func (e *EVM) GetEthBlockFromWait(ctx context.Context, wait *api.MsgLookup) ethtypes.EthBlock
- func (e *EVM) InvokeContractByFuncName(ctx context.Context, fromAddr address.Address, idAddr address.Address, ...) ([]byte, *api.MsgLookup, error)
- func (e *EVM) InvokeContractByFuncNameExpectExit(ctx context.Context, fromAddr address.Address, idAddr address.Address, ...)
- func (e *EVM) InvokeSolidity(ctx context.Context, sender address.Address, target address.Address, ...) (*api.MsgLookup, error)
- func (e *EVM) InvokeSolidityWithValue(ctx context.Context, sender address.Address, target address.Address, ...) (*api.MsgLookup, error)
- func (e *EVM) LoadEvents(ctx context.Context, eventsRoot cid.Cid) []types.Event
- func (e *EVM) NewAccount() (*key.Key, ethtypes.EthAddress, address.Address)
- func (e *EVM) SignTransaction(tx *ethtypes.EthTxArgs, privKey []byte)
- func (e *EVM) SubmitTransaction(ctx context.Context, tx *ethtypes.EthTxArgs) ethtypes.EthHash
- func (e *EVM) TransferValueOrFail(ctx context.Context, fromAddr address.Address, toAddr address.Address, ...) *api.MsgLookup
- func (e *EVM) WaitTransaction(ctx context.Context, hash ethtypes.EthHash) (*api.EthTxReceipt, error)
- type Ensemble
- func (n *Ensemble) AddInactiveMiner(m *TestMiner)
- func (n *Ensemble) BeginMining(blocktime time.Duration, miners ...*TestMiner) []*BlockMiner
- func (n *Ensemble) BeginMiningMustPost(blocktime time.Duration, miners ...*TestMiner) []*BlockMiner
- func (n *Ensemble) Connect(from api.Net, to ...api.Net) *Ensemble
- func (n *Ensemble) FullNode(full *TestFullNode, opts ...NodeOpt) *Ensemble
- func (n *Ensemble) InterconnectAll() *Ensemble
- func (n *Ensemble) Miner(minerNode *TestMiner, full *TestFullNode, opts ...NodeOpt) *Ensemble
- func (n *Ensemble) MinerEnroll(minerNode *TestMiner, full *TestFullNode, opts ...NodeOpt) *Ensemble
- func (n *Ensemble) Mocknet() mocknet.Mocknet
- func (n *Ensemble) NewPrivKey() (libp2pcrypto.PrivKey, peer.ID)
- func (n *Ensemble) Start() *Ensemble
- func (n *Ensemble) Worker(minerNode *TestMiner, worker *TestWorker, opts ...NodeOpt) *Ensemble
- type EnsembleOpt
- func Account(key *key.Key, balance abi.TokenAmount) EnsembleOpt
- func GenesisNetworkVersion(nv network.Version) EnsembleOpt
- func LatestActorsAt(upgradeHeight abi.ChainEpoch) EnsembleOpt
- func MockProofs(e ...bool) EnsembleOpt
- func RootVerifier(key *key.Key, balance abi.TokenAmount) EnsembleOpt
- func UpgradeSchedule(upgrades ...stmgr.Upgrade) EnsembleOpt
- type EthFilterBuilder
- func (e *EthFilterBuilder) AddressOneOf(as ...ethtypes.EthAddress) *EthFilterBuilder
- func (e *EthFilterBuilder) BlockHash(h ethtypes.EthHash) *EthFilterBuilder
- func (e *EthFilterBuilder) Filter() *ethtypes.EthFilterSpec
- func (e *EthFilterBuilder) FromBlock(v string) *EthFilterBuilder
- func (e *EthFilterBuilder) FromBlockEpoch(v abi.ChainEpoch) *EthFilterBuilder
- func (e *EthFilterBuilder) ToBlock(v string) *EthFilterBuilder
- func (e *EthFilterBuilder) ToBlockEpoch(v abi.ChainEpoch) *EthFilterBuilder
- func (e *EthFilterBuilder) Topic1OneOf(hs ...ethtypes.EthHash) *EthFilterBuilder
- func (e *EthFilterBuilder) Topic2OneOf(hs ...ethtypes.EthHash) *EthFilterBuilder
- func (e *EthFilterBuilder) Topic3OneOf(hs ...ethtypes.EthHash) *EthFilterBuilder
- func (e *EthFilterBuilder) Topic4OneOf(hs ...ethtypes.EthHash) *EthFilterBuilder
- type GeneratedDAGOpts
- type ItestdNotif
- type Libp2p
- type MakeFullDealParams
- type MinerSubsystem
- type MockCLI
- type MockCLIClient
- type NodeOpt
- func ConstructorOpts(extra ...node.Option) NodeOpt
- func DisableEthRPC() NodeOpt
- func DisableLibp2p() NodeOpt
- func FsRepo() NodeOpt
- func LiteNode() NodeOpt
- func MainMiner(m *TestMiner) NodeOpt
- func MutateSealingConfig(mut func(sc *config.SealingConfig)) NodeOpt
- func NoStorage() NodeOpt
- func OwnerAddr(wk *key.Key) NodeOpt
- func OwnerBalance(balance abi.TokenAmount) NodeOpt
- func PresealSectors(sectors int) NodeOpt
- func SectorSize(sectorSize abi.SectorSize) NodeOpt
- func SplitstoreDisable() NodeOpt
- func SplitstoreDiscard() NodeOpt
- func SplitstoreMessges() NodeOpt
- func SplitstoreUniversal() NodeOpt
- func ThroughRPC() NodeOpt
- func WithAllSubsystems() NodeOpt
- func WithAssigner(a string) NodeOpt
- func WithCfgOpt(opt CfgOption) NodeOpt
- func WithDisallowRemoteFinalize(d bool) NodeOpt
- func WithEthRPC() NodeOpt
- func WithMaxStagingDealsBytes(size int64) NodeOpt
- func WithNoLocalSealing(nope bool) NodeOpt
- func WithSectorIndexDB() NodeOpt
- func WithSubsystems(systems ...MinerSubsystem) NodeOpt
- func WithTaskTypes(tt []sealtasks.TaskType) NodeOpt
- func WithWorkerName(n string) NodeOpt
- func WithWorkerStorage(transform func(paths.Store) paths.Store) NodeOpt
- type OptBuilder
- type RunConcurrentDealsOpts
- type SchedInfo
- type SendCall
- type SolidityContractDef
- type TestDealState
- type TestFullNode
- func (f *TestFullNode) AssertActorType(ctx context.Context, addr address.Address, actorType string)
- func (f *TestFullNode) AssignPrivKey(pkey *Libp2p)
- func (f *TestFullNode) ClientImportCARFile(ctx context.Context, rseed int, size int) (res *api.ImportRes, carv1FilePath string, origFilePath string)
- func (f *TestFullNode) CreateImportFile(ctx context.Context, rseed int, size int) (res *api.ImportRes, path string)
- func (f *TestFullNode) EVM() *EVM
- func (f *TestFullNode) ExpectSend(ctx context.Context, from, to address.Address, value types.BigInt, ...) *types.SignedMessage
- func (f *TestFullNode) MakeSendCall(m abi.MethodNum, params cbg.CBORMarshaler) SendCall
- func (f TestFullNode) Shutdown(ctx context.Context) error
- func (f *TestFullNode) WaitForSectorActive(ctx context.Context, t *testing.T, sn abi.SectorNumber, maddr address.Address)
- func (f *TestFullNode) WaitMsg(ctx context.Context, msg cid.Cid)
- func (f *TestFullNode) WaitTillChain(ctx context.Context, pred ChainPredicate) *types.TipSet
- type TestMiner
- func (tm *TestMiner) AddStorage(ctx context.Context, t *testing.T, conf func(*storiface.LocalStorageMeta)) storiface.ID
- func (tm *TestMiner) FlushSealingBatches(ctx context.Context)
- func (tm *TestMiner) PledgeSectors(ctx context.Context, n, existing int, blockNotif <-chan struct{})
- func (tm *TestMiner) SchedInfo(ctx context.Context) SchedInfo
- func (tm *TestMiner) SectorsListNonGenesis(ctx context.Context) ([]abi.SectorNumber, error)
- func (tm *TestMiner) SetControlAddresses(addrs ...addr.Address)
- func (tm *TestMiner) StartPledge(ctx context.Context, n, existing int, blockNotif <-chan struct{}) map[abi.SectorNumber]struct{}
- func (tm *TestMiner) WaitSectorsProving(ctx context.Context, toCheck map[abi.SectorNumber]struct{})
- func (tm *TestMiner) WaitSectorsProvingAllowFails(ctx context.Context, toCheck map[abi.SectorNumber]struct{}, ...)
- type TestWorker
Constants ¶
const ( TestDealStateFailed = TestDealState(-1) TestDealStateInProgress = TestDealState(0) TestDealStateComplete = TestDealState(1) )
const DefaultPresealsPerBootstrapMiner = 2
DefaultPresealsPerBootstrapMiner is the number of preseals that every bootstrap miner has by default. It can be overridden through the PresealSectors option.
const EnvRunExpensiveTests = "LOTUS_RUN_EXPENSIVE_TESTS"
EnvRunExpensiveTests is the environment variable that needs to be present and set to value "1" to enable running expensive tests outside of CI.
const TestSpt = abi.RegisteredSealProof_StackedDrg2KiBV1_1
Variables ¶
var DefaultEnsembleOpts = ensembleOpts{ // contains filtered or unexported fields }
var DefaultNodeOpts = nodeOpts{ // contains filtered or unexported fields }
DefaultNodeOpts are the default options that will be applied to test nodes.
var EventMatrixContract = SolidityContractDef{ Filename: "contracts/EventMatrix.hex", Fn: map[string][]byte{ "logEventZeroData": EthFunctionHash("logEventZeroData()"), "logEventOneData": EthFunctionHash("logEventOneData(uint256)"), "logEventTwoData": EthFunctionHash("logEventTwoData(uint256,uint256)"), "logEventThreeData": EthFunctionHash("logEventThreeData(uint256,uint256,uint256)"), "logEventFourData": EthFunctionHash("logEventFourData(uint256,uint256,uint256,uint256)"), "logEventOneIndexed": EthFunctionHash("logEventOneIndexed(uint256)"), "logEventTwoIndexed": EthFunctionHash("logEventTwoIndexed(uint256,uint256)"), "logEventThreeIndexed": EthFunctionHash("logEventThreeIndexed(uint256,uint256,uint256)"), "logEventOneIndexedWithData": EthFunctionHash("logEventOneIndexedWithData(uint256,uint256)"), "logEventTwoIndexedWithData": EthFunctionHash("logEventTwoIndexedWithData(uint256,uint256,uint256)"), "logEventThreeIndexedWithData": EthFunctionHash("logEventThreeIndexedWithData(uint256,uint256,uint256,uint256)"), }, Ev: map[string]ethtypes.EthHash{ "EventZeroData": EthTopicHash("EventZeroData()"), "EventOneData": EthTopicHash("EventOneData(uint256)"), "EventTwoData": EthTopicHash("EventTwoData(uint256,uint256)"), "EventThreeData": EthTopicHash("EventThreeData(uint256,uint256,uint256)"), "EventFourData": EthTopicHash("EventFourData(uint256,uint256,uint256,uint256)"), "EventOneIndexed": EthTopicHash("EventOneIndexed(uint256)"), "EventTwoIndexed": EthTopicHash("EventTwoIndexed(uint256,uint256)"), "EventThreeIndexed": EthTopicHash("EventThreeIndexed(uint256,uint256,uint256)"), "EventOneIndexedWithData": EthTopicHash("EventOneIndexedWithData(uint256,uint256)"), "EventTwoIndexedWithData": EthTopicHash("EventTwoIndexedWithData(uint256,uint256,uint256)"), "EventThreeIndexedWithData": EthTopicHash("EventThreeIndexedWithData(uint256,uint256,uint256,uint256)"), }, }
var EventsContract = SolidityContractDef{ Filename: "contracts/events.bin", Fn: map[string][]byte{ "log_zero_data": {0x00, 0x00, 0x00, 0x00}, "log_zero_nodata": {0x00, 0x00, 0x00, 0x01}, "log_four_data": {0x00, 0x00, 0x00, 0x02}, }, Ev: map[string]ethtypes.EthHash{}, }
var WithSealWorkerTasks = WithTaskTypes(append([]sealtasks.TaskType{sealtasks.TTAddPiece, sealtasks.TTDataCid, sealtasks.TTPreCommit1, sealtasks.TTPreCommit2, sealtasks.TTCommit2, sealtasks.TTUnseal}, DefaultNodeOpts.workerTasks...))
Functions ¶
func AssertFilesEqual ¶
AssertFilesEqual compares two files by blake2b hash equality and fails the test if unequal.
func CalcFuncSignature ¶ added in v1.20.0
function signatures are the first 4 bytes of the hash of the function name and types
func CircuitBreaker ¶ added in v1.14.0
CircuitBreaker implements a simple time-based circuit breaker used for waiting for async operations to finish.
This is how it works:
- It runs the `cb` function until it returns true,
- waiting for `throttle` duration between each iteration,
- or at most `timeout` duration until it breaks test execution.
You can use it if t.Deadline() is not "granular" enough, and you want to know which specific piece of code timed out, or you need to set different deadlines in the same test.
func CreateImportFile ¶
func CreateRandomCARv1 ¶ added in v1.11.2
func CreateRandomCARv1(t *testing.T, rseed, size int, opts ...GeneratedDAGOpts) (carV1FilePath string, origFilePath string)
CreateRandomFile creates a normal file with the provided seed and the provided size and then transforms it to a CARv1 file and returns it.
func CreateRandomFile ¶
CreateRandomFile creates a random file with the provided seed and the provided size.
func EnsembleMinimal ¶
func EnsembleMinimal(t *testing.T, opts ...interface{}) (*TestFullNode, *TestMiner, *Ensemble)
EnsembleMinimal creates and starts an Ensemble with a single full node and a single miner. It does not interconnect nodes nor does it begin mining.
This function supports passing both ensemble and node functional options. Functional options are applied to all nodes.
func EnsembleOneTwo ¶
func EnsembleOneTwo(t *testing.T, opts ...interface{}) (*TestFullNode, *TestMiner, *TestMiner, *Ensemble)
EnsembleOneTwo creates and starts an Ensemble with one full node and two miners. It does not interconnect nodes nor does it begin mining.
This function supports passing both ensemble and node functional options. Functional options are applied to all nodes.
func EnsembleTwoOne ¶
func EnsembleTwoOne(t *testing.T, opts ...interface{}) (*TestFullNode, *TestFullNode, *TestMiner, *Ensemble)
EnsembleTwoOne creates and starts an Ensemble with two full nodes and one miner. It does not interconnect nodes nor does it begin mining.
This function supports passing both ensemble and node functional options. Functional options are applied to all nodes.
func EnsembleWithMinerAndMarketNodes ¶ added in v1.11.1
func EnsembleWorker ¶ added in v1.15.2
func EnsembleWorker(t *testing.T, opts ...interface{}) (*TestFullNode, *TestMiner, *TestWorker, *Ensemble)
func EthFunctionHash ¶ added in v1.20.0
func EthTopicHash ¶ added in v1.20.0
func QuietAllLogsExcept ¶ added in v1.20.0
func QuietAllLogsExcept(names ...string)
func QuietMiningLogs ¶
func QuietMiningLogs()
func RunClientTest ¶
func RunClientTest(t *testing.T, cmds []*lcli.Command, clientNode *TestFullNode)
RunClientTest exercises some of the Client CLI commands
func SendFunds ¶
func SendFunds(ctx context.Context, t *testing.T, sender *TestFullNode, recipient address.Address, amount abi.TokenAmount)
SendFunds sends funds from the default wallet of the specified sender node to the recipient address.
Types ¶
type BlockMiner ¶
type BlockMiner struct {
// contains filtered or unexported fields
}
BlockMiner is a utility that makes a test miner Mine blocks on a timer.
func NewBlockMiner ¶
func NewBlockMiner(t *testing.T, miner *TestMiner) *BlockMiner
func (*BlockMiner) InjectNulls ¶
func (bm *BlockMiner) InjectNulls(rounds abi.ChainEpoch)
InjectNulls injects the specified amount of null rounds in the next mining rounds.
func (*BlockMiner) MineBlocks ¶
func (bm *BlockMiner) MineBlocks(ctx context.Context, blocktime time.Duration)
func (*BlockMiner) MineBlocksMustPost ¶ added in v1.14.0
func (bm *BlockMiner) MineBlocksMustPost(ctx context.Context, blocktime time.Duration)
Like MineBlocks but refuses to mine until the window post scheduler has wdpost messages in the mempool and everything shuts down if a post fails. It also enforces that every block mined succeeds
func (*BlockMiner) MineUntilBlock ¶
func (bm *BlockMiner) MineUntilBlock(ctx context.Context, fn *TestFullNode, cb func(abi.ChainEpoch))
func (*BlockMiner) Pause ¶ added in v1.17.1
func (bm *BlockMiner) Pause()
Pause compels the miner to wait for a signal to restart
func (*BlockMiner) Restart ¶ added in v1.17.1
func (bm *BlockMiner) Restart()
Restart continues mining after a pause. This will hang if called before pause
type ChainPredicate ¶
ChainPredicate encapsulates a chain condition.
func BlocksMinedByAll ¶ added in v1.20.0
func BlocksMinedByAll(miner ...address.Address) ChainPredicate
BlocksMinedByAll returns a ChainPredicate that is satisfied when we observe a tipset including blocks from all the specified miners, in no particular order.
func HeightAtLeast ¶
func HeightAtLeast(target abi.ChainEpoch) ChainPredicate
HeightAtLeast returns a ChainPredicate that is satisfied when the chain height is equal or higher to the target.
type DealHarness ¶
type DealHarness struct {
// contains filtered or unexported fields
}
func NewDealHarness ¶
func NewDealHarness(t *testing.T, client *TestFullNode, main *TestMiner, market *TestMiner) *DealHarness
NewDealHarness creates a test harness that contains testing utilities for deals.
func (*DealHarness) DefaultStartDealParams ¶ added in v1.11.1
func (dh *DealHarness) DefaultStartDealParams() api.StartDealParams
func (*DealHarness) ExpectDealFailure ¶ added in v1.11.3
func (dh *DealHarness) ExpectDealFailure(ctx context.Context, deal *cid.Cid, errs string) error
func (*DealHarness) ExtractFileFromCAR ¶
func (*DealHarness) MakeOnlineDeal ¶
func (dh *DealHarness) MakeOnlineDeal(ctx context.Context, params MakeFullDealParams) (deal *cid.Cid, res *api.ImportRes, path string)
MakeOnlineDeal makes an online deal, generating a random file with the supplied seed, and setting the specified fast retrieval flag and start epoch on the storage deal. It returns when the deal is sealed.
TODO: convert input parameters to struct, and add size as an input param.
func (*DealHarness) PerformRetrieval ¶
func (dh *DealHarness) PerformRetrieval(ctx context.Context, deal *cid.Cid, root cid.Cid, carExport bool, offers ...api.QueryOffer) (path string)
func (*DealHarness) PerformRetrievalWithOrder ¶ added in v1.19.0
func (dh *DealHarness) PerformRetrievalWithOrder(ctx context.Context, deal *cid.Cid, root cid.Cid, carExport bool, makeOrder func(api.QueryOffer, address.Address) api.RetrievalOrder, offers ...api.QueryOffer) (path string)
func (*DealHarness) RunConcurrentDeals ¶
func (dh *DealHarness) RunConcurrentDeals(opts RunConcurrentDealsOpts)
func (*DealHarness) StartDeal ¶
func (dh *DealHarness) StartDeal(ctx context.Context, dealParams api.StartDealParams) *cid.Cid
StartDeal starts a storage deal between the client and the miner.
func (*DealHarness) StartRandomDeal ¶ added in v1.25.0
func (dh *DealHarness) StartRandomDeal(ctx context.Context, params MakeFullDealParams) (deal *cid.Cid, res *api.ImportRes, path string)
func (*DealHarness) StartSealingWaiting ¶
func (dh *DealHarness) StartSealingWaiting(ctx context.Context)
func (*DealHarness) WaitDealPublished ¶
func (dh *DealHarness) WaitDealPublished(ctx context.Context, deal *cid.Cid)
WaitDealPublished waits until the deal is published.
func (*DealHarness) WaitDealSealed ¶
func (dh *DealHarness) WaitDealSealed(ctx context.Context, deal *cid.Cid, noseal, noSealStart bool, cb func())
WaitDealSealed waits until the deal is sealed.
func (*DealHarness) WaitDealSealedQuiet ¶ added in v1.13.1
func (dh *DealHarness) WaitDealSealedQuiet(ctx context.Context, deal *cid.Cid, noseal, noSealStart bool, cb func())
WaitDealSealedQuiet waits until the deal is sealed, without logging anything.
type EVM ¶ added in v1.20.0
type EVM struct{ *TestFullNode }
EVM groups EVM-related actions.
func (*EVM) AssertAddressBalanceConsistent ¶ added in v1.20.0
AssertAddressBalanceConsistent checks that the balance reported via the Filecoin and Ethereum operations for an f410 address is identical, returning the balance.
func (*EVM) ComputeContractAddress ¶ added in v1.20.0
func (e *EVM) ComputeContractAddress(deployer ethtypes.EthAddress, nonce uint64) ethtypes.EthAddress
ComputeContractAddress computes the address of a contract deployed by the specified address with the specified nonce.
func (*EVM) DeployContract ¶ added in v1.20.0
func (*EVM) DeployContractFromFilename ¶ added in v1.20.0
func (*EVM) DeployContractFromFilenameWithValue ¶ added in v1.20.0
func (*EVM) DeployContractWithValue ¶ added in v1.20.0
func (*EVM) GetEthBlockFromWait ¶ added in v1.20.0
return eth block from a wait return this necessarily goes back one parent in the chain because wait is one block ahead of execution
func (*EVM) InvokeContractByFuncName ¶ added in v1.20.0
func (*EVM) InvokeContractByFuncNameExpectExit ¶ added in v1.20.0
func (*EVM) InvokeSolidity ¶ added in v1.20.0
func (*EVM) InvokeSolidityWithValue ¶ added in v1.23.0
func (*EVM) LoadEvents ¶ added in v1.20.0
LoadEvents loads all events in an event AMT.
func (*EVM) NewAccount ¶ added in v1.20.0
func (e *EVM) NewAccount() (*key.Key, ethtypes.EthAddress, address.Address)
func (*EVM) SignTransaction ¶ added in v1.20.0
SignTransaction signs an Ethereum transaction in place with the supplied private key.
func (*EVM) SubmitTransaction ¶ added in v1.20.0
SubmitTransaction submits the transaction via the Eth endpoint.
func (*EVM) TransferValueOrFail ¶ added in v1.20.0
func (*EVM) WaitTransaction ¶ added in v1.25.2
type Ensemble ¶
type Ensemble struct {
// contains filtered or unexported fields
}
Ensemble is a collection of nodes instantiated within a test.
Create a new ensemble with:
ens := kit.NewEnsemble()
Create full nodes and miners:
var full TestFullNode var miner TestMiner ens.FullNode(&full, opts...) // populates a full node ens.Miner(&miner, &full, opts...) // populates a miner, using the full node as its chain daemon
It is possible to pass functional options to set initial balances, presealed sectors, owner keys, etc.
After the initial nodes are added, call `ens.Start()` to forge genesis and start the network. Mining will NOT be started automatically. It needs to be started explicitly by calling `BeginMining`.
Nodes also need to be connected with one another, either via `ens.Connect()` or `ens.InterconnectAll()`. A common inchantation for simple tests is to do:
ens.InterconnectAll().BeginMining(blocktime)
You can continue to add more nodes, but you must always follow with `ens.Start()` to activate the new nodes.
The API is chainable, so it's possible to do a lot in a very succinct way:
kit.NewEnsemble().FullNode(&full).Miner(&miner, &full).Start().InterconnectAll().BeginMining()
You can also find convenient fullnode:miner presets, such as 1:1, 1:2, and 2:1, e.g.:
kit.EnsembleMinimal() kit.EnsembleOneTwo() kit.EnsembleTwoOne()
func NewEnsemble ¶
func NewEnsemble(t *testing.T, opts ...EnsembleOpt) *Ensemble
NewEnsemble instantiates a new blank Ensemble.
func (*Ensemble) AddInactiveMiner ¶ added in v1.19.0
func (*Ensemble) BeginMining ¶
func (n *Ensemble) BeginMining(blocktime time.Duration, miners ...*TestMiner) []*BlockMiner
BeginMining kicks off mining for the specified miners. If nil or 0-length, it will kick off mining for all enrolled and active miners. It also adds a cleanup function to stop all mining operations on test teardown.
func (*Ensemble) BeginMiningMustPost ¶ added in v1.14.0
func (n *Ensemble) BeginMiningMustPost(blocktime time.Duration, miners ...*TestMiner) []*BlockMiner
func (*Ensemble) FullNode ¶
func (n *Ensemble) FullNode(full *TestFullNode, opts ...NodeOpt) *Ensemble
FullNode enrolls a new full node.
func (*Ensemble) InterconnectAll ¶
InterconnectAll connects all miners and full nodes to one another.
func (*Ensemble) Miner ¶
func (n *Ensemble) Miner(minerNode *TestMiner, full *TestFullNode, opts ...NodeOpt) *Ensemble
func (*Ensemble) MinerEnroll ¶ added in v1.19.0
func (n *Ensemble) MinerEnroll(minerNode *TestMiner, full *TestFullNode, opts ...NodeOpt) *Ensemble
Miner enrolls a new miner, using the provided full node for chain interactions.
func (*Ensemble) NewPrivKey ¶ added in v1.19.0
func (n *Ensemble) NewPrivKey() (libp2pcrypto.PrivKey, peer.ID)
type EnsembleOpt ¶
type EnsembleOpt func(opts *ensembleOpts) error
func Account ¶
func Account(key *key.Key, balance abi.TokenAmount) EnsembleOpt
Account sets up an account at genesis with the specified key and balance.
func GenesisNetworkVersion ¶ added in v1.11.2
func GenesisNetworkVersion(nv network.Version) EnsembleOpt
GenesisNetworkVersion sets the network version of genesis.
func LatestActorsAt ¶
func LatestActorsAt(upgradeHeight abi.ChainEpoch) EnsembleOpt
func MockProofs ¶
func MockProofs(e ...bool) EnsembleOpt
MockProofs activates mock proofs for the entire ensemble.
func RootVerifier ¶
func RootVerifier(key *key.Key, balance abi.TokenAmount) EnsembleOpt
RootVerifier specifies the key to be enlisted as the verified registry root, as well as the initial balance to be attributed during genesis.
func UpgradeSchedule ¶ added in v1.11.2
func UpgradeSchedule(upgrades ...stmgr.Upgrade) EnsembleOpt
type EthFilterBuilder ¶ added in v1.20.0
type EthFilterBuilder struct {
// contains filtered or unexported fields
}
func NewEthFilterBuilder ¶ added in v1.20.0
func NewEthFilterBuilder() *EthFilterBuilder
func (*EthFilterBuilder) AddressOneOf ¶ added in v1.20.0
func (e *EthFilterBuilder) AddressOneOf(as ...ethtypes.EthAddress) *EthFilterBuilder
func (*EthFilterBuilder) BlockHash ¶ added in v1.20.0
func (e *EthFilterBuilder) BlockHash(h ethtypes.EthHash) *EthFilterBuilder
func (*EthFilterBuilder) Filter ¶ added in v1.20.0
func (e *EthFilterBuilder) Filter() *ethtypes.EthFilterSpec
func (*EthFilterBuilder) FromBlock ¶ added in v1.20.0
func (e *EthFilterBuilder) FromBlock(v string) *EthFilterBuilder
func (*EthFilterBuilder) FromBlockEpoch ¶ added in v1.20.0
func (e *EthFilterBuilder) FromBlockEpoch(v abi.ChainEpoch) *EthFilterBuilder
func (*EthFilterBuilder) ToBlock ¶ added in v1.20.0
func (e *EthFilterBuilder) ToBlock(v string) *EthFilterBuilder
func (*EthFilterBuilder) ToBlockEpoch ¶ added in v1.20.0
func (e *EthFilterBuilder) ToBlockEpoch(v abi.ChainEpoch) *EthFilterBuilder
func (*EthFilterBuilder) Topic1OneOf ¶ added in v1.20.0
func (e *EthFilterBuilder) Topic1OneOf(hs ...ethtypes.EthHash) *EthFilterBuilder
func (*EthFilterBuilder) Topic2OneOf ¶ added in v1.20.0
func (e *EthFilterBuilder) Topic2OneOf(hs ...ethtypes.EthHash) *EthFilterBuilder
func (*EthFilterBuilder) Topic3OneOf ¶ added in v1.20.0
func (e *EthFilterBuilder) Topic3OneOf(hs ...ethtypes.EthHash) *EthFilterBuilder
func (*EthFilterBuilder) Topic4OneOf ¶ added in v1.20.0
func (e *EthFilterBuilder) Topic4OneOf(hs ...ethtypes.EthHash) *EthFilterBuilder
type GeneratedDAGOpts ¶ added in v1.15.1
type ItestdNotif ¶ added in v1.15.1
type MakeFullDealParams ¶
type MakeFullDealParams struct { Rseed int FastRet bool StartEpoch abi.ChainEpoch UseCARFileForStorageDeal bool // SuspendUntilCryptoeconStable suspends deal-making, until cryptoecon // parameters are stabilised. This affects projected collateral, and tests // will fail in network version 13 and higher if deals are started too soon // after network birth. // // The reason is that the formula for collateral calculation takes // circulating supply into account: // // [portion of power this deal will be] * [~1% of tokens]. // // In the first epochs after genesis, the total circulating supply is // changing dramatically in percentual terms. Therefore, if the deal is // proposed too soon, by the time it gets published on chain, the quoted // provider collateral will no longer be valid. // // The observation is that deals fail with: // // GasEstimateMessageGas error: estimating gas used: message execution // failed: exit 16, reason: Provider collateral out of bounds. (RetCode=16) // // Enabling this will suspend deal-making until the network has reached a // height of 300. SuspendUntilCryptoeconStable bool }
type MinerSubsystem ¶ added in v1.11.1
type MinerSubsystem int
const ( SMarkets MinerSubsystem = 1 << iota SMining SSealing SSectorStorage SHarmony MinerSubsystems = iota )
func (MinerSubsystem) Add ¶ added in v1.11.1
func (ms MinerSubsystem) Add(single MinerSubsystem) MinerSubsystem
func (MinerSubsystem) All ¶ added in v1.11.1
func (ms MinerSubsystem) All() [MinerSubsystems]bool
func (MinerSubsystem) Has ¶ added in v1.11.1
func (ms MinerSubsystem) Has(single MinerSubsystem) bool
type MockCLI ¶
type MockCLI struct {
// contains filtered or unexported fields
}
func NewMockCLI ¶
func (*MockCLI) Client ¶
func (c *MockCLI) Client(addr multiaddr.Multiaddr) *MockCLIClient
type MockCLIClient ¶
type MockCLIClient struct {
// contains filtered or unexported fields
}
MockCLIClient runs commands against a particular node
func (*MockCLIClient) RunCmd ¶
func (c *MockCLIClient) RunCmd(input ...string) string
func (*MockCLIClient) RunCmdRaw ¶
func (c *MockCLIClient) RunCmdRaw(input ...string) (string, error)
func (*MockCLIClient) RunInteractiveCmd ¶
func (c *MockCLIClient) RunInteractiveCmd(cmd []string, interactive []string) string
type NodeOpt ¶
type NodeOpt func(opts *nodeOpts) error
NodeOpt is a functional option for test nodes.
func ConstructorOpts ¶
ConstructorOpts are Lotus node constructor options that are passed as-is to the node.
func DisableEthRPC ¶ added in v1.20.0
func DisableEthRPC() NodeOpt
func DisableLibp2p ¶ added in v1.11.1
func DisableLibp2p() NodeOpt
func LiteNode ¶
func LiteNode() NodeOpt
LiteNode specifies that this node will be a lite node. Only relevant when creating a fullnode.
func MutateSealingConfig ¶ added in v1.15.2
func MutateSealingConfig(mut func(sc *config.SealingConfig)) NodeOpt
func NoStorage ¶ added in v1.17.1
func NoStorage() NodeOpt
NoStorage initializes miners with no writable storage paths (just read-only preseal paths)
func OwnerBalance ¶
func OwnerBalance(balance abi.TokenAmount) NodeOpt
OwnerBalance specifies the balance to be attributed to a miner's owner account. Only relevant when creating a miner.
func PresealSectors ¶
PresealSectors specifies the amount of preseal sectors to give to a miner at genesis. Only relevant when creating a miner.
func SectorSize ¶ added in v1.11.3
func SectorSize(sectorSize abi.SectorSize) NodeOpt
SectorSize sets the sector size for this miner. Start() will populate the corresponding proof type depending on the network version (genesis network version if the Ensemble is unstarted, or the current network version if started).
func SplitstoreDisable ¶ added in v1.25.0
func SplitstoreDisable() NodeOpt
func SplitstoreDiscard ¶ added in v1.17.1
func SplitstoreDiscard() NodeOpt
func SplitstoreMessges ¶ added in v1.19.0
func SplitstoreMessges() NodeOpt
func SplitstoreUniversal ¶ added in v1.17.1
func SplitstoreUniversal() NodeOpt
func ThroughRPC ¶
func ThroughRPC() NodeOpt
ThroughRPC makes interactions with this node throughout the test flow through the JSON-RPC API.
func WithAllSubsystems ¶ added in v1.11.1
func WithAllSubsystems() NodeOpt
func WithAssigner ¶ added in v1.17.0
func WithCfgOpt ¶ added in v1.17.1
func WithDisallowRemoteFinalize ¶ added in v1.17.0
func WithEthRPC ¶ added in v1.20.0
func WithEthRPC() NodeOpt
func WithMaxStagingDealsBytes ¶ added in v1.11.3
func WithNoLocalSealing ¶ added in v1.15.2
func WithSectorIndexDB ¶ added in v1.25.2
func WithSectorIndexDB() NodeOpt
func WithSubsystems ¶ added in v1.11.1
func WithSubsystems(systems ...MinerSubsystem) NodeOpt
func WithTaskTypes ¶ added in v1.15.2
func WithWorkerName ¶ added in v1.17.1
type OptBuilder ¶
type OptBuilder func(activeNodes []*TestFullNode) node.Option
OptBuilder is used to create an option after some other node is already active. Takes all active nodes as a parameter.
type RunConcurrentDealsOpts ¶
type RunConcurrentDealsOpts struct { N int FastRetrieval bool CarExport bool StartEpoch abi.ChainEpoch UseCARFileForStorageDeal bool IndexProvider *shared_testutil.MockIndexProvider }
type SchedInfo ¶ added in v1.20.0
type SchedInfo struct { CallToWork struct{} EarlyRet interface{} ReturnedWork interface{} SchedInfo struct { OpenWindows []string Requests []struct { Priority int SchedId uuid.UUID Sector struct { Miner int Number int } TaskType string } } Waiting interface{} }
comes from https://github.com/filecoin-project/lotus/blob/8ba4355cabd25e5f65261aaa561ff676321ffbd8/storage/sealer/manager.go#L1226 todo: have this defined in one place
type SolidityContractDef ¶ added in v1.20.0
type SolidityContractDef struct { Filename string // filename of the hex of the contract, e.g. contracts/EventMatrix.hex Fn map[string][]byte // mapping of function names to 32-bit selector Ev map[string]ethtypes.EthHash // mapping of event names to 256-bit signature hashes }
SolidityContractDef holds information about one of the test contracts
type TestDealState ¶
type TestDealState int
func CategorizeDealState ¶
func CategorizeDealState(dealStatus string) TestDealState
CategorizeDealState categorizes deal states into one of three states: Complete, InProgress, Failed.
type TestFullNode ¶
type TestFullNode struct { v1api.FullNode // ListenAddr is the address on which an API server is listening, if an // API server is created for this Node. ListenAddr multiaddr.Multiaddr ListenURL string DefaultKey *key.Key Pkey *Libp2p Stop node.StopFunc // gateway handler makes it convenient to register callbalks per topic, so we // also use it for tests EthSubRouter *gateway.EthSubHandler // contains filtered or unexported fields }
TestFullNode represents a full node enrolled in an Ensemble.
func MergeFullNodes ¶ added in v1.19.0
func MergeFullNodes(fullNodes []*TestFullNode) *TestFullNode
func SetupFEVMTest ¶ added in v1.20.0
func SetupFEVMTest(t *testing.T) (context.Context, context.CancelFunc, *TestFullNode)
func (*TestFullNode) AssertActorType ¶ added in v1.20.0
func (f *TestFullNode) AssertActorType(ctx context.Context, addr address.Address, actorType string)
AssertActorType verifies that the supplied address is an actor of the specified type (as per its manifest key).
func (*TestFullNode) AssignPrivKey ¶ added in v1.19.0
func (f *TestFullNode) AssignPrivKey(pkey *Libp2p)
func (*TestFullNode) ClientImportCARFile ¶ added in v1.11.2
func (*TestFullNode) CreateImportFile ¶
func (f *TestFullNode) CreateImportFile(ctx context.Context, rseed int, size int) (res *api.ImportRes, path string)
CreateImportFile creates a random file with the specified seed and size, and imports it into the full node.
func (*TestFullNode) EVM ¶ added in v1.20.0
func (f *TestFullNode) EVM() *EVM
func (*TestFullNode) ExpectSend ¶ added in v1.20.0
func (f *TestFullNode) ExpectSend(ctx context.Context, from, to address.Address, value types.BigInt, errContains string, sc ...SendCall) *types.SignedMessage
func (*TestFullNode) MakeSendCall ¶ added in v1.20.0
func (f *TestFullNode) MakeSendCall(m abi.MethodNum, params cbg.CBORMarshaler) SendCall
func (TestFullNode) Shutdown ¶ added in v1.19.0
func (f TestFullNode) Shutdown(ctx context.Context) error
func (*TestFullNode) WaitForSectorActive ¶ added in v1.15.2
func (f *TestFullNode) WaitForSectorActive(ctx context.Context, t *testing.T, sn abi.SectorNumber, maddr address.Address)
func (*TestFullNode) WaitMsg ¶ added in v1.11.1
func (f *TestFullNode) WaitMsg(ctx context.Context, msg cid.Cid)
func (*TestFullNode) WaitTillChain ¶
func (f *TestFullNode) WaitTillChain(ctx context.Context, pred ChainPredicate) *types.TipSet
WaitTillChain waits until a specified chain condition is met. It returns the first tipset where the condition is met.
type TestMiner ¶
type TestMiner struct { api.StorageMiner BaseAPI api.StorageMiner // ListenAddr is the address on which an API server is listening, if an // API server is created for this Node ListenAddr multiaddr.Multiaddr ActorAddr address.Address OwnerKey *key.Key MineOne func(context.Context, miner.MineReq) error Stop func(context.Context) error FullNode *TestFullNode PresealDir string PresealSectors int Libp2p struct { PeerID peer.ID PrivKey libp2pcrypto.PrivKey } RemoteListener net.Listener // contains filtered or unexported fields }
TestMiner represents a miner enrolled in an Ensemble.
func (*TestMiner) AddStorage ¶
func (*TestMiner) FlushSealingBatches ¶
func (*TestMiner) PledgeSectors ¶
func (*TestMiner) SectorsListNonGenesis ¶ added in v1.17.1
func (*TestMiner) SetControlAddresses ¶ added in v1.11.1
func (*TestMiner) StartPledge ¶
func (*TestMiner) WaitSectorsProving ¶ added in v1.14.0
func (tm *TestMiner) WaitSectorsProving(ctx context.Context, toCheck map[abi.SectorNumber]struct{})
func (*TestMiner) WaitSectorsProvingAllowFails ¶ added in v1.17.2
func (tm *TestMiner) WaitSectorsProvingAllowFails(ctx context.Context, toCheck map[abi.SectorNumber]struct{}, okFails map[api.SectorState]struct{})
type TestWorker ¶ added in v1.15.2
type TestWorker struct { api.Worker // ListenAddr is the address on which an API server is listening, if an // API server is created for this Node ListenAddr multiaddr.Multiaddr Stop func(context.Context) error FetchHandler http.HandlerFunc MinerNode *TestMiner RemoteListener net.Listener // contains filtered or unexported fields }
TestWorker represents a worker enrolled in an Ensemble.
func (*TestWorker) AddStorage ¶ added in v1.17.1
func (tm *TestWorker) AddStorage(ctx context.Context, t *testing.T, conf func(*storiface.LocalStorageMeta)) storiface.ID