wasmsolo

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Oct 27, 2021 License: Apache-2.0, BSD-2-Clause Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SoloDebug        = false
	SoloHostTracing  = false
	SoloStackTracing = false
)

Variables

View Source
var (
	GoDebug = flag.Bool("godebug", false, "debug go smart contract code")
	GoWasm  = flag.Bool("gowasm", false, "prefer go wasm smart contract code")
)

Functions

func StartChain

func StartChain(t *testing.T, chainName string, env ...*solo.Solo) *solo.Chain

StartChain starts a new chain named chainName.

Types

type SoloAgent

type SoloAgent struct {
	Env  *solo.Solo
	Pair *ed25519.KeyPair
	// contains filtered or unexported fields
}

func NewSoloAgent

func NewSoloAgent(env *solo.Solo) *SoloAgent

func (*SoloAgent) Balance

func (a *SoloAgent) Balance(color ...wasmlib.ScColor) int64

func (*SoloAgent) Mint

func (a *SoloAgent) Mint(amount int64) (wasmlib.ScColor, error)

func (*SoloAgent) ScAddress

func (a *SoloAgent) ScAddress() wasmlib.ScAddress

func (*SoloAgent) ScAgentID

func (a *SoloAgent) ScAgentID() wasmlib.ScAgentID

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

func (cvt SoloConvertor) ScHname(hname iscp.Hname) wasmlib.ScHname

func (SoloConvertor) ScRequestID

func (cvt SoloConvertor) ScRequestID(requestID iscp.RequestID) wasmlib.ScRequestID

type SoloScContext

type SoloScContext struct {
	wasmproc.ScContext
	// contains filtered or unexported fields
}

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)

Jump to

Keyboard shortcuts

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