Documentation ¶
Overview ¶
Package testnodes contains stubbed implementations of the StorageProviderNode and StorageClientNode interface to simulate communications with a filecoin node
Index ¶
- type DelayFakeCommonNode
- type FakeClientNode
- func (n *FakeClientNode) GetDefaultWalletAddress(ctx context.Context) (address.Address, error)
- func (n *FakeClientNode) GetMinerInfo(ctx context.Context, maddr address.Address, tok shared.TipSetToken) (*storagemarket.StorageProviderInfo, error)
- func (n *FakeClientNode) ListStorageProviders(ctx context.Context, tok shared.TipSetToken) ([]*storagemarket.StorageProviderInfo, error)
- func (n *FakeClientNode) SignProposal(ctx context.Context, signer address.Address, proposal market.DealProposal) (*market.ClientDealProposal, error)
- func (n *FakeClientNode) ValidatePublishedDeal(ctx context.Context, deal storagemarket.ClientDeal) (abi.DealID, error)
- func (n *FakeClientNode) VerifyExpectations(t *testing.T)
- type FakeCommonNode
- func (n *FakeCommonNode) AddFunds(ctx context.Context, addr address.Address, amount abi.TokenAmount) (cid.Cid, error)
- func (n *FakeCommonNode) DealProviderCollateralBounds(ctx context.Context, size abi.PaddedPieceSize, isVerified bool) (abi.TokenAmount, abi.TokenAmount, error)
- func (n *FakeCommonNode) EnsureFunds(ctx context.Context, addr, wallet address.Address, amount abi.TokenAmount, ...) (cid.Cid, error)
- func (n *FakeCommonNode) GetBalance(ctx context.Context, addr address.Address, tok shared.TipSetToken) (storagemarket.Balance, error)
- func (n *FakeCommonNode) GetChainHead(ctx context.Context) (shared.TipSetToken, abi.ChainEpoch, error)
- func (n *FakeCommonNode) OnDealExpiredOrSlashed(ctx context.Context, dealID abi.DealID, ...) error
- func (n *FakeCommonNode) OnDealSectorCommitted(ctx context.Context, provider address.Address, dealID abi.DealID, ...) error
- func (n *FakeCommonNode) SignBytes(ctx context.Context, signer address.Address, b []byte) (*crypto.Signature, error)
- func (n *FakeCommonNode) VerifySignature(ctx context.Context, signature crypto.Signature, addr address.Address, ...) (bool, error)
- func (n *FakeCommonNode) WaitForMessage(ctx context.Context, mcid cid.Cid, ...) error
- type FakeProviderNode
- func (n *FakeProviderNode) GetDataCap(ctx context.Context, addr address.Address, tok shared.TipSetToken) (*verifreg.DataCap, error)
- func (n *FakeProviderNode) GetMinerWorkerAddress(ctx context.Context, miner address.Address, tok shared.TipSetToken) (address.Address, error)
- func (n *FakeProviderNode) LocatePieceForDealWithinSector(ctx context.Context, dealID abi.DealID, tok shared.TipSetToken) (sectorID abi.SectorNumber, offset abi.PaddedPieceSize, ...)
- func (n *FakeProviderNode) OnDealComplete(ctx context.Context, deal storagemarket.MinerDeal, ...) (*storagemarket.PackingResult, error)
- func (n *FakeProviderNode) PublishDeals(ctx context.Context, deal storagemarket.MinerDeal) (cid.Cid, error)
- type StorageMarketState
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DelayFakeCommonNode ¶ added in v0.6.1
type DelayFakeCommonNode struct { OnDealSectorCommitted bool OnDealSectorCommittedChan chan struct{} OnDealExpiredOrSlashed bool OnDealExpiredOrSlashedChan chan struct{} ValidatePublishedDeal bool ValidatePublishedDealChan chan struct{} }
DelayFakeCommonNode allows configuring delay in the FakeCommonNode functions
type FakeClientNode ¶
type FakeClientNode struct { FakeCommonNode ClientAddr address.Address MinerAddr address.Address WorkerAddr address.Address ValidationError error ValidatePublishedDealID abi.DealID ValidatePublishedError error ExpectedMinerInfos []address.Address // contains filtered or unexported fields }
FakeClientNode is a node adapter for a storage client whose responses are stubbed
func (*FakeClientNode) GetDefaultWalletAddress ¶
func (n *FakeClientNode) GetDefaultWalletAddress(ctx context.Context) (address.Address, error)
GetDefaultWalletAddress returns a stubbed ClientAddr
func (*FakeClientNode) GetMinerInfo ¶ added in v0.3.1
func (n *FakeClientNode) GetMinerInfo(ctx context.Context, maddr address.Address, tok shared.TipSetToken) (*storagemarket.StorageProviderInfo, error)
GetMinerInfo returns stubbed information for the first miner in storage market state
func (*FakeClientNode) ListStorageProviders ¶
func (n *FakeClientNode) ListStorageProviders(ctx context.Context, tok shared.TipSetToken) ([]*storagemarket.StorageProviderInfo, error)
ListStorageProviders lists the providers in the storage market state
func (*FakeClientNode) SignProposal ¶
func (n *FakeClientNode) SignProposal(ctx context.Context, signer address.Address, proposal market.DealProposal) (*market.ClientDealProposal, error)
SignProposal signs a deal with a dummy signature
func (*FakeClientNode) ValidatePublishedDeal ¶
func (n *FakeClientNode) ValidatePublishedDeal(ctx context.Context, deal storagemarket.ClientDeal) (abi.DealID, error)
ValidatePublishedDeal always succeeds
func (*FakeClientNode) VerifyExpectations ¶ added in v0.5.4
func (n *FakeClientNode) VerifyExpectations(t *testing.T)
type FakeCommonNode ¶
type FakeCommonNode struct { SMState *StorageMarketState AddFundsCid cid.Cid EnsureFundsError error VerifySignatureFails bool GetBalanceError error GetChainHeadError error SignBytesError error DealCommittedSyncError error DealCommittedAsyncError error WaitForDealCompletionError error OnDealExpiredError error OnDealSlashedError error OnDealSlashedEpoch abi.ChainEpoch WaitForMessageBlocks bool WaitForMessageError error WaitForMessageExitCode exitcode.ExitCode WaitForMessageRetBytes []byte WaitForMessageFinalCid cid.Cid WaitForMessageNodeError error WaitForMessageCalls []cid.Cid DelayFakeCommonNode DelayFakeCommonNode }
FakeCommonNode implements common methods for the storage & client node adapters where responses are stubbed
func (*FakeCommonNode) AddFunds ¶
func (n *FakeCommonNode) AddFunds(ctx context.Context, addr address.Address, amount abi.TokenAmount) (cid.Cid, error)
AddFunds adds funds to the given actor in the storage market state
func (*FakeCommonNode) DealProviderCollateralBounds ¶ added in v0.5.3
func (n *FakeCommonNode) DealProviderCollateralBounds(ctx context.Context, size abi.PaddedPieceSize, isVerified bool) (abi.TokenAmount, abi.TokenAmount, error)
func (*FakeCommonNode) EnsureFunds ¶
func (n *FakeCommonNode) EnsureFunds(ctx context.Context, addr, wallet address.Address, amount abi.TokenAmount, tok shared.TipSetToken) (cid.Cid, error)
EnsureFunds adds funds to the given actor in the storage market state to ensure it has at least the given amount
func (*FakeCommonNode) GetBalance ¶
func (n *FakeCommonNode) GetBalance(ctx context.Context, addr address.Address, tok shared.TipSetToken) (storagemarket.Balance, error)
GetBalance returns the funds in the storage market state
func (*FakeCommonNode) GetChainHead ¶
func (n *FakeCommonNode) GetChainHead(ctx context.Context) (shared.TipSetToken, abi.ChainEpoch, error)
GetChainHead returns the state id in the storage market state
func (*FakeCommonNode) OnDealExpiredOrSlashed ¶ added in v0.4.0
func (n *FakeCommonNode) OnDealExpiredOrSlashed(ctx context.Context, dealID abi.DealID, onDealExpired storagemarket.DealExpiredCallback, onDealSlashed storagemarket.DealSlashedCallback) error
OnDealExpiredOrSlashed simulates waiting for a deal to be expired or slashed, but provides stubbed behavior
func (*FakeCommonNode) OnDealSectorCommitted ¶ added in v0.3.2
func (n *FakeCommonNode) OnDealSectorCommitted(ctx context.Context, provider address.Address, dealID abi.DealID, proposal market.DealProposal, publishCid *cid.Cid, cb storagemarket.DealSectorCommittedCallback) error
OnDealSectorCommitted returns immediately, and returns stubbed errors
func (*FakeCommonNode) SignBytes ¶ added in v0.3.2
func (n *FakeCommonNode) SignBytes(ctx context.Context, signer address.Address, b []byte) (*crypto.Signature, error)
SignBytes simulates signing data by returning a test signature
func (*FakeCommonNode) VerifySignature ¶
func (n *FakeCommonNode) VerifySignature(ctx context.Context, signature crypto.Signature, addr address.Address, data []byte, tok shared.TipSetToken) (bool, error)
VerifySignature just always returns true, for now
type FakeProviderNode ¶
type FakeProviderNode struct { FakeCommonNode MinerAddr address.Address MinerWorkerError error PieceLength uint64 PieceSectorID uint64 PublishDealID abi.DealID PublishDealsError error OnDealCompleteError error LastOnDealCompleteBytes []byte OnDealCompleteCalls []storagemarket.MinerDeal LocatePieceForDealWithinSectorError error DataCap *verifreg.DataCap GetDataCapErr error }
FakeProviderNode implements functions specific to the StorageProviderNode
func (*FakeProviderNode) GetDataCap ¶ added in v0.4.0
func (n *FakeProviderNode) GetDataCap(ctx context.Context, addr address.Address, tok shared.TipSetToken) (*verifreg.DataCap, error)
GetDataCap gets the current data cap for addr
func (*FakeProviderNode) GetMinerWorkerAddress ¶
func (n *FakeProviderNode) GetMinerWorkerAddress(ctx context.Context, miner address.Address, tok shared.TipSetToken) (address.Address, error)
GetMinerWorkerAddress returns the address specified by MinerAddr
func (*FakeProviderNode) LocatePieceForDealWithinSector ¶
func (n *FakeProviderNode) LocatePieceForDealWithinSector(ctx context.Context, dealID abi.DealID, tok shared.TipSetToken) (sectorID abi.SectorNumber, offset abi.PaddedPieceSize, length abi.PaddedPieceSize, err error)
LocatePieceForDealWithinSector returns stubbed data for a pieces location in a sector
func (*FakeProviderNode) OnDealComplete ¶
func (n *FakeProviderNode) OnDealComplete(ctx context.Context, deal storagemarket.MinerDeal, pieceSize abi.UnpaddedPieceSize, pieceReader io.Reader) (*storagemarket.PackingResult, error)
OnDealComplete simulates passing of the deal to the storage miner, and does nothing
func (*FakeProviderNode) PublishDeals ¶
func (n *FakeProviderNode) PublishDeals(ctx context.Context, deal storagemarket.MinerDeal) (cid.Cid, error)
PublishDeals simulates publishing a deal by adding it to the storage market state
type StorageMarketState ¶
type StorageMarketState struct { TipSetToken shared.TipSetToken Epoch abi.ChainEpoch DealID abi.DealID Balances map[address.Address]abi.TokenAmount Providers map[address.Address]*storagemarket.StorageProviderInfo }
StorageMarketState represents a state for the storage market that can be inspected - methods on the provider nodes will affect this state
func NewStorageMarketState ¶
func NewStorageMarketState() *StorageMarketState
NewStorageMarketState returns a new empty state for the storage market
func (*StorageMarketState) AddFunds ¶
func (sma *StorageMarketState) AddFunds(addr address.Address, amount abi.TokenAmount)
AddFunds adds funds for a given address in the storage market
func (*StorageMarketState) Balance ¶
func (sma *StorageMarketState) Balance(addr address.Address) storagemarket.Balance
Balance returns the balance of a given address in the market
func (*StorageMarketState) StateKey ¶
func (sma *StorageMarketState) StateKey() (shared.TipSetToken, abi.ChainEpoch)
StateKey returns a state key with the storage market states set Epoch