Documentation ¶
Index ¶
- Variables
- func ApplyOk(t *testing.T, v *VM, from, to address.Address, value abi.TokenAmount, ...) cbor.Marshaler
- func CreateAccounts(ctx context.Context, t testing.TB, vm *VM, n int, balance abi.TokenAmount, ...) []address.Address
- func ExpectAttoFil(amount big.Int) *big.Int
- func ExpectBytes(b []byte) *objectExpectation
- func ExpectExitCode(code exitcode.ExitCode) *exitcode.ExitCode
- func ExpectObject(v cbor.Marshaler) *objectExpectation
- func GetDealState(t *testing.T, vm *VM, dealID abi.DealID) (*market.DealState, bool)
- func MinerDLInfo(t *testing.T, v *VM, minerIDAddr address.Address) *dline.Info
- func MinerPower(t *testing.T, vm *VM, minerIdAddr address.Address) miner.PowerPair
- func ParamsForInvocation(t *testing.T, vm *VM, idxs ...int) interface{}
- func PowerForMinerSector(t *testing.T, vm *VM, minerIdAddr address.Address, ...) miner.PowerPair
- func SectorDeadline(t *testing.T, v *VM, minerIDAddress address.Address, ...) (uint64, uint64)
- func ValueForInvocation(t *testing.T, vm *VM, idxs ...int) abi.TokenAmount
- type ActorImplLookup
- type CallStats
- type ExpectInvocation
- type InternalMessage
- type Invocation
- type MethodKey
- type MinerBalances
- type NetworkStats
- type StatsByCall
- type StatsSource
- type VM
- func AdvanceByDeadline(t *testing.T, v *VM, minerIDAddr address.Address, ...) (*VM, *dline.Info)
- func AdvanceByDeadlineTillEpoch(t *testing.T, v *VM, minerIDAddr address.Address, e abi.ChainEpoch) (*VM, *dline.Info)
- func AdvanceByDeadlineTillIndex(t *testing.T, v *VM, minerIDAddr address.Address, i uint64) (*VM, *dline.Info)
- func AdvanceTillProvingDeadline(t *testing.T, v *VM, minerIDAddress address.Address, ...) (*dline.Info, uint64, *VM)
- func NewVM(ctx context.Context, actorImpls ActorImplLookup, store adt.Store) *VM
- func NewVMAtEpoch(ctx context.Context, actorImpls ActorImplLookup, store adt.Store, ...) (*VM, error)
- func NewVMWithSingletons(ctx context.Context, t testing.TB, bs ipldcbor.IpldBlockstore) *VM
- func (vm *VM) Abortf(errExitCode exitcode.ExitCode, msg string, args ...interface{})
- func (vm *VM) ApplyMessage(from, to address.Address, value abi.TokenAmount, method abi.MethodNum, ...) (cbor.Marshaler, exitcode.ExitCode)
- func (vm *VM) GetActor(a address.Address) (*states.Actor, bool, error)
- func (vm *VM) GetCallStats() map[MethodKey]*CallStats
- func (vm *VM) GetEpoch() abi.ChainEpoch
- func (vm *VM) GetLogs() []string
- func (vm *VM) GetState(addr address.Address, out cbor.Unmarshaler) error
- func (vm *VM) GetStateTree() (*states.Tree, error)
- func (vm *VM) GetTotalActorBalance() (abi.TokenAmount, error)
- func (vm *VM) Invocations() []*Invocation
- func (vm *VM) LastInvocation() *Invocation
- func (vm *VM) Log(level rt.LogLevel, msg string, args ...interface{})
- func (vm *VM) NormalizeAddress(addr address.Address) (address.Address, bool)
- func (vm *VM) SetActorState(ctx context.Context, key address.Address, state cbor.Marshaler) error
- func (vm *VM) SetStatsSource(s StatsSource)
- func (vm *VM) StateRoot() cid.Cid
- func (vm *VM) Store() adt.Store
- func (vm *VM) WithEpoch(epoch abi.ChainEpoch) (*VM, error)
- func (vm *VM) WithNetworkVersion(nv network.Version) (*VM, error)
Constants ¶
This section is empty.
Variables ¶
var EmptyObjectCid cid.Cid
var ExpectOK = &okExitCode
var FIL = big.NewInt(1e18)
var VerifregRoot address.Address
Functions ¶
func CreateAccounts ¶
func CreateAccounts(ctx context.Context, t testing.TB, vm *VM, n int, balance abi.TokenAmount, seed int64) []address.Address
Creates n account actors in the VM with the given balance
func ExpectAttoFil ¶
helpers to simplify pointer creation
func ExpectBytes ¶
func ExpectBytes(b []byte) *objectExpectation
func ExpectObject ¶
func GetDealState ¶
func MinerPower ¶
func PowerForMinerSector ¶
func SectorDeadline ¶
func SectorDeadline(t *testing.T, v *VM, minerIDAddress address.Address, sectorNumber abi.SectorNumber) (uint64, uint64)
find the proving deadline and partition index of a miner's sector
func ValueForInvocation ¶
Types ¶
type ActorImplLookup ¶
type CallStats ¶
type CallStats struct { Reads uint64 Writes uint64 Calls uint64 SubStats StatsByCall // contains filtered or unexported fields }
func NewCallStats ¶
func NewCallStats(statsSource StatsSource) *CallStats
func (*CallStats) MergeStats ¶
assume stats have same method type and that other will be discarded after this call
type ExpectInvocation ¶
type ExpectInvocation struct { To address.Address Method abi.MethodNum // optional Exitcode exitcode.ExitCode From address.Address Value *abi.TokenAmount Params *objectExpectation Ret *objectExpectation SubInvocations []ExpectInvocation }
ExpectInvocation is a pattern for a message invocation within the VM. The To and Method fields must be supplied. Exitcode defaults to exitcode.Ok. All other field are optional, where a nil or Undef value indicates that any value will match. SubInvocations will be matched recursively.
func (ExpectInvocation) Matches ¶
func (ei ExpectInvocation) Matches(t *testing.T, invocations *Invocation)
type InternalMessage ¶
type InternalMessage struct {
// contains filtered or unexported fields
}
func (InternalMessage) Caller ¶
func (msg InternalMessage) Caller() address.Address
Caller implements runtime.MessageInfo.
func (InternalMessage) Receiver ¶
func (msg InternalMessage) Receiver() address.Address
Receiver implements runtime.MessageInfo.
func (InternalMessage) ValueReceived ¶
func (msg InternalMessage) ValueReceived() abi.TokenAmount
ValueReceived implements runtime.MessageInfo.
type Invocation ¶
type Invocation struct { Msg *InternalMessage Exitcode exitcode.ExitCode Ret cbor.Marshaler SubInvocations []*Invocation }
type MinerBalances ¶
type MinerBalances struct { AvailableBalance abi.TokenAmount VestingBalance abi.TokenAmount InitialPledge abi.TokenAmount PreCommitDeposit abi.TokenAmount }
func GetMinerBalances ¶
func GetMinerBalances(t *testing.T, vm *VM, minerIdAddr address.Address) MinerBalances
type NetworkStats ¶
type NetworkStats struct { power.State TotalRawBytePower abi.StoragePower TotalBytesCommitted abi.StoragePower TotalQualityAdjPower abi.StoragePower TotalQABytesCommitted abi.StoragePower TotalPledgeCollateral abi.TokenAmount ThisEpochRawBytePower abi.StoragePower ThisEpochQualityAdjPower abi.StoragePower ThisEpochPledgeCollateral abi.TokenAmount MinerCount int64 MinerAboveMinPowerCount int64 ThisEpochReward abi.TokenAmount ThisEpochRewardSmoothed smoothing.FilterEstimate ThisEpochBaselinePower abi.StoragePower TotalStoragePowerReward abi.TokenAmount TotalClientLockedCollateral abi.TokenAmount TotalProviderLockedCollateral abi.TokenAmount TotalClientStorageFee abi.TokenAmount }
func GetNetworkStats ¶
func GetNetworkStats(t *testing.T, vm *VM) NetworkStats
type StatsByCall ¶
func (StatsByCall) MergeAllStats ¶
func (sbc StatsByCall) MergeAllStats(other StatsByCall)
func (StatsByCall) MergeStats ¶
func (sbc StatsByCall) MergeStats(code cid.Cid, methodNum abi.MethodNum, newStats *CallStats)
type StatsSource ¶
type VM ¶
type VM struct {
// contains filtered or unexported fields
}
VM is a simplified message execution framework for the purposes of testing inter-actor communication. The VM maintains actor state and can be used to simulate message validation for a single block or tipset. The VM does not track gas charges, provide working syscalls, validate message nonces and many other things that a compliant VM needs to do.
func AdvanceByDeadline ¶
func AdvanceByDeadline(t *testing.T, v *VM, minerIDAddr address.Address, predicate advanceDeadlinePredicate) (*VM, *dline.Info)
AdvanceByDeadline creates a new VM advanced to an epoch specified by the predicate while keeping the miner state upu-to-date by running a cron at the end of each deadline period.
func AdvanceByDeadlineTillEpoch ¶
func AdvanceByDeadlineTillEpoch(t *testing.T, v *VM, minerIDAddr address.Address, e abi.ChainEpoch) (*VM, *dline.Info)
Advances by deadline until e is contained within the deadline period represented by the returned deadline info. The VM returned will be set to the last deadline close, not at e.
func AdvanceByDeadlineTillIndex ¶
func AdvanceByDeadlineTillIndex(t *testing.T, v *VM, minerIDAddr address.Address, i uint64) (*VM, *dline.Info)
Advances by deadline until the deadline index matches the given index. The vm returned will be set to the close epoch of the previous deadline.
func AdvanceTillProvingDeadline ¶
func AdvanceTillProvingDeadline(t *testing.T, v *VM, minerIDAddress address.Address, sectorNumber abi.SectorNumber) (*dline.Info, uint64, *VM)
Advance to the epoch when the sector is due to be proven. Returns the deadline info for proving deadline for sector, partition index of sector, and a VM at the opening of the deadline (ready for SubmitWindowedPoSt).
func NewVMAtEpoch ¶
func NewVMAtEpoch(ctx context.Context, actorImpls ActorImplLookup, store adt.Store, stateRoot cid.Cid, epoch abi.ChainEpoch) (*VM, error)
NewVM creates a new runtime for executing messages.
func NewVMWithSingletons ¶
Creates a new VM and initializes all singleton actors plus a root verifier account.
func (*VM) ApplyMessage ¶
func (vm *VM) ApplyMessage(from, to address.Address, value abi.TokenAmount, method abi.MethodNum, params interface{}) (cbor.Marshaler, exitcode.ExitCode)
ApplyMessage applies the message to the current state.
func (*VM) GetTotalActorBalance ¶
func (vm *VM) GetTotalActorBalance() (abi.TokenAmount, error)
func (*VM) Invocations ¶
func (vm *VM) Invocations() []*Invocation
func (*VM) LastInvocation ¶
func (vm *VM) LastInvocation() *Invocation
func (*VM) NormalizeAddress ¶
func (*VM) SetActorState ¶
SetActorState stores the state and updates the addressed actor
func (*VM) SetStatsSource ¶
func (vm *VM) SetStatsSource(s StatsSource)