mock

package
v2.3.12 Latest Latest
Warning

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

Go to latest
Published: Apr 22, 2021 License: Apache-2.0, MIT Imports: 25 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckActorExports

func CheckActorExports(t *testing.T, act interface{ Exports() []interface{} })

Types

type Runtime

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

A mock runtime for unit testing of actors in isolation. The mock allows direct specification of the runtime context as observable by an actor, supports the storage interface, and mocks out side-effect-inducing calls.

func (*Runtime) Abortf

func (rt *Runtime) Abortf(errExitCode exitcode.ExitCode, msg string, args ...interface{})

func (*Runtime) AddIDAddress

func (rt *Runtime) AddIDAddress(src addr.Address, target addr.Address)

func (*Runtime) AdtStore

func (rt *Runtime) AdtStore() adt.Store

func (*Runtime) Balance

func (rt *Runtime) Balance() abi.TokenAmount

func (*Runtime) BatchVerifySeals

func (rt *Runtime) BatchVerifySeals(vis map[addr.Address][]proof.SealVerifyInfo) (map[addr.Address][]bool, error)

func (*Runtime) BlockMiner

func (rt *Runtime) BlockMiner() addr.Address

func (*Runtime) Call

func (rt *Runtime) Call(method interface{}, params interface{}) interface{}

func (*Runtime) Caller

func (rt *Runtime) Caller() addr.Address

func (*Runtime) ChargeGas

func (rt *Runtime) ChargeGas(_ string, gas, _ int64)

func (*Runtime) ClearLogs

func (rt *Runtime) ClearLogs()

func (*Runtime) ComputeUnsealedSectorCID

func (rt *Runtime) ComputeUnsealedSectorCID(reg abi.RegisteredSealProof, pieces []abi.PieceInfo) (cid.Cid, error)

func (*Runtime) Context

func (rt *Runtime) Context() context.Context

func (*Runtime) CreateActor

func (rt *Runtime) CreateActor(codeId cid.Cid, address addr.Address)

func (*Runtime) CurrEpoch

func (rt *Runtime) CurrEpoch() abi.ChainEpoch

func (*Runtime) CurrentBalance

func (rt *Runtime) CurrentBalance() abi.TokenAmount

func (*Runtime) DeleteActor

func (rt *Runtime) DeleteActor(addr addr.Address)

func (*Runtime) Epoch

func (rt *Runtime) Epoch() abi.ChainEpoch

func (*Runtime) ExpectAbort

func (rt *Runtime) ExpectAbort(expected exitcode.ExitCode, f func())

Calls f() expecting it to invoke Runtime.Abortf() with a specified exit code.

func (*Runtime) ExpectAbortContainsMessage

func (rt *Runtime) ExpectAbortContainsMessage(expected exitcode.ExitCode, substr string, f func())

Calls f() expecting it to invoke Runtime.Abortf() with a specified exit code and message.

func (*Runtime) ExpectAssertionFailure

func (rt *Runtime) ExpectAssertionFailure(expected string, f func())

func (*Runtime) ExpectBatchVerifySeals

func (rt *Runtime) ExpectBatchVerifySeals(in map[addr.Address][]proof.SealVerifyInfo, out map[addr.Address][]bool, err error)

func (*Runtime) ExpectComputeUnsealedSectorCID

func (rt *Runtime) ExpectComputeUnsealedSectorCID(reg abi.RegisteredSealProof, pieces []abi.PieceInfo, cid cid.Cid, err error)

func (*Runtime) ExpectCreateActor

func (rt *Runtime) ExpectCreateActor(codeId cid.Cid, address addr.Address)

func (*Runtime) ExpectDeleteActor

func (rt *Runtime) ExpectDeleteActor(beneficiary addr.Address)

func (*Runtime) ExpectGasCharged

func (rt *Runtime) ExpectGasCharged(gas int64)

func (*Runtime) ExpectGetRandomnessBeacon

func (rt *Runtime) ExpectGetRandomnessBeacon(tag crypto.DomainSeparationTag, epoch abi.ChainEpoch, entropy []byte, out abi.Randomness)

func (*Runtime) ExpectGetRandomnessTickets

