Documentation ¶
Index ¶
- Constants
- Variables
- func StartChain(t *testing.T, chainName string, env ...*solo.Solo) *solo.Chain
- type SoloAgent
- type SoloContext
- func NewSoloContext(t *testing.T, scName string, onLoad func(), init ...*wasmlib.ScInitFunc) *SoloContext
- func NewSoloContextForChain(t *testing.T, chain *solo.Chain, creator *SoloAgent, scName string, ...) *SoloContext
- func NewSoloContextForNative(t *testing.T, chain *solo.Chain, creator *SoloAgent, scName string, ...) *SoloContext
- func (ctx *SoloContext) Account() *SoloAgent
- func (ctx *SoloContext) AccountID() wasmlib.ScAgentID
- func (ctx *SoloContext) AdvanceClockBy(step time.Duration)
- func (ctx *SoloContext) Balance(agent *SoloAgent, color ...wasmlib.ScColor) int64
- func (ctx *SoloContext) ChainID() wasmlib.ScChainID
- func (ctx *SoloContext) ChainOwnerID() wasmlib.ScAgentID
- func (ctx *SoloContext) ContractCreator() wasmlib.ScAgentID
- func (ctx *SoloContext) ContractExists(scName string) error
- func (ctx *SoloContext) Creator() *SoloAgent
- func (ctx *SoloContext) EnqueueRequest()
- func (ctx *SoloContext) Host() wasmlib.ScHost
- func (ctx *SoloContext) InitFuncCallContext()
- func (ctx *SoloContext) InitViewCallContext()
- func (ctx *SoloContext) Minted() (wasmlib.ScColor, uint64)
- func (ctx *SoloContext) NewSoloAgent() *SoloAgent
- func (ctx *SoloContext) OffLedger(agent *SoloAgent) wasmlib.ScFuncCallContext
- func (ctx *SoloContext) Originator() *SoloAgent
- func (ctx *SoloContext) Sign(agent *SoloAgent, mint ...uint64) wasmlib.ScFuncCallContext
- func (ctx *SoloContext) SoloContextForCore(t *testing.T, scName string, onLoad func()) *SoloContext
- func (ctx *SoloContext) Transfer() wasmlib.ScTransfers
- func (ctx *SoloContext) WaitForPendingRequests(expectedRequests int, maxWait ...time.Duration) bool
- type SoloConvertor
- func (cvt SoloConvertor) ScAddress(address ledgerstate.Address) wasmlib.ScAddress
- func (cvt SoloConvertor) ScAgentID(agentID *iscp.AgentID) wasmlib.ScAgentID
- func (cvt SoloConvertor) ScChainID(chainID *iscp.ChainID) wasmlib.ScChainID
- func (cvt SoloConvertor) ScColor(color colored.Color) wasmlib.ScColor
- func (cvt SoloConvertor) ScHash(hash hashing.HashValue) wasmlib.ScHash
- func (cvt SoloConvertor) ScHname(hname iscp.Hname) wasmlib.ScHname
- func (cvt SoloConvertor) ScRequestID(requestID iscp.RequestID) wasmlib.ScRequestID
- type SoloScContext
Constants ¶
const ( SoloDebug = false SoloHostTracing = false SoloStackTracing = false )
Variables ¶
Functions ¶
Types ¶
type SoloAgent ¶
type SoloAgent struct { Env *solo.Solo Pair *ed25519.KeyPair // contains filtered or unexported fields }
func NewSoloAgent ¶
type SoloContext ¶
type SoloContext struct { Chain *solo.Chain Convertor SoloConvertor Err error Hprog hashing.HashValue Tx *ledgerstate.Transaction // contains filtered or unexported fields }
func NewSoloContext ¶
func NewSoloContext(t *testing.T, scName string, onLoad func(), init ...*wasmlib.ScInitFunc) *SoloContext
NewSoloContext can be used to create a SoloContext associated with a smart contract with minimal information and will verify successful creation before returning ctx. It will start a default chain "chain1" before initializing the smart contract. It takes the scName and onLoad() function associated with the contract. Optionally, an init.Func that has been initialized with the parameters to pass to the contract's init() function can be specified. Unless you want to use a different chain than the default "chain1" this will be your function of choice to set up a smart contract for your tests
func NewSoloContextForChain ¶
func NewSoloContextForChain(t *testing.T, chain *solo.Chain, creator *SoloAgent, scName string, onLoad func(), init ...*wasmlib.ScInitFunc) *SoloContext
NewSoloContextForChain can be used to create a SoloContext associated with a smart contract on a particular chain. When chain is nil the function will start a default chain "chain1" before initializing the smart contract. When creator is nil the creator will be the chain originator It takes the scName and onLoad() function associated with the contract. Optionally, an init.Func that has been initialized with the parameters to pass to the contract's init() function can be specified. You can check for any error that occurred by checking the ctx.Err member.
func NewSoloContextForNative ¶
func NewSoloContextForNative(t *testing.T, chain *solo.Chain, creator *SoloAgent, scName string, onLoad func(), proc *coreutil.ContractProcessor, init ...*wasmlib.ScInitFunc) *SoloContext
NewSoloContextForNative can be used to create a SoloContext associated with a native smart contract on a particular chain. When chain is nil the function will start a default chain "chain1" before deploying and initializing the smart contract. When creator is nil the creator will be the chain originator It takes the scName, onLoad() function, and processor associated with the contract. Optionally, an init.Func that has been initialized with the parameters to pass to the contract's init() function can be specified. You can check for any error that occurred by checking the ctx.Err member.
func (*SoloContext) Account ¶
func (ctx *SoloContext) Account() *SoloAgent
Account returns a SoloAgent for the smart contract associated with ctx
func (*SoloContext) AccountID ¶
func (ctx *SoloContext) AccountID() wasmlib.ScAgentID
func (*SoloContext) AdvanceClockBy ¶
func (ctx *SoloContext) AdvanceClockBy(step time.Duration)
AdvanceClockBy is used to forward the internal clock by the provided step duration.
func (*SoloContext) Balance ¶
func (ctx *SoloContext) Balance(agent *SoloAgent, color ...wasmlib.ScColor) int64
Balance returns the account balance of the specified agent on the chain associated with ctx. The optional color parameter can be used to retrieve the balance for the specific color. When color is omitted, wasmlib.IOTA is assumed.
func (*SoloContext) ChainID ¶
func (ctx *SoloContext) ChainID() wasmlib.ScChainID
func (*SoloContext) ChainOwnerID ¶
func (ctx *SoloContext) ChainOwnerID() wasmlib.ScAgentID
func (*SoloContext) ContractCreator ¶
func (ctx *SoloContext) ContractCreator() wasmlib.ScAgentID
func (*SoloContext) ContractExists ¶
func (ctx *SoloContext) ContractExists(scName string) error
ContractExists checks to see if the contract named scName exists in the chain associated with ctx.
func (*SoloContext) Creator ¶
func (ctx *SoloContext) Creator() *SoloAgent
Creator returns a SoloAgent representing the contract creator
func (*SoloContext) EnqueueRequest ¶
func (ctx *SoloContext) EnqueueRequest()
func (*SoloContext) Host ¶
func (ctx *SoloContext) Host() wasmlib.ScHost
func (*SoloContext) InitFuncCallContext ¶
func (ctx *SoloContext) InitFuncCallContext()
InitFuncCallContext is a function that is required to use SoloContext as an ScFuncCallContext
func (*SoloContext) InitViewCallContext ¶
func (ctx *SoloContext) InitViewCallContext()
InitViewCallContext is a function that is required to use SoloContext as an ScViewCallContext
func (*SoloContext) Minted ¶
func (ctx *SoloContext) Minted() (wasmlib.ScColor, uint64)
Minted returns the color and amount of newly minted tokens
func (*SoloContext) NewSoloAgent ¶
func (ctx *SoloContext) NewSoloAgent() *SoloAgent
NewSoloAgent creates a new SoloAgent with solo.Saldo tokens in its address
func (*SoloContext) OffLedger ¶
func (ctx *SoloContext) OffLedger(agent *SoloAgent) wasmlib.ScFuncCallContext
OffLedger tells SoloContext to Post() the next request off-ledger
func (*SoloContext) Originator ¶
func (ctx *SoloContext) Originator() *SoloAgent
Originator returns a SoloAgent representing the chain originator
func (*SoloContext) Sign ¶
func (ctx *SoloContext) Sign(agent *SoloAgent, mint ...uint64) wasmlib.ScFuncCallContext
Sign is used to force a different agent for signing a Post() request
func (*SoloContext) SoloContextForCore ¶
func (ctx *SoloContext) SoloContextForCore(t *testing.T, scName string, onLoad func()) *SoloContext
func (*SoloContext) Transfer ¶
func (ctx *SoloContext) Transfer() wasmlib.ScTransfers
Transfer creates a new ScTransfers proxy
func (*SoloContext) WaitForPendingRequests ¶
func (ctx *SoloContext) WaitForPendingRequests(expectedRequests int, maxWait ...time.Duration) bool
WaitForPendingRequests waits for expectedRequests pending requests to be processed. a negative value indicates the absolute amount of requests The function will wait for maxWait (default 5 seconds) duration before giving up with a timeout. The function returns the false in case of a timeout.
type SoloConvertor ¶
type SoloConvertor struct{}
SoloConvertor converts ISCP data types to WasmLib data types
func (SoloConvertor) ScAddress ¶
func (cvt SoloConvertor) ScAddress(address ledgerstate.Address) wasmlib.ScAddress
func (SoloConvertor) ScAgentID ¶
func (cvt SoloConvertor) ScAgentID(agentID *iscp.AgentID) wasmlib.ScAgentID
func (SoloConvertor) ScChainID ¶
func (cvt SoloConvertor) ScChainID(chainID *iscp.ChainID) wasmlib.ScChainID
func (SoloConvertor) ScColor ¶
func (cvt SoloConvertor) ScColor(color colored.Color) wasmlib.ScColor
func (SoloConvertor) ScHash ¶
func (cvt SoloConvertor) ScHash(hash hashing.HashValue) wasmlib.ScHash
func (SoloConvertor) ScRequestID ¶
func (cvt SoloConvertor) ScRequestID(requestID iscp.RequestID) wasmlib.ScRequestID
type SoloScContext ¶
func NewSoloScContext ¶
func NewSoloScContext(ctx *SoloContext) *SoloScContext
func (*SoloScContext) Exists ¶
func (o *SoloScContext) Exists(keyID, typeID int32) bool
func (*SoloScContext) GetBytes ¶
func (o *SoloScContext) GetBytes(keyID, typeID int32) []byte
func (*SoloScContext) GetObjectID ¶
func (o *SoloScContext) GetObjectID(keyID, typeID int32) int32
func (*SoloScContext) SetBytes ¶
func (o *SoloScContext) SetBytes(keyID, typeID int32, bytes []byte)