testnodes

package
v0.0.0-...-f311442 Latest Latest
Warning

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

Go to latest
Published: Mar 7, 2023 License: Apache-2.0, MIT Imports: 22 Imported by: 0

Documentation

Overview

Package testnodes contains stubbed implementations of the RetrievalProviderNode and RetrievalClientNode interface to simulate communications with a filecoin node

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type TestRetrievalClientNode

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

TestRetrievalClientNode is a node adapter for a retrieval client whose responses are stubbed

func NewTestRetrievalClientNode

func NewTestRetrievalClientNode(params TestRetrievalClientNodeParams) *TestRetrievalClientNode

NewTestRetrievalClientNode initializes a new TestRetrievalClientNode based on the given params

func (*TestRetrievalClientNode) AllocateLane

func (trcn *TestRetrievalClientNode) AllocateLane(ctx context.Context, paymentChannel address.Address) (uint64, error)

AllocateLane creates a mock lane on a payment channel

func (*TestRetrievalClientNode) CheckAvailableFunds

func (trcn *TestRetrievalClientNode) CheckAvailableFunds(ctx context.Context, payCh address.Address) (retrievalmarket.ChannelAvailableFunds, error)

CheckAvailableFunds returns the amount of available funds in a payment channel

func (*TestRetrievalClientNode) CreatePaymentVoucher

func (trcn *TestRetrievalClientNode) CreatePaymentVoucher(ctx context.Context, paymentChannel address.Address, amount abi.TokenAmount, lane uint64, tok shared.TipSetToken) (*paychtypes.SignedVoucher, error)

CreatePaymentVoucher creates a mock payment voucher based on a channel and lane

func (*TestRetrievalClientNode) ExpectKnownAddresses

func (trcn *TestRetrievalClientNode) ExpectKnownAddresses(p retrievalmarket.RetrievalPeer, maddrs []ma.Multiaddr)

ExpectKnownAddresses stubs a return for a look up of known addresses for the given retrieval peer and the fact that it was looked up is verified with VerifyExpectations

func (*TestRetrievalClientNode) GetChainHead

GetChainHead returns a mock value for the chain head

func (*TestRetrievalClientNode) GetKnownAddresses

GetKnownAddresses gets any on known multiaddrs for a given address, so we can add to the peer store

func (*TestRetrievalClientNode) GetOrCreatePaymentChannel

func (trcn *TestRetrievalClientNode) GetOrCreatePaymentChannel(ctx context.Context, clientAddress address.Address, minerAddress address.Address, clientFundsAvailable abi.TokenAmount, tok shared.TipSetToken) (address.Address, cid.Cid, error)

GetOrCreatePaymentChannel returns a mocked payment channel

func (*TestRetrievalClientNode) ResetChannelAvailableFunds

func (trcn *TestRetrievalClientNode) ResetChannelAvailableFunds(channelAvailableFunds retrievalmarket.ChannelAvailableFunds)

ResetChannelAvailableFunds is a way to manually change the funds in the payment channel

func (*TestRetrievalClientNode) VerifyExpectations

func (trcn *TestRetrievalClientNode) VerifyExpectations(t *testing.T)

VerifyExpectations verifies that all expected known addresses were looked up

func (*TestRetrievalClientNode) WaitForPaymentChannelReady

func (trcn *TestRetrievalClientNode) WaitForPaymentChannelReady(ctx context.Context, messageCID cid.Cid) (address.Address, error)

WaitForPaymentChannelReady simulates waiting for a payment channel to finish adding funds

type TestRetrievalClientNodeParams

type TestRetrievalClientNodeParams struct {
	PayCh                       address.Address
	PayChErr                    error
	CreatePaychCID, AddFundsCID cid.Cid
	Lane                        uint64
	LaneError                   error
	Voucher                     *paychtypes.SignedVoucher
	VoucherError                error
	AllocateLaneRecorder        func(address.Address)
	PaymentVoucherRecorder      func(voucher *paychtypes.SignedVoucher)
	PaymentChannelRecorder      func(address.Address, address.Address, abi.TokenAmount)
	AddFundsOnly                bool
	WaitForReadyErr             error
	ChannelAvailableFunds       retrievalmarket.ChannelAvailableFunds
	CheckAvailableFundsErr      error
	IntegrationTest             bool
}

TestRetrievalClientNodeParams are parameters for initializing a TestRetrievalClientNode

type TestRetrievalProviderNode

type TestRetrievalProviderNode struct {
	ChainHeadError error
	// contains filtered or unexported fields
}

TestRetrievalProviderNode is a node adapter for a retrieval provider whose responses are mocked

func NewTestRetrievalProviderNode

func NewTestRetrievalProviderNode() *TestRetrievalProviderNode

NewTestRetrievalProviderNode instantiates a new TestRetrievalProviderNode

func (*TestRetrievalProviderNode) ExpectPricingParams

func (trpn *TestRetrievalProviderNode) ExpectPricingParams(pieceCID cid.Cid, deals []abi.DealID)