func (rt *Runtime) ExpectGetRandomnessTickets(tag crypto.DomainSeparationTag, epoch abi.ChainEpoch, entropy []byte, out abi.Randomness)

func (*Runtime) ExpectLogsContain

func (rt *Runtime) ExpectLogsContain(substr string)

func (*Runtime) ExpectSend

func (rt *Runtime) ExpectSend(toAddr addr.Address, methodNum abi.MethodNum, params cbor.Marshaler, value abi.TokenAmount, ret cbor.Er, exitCode exitcode.ExitCode)

func (*Runtime) ExpectValidateCallerAddr

func (rt *Runtime) ExpectValidateCallerAddr(addrs ...addr.Address)

func (*Runtime) ExpectValidateCallerAny

func (rt *Runtime) ExpectValidateCallerAny()

func (*Runtime) ExpectValidateCallerType

func (rt *Runtime) ExpectValidateCallerType(types ...cid.Cid)

func (*Runtime) ExpectVerifyConsensusFault

func (rt *Runtime) ExpectVerifyConsensusFault(h1, h2, extra []byte, result *runtime.ConsensusFault, resultErr error)

func (*Runtime) ExpectVerifyPoSt

func (rt *Runtime) ExpectVerifyPoSt(post proof.WindowPoStVerifyInfo, result error)

func (*Runtime) ExpectVerifySeal

func (rt *Runtime) ExpectVerifySeal(seal proof.SealVerifyInfo, result error)

func (*Runtime) ExpectVerifySignature

func (rt *Runtime) ExpectVerifySignature(sig crypto.Signature, signer addr.Address, plaintext []byte, result error)

func (*Runtime) GetActorCodeCID

func (rt *Runtime) GetActorCodeCID(addr addr.Address) (ret cid.Cid, ok bool)

func (*Runtime) GetIdAddr

func (rt *Runtime) GetIdAddr(raw addr.Address) (addr.Address, bool)

func (*Runtime) GetRandomnessFromBeacon

func (rt *Runtime) GetRandomnessFromBeacon(tag crypto.DomainSeparationTag, epoch abi.ChainEpoch, entropy []byte) abi.Randomness

func (*Runtime) GetRandomnessFromTickets

func (rt *Runtime) GetRandomnessFromTickets(tag crypto.DomainSeparationTag, epoch abi.ChainEpoch, entropy []byte) abi.Randomness

func (*Runtime) GetState

func (rt *Runtime) GetState(o cbor.Unmarshaler)

func (*Runtime) HashBlake2b

func (rt *Runtime) HashBlake2b(data []byte) [32]byte

func (*Runtime) Log

func (rt *Runtime) Log(level rt.LogLevel, msg string, args ...interface{})

func (*Runtime) NetworkVersion

func (rt *Runtime) NetworkVersion() network.Version

func (*Runtime) NewActorAddress

func (rt *Runtime) NewActorAddress() addr.Address

func (*Runtime) Receiver

func (rt *Runtime) Receiver() addr.Address

func (*Runtime) ReplaceState

func (rt *Runtime) ReplaceState(o cbor.Marshaler)

func (*Runtime) Reset

func (rt *Runtime) Reset()

Resets expectations

func (*Runtime) ResolveAddress

func (rt *Runtime) ResolveAddress(address addr.Address) (ret addr.Address, ok bool)

func (*Runtime) Send

func (rt *Runtime) Send(toAddr addr.Address, methodNum abi.MethodNum, params cbor.Marshaler, value abi.TokenAmount, out cbor.Er) exitcode.ExitCode

func (*Runtime) SetAddressActorType

func (rt *Runtime) SetAddressActorType(address addr.Address, actorType cid.Cid)

func (*Runtime) SetBalance

func (rt *Runtime) SetBalance(amt abi.TokenAmount)

func (*Runtime) SetCaller

func (rt *Runtime) SetCaller(address addr.Address, actorType cid.Cid)

func (*Runtime) SetCirculatingSupply

func (rt *Runtime) SetCirculatingSupply(amt abi.TokenAmount)

func (*Runtime) SetEpoch

func (rt *Runtime) SetEpoch(epoch abi.ChainEpoch)

func (*Runtime) SetHasher

func (rt *Runtime) SetHasher(f func(data []byte) [32]byte)

