testnodes

package
v0.3.2 Latest Latest
Warning

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

Go to latest
Published: Jun 30, 2020 License: Apache-2.0, MIT Imports: 15 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(paymentChannel address.Address) (uint64, error)

AllocateLane creates a mock lane on a payment channel

func (*TestRetrievalClientNode) CreatePaymentVoucher

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

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

func (*TestRetrievalClientNode) GetChainHead

GetChainHead returns a mock value for the chain head

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) WaitForPaymentChannelAddFunds

func (trcn *TestRetrievalClientNode) WaitForPaymentChannelAddFunds(messageCID cid.Cid) error

WaitForPaymentChannelAddFunds simulates waiting for a payment channel add funds message to complete

func (*TestRetrievalClientNode) WaitForPaymentChannelCreation

func (trcn *TestRetrievalClientNode) WaitForPaymentChannelCreation(messageCID cid.Cid) (address.Address, error)

WaitForPaymentChannelCreation simulates waiting for a payment channel creation message to complete

type TestRetrievalClientNodeParams

type TestRetrievalClientNodeParams struct {
	PayCh                                  address.Address
	PayChErr                               error
	CreatePaychCID, AddFundsCID            cid.Cid
	Lane                                   uint64
	LaneError                              error
	Voucher                                *paych.SignedVoucher
	VoucherError                           error
	AllocateLaneRecorder                   func(address.Address)
	PaymentVoucherRecorder                 func(voucher *paych.SignedVoucher)
	PaymentChannelRecorder                 func(address.Address, address.Address, abi.TokenAmount)
	AddFundsOnly                           bool
	WaitForAddFundsErr, WaitForChCreateErr error
}

TestRetrievalClientNodeParams are parameters for initializing a TestRetrievalClientNode

type TestRetrievalProviderNode

type TestRetrievalProviderNode struct {
	// 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) ExpectFailedUnseal

func (trpn *TestRetrievalProviderNode) ExpectFailedUnseal(sectorID uint64, offset uint64, length uint64)

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

func (*TestRetrievalProviderNode) ExpectUnseal

func (trpn *TestRetrievalProviderNode) ExpectUnseal(sectorID uint64, offset uint64, length uint64, 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 (*TestRetrievalProviderNode) ExpectVoucher

func (trpn *TestRetrievalProviderNode) ExpectVoucher(
	paymentChannel address.Address,
	voucher *paych.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) SavePaymentVoucher

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

SavePaymentVoucher simulates saving a payment voucher with a stubbed result

func (*TestRetrievalProviderNode) StubUnseal

func (trpn *TestRetrievalProviderNode) StubUnseal(sectorID uint64, offset uint64, length uint64, data []byte)

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

func (*TestRetrievalProviderNode) UnsealSector

func (trpn *TestRetrievalProviderNode) UnsealSector(ctx context.Context, sectorID uint64, offset uint64, length uint64) (io.ReadCloser, error)

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

func (*TestRetrievalProviderNode) VerifyExpectations

func (trpn *TestRetrievalProviderNode) 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