mirror of
https://github.com/nspcc-dev/neo-go.git
synced 2024-11-25 23:42:23 +00:00
neotest: extend Executor with InvokeScript* helpers
It is useful for tests and allows to omit code duplication.
This commit is contained in:
parent
00929be712
commit
a06fbae0ee
1 changed files with 25 additions and 0 deletions
|
@ -135,6 +135,31 @@ func (e *Executor) DeployContract(t *testing.T, c *Contract, data interface{}) u
|
|||
return tx.Hash()
|
||||
}
|
||||
|
||||
// InvokeScript adds transaction with the specified script to the chain and
|
||||
// returns its hash. It does no faults check.
|
||||
func (e *Executor) InvokeScript(t *testing.T, script []byte, signers []Signer) util.Uint256 {
|
||||
tx := transaction.New(script, 0)
|
||||
tx.Nonce = Nonce()
|
||||
tx.ValidUntilBlock = e.Chain.BlockHeight() + 1
|
||||
e.SignTx(t, tx, -1, signers...)
|
||||
e.AddNewBlock(t, tx)
|
||||
return tx.Hash()
|
||||
}
|
||||
|
||||
// InvokeScriptCheckHALT adds transaction with the specified script to the chain
|
||||
// and checks it's HALTed with the specified items on stack.
|
||||
func (e *Executor) InvokeScriptCheckHALT(t *testing.T, script []byte, signers []Signer, stack ...stackitem.Item) {
|
||||
hash := e.InvokeScript(t, script, signers)
|
||||
e.CheckHalt(t, hash, stack...)
|
||||
}
|
||||
|
||||
// InvokeScriptCheckFAULT adds transaction with the specified script to the
|
||||
// chain and checks it's FAULTed with the specified error.
|
||||
func (e *Executor) InvokeScriptCheckFAULT(t *testing.T, script []byte, signers []Signer, errMessage string) {
|
||||
hash := e.InvokeScript(t, script, signers)
|
||||
e.CheckFault(t, hash, errMessage)
|
||||
}
|
||||
|
||||
// CheckHalt checks that transaction persisted with HALT state.
|
||||
func (e *Executor) CheckHalt(t *testing.T, h util.Uint256, stack ...stackitem.Item) *state.AppExecResult {
|
||||
aer, err := e.Chain.GetAppExecResults(h, trigger.Application)
|
||||
|
|
Loading…
Reference in a new issue