Documentation
¶
Index ¶
- func Nonce() uint32
- func TestInvoke(bc blockchainer.Blockchainer, tx *transaction.Transaction) (*vm.VM, error)
- type Contract
- type ContractInvoker
- func (c *ContractInvoker) Invoke(t *testing.T, result interface{}, method string, args ...interface{}) util.Uint256
- func (c *ContractInvoker) InvokeFail(t *testing.T, message string, method string, args ...interface{})
- func (c *ContractInvoker) InvokeWithFeeFail(t *testing.T, message string, sysFee int64, method string, args ...interface{}) util.Uint256
- func (c *ContractInvoker) PrepareInvoke(t *testing.T, method string, args ...interface{}) *transaction.Transaction
- func (c *ContractInvoker) PrepareInvokeNoSign(t *testing.T, method string, args ...interface{}) *transaction.Transaction
- func (c *ContractInvoker) TestInvoke(t *testing.T, method string, args ...interface{}) (*vm.Stack, error)
- func (c *ContractInvoker) WithSigners(signers ...Signer) *ContractInvoker
- type Executor
- func (e *Executor) AddBlockCheckHalt(t *testing.T, txs ...*transaction.Transaction) *block.Block
- func (e *Executor) AddNewBlock(t *testing.T, txs ...*transaction.Transaction) *block.Block
- func (e *Executor) CheckFault(t *testing.T, h util.Uint256, s string)
- func (e *Executor) CheckHalt(t *testing.T, h util.Uint256, stack ...stackitem.Item) *state.AppExecResult
- func (e *Executor) CheckTxNotificationEvent(t *testing.T, h util.Uint256, index int, expected state.NotificationEvent)
- func (e *Executor) CommitteeInvoker(h util.Uint160) *ContractInvoker
- func (e *Executor) DeployContract(t *testing.T, c *Contract, data interface{}) util.Uint256
- func (e *Executor) DeployContractCheckFAULT(t *testing.T, c *Contract, data interface{}, errMessage string)
- func (e *Executor) InvokeScript(t *testing.T, script []byte, signers []Signer) util.Uint256
- func (e *Executor) InvokeScriptCheckFAULT(t *testing.T, script []byte, signers []Signer, errMessage string)
- func (e *Executor) InvokeScriptCheckHALT(t *testing.T, script []byte, signers []Signer, stack ...stackitem.Item)
- func (e *Executor) NativeHash(t *testing.T, name string) util.Uint160
- func (e *Executor) NewAccount(t *testing.T) Signer
- func (e *Executor) NewDeployTx(t *testing.T, bc blockchainer.Blockchainer, c *Contract, data interface{}) *transaction.Transaction
- func (e *Executor) NewTx(t *testing.T, signers []Signer, hash util.Uint160, method string, ...) *transaction.Transaction
- func (e *Executor) NewUnsignedBlock(t *testing.T, txs ...*transaction.Transaction) *block.Block
- func (e *Executor) NewUnsignedTx(t *testing.T, hash util.Uint160, method string, args ...interface{}) *transaction.Transaction
- func (e *Executor) SignBlock(b *block.Block) *block.Block
- func (e *Executor) SignTx(t *testing.T, tx *transaction.Transaction, sysFee int64, signers ...Signer) *transaction.Transaction
- func (e *Executor) TopBlock(t *testing.T) *block.Block
- type Signer
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Nonce ¶
func Nonce() uint32
Nonce returns unique number that can be used as nonce for new transactions.
func TestInvoke ¶
func TestInvoke(bc blockchainer.Blockchainer, tx *transaction.Transaction) (*vm.VM, error)
TestInvoke creates a test VM with dummy block and executes transaction in it.
Types ¶
type Contract ¶
Contract contains contract info for deployment.
func CompileFile ¶
CompileFile compiles contract from file and returns it's NEF, manifest and hash.
type ContractInvoker ¶
ContractInvoker is a client for specific contract.
func (*ContractInvoker) Invoke ¶
func (c *ContractInvoker) Invoke(t *testing.T, result interface{}, method string, args ...interface{}) util.Uint256
Invoke invokes method with args, persists transaction and checks the result. Returns transaction hash.
func (*ContractInvoker) InvokeFail ¶
func (c *ContractInvoker) InvokeFail(t *testing.T, message string, method string, args ...interface{})
InvokeFail invokes method with args, persists transaction and checks the error message. Returns transaction hash.
func (*ContractInvoker) InvokeWithFeeFail ¶
func (c *ContractInvoker) InvokeWithFeeFail(t *testing.T, message string, sysFee int64, method string, args ...interface{}) util.Uint256
InvokeWithFeeFail is like InvokeFail but sets custom system fee for the transaction.
func (*ContractInvoker) PrepareInvoke ¶
func (c *ContractInvoker) PrepareInvoke(t *testing.T, method string, args ...interface{}) *transaction.Transaction
PrepareInvoke creates new invocation transaction.
func (*ContractInvoker) PrepareInvokeNoSign ¶
func (c *ContractInvoker) PrepareInvokeNoSign(t *testing.T, method string, args ...interface{}) *transaction.Transaction
PrepareInvokeNoSign creates new unsigned invocation transaction.
func (*ContractInvoker) TestInvoke ¶
func (c *ContractInvoker) TestInvoke(t *testing.T, method string, args ...interface{}) (*vm.Stack, error)
TestInvoke creates test VM and invokes method with args.
func (*ContractInvoker) WithSigners ¶
func (c *ContractInvoker) WithSigners(signers ...Signer) *ContractInvoker
WithSigners creates new client with the provided signer.
type Executor ¶
type Executor struct { Chain blockchainer.Blockchainer Validator Signer Committee Signer CommitteeHash util.Uint160 Contracts map[string]*Contract }
Executor is a wrapper over chain state.
func NewExecutor ¶
func NewExecutor(t *testing.T, bc blockchainer.Blockchainer, validator, committee Signer) *Executor
NewExecutor creates new executor instance from provided blockchain and committee.
func (*Executor) AddBlockCheckHalt ¶
func (e *Executor) AddBlockCheckHalt(t *testing.T, txs ...*transaction.Transaction) *block.Block
AddBlockCheckHalt is a convenient wrapper over AddBlock and CheckHalt.
func (*Executor) AddNewBlock ¶
func (e *Executor) AddNewBlock(t *testing.T, txs ...*transaction.Transaction) *block.Block
AddNewBlock creates a new block from provided transactions and adds it on bc.
func (*Executor) CheckFault ¶
CheckFault checks that transaction persisted with FAULT state. Raised exception is also checked to contain s as a substring.
func (*Executor) CheckHalt ¶
func (e *Executor) CheckHalt(t *testing.T, h util.Uint256, stack ...stackitem.Item) *state.AppExecResult
CheckHalt checks that transaction persisted with HALT state.
func (*Executor) CheckTxNotificationEvent ¶
func (e *Executor) CheckTxNotificationEvent(t *testing.T, h util.Uint256, index int, expected state.NotificationEvent)
CheckTxNotificationEvent checks that specified event was emitted at the specified position during transaction script execution. Negative index corresponds to backwards enumeration.
func (*Executor) CommitteeInvoker ¶
func (e *Executor) CommitteeInvoker(h util.Uint160) *ContractInvoker
CommitteeInvoker creates new ContractInvoker for contract with hash h.
func (*Executor) DeployContract ¶
DeployContract compiles and deploys contract to bc. It also checks that precalculated contract hash matches the actual one. data is an optional argument to `_deploy`. Returns hash of the deploy transaction.
func (*Executor) DeployContractCheckFAULT ¶
func (e *Executor) DeployContractCheckFAULT(t *testing.T, c *Contract, data interface{}, errMessage string)
DeployContractCheckFAULT compiles and deploys contract to bc. It checks that deploy transaction FAULTed with the specified error.
func (*Executor) InvokeScript ¶
InvokeScript adds transaction with the specified script to the chain and returns its hash. It does no faults check.
func (*Executor) InvokeScriptCheckFAULT ¶
func (e *Executor) InvokeScriptCheckFAULT(t *testing.T, script []byte, signers []Signer, errMessage string)
InvokeScriptCheckFAULT adds transaction with the specified script to the chain and checks it's FAULTed with the specified error.
func (*Executor) InvokeScriptCheckHALT ¶
func (e *Executor) InvokeScriptCheckHALT(t *testing.T, script []byte, signers []Signer, stack ...stackitem.Item)
InvokeScriptCheckHALT adds transaction with the specified script to the chain and checks it's HALTed with the specified items on stack.
func (*Executor) NativeHash ¶
NativeHash returns native contract hash by name.
func (*Executor) NewAccount ¶
NewAccount returns new signer holding 100.0 GAS. This method advances the chain by one block with a transfer transaction.
func (*Executor) NewDeployTx ¶
func (e *Executor) NewDeployTx(t *testing.T, bc blockchainer.Blockchainer, c *Contract, data interface{}) *transaction.Transaction
NewDeployTx returns new deployment tx for contract signed by committee.
func (*Executor) NewTx ¶
func (e *Executor) NewTx(t *testing.T, signers []Signer, hash util.Uint160, method string, args ...interface{}) *transaction.Transaction
NewTx creates new transaction which invokes contract method. Transaction is signed with signer.
func (*Executor) NewUnsignedBlock ¶
func (e *Executor) NewUnsignedBlock(t *testing.T, txs ...*transaction.Transaction) *block.Block
NewUnsignedBlock creates new unsigned block from txs.
func (*Executor) NewUnsignedTx ¶
func (e *Executor) NewUnsignedTx(t *testing.T, hash util.Uint160, method string, args ...interface{}) *transaction.Transaction
NewUnsignedTx creates new unsigned transaction which invokes method of contract with hash.
func (*Executor) SignTx ¶
func (e *Executor) SignTx(t *testing.T, tx *transaction.Transaction, sysFee int64, signers ...Signer) *transaction.Transaction
SignTx signs a transaction using provided signers.
type Signer ¶
type Signer interface { // ScriptHash returns signer script hash. Script() []byte // Script returns signer verification script. ScriptHash() util.Uint160 // SignHashable returns invocation script for signing an item. SignHashable(uint32, hash.Hashable) []byte // SignTx signs a transaction. SignTx(netmode.Magic, *transaction.Transaction) error }
Signer is a generic interface which can be either simple- or multi-signature signer.
func NewMultiSigner ¶
NewMultiSigner returns multi-signature signer for the provided account. It must contain at least as many accounts as needed to sign the script.
func NewSingleSigner ¶
NewSingleSigner returns multi-signature signer for the provided account. It must contain exactly as many accounts as needed to sign the script.