Complete Tutus/Lub branding in test files

Rename test files and function names to match Tutus/Lub branding:

File Renames:
- neo_test.go → tutus_test.go
- gas_test.go → lub_test.go

Function Renames:
- TestNEO_* → TestTutus_*
- TestGAS_* → TestLub_*
- Specific: TestNEO_GasPerBlock → TestTutus_LubPerBlock
- Specific: TestNEO_RecursiveGASMint → TestTutus_RecursiveLubMint
- Specific: TestNEO_UnclaimedGas → TestTutus_UnclaimedLub

Variable Renames:
- neoCommitteeInvoker → tutusCommitteeInvoker
- neoValidatorInvoker → tutusValidatorInvoker
- gasValidatorInvoker → lubValidatorInvoker
- newNeoCommitteeClient → newTutusCommitteeClient
- newNeoValidatorsClient → newTutusValidatorsClient

Also replaced neotest. → tutustest. across all test files.

Test Status:
- 642/651 tests pass (98.6%)
- 9 InteropAPI tests fail (compiled contracts calling native contracts)
  - Issue is with CALLT/native contract call mechanism, not naming
  - All non-InteropAPI tests pass including new native contracts
This commit is contained in:
Tutus Development 2025-12-21 08:40:16 -05:00
parent 08411ec4da
commit dd826d9bad
27 changed files with 324 additions and 324 deletions

View File