func (*TestRetrievalProviderNode) ExpectVoucher

func (trpn *TestRetrievalProviderNode) ExpectVoucher(
	paymentChannel address.Address,
	voucher *paychtypes.SignedVoucher,
	proof []byte,
	expectedAmount abi.TokenAmount,
	actualAmount abi.TokenAmount,
	expectedErr error) error

ExpectVoucher sets a voucher to be expected by SavePaymentVoucher

    paymentChannel: the address of the payment channel the client creates
    voucher: the voucher to match
    proof: the proof to use (can be blank)
	   expectedAmount: the expected tokenamount for this voucher
    actualAmount: the actual amount to use.  use same as expectedAmount unless you want to trigger an error
    expectedErr:  an error message to expect

func (*TestRetrievalProviderNode) GetChainHead

GetChainHead returns a mock value for the chain head

func (*TestRetrievalProviderNode) GetMinerWorkerAddress

func (trpn *TestRetrievalProviderNode) GetMinerWorkerAddress(ctx context.Context, addr address.Address, tok shared.TipSetToken) (address.Address, error)

GetMinerWorkerAddress translates an address

func (*TestRetrievalProviderNode) GetRetrievalPricingInput

func (trpn *TestRetrievalProviderNode) GetRetrievalPricingInput(_ context.Context, pieceCID cid.Cid, deals []abi.DealID) (retrievalmarket.PricingInput, error)

func (*TestRetrievalProviderNode) MarkVerified

func (trpn *TestRetrievalProviderNode) MarkVerified()

func (*TestRetrievalProviderNode) MaxReceivedVoucher

func (trpn *TestRetrievalProviderNode) MaxReceivedVoucher() abi.TokenAmount

func (*TestRetrievalProviderNode) SavePaymentVoucher

func (trpn *TestRetrievalProviderNode) SavePaymentVoucher(
	ctx context.Context,
	paymentChannel address.Address,
	voucher *paychtypes.SignedVoucher,
	proof []byte,
	expectedAmount abi.TokenAmount,
	tok shared.TipSetToken) (abi.TokenAmount, error)

SavePaymentVoucher simulates saving a payment voucher with a stubbed result

func (*TestRetrievalProviderNode) VerifyExpectations

func (trpn *TestRetrievalProviderNode) VerifyExpectations(t *testing.T)

VerifyExpectations verifies that all expected calls were made and no other calls were made

type TestSectorAccessor

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

TestSectorAccessor is a mock implementation of the SectorAccessor

func NewTestSectorAccessor

func NewTestSectorAccessor() *TestSectorAccessor

NewTestSectorAccessor instantiates a new TestSectorAccessor

func (*TestSectorAccessor) ExpectFailedUnseal

func (trpn *TestSectorAccessor) ExpectFailedUnseal(sectorID abi.SectorNumber, offset, length abi.UnpaddedPieceSize)

ExpectFailedUnseal indicates an expectation that a call will be made to unseal a sector with the given params and should fail

func (*TestSectorAccessor) ExpectUnseal

func (trpn *TestSectorAccessor) ExpectUnseal(sectorID abi.SectorNumber, offset, length abi.UnpaddedPieceSize, data []byte)

ExpectUnseal indicates an expectation that a call will be made to unseal a sector with the given params and should return the given data

func (*TestSectorAccessor) FinishUnseal

func (trpn *TestSectorAccessor) FinishUnseal()

func (*TestSectorAccessor) IsUnsealed

func (trpn *TestSectorAccessor) IsUnsealed(ctx context.Context, sectorID abi.SectorNumber, offset abi.UnpaddedPieceSize, length abi.UnpaddedPieceSize) (bool, error)

func (*TestSectorAccessor) MarkUnsealed

func (trpn *TestSectorAccessor) MarkUnsealed(ctx context.Context, sectorID abi.SectorNumber, offset abi.UnpaddedPieceSize, length abi.UnpaddedPieceSize)

func (*TestSectorAccessor) PauseUnseal

func (trpn *TestSectorAccessor) PauseUnseal()

func (*TestSectorAccessor) StubUnseal

func (trpn *TestSectorAccessor) StubUnseal(sectorID abi.SectorNumber, offset, length abi.UnpaddedPieceSize, data []byte)

StubUnseal stubs a response to attempting to unseal a sector with the given paramters

func (*TestSectorAccessor) UnsealSector

func (trpn *TestSectorAccessor) UnsealSector(ctx context.Context, sectorID abi.SectorNumber, offset, length abi.UnpaddedPieceSize) (io.ReadCloser, error)

UnsealSector simulates unsealing a sector by returning a stubbed response or erroring

func (*TestSectorAccessor) VerifyExpectations

func (trpn *TestSectorAccessor) VerifyExpectations(t *testing.T)

VerifyExpectations verifies that all expected calls were made and no other calls were made

Jump to

Keyboard shortcuts

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