func (*Runtime) SetNetworkVersion

func (rt *Runtime) SetNetworkVersion(v network.Version)

func (*Runtime) SetNewActorAddress

func (rt *Runtime) SetNewActorAddress(actAddr addr.Address)

func (*Runtime) SetReceived

func (rt *Runtime) SetReceived(amt abi.TokenAmount)

func (*Runtime) StartSpan

func (rt *Runtime) StartSpan(_ string) func()

func (*Runtime) StateCreate

func (rt *Runtime) StateCreate(obj cbor.Marshaler)

func (*Runtime) StateReadonly

func (rt *Runtime) StateReadonly(st cbor.Unmarshaler)

func (*Runtime) StateRoot

func (rt *Runtime) StateRoot() cid.Cid

func (*Runtime) StateTransaction

func (rt *Runtime) StateTransaction(st cbor.Er, f func())

func (*Runtime) StoreGet

func (rt *Runtime) StoreGet(c cid.Cid, o cbor.Unmarshaler) bool

func (*Runtime) StorePut

func (rt *Runtime) StorePut(o cbor.Marshaler) cid.Cid

func (*Runtime) TotalFilCircSupply

func (rt *Runtime) TotalFilCircSupply() abi.TokenAmount

func (*Runtime) ValidateImmediateCallerAcceptAny

func (rt *Runtime) ValidateImmediateCallerAcceptAny()

func (*Runtime) ValidateImmediateCallerIs

func (rt *Runtime) ValidateImmediateCallerIs(addrs ...addr.Address)

func (*Runtime) ValidateImmediateCallerType

func (rt *Runtime) ValidateImmediateCallerType(types ...cid.Cid)

func (*Runtime) ValueReceived

func (rt *Runtime) ValueReceived() abi.TokenAmount

func (*Runtime) Verify

func (rt *Runtime) Verify()

Verifies that expected calls were received, and resets all expectations.

func (*Runtime) VerifyConsensusFault

func (rt *Runtime) VerifyConsensusFault(h1, h2, extra []byte) (*runtime.ConsensusFault, error)

func (*Runtime) VerifyPoSt

func (rt *Runtime) VerifyPoSt(vi proof.WindowPoStVerifyInfo) error

func (*Runtime) VerifySeal

func (rt *Runtime) VerifySeal(seal proof.SealVerifyInfo) error

func (*Runtime) VerifySignature

func (rt *Runtime) VerifySignature(sig crypto.Signature, signer addr.Address, plaintext []byte) error

type RuntimeBuilder

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

Build for fluent initialization of a mock runtime.

func NewBuilder

func NewBuilder(ctx context.Context, receiver addr.Address) *RuntimeBuilder

Initializes a new builder with a receiving actor address.

func (*RuntimeBuilder) Build

func (b *RuntimeBuilder) Build(t testing.TB) *Runtime

Builds a new runtime object with the configured values.

func (*RuntimeBuilder) WithActorType

func (b *RuntimeBuilder) WithActorType(addr addr.Address, code cid.Cid) *RuntimeBuilder

func (*RuntimeBuilder) WithBalance

func (b *RuntimeBuilder) WithBalance(balance, received abi.TokenAmount) *RuntimeBuilder

func (*RuntimeBuilder) WithCaller

func (b *RuntimeBuilder) WithCaller(address addr.Address, code cid.Cid) *RuntimeBuilder

func (*RuntimeBuilder) WithEpoch

func (b *RuntimeBuilder) WithEpoch(epoch abi.ChainEpoch) *RuntimeBuilder

func (*RuntimeBuilder) WithHasher

func (b *RuntimeBuilder) WithHasher(f func(data []byte) [32]byte) *RuntimeBuilder

func (*RuntimeBuilder) WithMiner

func (b *RuntimeBuilder) WithMiner(miner addr.Address) *RuntimeBuilder

func (*RuntimeBuilder) WithNetworkVersion

func (b *RuntimeBuilder) WithNetworkVersion(version network.Version) *RuntimeBuilder

type TraceSpan

type TraceSpan struct {
}

func (TraceSpan) End

func (t TraceSpan) End()

Jump to

Keyboard shortcuts

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