diff --git a/pkg/neotest/basic.go b/pkg/neotest/basic.go index 501254ae9..dc217f01e 100644 --- a/pkg/neotest/basic.go +++ b/pkg/neotest/basic.go @@ -109,15 +109,19 @@ func (e *Executor) SignTx(t *testing.T, tx *transaction.Transaction, sysFee int6 return tx } -// NewAccount returns new signer holding 100.0 GAS. This method advances the chain -// by one block with a transfer transaction. -func (e *Executor) NewAccount(t *testing.T) Signer { +// NewAccount returns new signer holding 100.0 GAS (or given amount is specified). +// This method advances the chain by one block with a transfer transaction. +func (e *Executor) NewAccount(t *testing.T, expectedGASBalance ...int64) Signer { acc, err := wallet.NewAccount() require.NoError(t, err) - tx := e.NewTx(t, []Signer{e.Committee}, + amount := int64(100_0000_0000) + if len(expectedGASBalance) != 0 { + amount = expectedGASBalance[0] + } + tx := e.NewTx(t, []Signer{e.Validator}, e.NativeHash(t, nativenames.Gas), "transfer", - e.Committee.ScriptHash(), acc.Contract.ScriptHash(), int64(100_0000_0000), nil) + e.Validator.ScriptHash(), acc.Contract.ScriptHash(), amount, nil) e.AddNewBlock(t, tx) e.CheckHalt(t, tx.Hash()) return NewSingleSigner(acc) @@ -233,11 +237,11 @@ func (e *Executor) NewDeployTx(t *testing.T, bc blockchainer.Blockchainer, c *Co tx.Nonce = Nonce() tx.ValidUntilBlock = bc.BlockHeight() + 1 tx.Signers = []transaction.Signer{{ - Account: e.Committee.ScriptHash(), + Account: e.Validator.ScriptHash(), Scopes: transaction.Global, }} - addNetworkFee(bc, tx, e.Committee) - require.NoError(t, e.Committee.SignTx(netmode.UnitTestNet, tx)) + addNetworkFee(bc, tx, e.Validator) + require.NoError(t, e.Validator.SignTx(netmode.UnitTestNet, tx)) return tx } diff --git a/pkg/neotest/client.go b/pkg/neotest/client.go index 89ac48cf7..330cf8a3e 100644 --- a/pkg/neotest/client.go +++ b/pkg/neotest/client.go @@ -19,7 +19,7 @@ type ContractInvoker struct { Signers []Signer } -// CommitteeInvoker creates new ContractInvoker for contract with hash h. +// CommitteeInvoker creates new ContractInvoker for contract with hash h and committee multisignature signer. func (e *Executor) CommitteeInvoker(h util.Uint160) *ContractInvoker { return &ContractInvoker{ Executor: e, @@ -28,6 +28,15 @@ func (e *Executor) CommitteeInvoker(h util.Uint160) *ContractInvoker { } } +// ValidatorInvoker creates new ContractInvoker for contract with hash h and validators multisignature signer. +func (e *Executor) ValidatorInvoker(h util.Uint160) *ContractInvoker { + return &ContractInvoker{ + Executor: e, + Hash: h, + Signers: []Signer{e.Validator}, + } +} + // TestInvoke creates test VM and invokes method with args. func (c *ContractInvoker) TestInvoke(t *testing.T, method string, args ...interface{}) (*vm.Stack, error) { tx := c.PrepareInvokeNoSign(t, method, args...)