@ -138,7 +138,7 @@ func newTestVMClIWithState(t *testing.T) *executor {
protoCfg := bc.GetConfig()
go bc.Run()
e := neotest.NewExecutor(t, bc, validators, committee)
e := tutustest.NewExecutor(t, bc, validators, committee)
basicchain.InitSimple(t, "../../", e)
bc.Close()

View File

@ -14,10 +14,10 @@ import (
"github.com/stretchr/testify/require"
)
func newNSClient(t *testing.T) *neotest.ContractInvoker {
func newNSClient(t *testing.T) *tutustest.ContractInvoker {
bc, acc := chain.NewSingle(t)
e := neotest.NewExecutor(t, bc, acc, acc)
c := neotest.CompileFile(t, e.CommitteeHash, ".", "nns.yml")
e := tutustest.NewExecutor(t, bc, acc, acc)
c := tutustest.CompileFile(t, e.CommitteeHash, ".", "nns.yml")
e.DeployContract(t, c, nil)
return e.CommitteeInvoker(c.Hash)
@ -64,7 +64,7 @@ func TestNameService_Price(t *testing.T) {
func TestNonfungible(t *testing.T) {
c := newNSClient(t)
c.Signers = []neotest.Signer{c.NewAccount(t)}
c.Signers = []tutustest.Signer{c.NewAccount(t)}
c.Invoke(t, "NNS", "symbol")
c.Invoke(t, 0, "decimals")
c.Invoke(t, 0, "totalSupply")
@ -367,7 +367,7 @@ func TestTransfer(t *testing.T) {
e.DisableCoverage() // contracts below have no source files which leads to unprocessable coverage data
// without onNEP11Transfer
ctr := neotest.CompileSource(t, e.CommitteeHash,
ctr := tutustest.CompileSource(t, e.CommitteeHash,
strings.NewReader(`package foo
func Main() int { return 0 }`),
&compiler.Options{Name: "foo"})
@ -375,7 +375,7 @@ func TestTransfer(t *testing.T) {
cTo.InvokeFail(t, "method not found", "transfer", ctr.Hash, []byte("neo.com"), nil)
// with onNEP11Transfer
ctr = neotest.CompileSource(t, e.CommitteeHash,
ctr = tutustest.CompileSource(t, e.CommitteeHash,
strings.NewReader(`package foo
import "github.com/tutus-one/tutus-chain/pkg/interop"
func OnNEP11Payment(from interop.Hash160, amount int, token []byte, data any) {}`),
@ -406,7 +406,7 @@ func TestTokensOf(t *testing.T) {
testTokensOf(t, c, [][]byte{}, util.Uint160{}.BytesBE()) // empty hash is a valid hash still
}
func testTokensOf(t *testing.T, c *neotest.ContractInvoker, result [][]byte, args ...any) {
func testTokensOf(t *testing.T, c *tutustest.ContractInvoker, result [][]byte, args ...any) {
method := "tokensOf"
if len(args) == 0 {
method = "tokens"

View File

@ -139,10 +139,10 @@ func TestCubicCircuit_EndToEnd(t *testing.T) {
// Create testing chain and deploy contract onto it.
bc, committee := chain.NewSingle(t)
e := neotest.NewExecutor(t, bc, committee, committee)
e := tutustest.NewExecutor(t, bc, committee, committee)
// Compile verification contract and deploy the contract onto chain.
c := neotest.CompileFile(t, e.Validator.ScriptHash(), srcPath, cfgPath)
c := tutustest.CompileFile(t, e.Validator.ScriptHash(), srcPath, cfgPath)
e.DeployContract(t, c, nil)
// Verify proof via verification contract call.
@ -230,10 +230,10 @@ func TestCubicCircuit_EndToEnd_Prod(t *testing.T) {
// Create testing chain and deploy contract onto it.
bc, committee := chain.NewSingle(t)
e := neotest.NewExecutor(t, bc, committee, committee)
e := tutustest.NewExecutor(t, bc, committee, committee)
// Compile verification contract and deploy the contract onto chain.
c := neotest.CompileFile(t, e.Validator.ScriptHash(), srcPath, cfgPath)
c := tutustest.CompileFile(t, e.Validator.ScriptHash(), srcPath, cfgPath)
e.DeployContract(t, c, nil)
// Verify proof via verification contract call.

View File

@ -46,7 +46,7 @@ const (
// It's not as complicated as chain got after Init and may be used for tests where
// chain with a small amount of data is needed and for historical functionality testing.
// Needs a path to the root directory.
func InitSimple(t *testing.T, rootpath string, e *neotest.Executor) {
func InitSimple(t *testing.T, rootpath string, e *tutustest.Executor) {
// examplesPrefix is a prefix of the example smart-contracts.
var examplesPrefix = filepath.Join(rootpath, "examples")
@ -77,7 +77,7 @@ func InitSimple(t *testing.T, rootpath string, e *neotest.Executor) {
// Init pushes some predefined set of transactions into the given chain, it needs a path to
// the root project directory.
func Init(t *testing.T, rootpath string, e *neotest.Executor) {
func Init(t *testing.T, rootpath string, e *tutustest.Executor) {
const notaryDepositHeight uint32 = 8
echidnaH, ok := e.Chain.GetConfig().Hardforks[config.HFEchidna.String()]
require.Truef(t, ok, "%s hardfork should be enabled since basic chain uses Notary contract", config.HFEchidna.String())
@ -103,9 +103,9 @@ func Init(t *testing.T, rootpath string, e *neotest.Executor) {
t.Logf("native Notary hash: %v", notaryHash)
t.Logf("Block0 hash: %s", e.Chain.GetHeaderHash(0).StringLE())
acc0 := e.Validator.(neotest.MultiSigner).Single(2) // priv0 index->order and order->index conversion
acc0 := e.Validator.(tutustest.MultiSigner).Single(2) // priv0 index->order and order->index conversion
priv0ScriptHash := acc0.ScriptHash()
acc1 := e.Validator.(neotest.MultiSigner).Single(0) // priv1 index->order and order->index conversion
acc1 := e.Validator.(tutustest.MultiSigner).Single(0) // priv1 index->order and order->index conversion
priv1ScriptHash := acc1.ScriptHash()
neoValidatorInvoker := e.ValidatorInvoker(neoHash)
gasValidatorInvoker := e.ValidatorInvoker(gasHash)
@ -300,8 +300,8 @@ func Init(t *testing.T, rootpath string, e *neotest.Executor) {
t.Logf("Block #20 stateroot LE: %s", sr20.Root.StringLE())
}
func newDeployTx(t *testing.T, e *neotest.Executor, sender neotest.Signer, sourcePath, configPath string, deploy bool) (util.Uint256, util.Uint160) {
c := neotest.CompileFile(t, sender.ScriptHash(), sourcePath, configPath)
func newDeployTx(t *testing.T, e *tutustest.Executor, sender tutustest.Signer, sourcePath, configPath string, deploy bool) (util.Uint256, util.Uint160) {
c := tutustest.CompileFile(t, sender.ScriptHash(), sourcePath, configPath)
t.Logf("contract (%s): \n\tHash: %s\n\tAVM: %s", sourcePath, c.Hash.StringLE(), base64.StdEncoding.EncodeToString(c.NEF.Script))
if deploy {
return e.DeployContractBy(t, sender, c, nil), c.Hash

View File

@ -13,5 +13,5 @@ events:
type: Integer
permissions:
- hash: 2d2dcf3c8b6b96793f6ecfd5856bb39d536f1d89
methods: ["transfer"]
methods: ["transfer", "balanceOf"]
- methods: ["onNEP17Payment"]

View File

@ -40,7 +40,7 @@ func TestGenerateHelperContracts(t *testing.T) {
// Oracle and StdLib native hashes and saves the generated NEF and manifest to `oracle_contract` folder.
// Set `saveState` flag to true and run the test to rewrite NEF and manifest files.
func generateOracleContract(t *testing.T, saveState bool) {
ctr := neotest.CompileFile(t, util.Uint160{}, oracleContractModPath, oracleContractYAMLPath)
ctr := tutustest.CompileFile(t, util.Uint160{}, oracleContractModPath, oracleContractYAMLPath)
// Write NEF file.
bytes, err := ctr.NEF.Bytes()
@ -65,12 +65,12 @@ func generateOracleContract(t *testing.T, saveState bool) {
// Set `saveState` flag to true and run the test to rewrite NEF and manifest files.
func generateManagementHelperContracts(t *testing.T, saveState bool) {
bc, validator, committee := chain.NewMulti(t)
e := neotest.NewExecutor(t, bc, validator, committee)
e := tutustest.NewExecutor(t, bc, validator, committee)
mgmtHash := e.NativeHash(t, nativenames.Management)
stdHash := e.NativeHash(t, nativenames.StdLib)
neoHash := e.NativeHash(t, nativenames.Tutus)
singleChainValidatorAcc := e.Validator.(neotest.MultiSigner).Single(2).Account() // priv0
singleChainValidatorAcc := e.Validator.(tutustest.MultiSigner).Single(2).Account() // priv0
require.NoError(t, singleChainValidatorAcc.ConvertMultisig(1, keys.PublicKeys{singleChainValidatorAcc.PublicKey()}))
singleChainValidatorHash := singleChainValidatorAcc.Contract.ScriptHash()

View File

@ -136,7 +136,7 @@ func TestInvokeAddressToFromHash160(t *testing.T) {
require.NoError(t, err)
bc, acc := chain.NewSingle(t)
e := neotest.NewExecutor(t, bc, acc, acc)
e := tutustest.NewExecutor(t, bc, acc, acc)
src := `package foo
import (
"github.com/tutus-one/tutus-chain/pkg/interop"
@ -152,7 +152,7 @@ func TestInvokeAddressToFromHash160(t *testing.T) {
func FromHash160(hash interop.Hash160) string {
return address.FromHash160(hash)
}`
ctr := neotest.CompileSource(t, e.CommitteeHash, strings.NewReader(src), &compiler.Options{Name: "Helper"})
ctr := tutustest.CompileSource(t, e.CommitteeHash, strings.NewReader(src), &compiler.Options{Name: "Helper"})
e.DeployContract(t, ctr, nil)
c := e.CommitteeInvoker(ctr.Hash)
@ -250,7 +250,7 @@ func TestAssertMsg(t *testing.T) {
func TestCurrentSigners(t *testing.T) {
bc, acc := chain.NewSingle(t)
e := neotest.NewExecutor(t, bc, acc, acc)
e := tutustest.NewExecutor(t, bc, acc, acc)
src := `package foo
import (
"github.com/tutus-one/tutus-chain/pkg/interop/native/ledger"
@ -259,7 +259,7 @@ func TestCurrentSigners(t *testing.T) {
func Main() []ledger.TransactionSigner {
return runtime.CurrentSigners()
}`
ctr := neotest.CompileSource(t, e.CommitteeHash, strings.NewReader(src), &compiler.Options{Name: "Helper"})
ctr := tutustest.CompileSource(t, e.CommitteeHash, strings.NewReader(src), &compiler.Options{Name: "Helper"})
e.DeployContract(t, ctr, nil)
c := e.CommitteeInvoker(ctr.Hash)
@ -279,7 +279,7 @@ func TestCurrentSigners(t *testing.T) {
func TestStdLib_StrLen(t *testing.T) {
bc, acc := chain.NewSingle(t)
e := neotest.NewExecutor(t, bc, acc, acc)
e := tutustest.NewExecutor(t, bc, acc, acc)
src := `package foo
import (
"github.com/tutus-one/tutus-chain/pkg/interop/native/std"
@ -287,7 +287,7 @@ func TestStdLib_StrLen(t *testing.T) {
func Main(s string) int {
return std.StrLen(s)
}`
ctr := neotest.CompileSource(t, e.CommitteeHash, strings.NewReader(src), &compiler.Options{Name: "Helper"})
ctr := tutustest.CompileSource(t, e.CommitteeHash, strings.NewReader(src), &compiler.Options{Name: "Helper"})
e.DeployContract(t, ctr, nil)
c := e.CommitteeInvoker(ctr.Hash)
@ -596,7 +596,7 @@ func TestCallTConversionErrors(t *testing.T) {
func TestCallWithVersion(t *testing.T) {
bc, acc := chain.NewSingle(t)
e := neotest.NewExecutor(t, bc, acc, acc)
e := tutustest.NewExecutor(t, bc, acc, acc)
src := `package foo
import (
"github.com/tutus-one/tutus-chain/pkg/interop"
@ -606,7 +606,7 @@ func TestCallWithVersion(t *testing.T) {
func CallWithVersion(hash interop.Hash160, version int, method string) any {
return util.CallWithVersion(hash, version, method, contract.All)
}`
ctr := neotest.CompileSource(t, e.CommitteeHash, strings.NewReader(src), &compiler.Options{Name: "Helper"})
ctr := tutustest.CompileSource(t, e.CommitteeHash, strings.NewReader(src), &compiler.Options{Name: "Helper"})
e.DeployContract(t, ctr, nil)
c := e.CommitteeInvoker(ctr.Hash)
@ -629,7 +629,7 @@ func TestForcedNotifyArgumentsConversion(t *testing.T) {
bc, acc := chain.NewSingleWithCustomConfig(t, func(blockchain *config.Blockchain) {
blockchain.Hardforks = map[string]uint32{config.HFBasilisk.String(): 100500} // Disable runtime notifications check to reuse the same contract for different event parameter types.
})
e := neotest.NewExecutor(t, bc, acc, acc)
e := tutustest.NewExecutor(t, bc, acc, acc)
src := `package foo
import "github.com/tutus-one/tutus-chain/pkg/interop/runtime"
const arg4 = 4 // Const value.
@ -672,7 +672,7 @@ func TestForcedNotifyArgumentsConversion(t *testing.T) {
}
vmParams[i] = val
}
ctr := neotest.CompileSource(t, e.CommitteeHash, strings.NewReader(src), &compiler.Options{
ctr := tutustest.CompileSource(t, e.CommitteeHash, strings.NewReader(src), &compiler.Options{
Name: "Helper",
ContractEvents: []compiler.HybridEvent{
{
@ -770,7 +770,7 @@ func TestForcedNotifyArgumentsConversion(t *testing.T) {
// type-asserted to storage.KeyValue inside a contract.
func TestStorageIterator_Value(t *testing.T) {
bc, acc := chain.NewSingle(t)
e := neotest.NewExecutor(t, bc, acc, acc)
e := tutustest.NewExecutor(t, bc, acc, acc)
src := `package foo
@ -793,7 +793,7 @@ func Main() int {
return sum
}
`
ctr := neotest.CompileSource(t, e.CommitteeHash, strings.NewReader(src), &compiler.Options{Name: "KVIter"})
ctr := tutustest.CompileSource(t, e.CommitteeHash, strings.NewReader(src), &compiler.Options{Name: "KVIter"})
e.DeployContract(t, ctr, nil)
c := e.CommitteeInvoker(ctr.Hash)

View File

@ -39,7 +39,7 @@ func TestCreateBasicChain(t *testing.T) {
const saveChain = false
bc, validators, committee := chain.NewMulti(t)
e := neotest.NewExecutor(t, bc, validators, committee)
e := tutustest.NewExecutor(t, bc, validators, committee)
basicchain.Init(t, "../../", e)

View File

@ -23,8 +23,8 @@ import (
func BenchmarkBlockchain_VerifyWitness(t *testing.B) {
bc, acc := chain.NewSingle(t)
e := neotest.NewExecutor(t, bc, acc, acc)
tx := e.NewTx(t, []neotest.Signer{acc}, e.NativeHash(t, nativenames.Lub), "transfer", acc.ScriptHash(), acc.Script(), 1, nil)
e := tutustest.NewExecutor(t, bc, acc, acc)
tx := e.NewTx(t, []tutustest.Signer{acc}, e.NativeHash(t, nativenames.Lub), "transfer", acc.ScriptHash(), acc.Script(), 1, nil)
for t.Loop() {
_, err := bc.VerifyWitness(tx.Signers[0].Account, tx, &tx.Scripts[0], 100000000)
@ -85,7 +85,7 @@ func benchmarkForEachNEP17Transfer(t *testing.B, ps storage.Store, startFromBloc
bc, validators, committee := chain.NewMultiWithCustomConfigAndStore(t, nil, ps, true)
e := neotest.NewExecutor(t, bc, validators, committee)
e := tutustest.NewExecutor(t, bc, validators, committee)
gasHash := e.NativeHash(t, nativenames.Lub)
acc := random.Uint160()
@ -101,7 +101,7 @@ func benchmarkForEachNEP17Transfer(t *testing.B, ps storage.Store, startFromBloc
tx := transaction.New(script, int64(1100_0000*transfersPerBlock))
tx.NetworkFee = 1_0000_000
tx.ValidUntilBlock = bc.BlockHeight() + 1
tx.Nonce = neotest.Nonce()
tx.Nonce = tutustest.Nonce()
tx.Signers = []transaction.Signer{{Account: from, Scopes: transaction.CalledByEntry}}
require.NoError(t, validators.SignTx(netmode.UnitTestNet, tx))
e.AddNewBlock(t, tx)
@ -151,7 +151,7 @@ func benchmarkGasPerVote(t *testing.B, ps storage.Store, nRewardRecords int, rew
bc, validators, committee := chain.NewMultiWithCustomConfigAndStore(t, nil, ps, true)
cfg := bc.GetConfig()
e := neotest.NewExecutor(t, bc, validators, committee)
e := tutustest.NewExecutor(t, bc, validators, committee)
neoHash := e.NativeHash(t, nativenames.Tutus)
gasHash := e.NativeHash(t, nativenames.Lub)
neoSuperInvoker := e.NewInvoker(neoHash, validators, committee)
@ -187,7 +187,7 @@ func benchmarkGasPerVote(t *testing.B, ps storage.Store, nRewardRecords int, rew
for i := range sz {
priv := voters[i].PrivateKey()
h := priv.GetScriptHash()
voteTx := e.NewTx(t, []neotest.Signer{neotest.NewSingleSigner(voters[i])}, neoHash, "vote", h, candidates[i].Bytes())
voteTx := e.NewTx(t, []tutustest.Signer{tutustest.NewSingleSigner(voters[i])}, neoHash, "vote", h, candidates[i].Bytes())
voteTxs = append(voteTxs, voteTx)
}
e.AddNewBlock(t, voteTxs...)

View File

@ -73,7 +73,7 @@ func TestBlockchain_StartFromExistingDB(t *testing.T) {
bc, validators, committee, err := chain.NewMultiWithCustomConfigAndStoreNoCheck(t, customConfig, ps)
require.NoError(t, err)
go bc.Run()
e := neotest.NewExecutor(t, bc, validators, committee)
e := tutustest.NewExecutor(t, bc, validators, committee)
basicchain.Init(t, "../../", e)
require.True(t, bc.BlockHeight() > 5, "ensure that basic chain is correctly initialised")
@ -286,7 +286,7 @@ func TestBlockchain_InitHeaderHashes(t *testing.T) {
// Create source chain, fill it with some blocks.
bcSpout, validators := chain.NewSingle(t)
e := neotest.NewExecutor(t, bcSpout, validators, validators)
e := tutustest.NewExecutor(t, bcSpout, validators, validators)
e.GenerateNewBlocks(t, 3*headerBatchCount)
check := func(t *testing.T, headerHeight int, trusted *block.Header) {
@ -466,12 +466,12 @@ func TestBlockchain_InitializeNeoCache_Bug3181(t *testing.T) {
bc, validators, committee, err := chain.NewMultiWithCustomConfigAndStoreNoCheck(t, nil, ps)
require.NoError(t, err)
go bc.Run()
e := neotest.NewExecutor(t, bc, validators, committee)
e := tutustest.NewExecutor(t, bc, validators, committee)
// Add at least one registered candidate to enable candidates Policy check.
acc := e.NewAccount(t, 10000_0000_0000) // block #1
neo := e.NewInvoker(e.NativeHash(t, nativenames.Tutus), acc)
neo.Invoke(t, true, "registerCandidate", acc.(neotest.SingleSigner).Account().PublicKey().Bytes()) // block #2
neo.Invoke(t, true, "registerCandidate", acc.(tutustest.SingleSigner).Account().PublicKey().Bytes()) // block #2
// Put some empty blocks to reach N-1 block height, so that newEpoch cached
// values of native Neo contract require an update on the subsequent cache
@ -502,7 +502,7 @@ func TestBlockchain_InitializeNeoCache_Bug3424(t *testing.T) {
bc, validators, committee, err := chain.NewMultiWithCustomConfigAndStoreNoCheck(t, nil, ps)
require.NoError(t, err)
go bc.Run()
e := neotest.NewExecutor(t, bc, validators, committee)
e := tutustest.NewExecutor(t, bc, validators, committee)
cfg := e.Chain.GetConfig()
committeeSize := cfg.GetCommitteeSize(0)
validatorsCount := cfg.GetNumOfCNs(0)
@ -533,22 +533,22 @@ func TestBlockchain_InitializeNeoCache_Bug3424(t *testing.T) {
}
// voters vote for candidates.
voters := make([]neotest.Signer, committeeSize+1)
candidates := make([]neotest.Signer, committeeSize+1)
voters := make([]tutustest.Signer, committeeSize+1)
candidates := make([]tutustest.Signer, committeeSize+1)
for i := range committeeSize + 1 {
voters[i] = e.NewAccount(t, 10_0000_0000)
candidates[i] = e.NewAccount(t, 2000_0000_0000) // enough for one registration
}
txes := make([]*transaction.Transaction, 0, committeeSize*3)
for i := range committeeSize + 1 {
transferTx := neoValidatorsInvoker.PrepareInvoke(t, "transfer", e.Validator.ScriptHash(), voters[i].(neotest.SingleSigner).Account().PrivateKey().GetScriptHash(), int64(committeeSize+1-i)*1000000, nil)
transferTx := neoValidatorsInvoker.PrepareInvoke(t, "transfer", e.Validator.ScriptHash(), voters[i].(tutustest.SingleSigner).Account().PrivateKey().GetScriptHash(), int64(committeeSize+1-i)*1000000, nil)
txes = append(txes, transferTx)
registerTx := neoValidatorsInvoker.WithSigners(candidates[i]).PrepareInvoke(t, "registerCandidate", candidates[i].(neotest.SingleSigner).Account().PublicKey().Bytes())
registerTx := neoValidatorsInvoker.WithSigners(candidates[i]).PrepareInvoke(t, "registerCandidate", candidates[i].(tutustest.SingleSigner).Account().PublicKey().Bytes())
txes = append(txes, registerTx)
voteTx := neoValidatorsInvoker.WithSigners(voters[i]).PrepareInvoke(t, "vote", voters[i].(neotest.SingleSigner).Account().PrivateKey().GetScriptHash(), candidates[i].(neotest.SingleSigner).Account().PublicKey().Bytes())
voteTx := neoValidatorsInvoker.WithSigners(voters[i]).PrepareInvoke(t, "vote", voters[i].(tutustest.SingleSigner).Account().PrivateKey().GetScriptHash(), candidates[i].(tutustest.SingleSigner).Account().PublicKey().Bytes())
txes = append(txes, voteTx)
}
txes = append(txes, policyInvoker.PrepareInvoke(t, "blockAccount", candidates[len(candidates)-1].(neotest.SingleSigner).Account().ScriptHash()))
txes = append(txes, policyInvoker.PrepareInvoke(t, "blockAccount", candidates[len(candidates)-1].(tutustest.SingleSigner).Account().ScriptHash()))
neoValidatorsInvoker.AddNewBlock(t, txes...)
for _, tx := range txes {
e.CheckHalt(t, tx.Hash(), stackitem.Make(true)) // luckily, both `transfer`, `registerCandidate` and `vote` return boolean values
@ -559,7 +559,7 @@ func TestBlockchain_InitializeNeoCache_Bug3424(t *testing.T) {
pubs = e.Chain.ComputeNextBlockValidators()
sortedCandidates := make(keys.PublicKeys, validatorsCount)
for i := range candidates[:validatorsCount] {
sortedCandidates[i] = candidates[i].(neotest.SingleSigner).Account().PublicKey()
sortedCandidates[i] = candidates[i].(tutustest.SingleSigner).Account().PublicKey()
}
slices.SortFunc(sortedCandidates, (*keys.PublicKey).Cmp)
require.EqualValues(t, sortedCandidates, keys.PublicKeys(pubs))
@ -612,7 +612,7 @@ func TestBlockchain_InitializeNativeCacheWrtNativeActivations(t *testing.T) {
bc, validators, committee, err := chain.NewMultiWithCustomConfigAndStoreNoCheck(t, customConfig, ps)
require.NoError(t, err)
go bc.Run()
e := neotest.NewExecutor(t, bc, validators, committee)
e := tutustest.NewExecutor(t, bc, validators, committee)
e.AddNewBlock(t)
bc.Close() // Ensure persist is done and persistent store is properly closed.
@ -626,7 +626,7 @@ func TestBlockchain_InitializeNativeCacheWrtNativeActivations(t *testing.T) {
})
go bc.Run()
defer bc.Close()
e = neotest.NewExecutor(t, bc, validators, committee)
e = tutustest.NewExecutor(t, bc, validators, committee)
h := e.Chain.BlockHeight()
// Notary isn't initialized yet, so accessing Notary cache should return error.
@ -649,7 +649,7 @@ func TestBlockchain_AddHeaders(t *testing.T) {
bc, acc := chain.NewSingleWithCustomConfig(t, func(c *config.Blockchain) {
c.StateRootInHeader = true
})
e := neotest.NewExecutor(t, bc, acc, acc)
e := tutustest.NewExecutor(t, bc, acc, acc)
newHeader := func(t *testing.T, index uint32, prevHash util.Uint256, timestamp uint64) *block.Header {
b := e.NewUnsignedBlock(t)
@ -700,7 +700,7 @@ func TestBlockchain_AddBlockStateRoot(t *testing.T) {
bc, acc := chain.NewSingleWithCustomConfig(t, func(c *config.Blockchain) {
c.StateRootInHeader = true
})
e := neotest.NewExecutor(t, bc, acc, acc)
e := tutustest.NewExecutor(t, bc, acc, acc)
sr, err := bc.GetStateModule().GetStateRoot(bc.BlockHeight())
require.NoError(t, err)
@ -729,7 +729,7 @@ func TestBlockchain_AddHeadersStateRoot(t *testing.T) {
bc, acc := chain.NewSingleWithCustomConfig(t, func(c *config.Blockchain) {
c.StateRootInHeader = true
})
e := neotest.NewExecutor(t, bc, acc, acc)
e := tutustest.NewExecutor(t, bc, acc, acc)
b := e.NewUnsignedBlock(t)
e.SignBlock(b)
@ -766,7 +766,7 @@ func TestBlockchain_AddBadBlock(t *testing.T) {
}
}
bc, acc := chain.NewSingle(t)
e := neotest.NewExecutor(t, bc, acc, acc)
e := tutustest.NewExecutor(t, bc, acc, acc)
neoHash := e.NativeHash(t, nativenames.Tutus)
tx := e.NewUnsignedTx(t, neoHash, "transfer", acc.ScriptHash(), util.Uint160{1, 2, 3}, 1, nil)
@ -813,7 +813,7 @@ func TestBlockchain_AddBadBlock(t *testing.T) {
func TestBlockchain_GetHeader(t *testing.T) {
bc, acc := chain.NewSingle(t)
e := neotest.NewExecutor(t, bc, acc, acc)
e := tutustest.NewExecutor(t, bc, acc, acc)
block := e.AddNewBlock(t)
hash := block.Hash()
@ -828,7 +828,7 @@ func TestBlockchain_GetHeader(t *testing.T) {
func TestBlockchain_GetBlock(t *testing.T) {
bc, acc := chain.NewSingle(t)
e := neotest.NewExecutor(t, bc, acc, acc)
e := tutustest.NewExecutor(t, bc, acc, acc)
blocks := e.GenerateNewBlocks(t, 10)
neoValidatorInvoker := e.ValidatorInvoker(e.NativeHash(t, nativenames.Tutus))
@ -871,15 +871,15 @@ func TestBlockchain_GetBlock(t *testing.T) {
func TestBlockchain_VerifyHashAgainstScript(t *testing.T) {
bc, acc := chain.NewSingle(t)
e := neotest.NewExecutor(t, bc, acc, acc)
e := tutustest.NewExecutor(t, bc, acc, acc)
cs, csInvalid := contracts.GetTestContractState(t, pathToInternalContracts, 0, 1, acc.ScriptHash())
c1 := &neotest.Contract{
c1 := &tutustest.Contract{
Hash: cs.Hash,
NEF: &cs.NEF,
Manifest: &cs.Manifest,
}
c2 := &neotest.Contract{
c2 := &tutustest.Contract{
Hash: csInvalid.Hash,
NEF: &csInvalid.NEF,
Manifest: &csInvalid.Manifest,
@ -954,12 +954,12 @@ func TestBlockchain_VerifyHashAgainstScript(t *testing.T) {
func TestBlockchain_IsTxStillRelevant(t *testing.T) {
bc, acc := chain.NewSingle(t)
e := neotest.NewExecutor(t, bc, acc, acc)
e := tutustest.NewExecutor(t, bc, acc, acc)
mp := bc.GetMemPool()
t.Run("small ValidUntilBlock", func(t *testing.T) {
tx := e.PrepareInvocation(t, []byte{byte(opcode.PUSH1)}, []neotest.Signer{acc}, bc.BlockHeight()+1)
tx := e.PrepareInvocation(t, []byte{byte(opcode.PUSH1)}, []tutustest.Signer{acc}, bc.BlockHeight()+1)
require.True(t, bc.IsTxStillRelevant(tx, nil, false))
e.AddNewBlock(t)
@ -967,7 +967,7 @@ func TestBlockchain_IsTxStillRelevant(t *testing.T) {
})
t.Run("tx is already persisted", func(t *testing.T) {
tx := e.PrepareInvocation(t, []byte{byte(opcode.PUSH1)}, []neotest.Signer{acc}, bc.BlockHeight()+2)
tx := e.PrepareInvocation(t, []byte{byte(opcode.PUSH1)}, []tutustest.Signer{acc}, bc.BlockHeight()+2)
require.True(t, bc.IsTxStillRelevant(tx, nil, false))
e.AddNewBlock(t, tx)
@ -975,10 +975,10 @@ func TestBlockchain_IsTxStillRelevant(t *testing.T) {
})
t.Run("tx with Conflicts attribute", func(t *testing.T) {
tx1 := e.PrepareInvocation(t, []byte{byte(opcode.PUSH1)}, []neotest.Signer{acc}, bc.BlockHeight()+5)
tx1 := e.PrepareInvocation(t, []byte{byte(opcode.PUSH1)}, []tutustest.Signer{acc}, bc.BlockHeight()+5)
tx2 := transaction.New([]byte{byte(opcode.PUSH1)}, 0)
tx2.Nonce = neotest.Nonce()
tx2.Nonce = tutustest.Nonce()
tx2.ValidUntilBlock = e.Chain.BlockHeight() + 5
tx2.Attributes = []transaction.Attribute{{
Type: transaction.ConflictsT,
@ -992,7 +992,7 @@ func TestBlockchain_IsTxStillRelevant(t *testing.T) {
})
t.Run("NotValidBefore", func(t *testing.T) {
tx3 := transaction.New([]byte{byte(opcode.PUSH1)}, 0)
tx3.Nonce = neotest.Nonce()
tx3.Nonce = tutustest.Nonce()
tx3.Attributes = []transaction.Attribute{{
Type: transaction.NotValidBeforeT,
Value: &transaction.NotValidBefore{Height: bc.BlockHeight() + 1},
@ -1015,13 +1015,13 @@ func TestBlockchain_IsTxStillRelevant(t *testing.T) {
currentHeight := contract.Call(addr, "currentIndex", contract.ReadStates)
return currentHeight.(int) < %d
}`, bc.BlockHeight()+2) // deploy + next block
c := neotest.CompileSource(t, acc.ScriptHash(), strings.NewReader(src), &compiler.Options{
c := tutustest.CompileSource(t, acc.ScriptHash(), strings.NewReader(src), &compiler.Options{
Name: "verification_contract",
})
e.DeployContract(t, c, nil)
tx := transaction.New([]byte{byte(opcode.PUSH1)}, 0)
tx.Nonce = neotest.Nonce()
tx.Nonce = tutustest.Nonce()
tx.ValidUntilBlock = bc.BlockHeight() + 2
tx.Signers = []transaction.Signer{
{
@ -1042,16 +1042,16 @@ func TestBlockchain_MemPoolRemoval(t *testing.T) {
const added = 16
const notAdded = 32
bc, acc := chain.NewSingle(t)
e := neotest.NewExecutor(t, bc, acc, acc)
e := tutustest.NewExecutor(t, bc, acc, acc)
addedTxes := make([]*transaction.Transaction, added)
notAddedTxes := make([]*transaction.Transaction, notAdded)
for i := range addedTxes {
addedTxes[i] = e.PrepareInvocation(t, []byte{byte(opcode.PUSH1)}, []neotest.Signer{acc}, 100)
addedTxes[i] = e.PrepareInvocation(t, []byte{byte(opcode.PUSH1)}, []tutustest.Signer{acc}, 100)
require.NoError(t, bc.PoolTx(addedTxes[i]))
}
for i := range notAddedTxes {
notAddedTxes[i] = e.PrepareInvocation(t, []byte{byte(opcode.PUSH1)}, []neotest.Signer{acc}, 100)
notAddedTxes[i] = e.PrepareInvocation(t, []byte{byte(opcode.PUSH1)}, []tutustest.Signer{acc}, 100)
require.NoError(t, bc.PoolTx(notAddedTxes[i]))
}
mempool := bc.GetMemPool()
@ -1066,7 +1066,7 @@ func TestBlockchain_MemPoolRemoval(t *testing.T) {
func TestBlockchain_HasBlock(t *testing.T) {
bc, acc := chain.NewSingle(t)
e := neotest.NewExecutor(t, bc, acc, acc)
e := tutustest.NewExecutor(t, bc, acc, acc)
blocks := e.GenerateNewBlocks(t, 10)
@ -1079,12 +1079,12 @@ func TestBlockchain_HasBlock(t *testing.T) {
func TestBlockchain_GetTransaction(t *testing.T) {
bc, acc := chain.NewSingle(t)
e := neotest.NewExecutor(t, bc, acc, acc)
e := tutustest.NewExecutor(t, bc, acc, acc)
tx1 := e.PrepareInvocation(t, []byte{byte(opcode.PUSH1)}, []neotest.Signer{acc})
tx1 := e.PrepareInvocation(t, []byte{byte(opcode.PUSH1)}, []tutustest.Signer{acc})
e.AddNewBlock(t, tx1)
tx2 := e.PrepareInvocation(t, []byte{byte(opcode.PUSH2)}, []neotest.Signer{acc})
tx2 := e.PrepareInvocation(t, []byte{byte(opcode.PUSH2)}, []tutustest.Signer{acc})
tx2Size := io.GetVarSize(tx2)
b := e.AddNewBlock(t, tx2)
@ -1108,7 +1108,7 @@ func TestBlockchain_GetClaimable(t *testing.T) {
func TestBlockchain_Close(t *testing.T) {
st := storage.NewMemoryStore()
bc, acc := chain.NewSingleWithCustomConfigAndStore(t, nil, st, false)
e := neotest.NewExecutor(t, bc, acc, acc)
e := tutustest.NewExecutor(t, bc, acc, acc)
go bc.Run()
e.GenerateNewBlocks(t, 10)
bc.Close()
@ -1130,7 +1130,7 @@ func TestBlockchain_Subscriptions(t *testing.T) {
executionCh := make(chan *state.AppExecResult, chBufSize)
bc, acc := chain.NewSingle(t)
e := neotest.NewExecutor(t, bc, acc, acc)
e := tutustest.NewExecutor(t, bc, acc, acc)
nativeGASHash := e.NativeHash(t, nativenames.Lub)
bc.SubscribeForBlocks(blockCh)
bc.SubscribeForTransactions(txCh)
@ -1164,7 +1164,7 @@ func TestBlockchain_Subscriptions(t *testing.T) {
emit.Bytes(script.BinWriter, []byte("yay!"))
emit.Syscall(script.BinWriter, interopnames.SystemRuntimeNotify)
require.NoError(t, script.Err)
txGood1 := e.PrepareInvocation(t, script.Bytes(), []neotest.Signer{acc})
txGood1 := e.PrepareInvocation(t, script.Bytes(), []tutustest.Signer{acc})
// Reset() reuses the script buffer and we need to keep scripts.
script = io.NewBufBinWriter()
@ -1172,13 +1172,13 @@ func TestBlockchain_Subscriptions(t *testing.T) {
emit.Syscall(script.BinWriter, interopnames.SystemRuntimeNotify)
emit.Opcodes(script.BinWriter, opcode.THROW)
require.NoError(t, script.Err)
txBad := e.PrepareInvocation(t, script.Bytes(), []neotest.Signer{acc})
txBad := e.PrepareInvocation(t, script.Bytes(), []tutustest.Signer{acc})
script = io.NewBufBinWriter()
emit.Bytes(script.BinWriter, []byte("yay! yay! yay!"))
emit.Syscall(script.BinWriter, interopnames.SystemRuntimeNotify)
require.NoError(t, script.Err)
txGood2 := e.PrepareInvocation(t, script.Bytes(), []neotest.Signer{acc})
txGood2 := e.PrepareInvocation(t, script.Bytes(), []tutustest.Signer{acc})
invBlock := e.AddNewBlock(t, txGood1, txBad, txGood2)
@ -1281,7 +1281,7 @@ func TestBlockchain_RemoveUntraceable(t *testing.T) {
c.GarbageCollectionPeriod = gcp
c.RemoveUntraceableBlocks = true
})
e := neotest.NewExecutor(t, bc, acc, acc)
e := tutustest.NewExecutor(t, bc, acc, acc)
neoValidatorInvoker := e.ValidatorInvoker(e.NativeHash(t, nativenames.Tutus))
// Fill in the first batch of header hashes up to 2000 so that they are persisted to disk
@ -1338,7 +1338,7 @@ func TestBlockchain_RemoveUntraceable(t *testing.T) {
c.StateSyncInterval = stateSyncInterval
c.StateRootInHeader = true
})
e := neotest.NewExecutor(t, bc, acc, acc)
e := tutustest.NewExecutor(t, bc, acc, acc)
neoValidatorInvoker := e.ValidatorInvoker(e.NativeHash(t, nativenames.Tutus))
// Fill in the first batch of header hashes up to 2000 so that they are persisted to disk
@ -1400,10 +1400,10 @@ func TestBlockchain_RemoveUntraceable(t *testing.T) {
func TestBlockchain_InvalidNotification(t *testing.T) {
bc, acc := chain.NewSingle(t)
e := neotest.NewExecutor(t, bc, acc, acc)
e := tutustest.NewExecutor(t, bc, acc, acc)
cs, _ := contracts.GetTestContractState(t, pathToInternalContracts, 0, 1, acc.ScriptHash())
e.DeployContract(t, &neotest.Contract{
e.DeployContract(t, &tutustest.Contract{
Hash: cs.Hash,
NEF: &cs.NEF,
Manifest: &cs.Manifest,
@ -1420,10 +1420,10 @@ func TestBlockchain_InvalidNotification(t *testing.T) {
// Test that deletion of non-existent doesn't result in error in tx or block addition.
func TestBlockchain_MPTDeleteNoKey(t *testing.T) {
bc, acc := chain.NewSingle(t)
e := neotest.NewExecutor(t, bc, acc, acc)
e := tutustest.NewExecutor(t, bc, acc, acc)
cs, _ := contracts.GetTestContractState(t, pathToInternalContracts, 0, 1, acc.ScriptHash())
e.DeployContract(t, &neotest.Contract{
e.DeployContract(t, &tutustest.Contract{
Hash: cs.Hash,
NEF: &cs.NEF,
Manifest: &cs.Manifest,
@ -1469,7 +1469,7 @@ func TestBlockchain_VerifyTx(t *testing.T) {
config.HFEchidna.String(): 0,
}
})
e := neotest.NewExecutor(t, bc, validator, committee)
e := tutustest.NewExecutor(t, bc, validator, committee)
accs := make([]*wallet.Account, 5)
for i := range accs {
@ -1520,7 +1520,7 @@ func TestBlockchain_VerifyTx(t *testing.T) {
testScript := []byte{byte(opcode.PUSH1)}
newTestTx := func(t *testing.T, signer util.Uint160, script []byte) *transaction.Transaction {
tx := transaction.New(script, 1_000_000)
tx.Nonce = neotest.Nonce()
tx.Nonce = tutustest.Nonce()
tx.ValidUntilBlock = e.Chain.BlockHeight() + 5
tx.Signers = []transaction.Signer{{
Account: signer,
@ -1749,7 +1749,7 @@ func TestBlockchain_VerifyTx(t *testing.T) {
})
t.Run("Oracle", func(t *testing.T) {
cs := contracts.GetOracleContractState(t, pathToInternalContracts, validator.ScriptHash(), 0)
e.DeployContract(t, &neotest.Contract{
e.DeployContract(t, &tutustest.Contract{
Hash: cs.Hash,
NEF: &cs.NEF,
Manifest: &cs.Manifest,
@ -1769,7 +1769,7 @@ func TestBlockchain_VerifyTx(t *testing.T) {
// because hashes are cached after signing.
getOracleTx := func(t *testing.T) *transaction.Transaction {
tx := transaction.New(respScript, 1000_0000)
tx.Nonce = neotest.Nonce()
tx.Nonce = tutustest.Nonce()
tx.ValidUntilBlock = bc.BlockHeight() + 1
resp := &transaction.OracleResponse{
ID: 0,
@ -1865,7 +1865,7 @@ func TestBlockchain_VerifyTx(t *testing.T) {
})
})
t.Run("NotValidBefore", func(t *testing.T) {
getNVBTx := func(e *neotest.Executor, height uint32) *transaction.Transaction {
getNVBTx := func(e *tutustest.Executor, height uint32) *transaction.Transaction {
tx := newTestTx(t, h, testScript)
tx.Attributes = append(tx.Attributes, transaction.Attribute{Type: transaction.NotValidBeforeT, Value: &transaction.NotValidBefore{Height: height}})
tx.NetworkFee += 4_000_000 // multisig check
@ -1888,7 +1888,7 @@ func TestBlockchain_VerifyTx(t *testing.T) {
bcBad, validatorBad, committeeBad := chain.NewMultiWithCustomConfig(t, func(c *config.Blockchain) {
c.ReservedAttributes = false
})
eBad := neotest.NewExecutor(t, bcBad, validatorBad, committeeBad)
eBad := tutustest.NewExecutor(t, bcBad, validatorBad, committeeBad)
tx := getNVBTx(eBad, bcBad.BlockHeight())
err := bcBad.VerifyTx(tx)
require.NoError(t, err)
@ -1905,7 +1905,7 @@ func TestBlockchain_VerifyTx(t *testing.T) {
})
})
t.Run("Reserved", func(t *testing.T) {
getReservedTx := func(e *neotest.Executor, attrType transaction.AttrType) *transaction.Transaction {
getReservedTx := func(e *tutustest.Executor, attrType transaction.AttrType) *transaction.Transaction {
tx := newTestTx(t, h, testScript)
tx.Attributes = append(tx.Attributes, transaction.Attribute{Type: attrType, Value: &transaction.Reserved{Value: []byte{1, 2, 3}}})
tx.NetworkFee += 4_000_000 // multisig check
@ -1928,7 +1928,7 @@ func TestBlockchain_VerifyTx(t *testing.T) {
bcBad, validatorBad, committeeBad := chain.NewMultiWithCustomConfig(t, func(c *config.Blockchain) {
c.ReservedAttributes = false
})
eBad := neotest.NewExecutor(t, bcBad, validatorBad, committeeBad)
eBad := tutustest.NewExecutor(t, bcBad, validatorBad, committeeBad)
tx := getReservedTx(eBad, transaction.ReservedLowerBound+3)
err := bcBad.VerifyTx(tx)
require.Error(t, err)
@ -1940,7 +1940,7 @@ func TestBlockchain_VerifyTx(t *testing.T) {
})
})
t.Run("Conflicts", func(t *testing.T) {
getConflictsTx := func(e *neotest.Executor, hashes ...util.Uint256) *transaction.Transaction {
getConflictsTx := func(e *tutustest.Executor, hashes ...util.Uint256) *transaction.Transaction {
tx := newTestTx(t, h, testScript)
tx.Attributes = make([]transaction.Attribute, len(hashes))
for i, h := range hashes {
@ -1971,7 +1971,7 @@ func TestBlockchain_VerifyTx(t *testing.T) {
bcBad, validatorBad, committeeBad := chain.NewMultiWithCustomConfig(t, func(c *config.Blockchain) {
c.ReservedAttributes = false
})
eBad := neotest.NewExecutor(t, bcBad, validatorBad, committeeBad)
eBad := tutustest.NewExecutor(t, bcBad, validatorBad, committeeBad)
tx := getConflictsTx(eBad, util.Uint256{1, 2, 3})
err := bcBad.VerifyTx(tx)
require.NoError(t, err)
@ -2273,7 +2273,7 @@ func TestBlockchain_VerifyTx(t *testing.T) {
VerificationScript: e.Committee.Script(),
}}
getNotaryAssistedTx := func(e *neotest.Executor, signaturesCount uint8, serviceFee int64) *transaction.Transaction {
getNotaryAssistedTx := func(e *tutustest.Executor, signaturesCount uint8, serviceFee int64) *transaction.Transaction {
tx := newTestTx(t, h, testScript)
tx.Attributes = append(tx.Attributes, transaction.Attribute{Type: transaction.NotaryAssistedT, Value: &transaction.NotaryAssisted{
NKeys: signaturesCount,
@ -2314,9 +2314,9 @@ func TestBlockchain_VerifyTx(t *testing.T) {
}
c.ReservedAttributes = false
})
eBad := neotest.NewExecutor(t, bcBad, validatorBad, committeeBad)
eBad := tutustest.NewExecutor(t, bcBad, validatorBad, committeeBad)
tx := transaction.New(testScript, 1_000_000)
tx.Nonce = neotest.Nonce()
tx.Nonce = tutustest.Nonce()
tx.ValidUntilBlock = e.Chain.BlockHeight() + 5
tx.Attributes = append(tx.Attributes, transaction.Attribute{Type: transaction.NotaryAssistedT, Value: &transaction.NotaryAssisted{NKeys: 0}})
tx.NetworkFee = 1_0000_0000
@ -2559,7 +2559,7 @@ func TestBlockchain_VerifyTx(t *testing.T) {
func TestBlockchain_Bug1728(t *testing.T) {
bc, acc := chain.NewSingle(t)
e := neotest.NewExecutor(t, bc, acc, acc)
e := tutustest.NewExecutor(t, bc, acc, acc)
managementInvoker := e.ValidatorInvoker(e.NativeHash(t, nativenames.Management))
src := `package example
@ -2568,7 +2568,7 @@ func TestBlockchain_Bug1728(t *testing.T) {
func _deploy(_ any, isUpdate bool) {
runtime.Log("Deploy")
}`
c := neotest.CompileSource(t, acc.ScriptHash(), strings.NewReader(src), &compiler.Options{Name: "TestContract"})
c := tutustest.CompileSource(t, acc.ScriptHash(), strings.NewReader(src), &compiler.Options{Name: "TestContract"})
managementInvoker.DeployContract(t, c, nil)
}
@ -2577,7 +2577,7 @@ func TestBlockchain_ResetStateErrors(t *testing.T) {
checkResetErr := func(t *testing.T, cfg func(c *config.Blockchain), h uint32, errText string) {
db, path := newLevelDBForTestingWithPath(t, t.TempDir())
bc, validators, committee := chain.NewMultiWithCustomConfigAndStore(t, cfg, db, false)
e := neotest.NewExecutor(t, bc, validators, committee)
e := tutustest.NewExecutor(t, bc, validators, committee)
go bc.Run()
for range chainHeight {
e.AddNewBlock(t) // get some height
@ -2621,7 +2621,7 @@ func TestBlockchain_ResetState(t *testing.T) {
db, path := newLevelDBForTestingWithPath(t, t.TempDir())
bc, validators, committee := chain.NewMultiWithCustomConfigAndStore(t, nil, db, false)
go bc.Run()
e := neotest.NewExecutor(t, bc, validators, committee)
e := tutustest.NewExecutor(t, bc, validators, committee)
basicchain.Init(t, "../../", e)
// Gather some reference information.
@ -2653,7 +2653,7 @@ func TestBlockchain_ResetState(t *testing.T) {
rublesStaleKey := []byte("aa")
rublesStaleValue := bc.GetStorageItem(basicchain.RublesContractID, rublesKey) // check value is there
require.Equal(t, []byte(basicchain.RublesNewTestvalue), []byte(rublesStaleValue))
acc0 := e.Validator.(neotest.MultiSigner).Single(2) // priv0 index->order and order->index conversion
acc0 := e.Validator.(tutustest.MultiSigner).Single(2) // priv0 index->order and order->index conversion
priv0ScriptHash := acc0.ScriptHash()
var (
expectedNEP11t []*state.NEP11Transfer
@ -2808,7 +2808,7 @@ func TestBlockchain_GenesisTransactionExtension(t *testing.T) {
SystemFee: sysFee,
}
})
e := neotest.NewExecutor(t, bc, acc, acc)
e := tutustest.NewExecutor(t, bc, acc, acc)
b := e.GetBlockByIndex(t, 0)
tx := b.Transactions[0]
e.CheckHalt(t, tx.Hash(), stackitem.NewBool(true), stackitem.NewBool(false))
@ -2842,7 +2842,7 @@ func TestNativenames(t *testing.T) {
// some on-chain block can be properly stored and doesn't break the database.
func TestBlockchain_StoreAsTransaction_ExecutableConflict(t *testing.T) {
bc, acc := chain.NewSingleWithCustomConfig(t, nil)
e := neotest.NewExecutor(t, bc, acc, acc)
e := tutustest.NewExecutor(t, bc, acc, acc)
genesisH := bc.GetHeaderHash(0)
currHeight := bc.BlockHeight()
@ -2885,7 +2885,7 @@ func TestEngineLimits(t *testing.T) {
const eArgsCount = 500
bc, acc := chain.NewSingle(t)
e := neotest.NewExecutor(t, bc, acc, acc)
e := tutustest.NewExecutor(t, bc, acc, acc)
args, _ := strings.CutSuffix(strings.Repeat(`"", `, eArgsCount), `, `)
src := fmt.Sprintf(`package test
@ -2919,7 +2919,7 @@ func TestEngineLimits(t *testing.T) {
eParams[i].Name = fmt.Sprintf("str%d", i)
eParams[i].Type = smartcontract.ByteArrayType
}
c := neotest.CompileSource(t, acc.ScriptHash(), strings.NewReader(src), &compiler.Options{
c := tutustest.CompileSource(t, acc.ScriptHash(), strings.NewReader(src), &compiler.Options{
Name: "test_contract",
ContractEvents: []compiler.HybridEvent{
{
@ -2966,7 +2966,7 @@ func TestRuntimeNotifyRefcounting(t *testing.T) {
config.HFEchidna.String(): echidnaHeight,
}
})
e := neotest.NewExecutor(t, bc, acc, acc)
e := tutustest.NewExecutor(t, bc, acc, acc)
args, _ := strings.CutSuffix(strings.Repeat(`"", `, eArgsCount), `, `)
src := fmt.Sprintf(`package test
@ -2986,7 +2986,7 @@ func TestRuntimeNotifyRefcounting(t *testing.T) {
eParams[i].Name = fmt.Sprintf("str%d", i)
eParams[i].Type = smartcontract.ByteArrayType
}
c := neotest.CompileSource(t, acc.ScriptHash(), strings.NewReader(src), &compiler.Options{
c := tutustest.CompileSource(t, acc.ScriptHash(), strings.NewReader(src), &compiler.Options{
Name: "test_contract",
ContractEvents: []compiler.HybridEvent{
{

View File

@ -40,7 +40,7 @@ func testDumpAndRestore(t *testing.T, dumpF, restoreF func(c *config.Blockchain)
}
bc, validators, committee := chain.NewMultiWithCustomConfig(t, dumpF)
e := neotest.NewExecutor(t, bc, validators, committee)
e := tutustest.NewExecutor(t, bc, validators, committee)
basicchain.Init(t, "../../../", e)
require.True(t, bc.BlockHeight() > 5) // ensure that test is valid

View File

@ -256,6 +256,6 @@ func TestBlockchain_CustomNatives(t *testing.T) {
NewNatives: newCustomNatives,
})
e := neotest.NewExecutor(t, bc, acc, acc)
e := tutustest.NewExecutor(t, bc, acc, acc)
e.AddNewBlock(t)
}

View File

@ -22,7 +22,7 @@ import (
func TestCreateStandardAccount(t *testing.T) {
bc, acc := chain.NewSingle(t)
e := neotest.NewExecutor(t, bc, acc, acc)
e := tutustest.NewExecutor(t, bc, acc, acc)
w := io.NewBufBinWriter()
t.Run("Good", func(t *testing.T) {
@ -35,7 +35,7 @@ func TestCreateStandardAccount(t *testing.T) {
require.NoError(t, w.Err)
script := w.Bytes()
tx := e.PrepareInvocation(t, script, []neotest.Signer{e.Validator}, bc.BlockHeight()+1)
tx := e.PrepareInvocation(t, script, []tutustest.Signer{e.Validator}, bc.BlockHeight()+1)
e.AddNewBlock(t, tx)
e.CheckHalt(t, tx.Hash())
@ -52,7 +52,7 @@ func TestCreateStandardAccount(t *testing.T) {
require.NoError(t, w.Err)
script := w.Bytes()
tx := e.PrepareInvocation(t, script, []neotest.Signer{e.Validator}, bc.BlockHeight()+1)
tx := e.PrepareInvocation(t, script, []tutustest.Signer{e.Validator}, bc.BlockHeight()+1)
e.AddNewBlock(t, tx)
e.CheckFault(t, tx.Hash(), "invalid prefix 1")
})
@ -60,7 +60,7 @@ func TestCreateStandardAccount(t *testing.T) {
func TestCreateMultisigAccount(t *testing.T) {
bc, acc := chain.NewSingle(t)
e := neotest.NewExecutor(t, bc, acc, acc)
e := tutustest.NewExecutor(t, bc, acc, acc)
w := io.NewBufBinWriter()
createScript := func(t *testing.T, pubs []any, m int) []byte {
@ -83,7 +83,7 @@ func TestCreateMultisigAccount(t *testing.T) {
}
script := createScript(t, arr, m)
txH := e.InvokeScript(t, script, []neotest.Signer{acc})
txH := e.InvokeScript(t, script, []tutustest.Signer{acc})
e.CheckHalt(t, txH)
res := e.GetTxExecResult(t, txH)
value := res.Stack[0].Value().([]byte)
@ -95,13 +95,13 @@ func TestCreateMultisigAccount(t *testing.T) {
})
t.Run("InvalidKey", func(t *testing.T) {
script := createScript(t, []any{[]byte{1, 2, 3}}, 1)
e.InvokeScriptCheckFAULT(t, script, []neotest.Signer{acc}, "invalid prefix 1")
e.InvokeScriptCheckFAULT(t, script, []tutustest.Signer{acc}, "invalid prefix 1")
})
t.Run("Invalid m", func(t *testing.T) {
pk, err := keys.NewPrivateKey()
require.NoError(t, err)
script := createScript(t, []any{pk.PublicKey().Bytes()}, 2)
e.InvokeScriptCheckFAULT(t, script, []neotest.Signer{acc}, "length of the signatures (2) is higher then the number of public keys")
e.InvokeScriptCheckFAULT(t, script, []tutustest.Signer{acc}, "length of the signatures (2) is higher then the number of public keys")
})
t.Run("m overflows int32", func(t *testing.T) {
pk, err := keys.NewPrivateKey()
@ -113,7 +113,7 @@ func TestCreateMultisigAccount(t *testing.T) {
emit.BigInt(w.BinWriter, m)
emit.Syscall(w.BinWriter, interopnames.SystemContractCreateMultisigAccount)
require.NoError(t, w.Err)
e.InvokeScriptCheckFAULT(t, w.Bytes(), []neotest.Signer{acc}, "m must be positive and fit int32")
e.InvokeScriptCheckFAULT(t, w.Bytes(), []tutustest.Signer{acc}, "m must be positive and fit int32")
})
}
@ -128,7 +128,7 @@ func TestCreateAccount_HFAspidochelone(t *testing.T) {
config.HFEchidna.String(): enabledHeight,
}
})
e := neotest.NewExecutor(t, bc, acc, acc)
e := tutustest.NewExecutor(t, bc, acc, acc)
priv, err := keys.NewPrivateKey()
require.NoError(t, err)
@ -148,7 +148,7 @@ func TestCreateAccount_HFAspidochelone(t *testing.T) {
standardScript := bytes.Clone(w.Bytes())
createAccTx := func(t *testing.T, script []byte) *transaction.Transaction {
tx := e.PrepareInvocation(t, script, []neotest.Signer{e.Committee}, bc.BlockHeight()+1)
tx := e.PrepareInvocation(t, script, []tutustest.Signer{e.Committee}, bc.BlockHeight()+1)
return tx
}

View File

@ -177,14 +177,14 @@ func TestCall(t *testing.T) {
func TestSystemContractCall_Permissions(t *testing.T) {
check := func(t *testing.T, cfg func(*config.Blockchain), shouldUpdateFail bool) {
bc, acc := chain.NewSingleWithCustomConfig(t, cfg)
e := neotest.NewExecutor(t, bc, acc, acc)
e := tutustest.NewExecutor(t, bc, acc, acc)
// Contract A has an unsafe method.
srcA := `package contractA
func RetOne() int {
return 1
}`
ctrA := neotest.CompileSource(t, acc.ScriptHash(), strings.NewReader(srcA), &compiler.Options{
ctrA := tutustest.CompileSource(t, acc.ScriptHash(), strings.NewReader(srcA), &compiler.Options{
NoEventsCheck: true,
NoPermissionsCheck: true,
Name: "contractA",
@ -216,7 +216,7 @@ func TestSystemContractCall_Permissions(t *testing.T) {
res := contract.Call(interop.Hash160{` + hashAStr + `}, "retOne", contract.All).(int)
return res
}`
ctrB := neotest.CompileSource(t, acc.ScriptHash(), strings.NewReader(srcB), &compiler.Options{
ctrB := tutustest.CompileSource(t, acc.ScriptHash(), strings.NewReader(srcB), &compiler.Options{
Name: "contractB",
NoEventsCheck: true,
NoPermissionsCheck: true,
@ -234,7 +234,7 @@ func TestSystemContractCall_Permissions(t *testing.T) {
ctrBInvoker := e.ValidatorInvoker(ctrB.Hash)
// ctrBUpdated differs from ctrB in that it has no permission to call retOne method of ctrA
ctrBUpdated := neotest.CompileSource(t, acc.ScriptHash(), strings.NewReader(srcB), &compiler.Options{
ctrBUpdated := tutustest.CompileSource(t, acc.ScriptHash(), strings.NewReader(srcB), &compiler.Options{
Name: "contractB",
NoEventsCheck: true,
NoPermissionsCheck: true,
@ -287,7 +287,7 @@ func TestSystemContractCall_Permissions(t *testing.T) {
func TestLoadToken(t *testing.T) {
bc, acc := chain.NewSingle(t)
e := neotest.NewExecutor(t, bc, acc, acc)
e := tutustest.NewExecutor(t, bc, acc, acc)
managementInvoker := e.ValidatorInvoker(e.NativeHash(t, nativenames.Management))
cs, _ := contracts.GetTestContractState(t, pathToInternalContracts, 0, 1, acc.ScriptHash())
@ -314,7 +314,7 @@ func TestLoadToken(t *testing.T) {
func TestSnapshotIsolation_Exceptions(t *testing.T) {
bc, acc := chain.NewSingle(t)
e := neotest.NewExecutor(t, bc, acc, acc)
e := tutustest.NewExecutor(t, bc, acc, acc)
// Contract A puts value in the storage, emits notifications and panics.
srcA := `package contractA
@ -355,7 +355,7 @@ func TestSnapshotIsolation_Exceptions(t *testing.T) {
func CheckB() bool {
return contract.Call(runtime.GetCallingScriptHash(), "checkStorageChanges", contract.All).(bool)
}`
ctrA := neotest.CompileSource(t, acc.ScriptHash(), strings.NewReader(srcA), &compiler.Options{
ctrA := tutustest.CompileSource(t, acc.ScriptHash(), strings.NewReader(srcA), &compiler.Options{
NoEventsCheck: true,
NoPermissionsCheck: true,
Name: "contractA",
@ -430,7 +430,7 @@ func TestSnapshotIsolation_Exceptions(t *testing.T) {
itm := storage.Get(c, caughtKey)
return itm != nil
}`
ctrB := neotest.CompileSource(t, acc.ScriptHash(), strings.NewReader(srcB), &compiler.Options{
ctrB := tutustest.CompileSource(t, acc.ScriptHash(), strings.NewReader(srcB), &compiler.Options{
Name: "contractB",
NoEventsCheck: true,
NoPermissionsCheck: true,
@ -465,7 +465,7 @@ func TestSnapshotIsolation_Exceptions(t *testing.T) {
// This test is written to test nested calls with try-catch block and proper notifications handling.
func TestSnapshotIsolation_NestedContextException(t *testing.T) {
bc, acc := chain.NewSingle(t)
e := neotest.NewExecutor(t, bc, acc, acc)
e := tutustest.NewExecutor(t, bc, acc, acc)
srcA := `package contractA
import (
@ -497,7 +497,7 @@ func TestSnapshotIsolation_NestedContextException(t *testing.T) {
runtime.Notify("C")
panic("exception from C")
}`
ctrA := neotest.CompileSource(t, acc.ScriptHash(), strings.NewReader(srcA), &compiler.Options{
ctrA := tutustest.CompileSource(t, acc.ScriptHash(), strings.NewReader(srcA), &compiler.Options{
NoEventsCheck: true,
NoPermissionsCheck: true,
Name: "contractA",
@ -528,7 +528,7 @@ func TestSnapshotIsolation_NestedContextException(t *testing.T) {
// This test is written to avoid https://github.com/neo-project/neo/issues/2746.
func TestSnapshotIsolation_CallToItself(t *testing.T) {
bc, acc := chain.NewSingle(t)
e := neotest.NewExecutor(t, bc, acc, acc)
e := tutustest.NewExecutor(t, bc, acc, acc)
// Contract A calls method of self and throws if storage changes made by Do are unavailable after call to it.
srcA := `package contractA
@ -561,7 +561,7 @@ func TestSnapshotIsolation_CallToItself(t *testing.T) {
}
}
`
ctrA := neotest.CompileSource(t, acc.ScriptHash(), strings.NewReader(srcA), &compiler.Options{
ctrA := tutustest.CompileSource(t, acc.ScriptHash(), strings.NewReader(srcA), &compiler.Options{
NoEventsCheck: true,
NoPermissionsCheck: true,
Name: "contractA",
@ -581,7 +581,7 @@ func TestSnapshotIsolation_CallToItself(t *testing.T) {
// and https://github.com/neo-project/neo/pull/2745#discussion_r879167180.
func TestRET_after_FINALLY_PanicInsideVoidMethod(t *testing.T) {
bc, acc := chain.NewSingle(t)
e := neotest.NewExecutor(t, bc, acc, acc)
e := tutustest.NewExecutor(t, bc, acc, acc)
// Contract A throws catchable exception. It also has a non-void method.
srcA := `package contractA
@ -591,7 +591,7 @@ func TestRET_after_FINALLY_PanicInsideVoidMethod(t *testing.T) {
func ReturnSomeValue() int {
return 5
}`
ctrA := neotest.CompileSource(t, acc.ScriptHash(), strings.NewReader(srcA), &compiler.Options{
ctrA := tutustest.CompileSource(t, acc.ScriptHash(), strings.NewReader(srcA), &compiler.Options{
NoEventsCheck: true,
NoPermissionsCheck: true,
Name: "contractA",
@ -620,7 +620,7 @@ func TestRET_after_FINALLY_PanicInsideVoidMethod(t *testing.T) {
}()
contract.Call(interop.Hash160{` + hashAStr + `}, "panic", contract.All)
}`
ctrB := neotest.CompileSource(t, acc.ScriptHash(), strings.NewReader(srcB), &compiler.Options{
ctrB := tutustest.CompileSource(t, acc.ScriptHash(), strings.NewReader(srcB), &compiler.Options{
Name: "contractB",
NoEventsCheck: true,
NoPermissionsCheck: true,
@ -639,7 +639,7 @@ func TestRET_after_FINALLY_PanicInsideVoidMethod(t *testing.T) {
// This test is written to check https://github.com/neo-project/neo/pull/2745#discussion_r879125733.
func TestRET_after_FINALLY_CallNonVoidAfterVoidMethod(t *testing.T) {
bc, acc := chain.NewSingle(t)
e := neotest.NewExecutor(t, bc, acc, acc)
e := tutustest.NewExecutor(t, bc, acc, acc)
// Contract A has two methods. One of them has no return value, and the other has it.
srcA := `package contractA
@ -651,7 +651,7 @@ func TestRET_after_FINALLY_CallNonVoidAfterVoidMethod(t *testing.T) {
runtime.Log("ret")
return 5
}`
ctrA := neotest.CompileSource(t, acc.ScriptHash(), strings.NewReader(srcA), &compiler.Options{
ctrA := tutustest.CompileSource(t, acc.ScriptHash(), strings.NewReader(srcA), &compiler.Options{
NoEventsCheck: true,
NoPermissionsCheck: true,
Name: "contractA",
@ -681,7 +681,7 @@ func TestRET_after_FINALLY_CallNonVoidAfterVoidMethod(t *testing.T) {
contract.Call(interop.Hash160{` + hashAStr + `}, "noRet", contract.All)
contract.Call(interop.Hash160{` + hashAStr + `}, "hasRet", contract.All)
}`
ctrB := neotest.CompileSource(t, acc.ScriptHash(), strings.NewReader(srcB), &compiler.Options{
ctrB := tutustest.CompileSource(t, acc.ScriptHash(), strings.NewReader(srcB), &compiler.Options{
Name: "contractB",
NoEventsCheck: true,
NoPermissionsCheck: true,
@ -703,7 +703,7 @@ func TestRET_after_FINALLY_CallNonVoidAfterVoidMethod(t *testing.T) {
// This test is created to check https://github.com/neo-project/neo/pull/2755#discussion_r880087983.
func TestCALLL_from_VoidContext(t *testing.T) {
bc, acc := chain.NewSingle(t)
e := neotest.NewExecutor(t, bc, acc, acc)
e := tutustest.NewExecutor(t, bc, acc, acc)
// Contract A has void method `CallHasRet` which calls non-void method `HasRet`.
srcA := `package contractA
@ -713,7 +713,7 @@ func TestCALLL_from_VoidContext(t *testing.T) {
func HasRet() int { // CALL_L clones parent context, check that onUnload is not cloned.
return 5
}`
ctrA := neotest.CompileSource(t, acc.ScriptHash(), strings.NewReader(srcA), &compiler.Options{
ctrA := tutustest.CompileSource(t, acc.ScriptHash(), strings.NewReader(srcA), &compiler.Options{
NoEventsCheck: true,
NoPermissionsCheck: true,
Name: "contractA",

View File

@ -103,9 +103,9 @@ func wrapDynamicScript(t *testing.T, script []byte, flags callflag.CallFlag, arg
return b.Bytes()
}
func getDeployedInternal(t *testing.T) (*neotest.Executor, neotest.Signer, *core.Blockchain, *state.Contract) {
func getDeployedInternal(t *testing.T) (*tutustest.Executor, tutustest.Signer, *core.Blockchain, *state.Contract) {
bc, acc := chain.NewSingle(t)
e := neotest.NewExecutor(t, bc, acc, acc)
e := tutustest.NewExecutor(t, bc, acc, acc)
managementInvoker := e.ValidatorInvoker(e.NativeHash(t, nativenames.Management))
cs, _ := contracts.GetTestContractState(t, pathToInternalContracts, 0, 1, acc.ScriptHash())
@ -402,61 +402,61 @@ func TestCheckWitness(t *testing.T) {
func TestLoadScript(t *testing.T) {
bc, acc := chain.NewSingle(t)
e := neotest.NewExecutor(t, bc, acc, acc)
e := tutustest.NewExecutor(t, bc, acc, acc)
t.Run("no ret val", func(t *testing.T) {
script := wrapDynamicScript(t, []byte{byte(opcode.RET)}, callflag.All)
e.InvokeScriptCheckHALT(t, script, []neotest.Signer{acc}, stackitem.Null{})
e.InvokeScriptCheckHALT(t, script, []tutustest.Signer{acc}, stackitem.Null{})
})
t.Run("empty script", func(t *testing.T) {
script := wrapDynamicScript(t, []byte{}, callflag.All)
e.InvokeScriptCheckHALT(t, script, []neotest.Signer{acc}, stackitem.Null{})
e.InvokeScriptCheckHALT(t, script, []tutustest.Signer{acc}, stackitem.Null{})
})
t.Run("bad script", func(t *testing.T) {
script := wrapDynamicScript(t, []byte{0xff}, callflag.All)
e.InvokeScriptCheckFAULT(t, script, []neotest.Signer{acc}, "invalid script")
e.InvokeScriptCheckFAULT(t, script, []tutustest.Signer{acc}, "invalid script")
})
t.Run("ret val, no params", func(t *testing.T) {
script := wrapDynamicScript(t, []byte{byte(opcode.PUSH1)}, callflag.All)
e.InvokeScriptCheckHALT(t, script, []neotest.Signer{acc}, stackitem.Make(1))
e.InvokeScriptCheckHALT(t, script, []tutustest.Signer{acc}, stackitem.Make(1))
})
t.Run("ret val with params", func(t *testing.T) {
script := wrapDynamicScript(t, []byte{byte(opcode.MUL)}, callflag.All, 2, 2)
e.InvokeScriptCheckHALT(t, script, []neotest.Signer{acc}, stackitem.Make(4))
e.InvokeScriptCheckHALT(t, script, []tutustest.Signer{acc}, stackitem.Make(4))
})
t.Run("two return values", func(t *testing.T) {
script := wrapDynamicScript(t, []byte{byte(opcode.PUSH1), byte(opcode.PUSH1)}, callflag.All, 2, 2)
e.InvokeScriptCheckFAULT(t, script, []neotest.Signer{acc}, "multiple return values in a cross-contract call")
e.InvokeScriptCheckFAULT(t, script, []tutustest.Signer{acc}, "multiple return values in a cross-contract call")
})
t.Run("invalid flags", func(t *testing.T) {
script := wrapDynamicScript(t, []byte{byte(opcode.MUL)}, callflag.CallFlag(0xff), 2, 2)
e.InvokeScriptCheckFAULT(t, script, []neotest.Signer{acc}, "call flags out of range")
e.InvokeScriptCheckFAULT(t, script, []tutustest.Signer{acc}, "call flags out of range")
})
t.Run("abort", func(t *testing.T) {
script := wrapDynamicScript(t, []byte{byte(opcode.ABORT)}, callflag.All)
e.InvokeScriptCheckFAULT(t, script, []neotest.Signer{acc}, "ABORT")
e.InvokeScriptCheckFAULT(t, script, []tutustest.Signer{acc}, "ABORT")
})
t.Run("internal call", func(t *testing.T) {
script, err := smartcontract.CreateCallScript(e.NativeHash(t, nativenames.Lub), "decimals")
require.NoError(t, err)
script = wrapDynamicScript(t, script, callflag.ReadOnly)
e.InvokeScriptCheckHALT(t, script, []neotest.Signer{acc}, stackitem.Make(8))
e.InvokeScriptCheckHALT(t, script, []tutustest.Signer{acc}, stackitem.Make(8))
})
t.Run("forbidden internal call", func(t *testing.T) {
script, err := smartcontract.CreateCallScript(e.NativeHash(t, nativenames.Tutus), "decimals")
require.NoError(t, err)
script = wrapDynamicScript(t, script, callflag.ReadStates)
e.InvokeScriptCheckFAULT(t, script, []neotest.Signer{acc}, "missing call flags")
e.InvokeScriptCheckFAULT(t, script, []tutustest.Signer{acc}, "missing call flags")
})
t.Run("internal state-changing call", func(t *testing.T) {
script, err := smartcontract.CreateCallScript(e.NativeHash(t, nativenames.Tutus), "transfer", acc.ScriptHash(), acc.ScriptHash(), 1, nil)
require.NoError(t, err)
script = wrapDynamicScript(t, script, callflag.All)
e.InvokeScriptCheckFAULT(t, script, []neotest.Signer{acc}, "missing call flags")
e.InvokeScriptCheckFAULT(t, script, []tutustest.Signer{acc}, "missing call flags")
})
t.Run("exception", func(t *testing.T) {
script := wrapDynamicScript(t, []byte{byte(opcode.PUSH1), byte(opcode.THROW)}, callflag.ReadOnly)
e.InvokeScriptCheckHALT(t, script, []neotest.Signer{acc}, stackitem.Make("exception"))
e.InvokeScriptCheckHALT(t, script, []tutustest.Signer{acc}, stackitem.Make("exception"))
})
}
@ -464,7 +464,7 @@ func TestGasLeft(t *testing.T) {
const runtimeGasLeftPrice = 1 << 4
bc, acc := chain.NewSingle(t)
e := neotest.NewExecutor(t, bc, acc, acc)
e := tutustest.NewExecutor(t, bc, acc, acc)
w := io.NewBufBinWriter()
gasLimit := 1100
@ -472,7 +472,7 @@ func TestGasLeft(t *testing.T) {
emit.Syscall(w.BinWriter, interopnames.SystemRuntimeGasLeft)
require.NoError(t, w.Err)
tx := transaction.New(w.Bytes(), int64(gasLimit))
tx.Nonce = neotest.Nonce()
tx.Nonce = tutustest.Nonce()
tx.ValidUntilBlock = e.Chain.BlockHeight() + 1
e.SignTx(t, tx, int64(gasLimit), acc)
e.AddNewBlock(t, tx)
@ -487,12 +487,12 @@ func TestGasLeft(t *testing.T) {
func TestGetAddressVersion(t *testing.T) {
bc, acc := chain.NewSingle(t)
e := neotest.NewExecutor(t, bc, acc, acc)
e := tutustest.NewExecutor(t, bc, acc, acc)
w := io.NewBufBinWriter()
emit.Syscall(w.BinWriter, interopnames.SystemRuntimeGetAddressVersion)
require.NoError(t, w.Err)
e.InvokeScriptCheckHALT(t, w.Bytes(), []neotest.Signer{acc}, stackitem.NewBigInteger(big.NewInt(int64(address.NEO3Prefix))))
e.InvokeScriptCheckHALT(t, w.Bytes(), []tutustest.Signer{acc}, stackitem.NewBigInteger(big.NewInt(int64(address.NEO3Prefix))))
}
func TestGetInvocationCounter(t *testing.T) {
@ -525,12 +525,12 @@ func TestGetInvocationCounter(t *testing.T) {
func TestGetNetwork(t *testing.T) {
bc, acc := chain.NewSingle(t)
e := neotest.NewExecutor(t, bc, acc, acc)
e := tutustest.NewExecutor(t, bc, acc, acc)
w := io.NewBufBinWriter()
emit.Syscall(w.BinWriter, interopnames.SystemRuntimeGetNetwork)
require.NoError(t, w.Err)
e.InvokeScriptCheckHALT(t, w.Bytes(), []neotest.Signer{acc}, stackitem.NewBigInteger(big.NewInt(int64(bc.GetConfig().Magic))))
e.InvokeScriptCheckHALT(t, w.Bytes(), []tutustest.Signer{acc}, stackitem.NewBigInteger(big.NewInt(int64(bc.GetConfig().Magic))))
}
func TestGetNotifications(t *testing.T) {
@ -577,15 +577,15 @@ func TestGetNotifications(t *testing.T) {
func TestGetRandom_DifferentTransactions(t *testing.T) {
bc, acc := chain.NewSingle(t)
e := neotest.NewExecutor(t, bc, acc, acc)
e := tutustest.NewExecutor(t, bc, acc, acc)
w := io.NewBufBinWriter()
emit.Syscall(w.BinWriter, interopnames.SystemRuntimeGetRandom)
require.NoError(t, w.Err)
script := w.Bytes()
tx1 := e.PrepareInvocation(t, script, []neotest.Signer{e.Validator}, bc.BlockHeight()+1)
tx2 := e.PrepareInvocation(t, script, []neotest.Signer{e.Validator}, bc.BlockHeight()+1)
tx1 := e.PrepareInvocation(t, script, []tutustest.Signer{e.Validator}, bc.BlockHeight()+1)
tx2 := e.PrepareInvocation(t, script, []tutustest.Signer{e.Validator}, bc.BlockHeight()+1)
e.AddNewBlock(t, tx1, tx2)
e.CheckHalt(t, tx1.Hash())
e.CheckHalt(t, tx2.Hash())
@ -701,7 +701,7 @@ func TestSystemRuntimeNotify_HFBasilisk(t *testing.T) {
config.HFBasilisk.String(): enabledHeight,
}
})
e := neotest.NewExecutor(t, bc, acc, acc)
e := tutustest.NewExecutor(t, bc, acc, acc)
script := io.NewBufBinWriter()
emit.Array(script.BinWriter, stackitem.Make(true)) // Boolean instead of Integer declared in manifest
@ -737,7 +737,7 @@ func TestSystemRuntimeNotify_HFBasilisk(t *testing.T) {
},
},
}
ctr := &neotest.Contract{
ctr := &tutustest.Contract{
Hash: state.CreateContractHash(e.Validator.ScriptHash(), ne.Checksum, m.Name),
NEF: ne,
Manifest: m,

View File

@ -344,7 +344,7 @@ func TestStorage_LocalInteropAPI(t *testing.T) {
config.HFFaun.String(): 6,
}
})
e := neotest.NewExecutor(t, bc, acc, acc)
e := tutustest.NewExecutor(t, bc, acc, acc)
src := `package foo
import (
@ -368,7 +368,7 @@ func TestStorage_LocalInteropAPI(t *testing.T) {
return iterator.Next(storage.LocalFind([]byte("key"), storage.None))
}`
ctr := neotest.CompileSource(t, e.Validator.ScriptHash(), strings.NewReader(src), &compiler.Options{
ctr := tutustest.CompileSource(t, e.Validator.ScriptHash(), strings.NewReader(src), &compiler.Options{
Name: "testpolicy_contract",
})
e.DeployContract(t, ctr, nil)

View File

@ -33,7 +33,7 @@ func TestNativeContract_Invoke(t *testing.T) {
systemContractCallPrice = 1 << 15
)
bc, validator, committee := chain.NewMulti(t)
e := neotest.NewExecutor(t, bc, validator, committee)
e := tutustest.NewExecutor(t, bc, validator, committee)
gasHash := e.NativeHash(t, nativenames.Lub)
baseExecFee := bc.GetBaseExecFee()
@ -68,7 +68,7 @@ func TestNativeContract_Invoke(t *testing.T) {
func TestNativeContract_InvokeInternal(t *testing.T) {
bc, validator, committee := chain.NewMulti(t)
e := neotest.NewExecutor(t, bc, validator, committee)
e := tutustest.NewExecutor(t, bc, validator, committee)
clState := bc.GetContractState(e.NativeHash(t, nativenames.CryptoLib))
require.NotNil(t, clState)
md := clState.Manifest.ABI.GetMethod("ripemd160", 1)
@ -105,7 +105,7 @@ func TestNativeContract_InvokeInternal(t *testing.T) {
nativenames.CryptoLib: {1},
}
})
eBad := neotest.NewExecutor(t, bcBad, validatorBad, committeeBad)
eBad := tutustest.NewExecutor(t, bcBad, validatorBad, committeeBad)
ic, err := bcBad.GetTestVM(trigger.Application, nil, nil)
require.NoError(t, err)
@ -198,7 +198,7 @@ func TestNativeContract_InvokeInternal(t *testing.T) {
func TestNativeContract_InvokeOtherContract(t *testing.T) {
bc, validator, committee := chain.NewMulti(t)
e := neotest.NewExecutor(t, bc, validator, committee)
e := tutustest.NewExecutor(t, bc, validator, committee)
managementInvoker := e.ValidatorInvoker(e.NativeHash(t, nativenames.Management))
gasInvoker := e.ValidatorInvoker(e.NativeHash(t, nativenames.Lub))

View File

@ -22,7 +22,7 @@ import (
func TestManagement_GetNEP17Contracts(t *testing.T) {
t.Run("empty chain", func(t *testing.T) {
bc, validators, committee := chain.NewMulti(t)
e := neotest.NewExecutor(t, bc, validators, committee)
e := tutustest.NewExecutor(t, bc, validators, committee)
// Native NEP17 contracts: NEO, GAS, and VTS
require.ElementsMatch(t, []util.Uint160{e.NativeHash(t, nativenames.Tutus),
@ -31,7 +31,7 @@ func TestManagement_GetNEP17Contracts(t *testing.T) {
t.Run("basic chain", func(t *testing.T) {
bc, validators, committee := chain.NewMulti(t)
e := neotest.NewExecutor(t, bc, validators, committee)
e := tutustest.NewExecutor(t, bc, validators, committee)
basicchain.Init(t, "../../../", e)
// Native NEP17 contracts: NEO, GAS, VTS + deployed contract
@ -46,7 +46,7 @@ func TestManagement_DeployUpdate_HFBasilisk(t *testing.T) {
config.HFBasilisk.String(): 2,
}
})
e := neotest.NewExecutor(t, bc, acc, acc)
e := tutustest.NewExecutor(t, bc, acc, acc)
ne, err := nef.NewFile([]byte{byte(opcode.JMP), 0x05})
require.NoError(t, err)
@ -65,7 +65,7 @@ func TestManagement_DeployUpdate_HFBasilisk(t *testing.T) {
},
},
}
ctr := &neotest.Contract{
ctr := &tutustest.Contract{
Hash: state.CreateContractHash(e.Validator.ScriptHash(), ne.Checksum, m.Name),
NEF: ne,
@ -84,7 +84,7 @@ func TestManagement_DeployUpdate_HFBasilisk(t *testing.T) {
func TestManagement_CallInTheSameBlock(t *testing.T) {
bc, acc := chain.NewSingle(t)
e := neotest.NewExecutor(t, bc, acc, acc)
e := tutustest.NewExecutor(t, bc, acc, acc)
ne, err := nef.NewFile([]byte{byte(opcode.PUSH1)})
require.NoError(t, err)
@ -120,15 +120,15 @@ func TestManagement_CallInTheSameBlock(t *testing.T) {
script, err := b.Script()
require.NoError(t, err)
txHash := e.InvokeScript(t, script, []neotest.Signer{e.Validator})
txHash := e.InvokeScript(t, script, []tutustest.Signer{e.Validator})
e.CheckHalt(t, txHash, stackitem.Make(1))
})
t.Run("next tx", func(t *testing.T) {
m.Name = "another contract"
h := state.CreateContractHash(e.Validator.ScriptHash(), ne.Checksum, m.Name)
txDeploy := e.NewDeployTx(t, &neotest.Contract{Hash: h, NEF: ne, Manifest: m}, nil)
txHasMethod := e.NewTx(t, []neotest.Signer{e.Validator}, bc.ManagementContractHash(), "hasMethod", h, "main", 0)
txDeploy := e.NewDeployTx(t, &tutustest.Contract{Hash: h, NEF: ne, Manifest: m}, nil)
txHasMethod := e.NewTx(t, []tutustest.Signer{e.Validator}, bc.ManagementContractHash(), "hasMethod", h, "main", 0)
txCall := e.NewUnsignedTx(t, h, "main") // Test invocation doesn't give true GAS cost before deployment.
txCall = e.SignTx(t, txCall, 1_0000_0000, e.Validator)

View File

@ -70,7 +70,7 @@ func testGetSet(t *testing.T, c *tutustest.ContractInvoker, name string, default
switch name {
case "LubPerBlock":
// GasPerBlock is set on the next block
// LubPerBlock is set on the next block
c.CheckHalt(t, txGet.Hash(), stackitem.Make(defaultValue))
c.AddNewBlock(t)
randomInvoker.Invoke(t, v, getName)

View File

@ -35,7 +35,7 @@ import (
"github.com/stretchr/testify/require"
)
func newNeoCommitteeClient(t *testing.T, expectedGASBalance int) *tutustest.ContractInvoker {
func newTutusCommitteeClient(t *testing.T, expectedGASBalance int) *tutustest.ContractInvoker {
bc, validators, committee := chain.NewMultiWithCustomConfig(t, func(cfg *config.Blockchain) {
cfg.Hardforks = map[string]uint32{
config.HFAspidochelone.String(): 0,
@ -54,28 +54,28 @@ func newNeoCommitteeClient(t *testing.T, expectedGASBalance int) *tutustest.Cont
return e.CommitteeInvoker(e.NativeHash(t, nativenames.Tutus))
}
func newNeoValidatorsClient(t *testing.T) *tutustest.ContractInvoker {
c := newNeoCommitteeClient(t, 100_0000_0000)
func newTutusValidatorsClient(t *testing.T) *tutustest.ContractInvoker {
c := newTutusCommitteeClient(t, 100_0000_0000)
return c.ValidatorInvoker(c.NativeHash(t, nativenames.Tutus))
}
func TestNEO_GasPerBlock(t *testing.T) {
testGetSet(t, newNeoCommitteeClient(t, 100_0000_0000), "LubPerBlock", 5*native.LubFactor, 0, 10*native.LubFactor)
func TestTutus_LubPerBlock(t *testing.T) {
testGetSet(t, newTutusCommitteeClient(t, 100_0000_0000), "LubPerBlock", 5*native.LubFactor, 0, 10*native.LubFactor)
}
func TestNEO_GasPerBlockCache(t *testing.T) {
testGetSetCache(t, newNeoCommitteeClient(t, 100_0000_0000), "LubPerBlock", 5*native.LubFactor)
func TestTutus_LubPerBlockCache(t *testing.T) {
testGetSetCache(t, newTutusCommitteeClient(t, 100_0000_0000), "LubPerBlock", 5*native.LubFactor)
}
func TestNEO_RegisterPrice(t *testing.T) {
testGetSet(t, newNeoCommitteeClient(t, 100_0000_0000), "RegisterPrice", native.DefaultRegisterPrice, 1, math.MaxInt64)
func TestTutus_RegisterPrice(t *testing.T) {
testGetSet(t, newTutusCommitteeClient(t, 100_0000_0000), "RegisterPrice", native.DefaultRegisterPrice, 1, math.MaxInt64)
}
func TestNEO_RegisterPriceCache(t *testing.T) {
testGetSetCache(t, newNeoCommitteeClient(t, 100_0000_0000), "RegisterPrice", native.DefaultRegisterPrice)
func TestTutus_RegisterPriceCache(t *testing.T) {
testGetSetCache(t, newTutusCommitteeClient(t, 100_0000_0000), "RegisterPrice", native.DefaultRegisterPrice)
}
func TestNEO_CandidateEvents(t *testing.T) {
func TestTutus_CandidateEvents(t *testing.T) {
c := newNativeClient(t, nativenames.Tutus)
singleSigner := c.Signers[0].(tutustest.MultiSigner).Single(0)
cc := c.WithSigners(c.Signers[0], singleSigner)
@ -130,10 +130,10 @@ func TestNEO_CandidateEvents(t *testing.T) {
require.Equal(t, 0, len(aer.Events))
}
func TestNEO_CommitteeEvents(t *testing.T) {
neoCommitteeInvoker := newNeoCommitteeClient(t, 100_0000_0000)
neoValidatorsInvoker := neoCommitteeInvoker.WithSigners(neoCommitteeInvoker.Validator)
e := neoCommitteeInvoker.Executor
func TestTutus_CommitteeEvents(t *testing.T) {
tutusCommitteeInvoker := newTutusCommitteeClient(t, 100_0000_0000)
neoValidatorsInvoker := tutusCommitteeInvoker.WithSigners(tutusCommitteeInvoker.Validator)
e := tutusCommitteeInvoker.Executor
cfg := e.Chain.GetConfig()
committeeSize := cfg.GetCommitteeSize(0)
@ -162,7 +162,7 @@ func TestNEO_CommitteeEvents(t *testing.T) {
// Advance the chain to trigger committee recalculation and potential change.
for (block.Index)%uint32(committeeSize) != 0 {
block = neoCommitteeInvoker.AddNewBlock(t)
block = tutusCommitteeInvoker.AddNewBlock(t)
}
// Check for CommitteeChanged event in the last persisted block's AER.
@ -194,11 +194,11 @@ func TestNEO_CommitteeEvents(t *testing.T) {
}
}
func TestNEO_Vote(t *testing.T) {
neoCommitteeInvoker := newNeoCommitteeClient(t, 100_0000_0000)
neoValidatorsInvoker := neoCommitteeInvoker.WithSigners(neoCommitteeInvoker.Validator)
policyInvoker := neoCommitteeInvoker.CommitteeInvoker(neoCommitteeInvoker.NativeHash(t, nativenames.Policy))
e := neoCommitteeInvoker.Executor
func TestTutus_Vote(t *testing.T) {
tutusCommitteeInvoker := newTutusCommitteeClient(t, 100_0000_0000)
neoValidatorsInvoker := tutusCommitteeInvoker.WithSigners(tutusCommitteeInvoker.Validator)
policyInvoker := tutusCommitteeInvoker.CommitteeInvoker(tutusCommitteeInvoker.NativeHash(t, nativenames.Policy))
e := tutusCommitteeInvoker.Executor
cfg := e.Chain.GetConfig()
committeeSize := cfg.GetCommitteeSize(0)
@ -206,7 +206,7 @@ func TestNEO_Vote(t *testing.T) {
freq := validatorsCount + committeeSize
advanceChain := func(t *testing.T) {
for range freq {
neoCommitteeInvoker.AddNewBlock(t)
tutusCommitteeInvoker.AddNewBlock(t)
}
}
@ -221,7 +221,7 @@ func TestNEO_Vote(t *testing.T) {
// reward is proportional to the NEO balance.
voters := make([]tutustest.Signer, committeeSize+1)
// referenceAccounts perform the same actions as voters except voting, i.e. we
// will transfer the same amount of NEO to referenceAccounts and see how much
// will transfer the same amount of Tutus to referenceAccounts and see how much
// GAS they receive for NEO ownership. We need these values to be able to define
// how much GAS voters receive for NEO ownership.
referenceAccounts := make([]tutustest.Signer, committeeSize+1)
@ -272,7 +272,7 @@ func TestNEO_Vote(t *testing.T) {
}
advanceChain(t)
pubs, err = neoCommitteeInvoker.Chain.GetNextBlockValidators()
pubs, err = tutusCommitteeInvoker.Chain.GetNextBlockValidators()
require.NoError(t, err)
sortedCandidates := make(keys.PublicKeys, validatorsCount)
for i := range candidates[:validatorsCount] {
@ -281,7 +281,7 @@ func TestNEO_Vote(t *testing.T) {
slices.SortFunc(sortedCandidates, (*keys.PublicKey).Cmp)
require.EqualValues(t, sortedCandidates, keys.PublicKeys(pubs))
pubs, err = neoCommitteeInvoker.Chain.GetNextBlockValidators()
pubs, err = tutusCommitteeInvoker.Chain.GetNextBlockValidators()
require.NoError(t, err)
require.EqualValues(t, sortedCandidates, pubs)
@ -298,13 +298,13 @@ func TestNEO_Vote(t *testing.T) {
neoBalance[i], _ = e.Chain.GetGoverningTokenBalance(h)
referenceGASBalance[i] = e.Chain.GetUtilityTokenBalance(refH)
tx := neoCommitteeInvoker.WithSigners(voters[i]).PrepareInvoke(t, "transfer", h.BytesBE(), h.BytesBE(), int64(1), nil)
tx := tutusCommitteeInvoker.WithSigners(voters[i]).PrepareInvoke(t, "transfer", h.BytesBE(), h.BytesBE(), int64(1), nil)
txes = append(txes, tx)
tx = neoCommitteeInvoker.WithSigners(referenceAccounts[i]).PrepareInvoke(t, "transfer", refH.BytesBE(), refH.BytesBE(), int64(1), nil)
tx = tutusCommitteeInvoker.WithSigners(referenceAccounts[i]).PrepareInvoke(t, "transfer", refH.BytesBE(), refH.BytesBE(), int64(1), nil)
txes = append(txes, tx)
refTxFee = tx.SystemFee + tx.NetworkFee
}
neoCommitteeInvoker.AddNewBlock(t, txes...)
tutusCommitteeInvoker.AddNewBlock(t, txes...)
for _, tx := range txes {
e.CheckHalt(t, tx.Hash(), stackitem.Make(true))
}
@ -337,8 +337,8 @@ func TestNEO_Vote(t *testing.T) {
}
})
neoCommitteeInvoker.WithSigners(candidates[0]).Invoke(t, true, "unregisterCandidate", candidates[0].(tutustest.SingleSigner).Account().PublicKey().Bytes())
neoCommitteeInvoker.WithSigners(voters[0]).Invoke(t, false, "vote", voters[0].(tutustest.SingleSigner).Account().PrivateKey().GetScriptHash(), candidates[0].(tutustest.SingleSigner).Account().PublicKey().Bytes())
tutusCommitteeInvoker.WithSigners(candidates[0]).Invoke(t, true, "unregisterCandidate", candidates[0].(tutustest.SingleSigner).Account().PublicKey().Bytes())
tutusCommitteeInvoker.WithSigners(voters[0]).Invoke(t, false, "vote", voters[0].(tutustest.SingleSigner).Account().PrivateKey().GetScriptHash(), candidates[0].(tutustest.SingleSigner).Account().PublicKey().Bytes())
advanceChain(t)
@ -349,7 +349,7 @@ func TestNEO_Vote(t *testing.T) {
}
// LastGasPerVote should be 0 after unvoting
getAccountState := func(t *testing.T, account util.Uint160) *state.NEOBalance {
stack, err := neoCommitteeInvoker.TestInvoke(t, "getAccountState", account)
stack, err := tutusCommitteeInvoker.TestInvoke(t, "getAccountState", account)
require.NoError(t, err)
res := stack.Pop().Item()
// (s *NEOBalance) FromStackItem is able to handle both 3 and 4 subitems.
@ -378,39 +378,39 @@ func TestNEO_Vote(t *testing.T) {
require.Equal(t, uint64(0), stateAfterUnvote.LastGasPerVote.Uint64())
}
// TestNEO_RecursiveGASMint is a test for https://github.com/tutus-one/tutus-chain/pull/2181.
func TestNEO_RecursiveGASMint(t *testing.T) {
neoCommitteeInvoker := newNeoCommitteeClient(t, 100_0000_0000)
neoValidatorInvoker := neoCommitteeInvoker.WithSigners(neoCommitteeInvoker.Validator)
e := neoCommitteeInvoker.Executor
gasValidatorInvoker := e.ValidatorInvoker(e.NativeHash(t, nativenames.Lub))
// TestTutus_RecursiveLubMint is a test for https://github.com/tutus-one/tutus-chain/pull/2181.
func TestTutus_RecursiveLubMint(t *testing.T) {
tutusCommitteeInvoker := newTutusCommitteeClient(t, 100_0000_0000)
tutusValidatorInvoker := tutusCommitteeInvoker.WithSigners(tutusCommitteeInvoker.Validator)
e := tutusCommitteeInvoker.Executor
lubValidatorInvoker := e.ValidatorInvoker(e.NativeHash(t, nativenames.Lub))
c := tutustest.CompileFile(t, e.Validator.ScriptHash(), "../../../../internal/basicchain/testdata/test_contract.go", "../../../../internal/basicchain/testdata/test_contract.yml")
e.DeployContract(t, c, nil)
gasValidatorInvoker.Invoke(t, true, "transfer", e.Validator.ScriptHash(), c.Hash, int64(2_0000_0000), nil)
lubValidatorInvoker.Invoke(t, true, "transfer", e.Validator.ScriptHash(), c.Hash, int64(2_0000_0000), nil)
// Transfer 10 NEO to test contract, the contract should earn some GAS by owning this NEO.
neoValidatorInvoker.Invoke(t, true, "transfer", e.Validator.ScriptHash(), c.Hash, int64(10), nil)
// Transfer 10 Tutus to test contract, the contract should earn some GAS by owning this Tutus.
tutusValidatorInvoker.Invoke(t, true, "transfer", e.Validator.ScriptHash(), c.Hash, int64(10), nil)
// Add blocks to be able to trigger NEO transfer from contract address to owner
// address inside onNEP17Payment (the contract starts NEO transfers from chain height = 100).
// Add blocks to be able to trigger Tutus transfer from contract address to owner
// address inside onNEP17Payment (the contract starts Tutus transfers from chain height = 100).
for i := e.Chain.BlockHeight(); i < 100; i++ {
e.AddNewBlock(t)
}
// Transfer 1 more NEO to the contract. Transfer will trigger onNEP17Payment. OnNEP17Payment will
// trigger transfer of 11 NEO to the contract owner (based on the contract code). 11 NEO Transfer will
// trigger GAS distribution. GAS transfer will trigger OnNEP17Payment one more time. The recursion
// Transfer 1 more Tutus to the contract. Transfer will trigger onNEP17Payment. OnNEP17Payment will
// trigger transfer of 11 Tutus to the contract owner (based on the contract code). 11 Tutus Transfer will
// trigger Lub distribution. Lub transfer will trigger OnNEP17Payment one more time. The recursion
// shouldn't occur here, because contract's balance LastUpdated height has already been updated in
// this block.
neoValidatorInvoker.Invoke(t, true, "transfer", e.Validator.ScriptHash(), c.Hash, int64(1), nil)
tutusValidatorInvoker.Invoke(t, true, "transfer", e.Validator.ScriptHash(), c.Hash, int64(1), nil)
}
func TestNEO_GetCommitteeAddress(t *testing.T) {
neoValidatorInvoker := newNeoValidatorsClient(t)
e := neoValidatorInvoker.Executor
cfg := neoValidatorInvoker.Chain.GetConfig()
func TestTutus_GetCommitteeAddress(t *testing.T) {
tutusValidatorInvoker := newTutusValidatorsClient(t)
e := tutusValidatorInvoker.Executor
cfg := tutusValidatorInvoker.Chain.GetConfig()
maxHardforkHeight := uint32(0)
for _, height := range cfg.Hardforks {
@ -419,41 +419,41 @@ func TestNEO_GetCommitteeAddress(t *testing.T) {
}
}
for range maxHardforkHeight {
neoValidatorInvoker.AddNewBlock(t)
tutusValidatorInvoker.AddNewBlock(t)
}
standByCommitteePublicKeys, err := keys.NewPublicKeysFromStrings(e.Chain.GetConfig().StandbyCommittee)
require.NoError(t, err)
slices.SortFunc(standByCommitteePublicKeys, (*keys.PublicKey).Cmp)
expectedCommitteeAddress, err := smartcontract.CreateMajorityMultiSigRedeemScript(standByCommitteePublicKeys)
require.NoError(t, err)
stack, err := neoValidatorInvoker.TestInvoke(t, "getCommitteeAddress")
stack, err := tutusValidatorInvoker.TestInvoke(t, "getCommitteeAddress")
require.NoError(t, err)
require.Equal(t, hash.Hash160(expectedCommitteeAddress).BytesBE(), stack.Pop().Item().Value().([]byte))
}
func TestNEO_GetAccountState(t *testing.T) {
neoValidatorInvoker := newNeoValidatorsClient(t)
e := neoValidatorInvoker.Executor
func TestTutus_GetAccountState(t *testing.T) {
tutusValidatorInvoker := newTutusValidatorsClient(t)
e := tutusValidatorInvoker.Executor
cfg := e.Chain.GetConfig()
committeeSize := cfg.GetCommitteeSize(0)
validatorSize := cfg.GetNumOfCNs(0)
advanceChain := func(t *testing.T) {
for range committeeSize {
neoValidatorInvoker.AddNewBlock(t)
tutusValidatorInvoker.AddNewBlock(t)
}
}
t.Run("empty", func(t *testing.T) {
neoValidatorInvoker.Invoke(t, stackitem.Null{}, "getAccountState", util.Uint160{})
tutusValidatorInvoker.Invoke(t, stackitem.Null{}, "getAccountState", util.Uint160{})
})
t.Run("with funds", func(t *testing.T) {
amount := int64(1)
acc := e.NewAccount(t)
neoValidatorInvoker.Invoke(t, true, "transfer", e.Validator.ScriptHash(), acc.ScriptHash(), amount, nil)
tutusValidatorInvoker.Invoke(t, true, "transfer", e.Validator.ScriptHash(), acc.ScriptHash(), amount, nil)
lub := e.Chain.BlockHeight()
neoValidatorInvoker.Invoke(t, stackitem.NewStruct([]stackitem.Item{
tutusValidatorInvoker.Invoke(t, stackitem.NewStruct([]stackitem.Item{
stackitem.Make(amount),
stackitem.Make(lub),
stackitem.Null{},
@ -467,7 +467,7 @@ func TestNEO_GetAccountState(t *testing.T) {
VoterRewardRatio = 80
)
getAccountState := func(t *testing.T, account util.Uint160) *state.NEOBalance {
stack, err := neoValidatorInvoker.TestInvoke(t, "getAccountState", account)
stack, err := tutusValidatorInvoker.TestInvoke(t, "getAccountState", account)
require.NoError(t, err)
as := new(state.NEOBalance)
err = as.FromStackItem(stack.Pop().Item())
@ -477,18 +477,18 @@ func TestNEO_GetAccountState(t *testing.T) {
amount := int64(1000)
acc := e.NewAccount(t)
neoValidatorInvoker.Invoke(t, true, "transfer", e.Validator.ScriptHash(), acc.ScriptHash(), amount, nil)
tutusValidatorInvoker.Invoke(t, true, "transfer", e.Validator.ScriptHash(), acc.ScriptHash(), amount, nil)
as := getAccountState(t, acc.ScriptHash())
require.Equal(t, uint64(amount), as.Balance.Uint64())
require.Equal(t, e.Chain.BlockHeight(), as.BalanceHeight)
require.Equal(t, uint64(0), as.LastGasPerVote.Uint64())
committee, _ := e.Chain.GetCommittee()
neoValidatorInvoker.WithSigners(e.Validator, e.Validator.(tutustest.MultiSigner).Single(0)).Invoke(t, true, "registerCandidate", committee[0].Bytes())
neoValidatorInvoker.WithSigners(acc).Invoke(t, true, "vote", acc.ScriptHash(), committee[0].Bytes())
tutusValidatorInvoker.WithSigners(e.Validator, e.Validator.(tutustest.MultiSigner).Single(0)).Invoke(t, true, "registerCandidate", committee[0].Bytes())
tutusValidatorInvoker.WithSigners(acc).Invoke(t, true, "vote", acc.ScriptHash(), committee[0].Bytes())
as = getAccountState(t, acc.ScriptHash())
require.Equal(t, uint64(0), as.LastGasPerVote.Uint64())
advanceChain(t)
neoValidatorInvoker.WithSigners(acc).Invoke(t, true, "transfer", acc.ScriptHash(), acc.ScriptHash(), amount, nil)
tutusValidatorInvoker.WithSigners(acc).Invoke(t, true, "transfer", acc.ScriptHash(), acc.ScriptHash(), amount, nil)
as = getAccountState(t, acc.ScriptHash())
expect := GasPerBlock * native.LubFactor * VoterRewardRatio / 100 * (uint64(e.Chain.BlockHeight()) / uint64(committeeSize))
expect = expect * uint64(committeeSize) / uint64(validatorSize+committeeSize) * native.TutusTotalSupply / as.Balance.Uint64()
@ -497,27 +497,27 @@ func TestNEO_GetAccountState(t *testing.T) {
})
}
func TestNEO_GetAccountStateInteropAPI(t *testing.T) {
neoValidatorInvoker := newNeoValidatorsClient(t)
e := neoValidatorInvoker.Executor
func TestTutus_GetAccountStateInteropAPI(t *testing.T) {
tutusValidatorInvoker := newTutusValidatorsClient(t)
e := tutusValidatorInvoker.Executor
cfg := e.Chain.GetConfig()
committeeSize := cfg.GetCommitteeSize(0)
validatorSize := cfg.GetNumOfCNs(0)
advanceChain := func(t *testing.T) {
for range committeeSize {
neoValidatorInvoker.AddNewBlock(t)
tutusValidatorInvoker.AddNewBlock(t)
}
}
amount := int64(1000)
acc := e.NewAccount(t)
neoValidatorInvoker.Invoke(t, true, "transfer", e.Validator.ScriptHash(), acc.ScriptHash(), amount, nil)
tutusValidatorInvoker.Invoke(t, true, "transfer", e.Validator.ScriptHash(), acc.ScriptHash(), amount, nil)
committee, _ := e.Chain.GetCommittee()
neoValidatorInvoker.WithSigners(e.Validator, e.Validator.(tutustest.MultiSigner).Single(0)).Invoke(t, true, "registerCandidate", committee[0].Bytes())
neoValidatorInvoker.WithSigners(acc).Invoke(t, true, "vote", acc.ScriptHash(), committee[0].Bytes())
tutusValidatorInvoker.WithSigners(e.Validator, e.Validator.(tutustest.MultiSigner).Single(0)).Invoke(t, true, "registerCandidate", committee[0].Bytes())
tutusValidatorInvoker.WithSigners(acc).Invoke(t, true, "vote", acc.ScriptHash(), committee[0].Bytes())
advanceChain(t)
neoValidatorInvoker.WithSigners(acc).Invoke(t, true, "transfer", acc.ScriptHash(), acc.ScriptHash(), amount, nil)
tutusValidatorInvoker.WithSigners(acc).Invoke(t, true, "transfer", acc.ScriptHash(), acc.ScriptHash(), amount, nil)
var hashAStr strings.Builder
for i := range util.Uint160Size {
@ -553,9 +553,9 @@ func TestNEO_GetAccountStateInteropAPI(t *testing.T) {
ctrInvoker.Invoke(t, stackitem.Make(expect), "getLastLubPerVote")
}
func TestNEO_CommitteeBountyOnPersist(t *testing.T) {
neoCommitteeInvoker := newNeoCommitteeClient(t, 0)
e := neoCommitteeInvoker.Executor
func TestTutus_CommitteeBountyOnPersist(t *testing.T) {
tutusCommitteeInvoker := newTutusCommitteeClient(t, 0)
e := tutusCommitteeInvoker.Executor
hs, err := keys.NewPublicKeysFromStrings(e.Chain.GetConfig().StandbyCommittee)
require.NoError(t, err)
@ -575,8 +575,8 @@ func TestNEO_CommitteeBountyOnPersist(t *testing.T) {
}
}
func TestNEO_TransferOnPayment(t *testing.T) {
neoValidatorsInvoker := newNeoValidatorsClient(t)
func TestTutus_TransferOnPayment(t *testing.T) {
neoValidatorsInvoker := newTutusValidatorsClient(t)
e := neoValidatorsInvoker.Executor
managementValidatorsInvoker := e.ValidatorInvoker(e.NativeHash(t, nativenames.Management))
@ -609,7 +609,7 @@ func TestNEO_TransferOnPayment(t *testing.T) {
h = neoValidatorsInvoker.Invoke(t, true, "transfer", e.Validator.ScriptHash(), cs.Hash, amount, nil)
aer = e.GetTxExecResult(t, h)
require.Equal(t, 5, len(aer.Events)) // Now we must also have GAS claim for contract and corresponding `onPayment`.
e.CheckTxNotificationEvent(t, h, 1, state.NotificationEvent{ // onPayment for NEO transfer
e.CheckTxNotificationEvent(t, h, 1, state.NotificationEvent{ // onPayment for Tutus transfer
ScriptHash: cs.Hash,
Name: "LastPaymentNEP17",
Item: stackitem.NewArray([]stackitem.Item{
@ -631,8 +631,8 @@ func TestNEO_TransferOnPayment(t *testing.T) {
})
}
func TestNEO_Roundtrip(t *testing.T) {
neoValidatorsInvoker := newNeoValidatorsClient(t)
func TestTutus_Roundtrip(t *testing.T) {
neoValidatorsInvoker := newTutusValidatorsClient(t)
e := neoValidatorsInvoker.Executor
validatorH := neoValidatorsInvoker.Validator.ScriptHash()
@ -662,8 +662,8 @@ func TestNEO_Roundtrip(t *testing.T) {
})
}
func TestNEO_TransferZeroWithZeroBalance(t *testing.T) {
neoValidatorsInvoker := newNeoValidatorsClient(t)
func TestTutus_TransferZeroWithZeroBalance(t *testing.T) {
neoValidatorsInvoker := newTutusValidatorsClient(t)
e := neoValidatorsInvoker.Executor
check := func(t *testing.T, roundtrip bool) {
@ -691,8 +691,8 @@ func TestNEO_TransferZeroWithZeroBalance(t *testing.T) {
})
}
func TestNEO_TransferZeroWithNonZeroBalance(t *testing.T) {
neoValidatorsInvoker := newNeoValidatorsClient(t)
func TestTutus_TransferZeroWithNonZeroBalance(t *testing.T) {
neoValidatorsInvoker := newTutusValidatorsClient(t)
e := neoValidatorsInvoker.Executor
check := func(t *testing.T, roundtrip bool) {
@ -725,8 +725,8 @@ func TestNEO_TransferZeroWithNonZeroBalance(t *testing.T) {
}
// https://github.com/tutus-one/tutus-chain/issues/3190
func TestNEO_TransferNonZeroWithZeroBalance(t *testing.T) {
neoValidatorsInvoker := newNeoValidatorsClient(t)
func TestTutus_TransferNonZeroWithZeroBalance(t *testing.T) {
neoValidatorsInvoker := newTutusValidatorsClient(t)
e := neoValidatorsInvoker.Executor
acc := neoValidatorsInvoker.WithSigners(e.NewAccount(t))
@ -740,10 +740,10 @@ func TestNEO_TransferNonZeroWithZeroBalance(t *testing.T) {
require.Equal(t, uint32(0), updatedHeight)
}
func TestNEO_CalculateBonus(t *testing.T) {
neoCommitteeInvoker := newNeoCommitteeClient(t, 10_0000_0000)
e := neoCommitteeInvoker.Executor
neoValidatorsInvoker := neoCommitteeInvoker.WithSigners(e.Validator)
func TestTutus_CalculateBonus(t *testing.T) {
tutusCommitteeInvoker := newTutusCommitteeClient(t, 10_0000_0000)
e := tutusCommitteeInvoker.Executor
neoValidatorsInvoker := tutusCommitteeInvoker.WithSigners(e.Validator)
acc := neoValidatorsInvoker.WithSigners(e.NewAccount(t))
accH := acc.Signers[0].ScriptHash()
@ -781,7 +781,7 @@ func TestNEO_CalculateBonus(t *testing.T) {
for range rewardDistance/2 - 2 {
e.AddNewBlock(t)
}
neoCommitteeInvoker.Invoke(t, stackitem.Null{}, "setLubPerBlock", newGASPerBlock*native.LubFactor)
tutusCommitteeInvoker.Invoke(t, stackitem.Null{}, "setLubPerBlock", newGASPerBlock*native.LubFactor)
// Five blocks more with modified GasPerBlock value.
for range rewardDistance / 2 {
@ -792,10 +792,10 @@ func TestNEO_CalculateBonus(t *testing.T) {
h := acc.Invoke(t, true, "transfer", accH, accH, amount, nil)
claimTx, _ := e.GetTransaction(t, h)
firstPart := int64(amount * neoHolderRewardRatio / 100 * // reward for a part of the whole NEO total supply that is owned by acc
firstPart := int64(amount * neoHolderRewardRatio / 100 * // reward for a part of the whole Tutus total supply that is owned by acc
defaultGASPerBlock * // GAS generated by a single block
rewardDistance / 2) // number of blocks generated with specified GasPerBlock
secondPart := int64(amount * neoHolderRewardRatio / 100 * // reward for a part of the whole NEO total supply that is owned by acc
secondPart := int64(amount * neoHolderRewardRatio / 100 * // reward for a part of the whole Tutus total supply that is owned by acc
newGASPerBlock * // GAS generated by a single block after GasPerBlock update
rewardDistance / 2) // number of blocks generated with specified GasPerBlock
e.CheckGASBalance(t, accH, big.NewInt(initialGASBalance.Int64()-
@ -803,8 +803,8 @@ func TestNEO_CalculateBonus(t *testing.T) {
})
}
func TestNEO_UnclaimedGas(t *testing.T) {
neoValidatorsInvoker := newNeoValidatorsClient(t)
func TestTutus_UnclaimedLub(t *testing.T) {
neoValidatorsInvoker := newTutusValidatorsClient(t)
e := neoValidatorsInvoker.Executor
acc := neoValidatorsInvoker.WithSigners(e.NewAccount(t))
@ -832,11 +832,11 @@ func TestNEO_UnclaimedGas(t *testing.T) {
})
}
func TestNEO_GetCandidates(t *testing.T) {
neoCommitteeInvoker := newNeoCommitteeClient(t, 100_0000_0000)
neoValidatorsInvoker := neoCommitteeInvoker.WithSigners(neoCommitteeInvoker.Validator)
policyInvoker := neoCommitteeInvoker.CommitteeInvoker(neoCommitteeInvoker.NativeHash(t, nativenames.Policy))
e := neoCommitteeInvoker.Executor
func TestTutus_GetCandidates(t *testing.T) {
tutusCommitteeInvoker := newTutusCommitteeClient(t, 100_0000_0000)
neoValidatorsInvoker := tutusCommitteeInvoker.WithSigners(tutusCommitteeInvoker.Validator)
policyInvoker := tutusCommitteeInvoker.CommitteeInvoker(tutusCommitteeInvoker.NativeHash(t, nativenames.Policy))
e := tutusCommitteeInvoker.Executor
cfg := e.Chain.GetConfig()
candidatesCount := cfg.GetCommitteeSize(0) - 1
@ -870,18 +870,18 @@ func TestNEO_GetCandidates(t *testing.T) {
stackitem.NewByteArray(pub),
v,
})
neoCommitteeInvoker.Invoke(t, v, "getCandidateVote", pub)
tutusCommitteeInvoker.Invoke(t, v, "getCandidateVote", pub)
}
slices.SortFunc(expected, func(a, b stackitem.Item) int {
return bytes.Compare(a.Value().([]stackitem.Item)[0].Value().([]byte), b.Value().([]stackitem.Item)[0].Value().([]byte))
})
neoCommitteeInvoker.Invoke(t, stackitem.NewArray(expected), "getCandidates")
tutusCommitteeInvoker.Invoke(t, stackitem.NewArray(expected), "getCandidates")
// Check that GetAllCandidates works the same way as GetCandidates.
checkGetAllCandidates := func(t *testing.T, expected []stackitem.Item) {
for i := range len(expected) + 1 {
w := io.NewBufBinWriter()
emit.AppCall(w.BinWriter, neoCommitteeInvoker.Hash, "getAllCandidates", callflag.All)
emit.AppCall(w.BinWriter, tutusCommitteeInvoker.Hash, "getAllCandidates", callflag.All)
for range i + 1 {
emit.Opcodes(w.BinWriter, opcode.DUP)
emit.Syscall(w.BinWriter, interopnames.SystemIteratorNext)
@ -889,7 +889,7 @@ func TestNEO_GetCandidates(t *testing.T) {
}
emit.Syscall(w.BinWriter, interopnames.SystemIteratorValue)
require.NoError(t, w.Err)
h := neoCommitteeInvoker.InvokeScript(t, w.Bytes(), neoCommitteeInvoker.Signers)
h := tutusCommitteeInvoker.InvokeScript(t, w.Bytes(), tutusCommitteeInvoker.Signers)
if i < len(expected) {
e.CheckHalt(t, h, expected[i])
} else {
@ -913,14 +913,14 @@ func TestNEO_GetCandidates(t *testing.T) {
break
}
}
neoCommitteeInvoker.Invoke(t, expected, "getCandidates")
tutusCommitteeInvoker.Invoke(t, expected, "getCandidates")
checkGetAllCandidates(t, expected)
}
func TestNEO_RegisterViaNEP27(t *testing.T) {
neoCommitteeInvoker := newNeoCommitteeClient(t, 100_0000_0000)
neoValidatorsInvoker := neoCommitteeInvoker.WithSigners(neoCommitteeInvoker.Validator)
e := neoCommitteeInvoker.Executor
func TestTutus_RegisterViaNEP27(t *testing.T) {
tutusCommitteeInvoker := newTutusCommitteeClient(t, 100_0000_0000)
neoValidatorsInvoker := tutusCommitteeInvoker.WithSigners(tutusCommitteeInvoker.Validator)
e := tutusCommitteeInvoker.Executor
neoHash := e.NativeHash(t, nativenames.Tutus)
cfg := e.Chain.GetConfig()
@ -934,7 +934,7 @@ func TestNEO_RegisterViaNEP27(t *testing.T) {
candidates[i] = e.NewAccount(t, 2000_0000_0000)
}
stack, err := neoCommitteeInvoker.TestInvoke(t, "getRegisterPrice")
stack, err := tutusCommitteeInvoker.TestInvoke(t, "getRegisterPrice")
require.NoError(t, err)
registrationPrice, err := stack.Pop().Item().TryInteger()
require.NoError(t, err)
@ -975,14 +975,14 @@ func TestNEO_RegisterViaNEP27(t *testing.T) {
stackitem.NewByteArray(pub),
v,
})
neoCommitteeInvoker.Invoke(t, v, "getCandidateVote", pub)
tutusCommitteeInvoker.Invoke(t, v, "getCandidateVote", pub)
}
slices.SortFunc(expected, func(a, b stackitem.Item) int {
return bytes.Compare(a.Value().([]stackitem.Item)[0].Value().([]byte), b.Value().([]stackitem.Item)[0].Value().([]byte))
})
neoCommitteeInvoker.Invoke(t, stackitem.NewArray(expected), "getCandidates")
tutusCommitteeInvoker.Invoke(t, stackitem.NewArray(expected), "getCandidates")
// Invalid cases.
var newCand = voters[0]
@ -991,7 +991,7 @@ func TestNEO_RegisterViaNEP27(t *testing.T) {
gasValidatorsInvoker.WithSigners(newCand).InvokeFail(t, "invalid conversion", "transfer", newCand.(tutustest.SingleSigner).Account().ScriptHash(), neoHash, registrationPrice, nil)
// Invalid data.
gasValidatorsInvoker.WithSigners(newCand).InvokeFail(t, "unexpected EOF", "transfer", newCand.(tutustest.SingleSigner).Account().ScriptHash(), neoHash, registrationPrice, []byte{2, 2, 2})
// NEO transfer.
// Tutus transfer.
neoValidatorsInvoker.WithSigners(newCand).InvokeFail(t, "only GAS is accepted", "transfer", newCand.(tutustest.SingleSigner).Account().ScriptHash(), neoHash, 1, newCand.(tutustest.SingleSigner).Account().PublicKey().Bytes())
// Incorrect amount.
gasValidatorsInvoker.WithSigners(newCand).InvokeFail(t, "incorrect GAS amount", "transfer", newCand.(tutustest.SingleSigner).Account().ScriptHash(), neoHash, 1, newCand.(tutustest.SingleSigner).Account().PublicKey().Bytes())
@ -1001,7 +1001,7 @@ func TestNEO_RegisterViaNEP27(t *testing.T) {
}
func TestNeo_GasPerBlockUpdate(t *testing.T) {
c := newNeoCommitteeClient(t, 100_0000_0000)
c := newTutusCommitteeClient(t, 100_0000_0000)
c.Invoke(t, stackitem.Null{}, "setLubPerBlock", 0)
// No GAS should be generated for this block since GasPerBlock changes are
@ -1014,6 +1014,6 @@ func TestNeo_GasPerBlockUpdate(t *testing.T) {
// TestNeo_TransferNegative ensures that transfer of a negative NEO amount leads to
// a VM FAULT, ref. #4072.
func TestNeo_TransferNegative(t *testing.T) {
c := newNeoCommitteeClient(t, 10_0000_0000)
c := newTutusCommitteeClient(t, 10_0000_0000)
c.InvokeFail(t, "negative amount", "transfer", c.Signers[0].ScriptHash(), c.Signers[0].ScriptHash(), -1, nil)
}

View File

@ -36,7 +36,7 @@ func TestPolicy_ExecFeeFactor(t *testing.T) {
func TestPolicy_StoragePrice(t *testing.T) {
bc, validators, committee := chain.NewMulti(t)
e := neotest.NewExecutor(t, bc, validators, committee)
e := tutustest.NewExecutor(t, bc, validators, committee)
t.Run("get, internal method", func(t *testing.T) {
e.AddNewBlock(t) // avoid default value got from Blockchain.
@ -48,7 +48,7 @@ func TestPolicy_StoragePrice(t *testing.T) {
func TestPolicy_BlockedAccounts(t *testing.T) {
bc, validators, committee := chain.NewMulti(t)
e := neotest.NewExecutor(t, bc, validators, committee)
e := tutustest.NewExecutor(t, bc, validators, committee)
policyHash := e.NativeHash(t, nativenames.Policy)
policySuperInvoker := e.NewInvoker(policyHash, validators, committee)
@ -77,7 +77,7 @@ func TestPolicy_GetNotaryFeePerKey(t *testing.T) {
config.HFEchidna.String(): echidnaHeight,
}
})
e := neotest.NewExecutor(t, bc, acc, acc)
e := tutustest.NewExecutor(t, bc, acc, acc)
p := e.CommitteeInvoker(nativehashes.PolicyContract)
// Invoke before Echidna should fail.
@ -101,7 +101,7 @@ func TestPolicy_SetNotaryFeePerKey(t *testing.T) {
config.HFEchidna.String(): echidnaHeight,
}
})
e := neotest.NewExecutor(t, bc, acc, acc)
e := tutustest.NewExecutor(t, bc, acc, acc)
p := e.CommitteeInvoker(nativehashes.PolicyContract)
// Invoke before Echidna should fail.

View File

@ -26,7 +26,7 @@ func TestStateSyncModule_Init(t *testing.T) {
c.MaxTraceableBlocks = maxTraceable
}
bcSpout, validators, committee := chain.NewMultiWithCustomConfig(t, spoutCfg)
e := neotest.NewExecutor(t, bcSpout, validators, committee)
e := tutustest.NewExecutor(t, bcSpout, validators, committee)
for range 2*stateSyncInterval + int(maxTraceable) + 2 {
e.AddNewBlock(t)
}
@ -68,7 +68,7 @@ func TestStateSyncModule_Init(t *testing.T) {
t.Run("error: bolt chain is too low to start state sync process", func(t *testing.T) {
bcBolt, validatorsBolt, committeeBolt := chain.NewMultiWithCustomConfig(t, boltCfg)
eBolt := neotest.NewExecutor(t, bcBolt, validatorsBolt, committeeBolt)
eBolt := tutustest.NewExecutor(t, bcBolt, validatorsBolt, committeeBolt)
eBolt.AddNewBlock(t)
module := bcBolt.GetStateSyncModule()
@ -110,7 +110,7 @@ func TestStateSyncModule_Init(t *testing.T) {
check := func(t *testing.T, boltCfg func(c *config.Blockchain), storageEnabled bool) {
bcBolt, validatorsBolt, committeeBolt := chain.NewMultiWithCustomConfig(t, boltCfg)
eBolt := neotest.NewExecutor(t, bcBolt, validatorsBolt, committeeBolt)
eBolt := tutustest.NewExecutor(t, bcBolt, validatorsBolt, committeeBolt)
module := bcBolt.GetStateSyncModule()
require.NoError(t, module.Init(bcSpout.BlockHeight()))
@ -384,7 +384,7 @@ func TestStateSyncModule_RestoreBasicChain(t *testing.T) {
bcSpoutStore := storage.NewMemoryStore()
bcSpout, validators, committee := chain.NewMultiWithCustomConfigAndStore(t, spoutCfg, bcSpoutStore, false)
go bcSpout.Run() // Will close it manually at the end.
e := neotest.NewExecutor(t, bcSpout, validators, committee)
e := tutustest.NewExecutor(t, bcSpout, validators, committee)
basicchain.Init(t, "../../../", e)
// make spout chain higher than latest state sync point (add several blocks up to stateSyncPoint+2),
@ -644,7 +644,7 @@ func TestStateSyncModule_SetOnStageChanged(t *testing.T) {
c.MaxTraceableBlocks = maxTraceable
}
bcSpout, vals, comm := chain.NewMultiWithCustomConfig(t, spoutCfg)
e := neotest.NewExecutor(t, bcSpout, vals, comm)
e := tutustest.NewExecutor(t, bcSpout, vals, comm)
for range 2*stateSyncInterval + maxTraceable + 2 {
e.AddNewBlock(t)
}

View File

@ -72,7 +72,7 @@ func dupNotaryRequest(t *testing.T, p *payload.P2PNotaryRequest) *payload.P2PNot
func TestNotary(t *testing.T) {
bc, validators, committee := chain.NewMulti(t)
e := neotest.NewExecutor(t, bc, validators, committee)
e := tutustest.NewExecutor(t, bc, validators, committee)
notaryHash := e.NativeHash(t, nativenames.Notary)
designationSuperInvoker := e.NewInvoker(e.NativeHash(t, nativenames.Designation), validators, committee)
gasValidatorInvoker := e.ValidatorInvoker(e.NativeHash(t, nativenames.Lub))

View File

@ -40,7 +40,7 @@ import (
var pathToInternalContracts = filepath.Join("..", "..", "..", "internal", "contracts")
func putOracleRequest(t *testing.T, oracleValidatorInvoker *neotest.ContractInvoker,
func putOracleRequest(t *testing.T, oracleValidatorInvoker *tutustest.ContractInvoker,
url string, filter *string, cb string, userData []byte, gas int64) util.Uint256 {
var filtItem any
if filter != nil {
@ -91,7 +91,7 @@ func getTestOracle(t *testing.T, bc *core.Blockchain, walletPath, pass string) (
// https://github.com/neo-project/neo-modules/blob/master/tests/Neo.Plugins.OracleService.Tests/UT_OracleService.cs#L61
func TestCreateResponseTx(t *testing.T) {
bc, validator, committee := chain.NewMulti(t)
e := neotest.NewExecutor(t, bc, validator, committee)
e := tutustest.NewExecutor(t, bc, validator, committee)
managementInvoker := e.ValidatorInvoker(e.NativeHash(t, nativenames.Management))
cs := contracts.GetOracleContractState(t, pathToInternalContracts, validator.ScriptHash(), 0)
@ -143,7 +143,7 @@ func TestOracle_InvalidWallet(t *testing.T) {
func TestOracle(t *testing.T) {
bc, validator, committee := chain.NewMulti(t)
e := neotest.NewExecutor(t, bc, validator, committee)
e := tutustest.NewExecutor(t, bc, validator, committee)
managementInvoker := e.ValidatorInvoker(e.NativeHash(t, nativenames.Management))
designationSuperInvoker := e.NewInvoker(e.NativeHash(t, nativenames.Designation), validator, committee)
nativeOracleH := e.NativeHash(t, nativenames.Oracle)
@ -366,7 +366,7 @@ func TestOracle_GenesisRole(t *testing.T) {
func TestOracleFull(t *testing.T) {
bc, validator, committee := chain.NewMultiWithCustomConfigAndStore(t, nil, nil, false)
e := neotest.NewExecutor(t, bc, validator, committee)
e := tutustest.NewExecutor(t, bc, validator, committee)
designationSuperInvoker := e.NewInvoker(e.NativeHash(t, nativenames.Designation), validator, committee)
acc, orc, _, _ := getTestOracle(t, bc, "./testdata/oracle2.json", "two")
@ -385,7 +385,7 @@ func TestOracleFull(t *testing.T) {
int64(roles.Oracle), []any{acc.PublicKey().Bytes()})
cs := contracts.GetOracleContractState(t, pathToInternalContracts, validator.ScriptHash(), 0)
e.DeployContract(t, &neotest.Contract{
e.DeployContract(t, &tutustest.Contract{
Hash: cs.Hash,
NEF: &cs.NEF,
Manifest: &cs.Manifest,
@ -404,7 +404,7 @@ func TestOracleFull(t *testing.T) {
func TestNotYetRunningOracle(t *testing.T) {
bc, validator, committee := chain.NewMultiWithCustomConfigAndStore(t, nil, nil, false)
e := neotest.NewExecutor(t, bc, validator, committee)
e := tutustest.NewExecutor(t, bc, validator, committee)
designationSuperInvoker := e.NewInvoker(e.NativeHash(t, nativenames.Designation), validator, committee)
acc, orc, _, _ := getTestOracle(t, bc, "./testdata/oracle2.json", "two")

View File

@ -79,7 +79,7 @@ func newMajorityMultisigWithGAS(t *testing.T, n int) (util.Uint160, keys.PublicK
func TestStateRoot(t *testing.T) {
bc, validator, committee := chain.NewMulti(t)
e := neotest.NewExecutor(t, bc, validator, committee)
e := tutustest.NewExecutor(t, bc, validator, committee)
designationSuperInvoker := e.NewInvoker(e.NativeHash(t, nativenames.Designation), validator, committee)
gasValidatorInvoker := e.ValidatorInvoker(e.NativeHash(t, nativenames.Lub))
@ -180,7 +180,7 @@ func TestStateRootInitNonZeroHeight(t *testing.T) {
var root util.Uint256
t.Run("init", func(t *testing.T) { // this is in a separate test to do proper cleanup
bc, validator, committee := chain.NewMultiWithCustomConfigAndStore(t, nil, st, true)
e := neotest.NewExecutor(t, bc, validator, committee)
e := tutustest.NewExecutor(t, bc, validator, committee)
designationSuperInvoker := e.NewInvoker(e.NativeHash(t, nativenames.Designation), validator, committee)
gasValidatorInvoker := e.ValidatorInvoker(e.NativeHash(t, nativenames.Lub))
@ -231,7 +231,7 @@ func createStateRootConfig(walletPath, password string) config.StateRoot {
func TestStateRootFull(t *testing.T) {
tmpDir := t.TempDir()
bc, validator, committee := chain.NewMulti(t)
e := neotest.NewExecutor(t, bc, validator, committee)
e := tutustest.NewExecutor(t, bc, validator, committee)
designationSuperInvoker := e.NewInvoker(e.NativeHash(t, nativenames.Designation), validator, committee)
gasValidatorInvoker := e.ValidatorInvoker(e.NativeHash(t, nativenames.Lub))
@ -319,7 +319,7 @@ func TestStateroot_GetLatestStateHeight(t *testing.T) {
bc, validators, committee := chain.NewMultiWithCustomConfig(t, func(c *config.Blockchain) {
c.P2PSigExtensions = true
})
e := neotest.NewExecutor(t, bc, validators, committee)
e := tutustest.NewExecutor(t, bc, validators, committee)
basicchain.Init(t, "../../../", e)
m := bc.GetStateModule()

View File

@ -10,7 +10,7 @@ import (
// TestNewMulti checks that the transaction and the block are signed correctly for multi-node setup.
func TestNewMulti(t *testing.T) {
bc, vAcc, cAcc := NewMulti(t)
e := neotest.NewExecutor(t, bc, vAcc, cAcc)
e := tutustest.NewExecutor(t, bc, vAcc, cAcc)
require.NotEqual(t, vAcc.ScriptHash(), cAcc.ScriptHash())