From 59f3fa1ef1c8fc9a159f759dbfef9b0be6047ae8 Mon Sep 17 00:00:00 2001 From: Anna Shaleva Date: Fri, 18 Mar 2022 18:11:24 +0300 Subject: [PATCH] neotest: adapt framework to work with *testing.B --- pkg/core/native/native_test/common_test.go | 2 +- pkg/core/native/native_test/ledger_test.go | 2 +- pkg/neotest/basic.go | 58 +++++++++++----------- pkg/neotest/chain/chain.go | 29 ++++++----- pkg/neotest/client.go | 14 +++--- pkg/neotest/compile.go | 4 +- pkg/neotest/signer.go | 2 +- 7 files changed, 55 insertions(+), 56 deletions(-) diff --git a/pkg/core/native/native_test/common_test.go b/pkg/core/native/native_test/common_test.go index da37b24b8..bf9c900ce 100644 --- a/pkg/core/native/native_test/common_test.go +++ b/pkg/core/native/native_test/common_test.go @@ -90,7 +90,7 @@ func setNodesByRole(t *testing.T, designateInvoker *neotest.ContractInvoker, ok func checkNodeRoles(t *testing.T, designateInvoker *neotest.ContractInvoker, ok bool, r noderoles.Role, index uint32, res keys.PublicKeys) { if ok { - designateInvoker.InvokeAndCheck(t, func(t *testing.T, stack []stackitem.Item) { + designateInvoker.InvokeAndCheck(t, func(t testing.TB, stack []stackitem.Item) { require.Equal(t, 1, len(stack)) arr := stack[0].Value().([]stackitem.Item) require.Equal(t, len(res), len(arr)) diff --git a/pkg/core/native/native_test/ledger_test.go b/pkg/core/native/native_test/ledger_test.go index a869a9de9..ab71dbee0 100644 --- a/pkg/core/native/native_test/ledger_test.go +++ b/pkg/core/native/native_test/ledger_test.go @@ -82,7 +82,7 @@ func TestLedger_GetTransactionFromBlock(t *testing.T) { ledgerInvoker.Invoke(t, e.Chain.BlockHeight(), "currentIndex") // Adds a block. b := e.GetBlockByIndex(t, int(e.Chain.BlockHeight())) - check := func(t *testing.T, stack []stackitem.Item) { + check := func(t testing.TB, stack []stackitem.Item) { require.Equal(t, 1, len(stack)) actual, ok := stack[0].Value().([]stackitem.Item) require.True(t, ok) diff --git a/pkg/neotest/basic.go b/pkg/neotest/basic.go index c5e820eac..4665f2ee1 100644 --- a/pkg/neotest/basic.go +++ b/pkg/neotest/basic.go @@ -36,7 +36,7 @@ type Executor struct { } // NewExecutor creates new executor instance from provided blockchain and committee. -func NewExecutor(t *testing.T, bc blockchainer.Blockchainer, validator, committee Signer) *Executor { +func NewExecutor(t testing.TB, bc blockchainer.Blockchainer, validator, committee Signer) *Executor { checkMultiSigner(t, validator) checkMultiSigner(t, committee) @@ -50,28 +50,28 @@ func NewExecutor(t *testing.T, bc blockchainer.Blockchainer, validator, committe } // TopBlock returns block with the highest index. -func (e *Executor) TopBlock(t *testing.T) *block.Block { +func (e *Executor) TopBlock(t testing.TB) *block.Block { b, err := e.Chain.GetBlock(e.Chain.GetHeaderHash(int(e.Chain.BlockHeight()))) require.NoError(t, err) return b } // NativeHash returns native contract hash by name. -func (e *Executor) NativeHash(t *testing.T, name string) util.Uint160 { +func (e *Executor) NativeHash(t testing.TB, name string) util.Uint160 { h, err := e.Chain.GetNativeContractScriptHash(name) require.NoError(t, err) return h } // ContractHash returns contract hash by ID. -func (e *Executor) ContractHash(t *testing.T, id int32) util.Uint160 { +func (e *Executor) ContractHash(t testing.TB, id int32) util.Uint160 { h, err := e.Chain.GetContractScriptHash(id) require.NoError(t, err) return h } // NativeID returns native contract ID by name. -func (e *Executor) NativeID(t *testing.T, name string) int32 { +func (e *Executor) NativeID(t testing.TB, name string) int32 { h := e.NativeHash(t, name) cs := e.Chain.GetContractState(h) require.NotNil(t, cs) @@ -79,7 +79,7 @@ func (e *Executor) NativeID(t *testing.T, name string) int32 { } // NewUnsignedTx creates new unsigned transaction which invokes method of contract with hash. -func (e *Executor) NewUnsignedTx(t *testing.T, hash util.Uint160, method string, args ...interface{}) *transaction.Transaction { +func (e *Executor) NewUnsignedTx(t testing.TB, hash util.Uint160, method string, args ...interface{}) *transaction.Transaction { w := io.NewBufBinWriter() emit.AppCall(w.BinWriter, hash, method, callflag.All, args...) require.NoError(t, w.Err) @@ -93,14 +93,14 @@ func (e *Executor) NewUnsignedTx(t *testing.T, hash util.Uint160, method string, // NewTx creates new transaction which invokes contract method. // Transaction is signed with signer. -func (e *Executor) NewTx(t *testing.T, signers []Signer, +func (e *Executor) NewTx(t testing.TB, signers []Signer, hash util.Uint160, method string, args ...interface{}) *transaction.Transaction { tx := e.NewUnsignedTx(t, hash, method, args...) return e.SignTx(t, tx, -1, signers...) } // SignTx signs a transaction using provided signers. -func (e *Executor) SignTx(t *testing.T, tx *transaction.Transaction, sysFee int64, signers ...Signer) *transaction.Transaction { +func (e *Executor) SignTx(t testing.TB, tx *transaction.Transaction, sysFee int64, signers ...Signer) *transaction.Transaction { for _, acc := range signers { tx.Signers = append(tx.Signers, transaction.Signer{ Account: acc.ScriptHash(), @@ -118,7 +118,7 @@ func (e *Executor) SignTx(t *testing.T, tx *transaction.Transaction, sysFee int6 // 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 { +func (e *Executor) NewAccount(t testing.TB, expectedGASBalance ...int64) Signer { acc, err := wallet.NewAccount() require.NoError(t, err) @@ -138,7 +138,7 @@ func (e *Executor) NewAccount(t *testing.T, expectedGASBalance ...int64) Signer // precalculated contract hash matches the actual one. // data is an optional argument to `_deploy`. // Returns hash of the deploy transaction. -func (e *Executor) DeployContract(t *testing.T, c *Contract, data interface{}) util.Uint256 { +func (e *Executor) DeployContract(t testing.TB, c *Contract, data interface{}) util.Uint256 { return e.DeployContractBy(t, e.Validator, c, data) } @@ -146,7 +146,7 @@ func (e *Executor) DeployContract(t *testing.T, c *Contract, data interface{}) u // 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 (e *Executor) DeployContractBy(t *testing.T, signer Signer, c *Contract, data interface{}) util.Uint256 { +func (e *Executor) DeployContractBy(t testing.TB, signer Signer, c *Contract, data interface{}) util.Uint256 { tx := NewDeployTxBy(t, e.Chain, signer, c, data) e.AddNewBlock(t, tx) e.CheckHalt(t, tx.Hash()) @@ -165,7 +165,7 @@ func (e *Executor) DeployContractBy(t *testing.T, signer Signer, c *Contract, da // DeployContractCheckFAULT compiles and deploys contract to bc using validator // account. It checks that deploy transaction FAULTed with the specified error. -func (e *Executor) DeployContractCheckFAULT(t *testing.T, c *Contract, data interface{}, errMessage string) { +func (e *Executor) DeployContractCheckFAULT(t testing.TB, c *Contract, data interface{}, errMessage string) { tx := e.NewDeployTx(t, e.Chain, c, data) e.AddNewBlock(t, tx) e.CheckFault(t, tx.Hash(), errMessage) @@ -173,7 +173,7 @@ func (e *Executor) DeployContractCheckFAULT(t *testing.T, c *Contract, data inte // 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 { +func (e *Executor) InvokeScript(t testing.TB, script []byte, signers []Signer) util.Uint256 { tx := transaction.New(script, 0) tx.Nonce = Nonce() tx.ValidUntilBlock = e.Chain.BlockHeight() + 1 @@ -184,20 +184,20 @@ func (e *Executor) InvokeScript(t *testing.T, script []byte, signers []Signer) u // 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) { +func (e *Executor) InvokeScriptCheckHALT(t testing.TB, 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) { +func (e *Executor) InvokeScriptCheckFAULT(t testing.TB, 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 { +func (e *Executor) CheckHalt(t testing.TB, h util.Uint256, stack ...stackitem.Item) *state.AppExecResult { aer, err := e.Chain.GetAppExecResults(h, trigger.Application) require.NoError(t, err) require.Equal(t, vm.HaltState, aer[0].VMState, aer[0].FaultException) @@ -209,7 +209,7 @@ func (e *Executor) CheckHalt(t *testing.T, h util.Uint256, stack ...stackitem.It // CheckFault checks that transaction persisted with FAULT state. // Raised exception is also checked to contain s as a substring. -func (e *Executor) CheckFault(t *testing.T, h util.Uint256, s string) { +func (e *Executor) CheckFault(t testing.TB, h util.Uint256, s string) { aer, err := e.Chain.GetAppExecResults(h, trigger.Application) require.NoError(t, err) require.Equal(t, vm.FaultState, aer[0].VMState) @@ -219,7 +219,7 @@ func (e *Executor) CheckFault(t *testing.T, h util.Uint256, s string) { // CheckTxNotificationEvent checks that specified event was emitted at the specified position // during transaction script execution. Negative index corresponds to backwards enumeration. -func (e *Executor) CheckTxNotificationEvent(t *testing.T, h util.Uint256, index int, expected state.NotificationEvent) { +func (e *Executor) CheckTxNotificationEvent(t testing.TB, h util.Uint256, index int, expected state.NotificationEvent) { aer, err := e.Chain.GetAppExecResults(h, trigger.Application) require.NoError(t, err) l := len(aer[0].Events) @@ -231,24 +231,24 @@ func (e *Executor) CheckTxNotificationEvent(t *testing.T, h util.Uint256, index } // CheckGASBalance ensures that provided account owns specified amount of GAS. -func (e *Executor) CheckGASBalance(t *testing.T, acc util.Uint160, expected *big.Int) { +func (e *Executor) CheckGASBalance(t testing.TB, acc util.Uint160, expected *big.Int) { actual := e.Chain.GetUtilityTokenBalance(acc) require.Equal(t, expected, actual, fmt.Errorf("invalid GAS balance: expected %s, got %s", expected.String(), actual.String())) } // EnsureGASBalance ensures that provided account owns amount of GAS that satisfies provided condition. -func (e *Executor) EnsureGASBalance(t *testing.T, acc util.Uint160, isOk func(balance *big.Int) bool) { +func (e *Executor) EnsureGASBalance(t testing.TB, acc util.Uint160, isOk func(balance *big.Int) bool) { actual := e.Chain.GetUtilityTokenBalance(acc) require.True(t, isOk(actual), fmt.Errorf("invalid GAS balance: got %s, condition is not satisfied", actual.String())) } // NewDeployTx returns new deployment tx for contract signed by committee. -func (e *Executor) NewDeployTx(t *testing.T, bc blockchainer.Blockchainer, c *Contract, data interface{}) *transaction.Transaction { +func (e *Executor) NewDeployTx(t testing.TB, bc blockchainer.Blockchainer, c *Contract, data interface{}) *transaction.Transaction { return NewDeployTxBy(t, bc, e.Validator, c, data) } // NewDeployTxBy returns new deployment tx for contract signed by the specified signer. -func NewDeployTxBy(t *testing.T, bc blockchainer.Blockchainer, signer Signer, c *Contract, data interface{}) *transaction.Transaction { +func NewDeployTxBy(t testing.TB, bc blockchainer.Blockchainer, signer Signer, c *Contract, data interface{}) *transaction.Transaction { rawManifest, err := json.Marshal(c.Manifest) require.NoError(t, err) @@ -292,7 +292,7 @@ func addNetworkFee(bc blockchainer.Blockchainer, tx *transaction.Transaction, si } // NewUnsignedBlock creates new unsigned block from txs. -func (e *Executor) NewUnsignedBlock(t *testing.T, txs ...*transaction.Transaction) *block.Block { +func (e *Executor) NewUnsignedBlock(t testing.TB, txs ...*transaction.Transaction) *block.Block { lastBlock := e.TopBlock(t) b := &block.Block{ Header: block.Header{ @@ -315,7 +315,7 @@ func (e *Executor) NewUnsignedBlock(t *testing.T, txs ...*transaction.Transactio } // AddNewBlock creates a new block from provided transactions and adds it on bc. -func (e *Executor) AddNewBlock(t *testing.T, txs ...*transaction.Transaction) *block.Block { +func (e *Executor) AddNewBlock(t testing.TB, txs ...*transaction.Transaction) *block.Block { b := e.NewUnsignedBlock(t, txs...) e.SignBlock(b) require.NoError(t, e.Chain.AddBlock(b)) @@ -323,7 +323,7 @@ func (e *Executor) AddNewBlock(t *testing.T, txs ...*transaction.Transaction) *b } // GenerateNewBlocks adds specified number of empty blocks to the chain. -func (e *Executor) GenerateNewBlocks(t *testing.T, count int) { +func (e *Executor) GenerateNewBlocks(t testing.TB, count int) { for i := 0; i < count; i++ { e.AddNewBlock(t) } @@ -337,7 +337,7 @@ func (e *Executor) SignBlock(b *block.Block) *block.Block { } // AddBlockCheckHalt is a convenient wrapper over AddBlock and CheckHalt. -func (e *Executor) AddBlockCheckHalt(t *testing.T, txs ...*transaction.Transaction) *block.Block { +func (e *Executor) AddBlockCheckHalt(t testing.TB, txs ...*transaction.Transaction) *block.Block { b := e.AddNewBlock(t, txs...) for _, tx := range txs { e.CheckHalt(t, tx.Hash()) @@ -370,14 +370,14 @@ func TestInvoke(bc blockchainer.Blockchainer, tx *transaction.Transaction) (*vm. } // GetTransaction returns transaction and its height by the specified hash. -func (e *Executor) GetTransaction(t *testing.T, h util.Uint256) (*transaction.Transaction, uint32) { +func (e *Executor) GetTransaction(t testing.TB, h util.Uint256) (*transaction.Transaction, uint32) { tx, height, err := e.Chain.GetTransaction(h) require.NoError(t, err) return tx, height } // GetBlockByIndex returns block by the specified index. -func (e *Executor) GetBlockByIndex(t *testing.T, idx int) *block.Block { +func (e *Executor) GetBlockByIndex(t testing.TB, idx int) *block.Block { h := e.Chain.GetHeaderHash(idx) require.NotEmpty(t, h) b, err := e.Chain.GetBlock(h) @@ -386,7 +386,7 @@ func (e *Executor) GetBlockByIndex(t *testing.T, idx int) *block.Block { } // GetTxExecResult returns application execution results for the specified transaction. -func (e *Executor) GetTxExecResult(t *testing.T, h util.Uint256) *state.AppExecResult { +func (e *Executor) GetTxExecResult(t testing.TB, h util.Uint256) *state.AppExecResult { aer, err := e.Chain.GetAppExecResults(h, trigger.Application) require.NoError(t, err) require.Equal(t, 1, len(aer)) diff --git a/pkg/neotest/chain/chain.go b/pkg/neotest/chain/chain.go index 8845bbcb6..453421b7c 100644 --- a/pkg/neotest/chain/chain.go +++ b/pkg/neotest/chain/chain.go @@ -121,13 +121,13 @@ func init() { // this package. MemoryStore is used as the backend storage, so all of the chain // contents is always in RAM. The Signer returned is validator (and committee at // the same time). -func NewSingle(t *testing.T) (*core.Blockchain, neotest.Signer) { +func NewSingle(t testing.TB) (*core.Blockchain, neotest.Signer) { return NewSingleWithCustomConfig(t, nil) } // NewSingleWithCustomConfig is similar to NewSingle, but allows to override the // default configuration. -func NewSingleWithCustomConfig(t *testing.T, f func(*config.ProtocolConfiguration)) (*core.Blockchain, neotest.Signer) { +func NewSingleWithCustomConfig(t testing.TB, f func(*config.ProtocolConfiguration)) (*core.Blockchain, neotest.Signer) { st := storage.NewMemoryStore() return NewSingleWithCustomConfigAndStore(t, f, st, true) } @@ -137,7 +137,7 @@ func NewSingleWithCustomConfig(t *testing.T, f func(*config.ProtocolConfiguratio // Run method is called on the Blockchain instance, if not then it's caller's // responsibility to do that before using the chain and its caller's responsibility // also to properly Close the chain when done. -func NewSingleWithCustomConfigAndStore(t *testing.T, f func(cfg *config.ProtocolConfiguration), st storage.Store, run bool) (*core.Blockchain, neotest.Signer) { +func NewSingleWithCustomConfigAndStore(t testing.TB, f func(cfg *config.ProtocolConfiguration), st storage.Store, run bool) (*core.Blockchain, neotest.Signer) { protoCfg := config.ProtocolConfiguration{ Magic: netmode.UnitTestNet, MaxTraceableBlocks: MaxTraceableBlocks, @@ -163,20 +163,22 @@ func NewSingleWithCustomConfigAndStore(t *testing.T, f func(cfg *config.Protocol // NewMulti creates new blockchain instance with four validators and six // committee members, otherwise not differring much from NewSingle. The // second value returned contains validators Signer, the third -- committee one. -func NewMulti(t *testing.T) (*core.Blockchain, neotest.Signer, neotest.Signer) { +func NewMulti(t testing.TB) (*core.Blockchain, neotest.Signer, neotest.Signer) { return NewMultiWithCustomConfig(t, nil) } // NewMultiWithCustomConfig is similar to NewMulti except it allows to override the // default configuration. -func NewMultiWithCustomConfig(t *testing.T, f func(*config.ProtocolConfiguration)) (*core.Blockchain, neotest.Signer, neotest.Signer) { +func NewMultiWithCustomConfig(t testing.TB, f func(*config.ProtocolConfiguration)) (*core.Blockchain, neotest.Signer, neotest.Signer) { return NewMultiWithCustomConfigAndStore(t, f, nil, true) } -// NewMultiWithCustomConfigAndStore creates new blockchain instance with custom -// protocol configuration, custom storage, 4 validators and 6 committee members. -// Second return value is for validator signer, third -- for committee. -func NewMultiWithCustomConfigAndStore(t *testing.T, f func(*config.ProtocolConfiguration), st storage.Store, run bool) (*core.Blockchain, neotest.Signer, neotest.Signer) { +// NewMultiWithCustomConfigAndStore is similar to NewMultiWithCustomConfig, but +// also allows to override backend Store being used. The last parameter controls if +// Run method is called on the Blockchain instance, if not then it's caller's +// responsibility to do that before using the chain and its caller's responsibility +// also to properly Close the chain when done. +func NewMultiWithCustomConfigAndStore(t testing.TB, f func(*config.ProtocolConfiguration), st storage.Store, run bool) (*core.Blockchain, neotest.Signer, neotest.Signer) { bc, validator, committee, err := NewMultiWithCustomConfigAndStoreNoCheck(t, f, st) require.NoError(t, err) if run { @@ -186,12 +188,9 @@ func NewMultiWithCustomConfigAndStore(t *testing.T, f func(*config.ProtocolConfi return bc, validator, committee } -// NewMultiWithCustomConfigAndStoreNoCheck creates new blockchain instance with -// custom protocol configuration, custom store, 4 validators and 6 committee -// members. Second return value is for validator signer, third -- for committee. -// The resulting blockchain instance is not running and constructor error is -// returned. -func NewMultiWithCustomConfigAndStoreNoCheck(t *testing.T, f func(*config.ProtocolConfiguration), st storage.Store) (*core.Blockchain, neotest.Signer, neotest.Signer, error) { +// NewMultiWithCustomConfigAndStoreNoCheck is similar to NewMultiWithCustomConfig, +// but do not perform Blockchain run and do not check Blockchain constructor error. +func NewMultiWithCustomConfigAndStoreNoCheck(t testing.TB, f func(*config.ProtocolConfiguration), st storage.Store) (*core.Blockchain, neotest.Signer, neotest.Signer, error) { protoCfg := config.ProtocolConfiguration{ Magic: netmode.UnitTestNet, MaxTraceableBlocks: MaxTraceableBlocks, diff --git a/pkg/neotest/client.go b/pkg/neotest/client.go index 2255b4249..ba8aaf695 100644 --- a/pkg/neotest/client.go +++ b/pkg/neotest/client.go @@ -47,7 +47,7 @@ func (e *Executor) ValidatorInvoker(h util.Uint160) *ContractInvoker { } // TestInvoke creates test VM and invokes method with args. -func (c *ContractInvoker) TestInvoke(t *testing.T, method string, args ...interface{}) (*vm.Stack, error) { +func (c *ContractInvoker) TestInvoke(t testing.TB, method string, args ...interface{}) (*vm.Stack, error) { tx := c.PrepareInvokeNoSign(t, method, args...) b := c.NewUnsignedBlock(t, tx) ic := c.Chain.GetTestVM(trigger.Application, tx, b) @@ -66,18 +66,18 @@ func (c *ContractInvoker) WithSigners(signers ...Signer) *ContractInvoker { } // PrepareInvoke creates new invocation transaction. -func (c *ContractInvoker) PrepareInvoke(t *testing.T, method string, args ...interface{}) *transaction.Transaction { +func (c *ContractInvoker) PrepareInvoke(t testing.TB, method string, args ...interface{}) *transaction.Transaction { return c.Executor.NewTx(t, c.Signers, c.Hash, method, args...) } // PrepareInvokeNoSign creates new unsigned invocation transaction. -func (c *ContractInvoker) PrepareInvokeNoSign(t *testing.T, method string, args ...interface{}) *transaction.Transaction { +func (c *ContractInvoker) PrepareInvokeNoSign(t testing.TB, method string, args ...interface{}) *transaction.Transaction { return c.Executor.NewUnsignedTx(t, c.Hash, method, args...) } // Invoke invokes method with args, persists transaction and checks the result. // Returns transaction hash. -func (c *ContractInvoker) Invoke(t *testing.T, result interface{}, method string, args ...interface{}) util.Uint256 { +func (c *ContractInvoker) Invoke(t testing.TB, result interface{}, method string, args ...interface{}) util.Uint256 { tx := c.PrepareInvoke(t, method, args...) c.AddNewBlock(t, tx) c.CheckHalt(t, tx.Hash(), stackitem.Make(result)) @@ -86,7 +86,7 @@ func (c *ContractInvoker) Invoke(t *testing.T, result interface{}, method string // InvokeAndCheck invokes method with args, persists transaction and checks the result // using provided function. Returns transaction hash. -func (c *ContractInvoker) InvokeAndCheck(t *testing.T, checkResult func(t *testing.T, stack []stackitem.Item), method string, args ...interface{}) util.Uint256 { +func (c *ContractInvoker) InvokeAndCheck(t testing.TB, checkResult func(t testing.TB, stack []stackitem.Item), method string, args ...interface{}) util.Uint256 { tx := c.PrepareInvoke(t, method, args...) c.AddNewBlock(t, tx) aer, err := c.Chain.GetAppExecResults(tx.Hash(), trigger.Application) @@ -99,7 +99,7 @@ func (c *ContractInvoker) InvokeAndCheck(t *testing.T, checkResult func(t *testi } // InvokeWithFeeFail is like InvokeFail but sets custom system fee for the transaction. -func (c *ContractInvoker) InvokeWithFeeFail(t *testing.T, message string, sysFee int64, method string, args ...interface{}) util.Uint256 { +func (c *ContractInvoker) InvokeWithFeeFail(t testing.TB, message string, sysFee int64, method string, args ...interface{}) util.Uint256 { tx := c.PrepareInvokeNoSign(t, method, args...) c.Executor.SignTx(t, tx, sysFee, c.Signers...) c.AddNewBlock(t, tx) @@ -109,7 +109,7 @@ func (c *ContractInvoker) InvokeWithFeeFail(t *testing.T, message string, sysFee // InvokeFail invokes method with args, persists transaction and checks the error message. // Returns transaction hash. -func (c *ContractInvoker) InvokeFail(t *testing.T, message string, method string, args ...interface{}) { +func (c *ContractInvoker) InvokeFail(t testing.TB, message string, method string, args ...interface{}) { tx := c.PrepareInvoke(t, method, args...) c.AddNewBlock(t, tx) c.CheckFault(t, tx.Hash(), message) diff --git a/pkg/neotest/compile.go b/pkg/neotest/compile.go index db215a221..4679ec269 100644 --- a/pkg/neotest/compile.go +++ b/pkg/neotest/compile.go @@ -25,7 +25,7 @@ type Contract struct { var contracts = make(map[string]*Contract) // CompileSource compiles contract from reader and returns it's NEF, manifest and hash. -func CompileSource(t *testing.T, sender util.Uint160, src io.Reader, opts *compiler.Options) *Contract { +func CompileSource(t testing.TB, sender util.Uint160, src io.Reader, opts *compiler.Options) *Contract { // nef.NewFile() cares about version a lot. config.Version = "neotest" @@ -43,7 +43,7 @@ func CompileSource(t *testing.T, sender util.Uint160, src io.Reader, opts *compi } // CompileFile compiles contract from file and returns it's NEF, manifest and hash. -func CompileFile(t *testing.T, sender util.Uint160, srcPath string, configPath string) *Contract { +func CompileFile(t testing.TB, sender util.Uint160, srcPath string, configPath string) *Contract { if c, ok := contracts[srcPath]; ok { return c } diff --git a/pkg/neotest/signer.go b/pkg/neotest/signer.go index e9580626c..e9f8ba9e3 100644 --- a/pkg/neotest/signer.go +++ b/pkg/neotest/signer.go @@ -162,7 +162,7 @@ func (m multiSigner) Single(n int) SingleSigner { return NewSingleSigner(wallet.NewAccountFromPrivateKey(m.accounts[n].PrivateKey())) } -func checkMultiSigner(t *testing.T, s Signer) { +func checkMultiSigner(t testing.TB, s Signer) { ms, ok := s.(multiSigner) require.True(t, ok, "expected to be a multi-signer")