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:
parent
08411ec4da
commit
dd826d9bad
|
|
@ -138,7 +138,7 @@ func newTestVMClIWithState(t *testing.T) *executor {
|
||||||
protoCfg := bc.GetConfig()
|
protoCfg := bc.GetConfig()
|
||||||
|
|
||||||
go bc.Run()
|
go bc.Run()
|
||||||
e := neotest.NewExecutor(t, bc, validators, committee)
|
e := tutustest.NewExecutor(t, bc, validators, committee)
|
||||||
basicchain.InitSimple(t, "../../", e)
|
basicchain.InitSimple(t, "../../", e)
|
||||||
bc.Close()
|
bc.Close()
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -14,10 +14,10 @@ import (
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
)
|
)
|
||||||
|
|
||||||
func newNSClient(t *testing.T) *neotest.ContractInvoker {
|
func newNSClient(t *testing.T) *tutustest.ContractInvoker {
|
||||||
bc, acc := chain.NewSingle(t)
|
bc, acc := chain.NewSingle(t)
|
||||||
e := neotest.NewExecutor(t, bc, acc, acc)
|
e := tutustest.NewExecutor(t, bc, acc, acc)
|
||||||
c := neotest.CompileFile(t, e.CommitteeHash, ".", "nns.yml")
|
c := tutustest.CompileFile(t, e.CommitteeHash, ".", "nns.yml")
|
||||||
e.DeployContract(t, c, nil)
|
e.DeployContract(t, c, nil)
|
||||||
|
|
||||||
return e.CommitteeInvoker(c.Hash)
|
return e.CommitteeInvoker(c.Hash)
|
||||||
|
|
@ -64,7 +64,7 @@ func TestNameService_Price(t *testing.T) {
|
||||||
func TestNonfungible(t *testing.T) {
|
func TestNonfungible(t *testing.T) {
|
||||||
c := newNSClient(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, "NNS", "symbol")
|
||||||
c.Invoke(t, 0, "decimals")
|
c.Invoke(t, 0, "decimals")
|
||||||
c.Invoke(t, 0, "totalSupply")
|
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
|
e.DisableCoverage() // contracts below have no source files which leads to unprocessable coverage data
|
||||||
// without onNEP11Transfer
|
// without onNEP11Transfer
|
||||||
ctr := neotest.CompileSource(t, e.CommitteeHash,
|
ctr := tutustest.CompileSource(t, e.CommitteeHash,
|
||||||
strings.NewReader(`package foo
|
strings.NewReader(`package foo
|
||||||
func Main() int { return 0 }`),
|
func Main() int { return 0 }`),
|
||||||
&compiler.Options{Name: "foo"})
|
&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)
|
cTo.InvokeFail(t, "method not found", "transfer", ctr.Hash, []byte("neo.com"), nil)
|
||||||
|
|
||||||
// with onNEP11Transfer
|
// with onNEP11Transfer
|
||||||
ctr = neotest.CompileSource(t, e.CommitteeHash,
|
ctr = tutustest.CompileSource(t, e.CommitteeHash,
|
||||||
strings.NewReader(`package foo
|
strings.NewReader(`package foo
|
||||||
import "github.com/tutus-one/tutus-chain/pkg/interop"
|
import "github.com/tutus-one/tutus-chain/pkg/interop"
|
||||||
func OnNEP11Payment(from interop.Hash160, amount int, token []byte, data any) {}`),
|
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
|
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"
|
method := "tokensOf"
|
||||||
if len(args) == 0 {
|
if len(args) == 0 {
|
||||||
method = "tokens"
|
method = "tokens"
|
||||||
|
|
|
||||||
|
|
@ -139,10 +139,10 @@ func TestCubicCircuit_EndToEnd(t *testing.T) {
|
||||||
|
|
||||||
// Create testing chain and deploy contract onto it.
|
// Create testing chain and deploy contract onto it.
|
||||||
bc, committee := chain.NewSingle(t)
|
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.
|
// 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)
|
e.DeployContract(t, c, nil)
|
||||||
|
|
||||||
// Verify proof via verification contract call.
|
// 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.
|
// Create testing chain and deploy contract onto it.
|
||||||
bc, committee := chain.NewSingle(t)
|
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.
|
// 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)
|
e.DeployContract(t, c, nil)
|
||||||
|
|
||||||
// Verify proof via verification contract call.
|
// Verify proof via verification contract call.
|
||||||
|
|
|
||||||
|
|
@ -46,7 +46,7 @@ const (
|
||||||
// It's not as complicated as chain got after Init and may be used for tests where
|
// 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.
|
// chain with a small amount of data is needed and for historical functionality testing.
|
||||||
// Needs a path to the root directory.
|
// 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.
|
// examplesPrefix is a prefix of the example smart-contracts.
|
||||||
var examplesPrefix = filepath.Join(rootpath, "examples")
|
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
|
// Init pushes some predefined set of transactions into the given chain, it needs a path to
|
||||||
// the root project directory.
|
// 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
|
const notaryDepositHeight uint32 = 8
|
||||||
echidnaH, ok := e.Chain.GetConfig().Hardforks[config.HFEchidna.String()]
|
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())
|
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("native Notary hash: %v", notaryHash)
|
||||||
t.Logf("Block0 hash: %s", e.Chain.GetHeaderHash(0).StringLE())
|
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()
|
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()
|
priv1ScriptHash := acc1.ScriptHash()
|
||||||
neoValidatorInvoker := e.ValidatorInvoker(neoHash)
|
neoValidatorInvoker := e.ValidatorInvoker(neoHash)
|
||||||
gasValidatorInvoker := e.ValidatorInvoker(gasHash)
|
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())
|
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) {
|
func newDeployTx(t *testing.T, e *tutustest.Executor, sender tutustest.Signer, sourcePath, configPath string, deploy bool) (util.Uint256, util.Uint160) {
|
||||||
c := neotest.CompileFile(t, sender.ScriptHash(), sourcePath, configPath)
|
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))
|
t.Logf("contract (%s): \n\tHash: %s\n\tAVM: %s", sourcePath, c.Hash.StringLE(), base64.StdEncoding.EncodeToString(c.NEF.Script))
|
||||||
if deploy {
|
if deploy {
|
||||||
return e.DeployContractBy(t, sender, c, nil), c.Hash
|
return e.DeployContractBy(t, sender, c, nil), c.Hash
|
||||||
|
|
|
||||||
|
|
@ -13,5 +13,5 @@ events:
|
||||||
type: Integer
|
type: Integer
|
||||||
permissions:
|
permissions:
|
||||||
- hash: 2d2dcf3c8b6b96793f6ecfd5856bb39d536f1d89
|
- hash: 2d2dcf3c8b6b96793f6ecfd5856bb39d536f1d89
|
||||||
methods: ["transfer"]
|
methods: ["transfer", "balanceOf"]
|
||||||
- methods: ["onNEP17Payment"]
|
- methods: ["onNEP17Payment"]
|
||||||
|
|
|
||||||
|
|
@ -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.
|
// 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.
|
// Set `saveState` flag to true and run the test to rewrite NEF and manifest files.
|
||||||
func generateOracleContract(t *testing.T, saveState bool) {
|
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.
|
// Write NEF file.
|
||||||
bytes, err := ctr.NEF.Bytes()
|
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.
|
// Set `saveState` flag to true and run the test to rewrite NEF and manifest files.
|
||||||
func generateManagementHelperContracts(t *testing.T, saveState bool) {
|
func generateManagementHelperContracts(t *testing.T, saveState bool) {
|
||||||
bc, validator, committee := chain.NewMulti(t)
|
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)
|
mgmtHash := e.NativeHash(t, nativenames.Management)
|
||||||
stdHash := e.NativeHash(t, nativenames.StdLib)
|
stdHash := e.NativeHash(t, nativenames.StdLib)
|
||||||
neoHash := e.NativeHash(t, nativenames.Tutus)
|
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()}))
|
require.NoError(t, singleChainValidatorAcc.ConvertMultisig(1, keys.PublicKeys{singleChainValidatorAcc.PublicKey()}))
|
||||||
singleChainValidatorHash := singleChainValidatorAcc.Contract.ScriptHash()
|
singleChainValidatorHash := singleChainValidatorAcc.Contract.ScriptHash()
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -136,7 +136,7 @@ func TestInvokeAddressToFromHash160(t *testing.T) {
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
bc, acc := chain.NewSingle(t)
|
bc, acc := chain.NewSingle(t)
|
||||||
e := neotest.NewExecutor(t, bc, acc, acc)
|
e := tutustest.NewExecutor(t, bc, acc, acc)
|
||||||
src := `package foo
|
src := `package foo
|
||||||
import (
|
import (
|
||||||
"github.com/tutus-one/tutus-chain/pkg/interop"
|
"github.com/tutus-one/tutus-chain/pkg/interop"
|
||||||
|
|
@ -152,7 +152,7 @@ func TestInvokeAddressToFromHash160(t *testing.T) {
|
||||||
func FromHash160(hash interop.Hash160) string {
|
func FromHash160(hash interop.Hash160) string {
|
||||||
return address.FromHash160(hash)
|
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)
|
e.DeployContract(t, ctr, nil)
|
||||||
c := e.CommitteeInvoker(ctr.Hash)
|
c := e.CommitteeInvoker(ctr.Hash)
|
||||||
|
|
||||||
|
|
@ -250,7 +250,7 @@ func TestAssertMsg(t *testing.T) {
|
||||||
|
|
||||||
func TestCurrentSigners(t *testing.T) {
|
func TestCurrentSigners(t *testing.T) {
|
||||||
bc, acc := chain.NewSingle(t)
|
bc, acc := chain.NewSingle(t)
|
||||||
e := neotest.NewExecutor(t, bc, acc, acc)
|
e := tutustest.NewExecutor(t, bc, acc, acc)
|
||||||
src := `package foo
|
src := `package foo
|
||||||
import (
|
import (
|
||||||
"github.com/tutus-one/tutus-chain/pkg/interop/native/ledger"
|
"github.com/tutus-one/tutus-chain/pkg/interop/native/ledger"
|
||||||
|
|
@ -259,7 +259,7 @@ func TestCurrentSigners(t *testing.T) {
|
||||||
func Main() []ledger.TransactionSigner {
|
func Main() []ledger.TransactionSigner {
|
||||||
return runtime.CurrentSigners()
|
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)
|
e.DeployContract(t, ctr, nil)
|
||||||
c := e.CommitteeInvoker(ctr.Hash)
|
c := e.CommitteeInvoker(ctr.Hash)
|
||||||
|
|
||||||
|
|
@ -279,7 +279,7 @@ func TestCurrentSigners(t *testing.T) {
|
||||||
|
|
||||||
func TestStdLib_StrLen(t *testing.T) {
|
func TestStdLib_StrLen(t *testing.T) {
|
||||||
bc, acc := chain.NewSingle(t)
|
bc, acc := chain.NewSingle(t)
|
||||||
e := neotest.NewExecutor(t, bc, acc, acc)
|
e := tutustest.NewExecutor(t, bc, acc, acc)
|
||||||
src := `package foo
|
src := `package foo
|
||||||
import (
|
import (
|
||||||
"github.com/tutus-one/tutus-chain/pkg/interop/native/std"
|
"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 {
|
func Main(s string) int {
|
||||||
return std.StrLen(s)
|
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)
|
e.DeployContract(t, ctr, nil)
|
||||||
c := e.CommitteeInvoker(ctr.Hash)
|
c := e.CommitteeInvoker(ctr.Hash)
|
||||||
|
|
||||||
|
|
@ -596,7 +596,7 @@ func TestCallTConversionErrors(t *testing.T) {
|
||||||
|
|
||||||
func TestCallWithVersion(t *testing.T) {
|
func TestCallWithVersion(t *testing.T) {
|
||||||
bc, acc := chain.NewSingle(t)
|
bc, acc := chain.NewSingle(t)
|
||||||
e := neotest.NewExecutor(t, bc, acc, acc)
|
e := tutustest.NewExecutor(t, bc, acc, acc)
|
||||||
src := `package foo
|
src := `package foo
|
||||||
import (
|
import (
|
||||||
"github.com/tutus-one/tutus-chain/pkg/interop"
|
"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 {
|
func CallWithVersion(hash interop.Hash160, version int, method string) any {
|
||||||
return util.CallWithVersion(hash, version, method, contract.All)
|
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)
|
e.DeployContract(t, ctr, nil)
|
||||||
c := e.CommitteeInvoker(ctr.Hash)
|
c := e.CommitteeInvoker(ctr.Hash)
|
||||||
|
|
||||||
|
|
@ -629,7 +629,7 @@ func TestForcedNotifyArgumentsConversion(t *testing.T) {
|
||||||
bc, acc := chain.NewSingleWithCustomConfig(t, func(blockchain *config.Blockchain) {
|
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.
|
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
|
src := `package foo
|
||||||
import "github.com/tutus-one/tutus-chain/pkg/interop/runtime"
|
import "github.com/tutus-one/tutus-chain/pkg/interop/runtime"
|
||||||
const arg4 = 4 // Const value.
|
const arg4 = 4 // Const value.
|
||||||
|
|
@ -672,7 +672,7 @@ func TestForcedNotifyArgumentsConversion(t *testing.T) {
|
||||||
}
|
}
|
||||||
vmParams[i] = val
|
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",
|
Name: "Helper",
|
||||||
ContractEvents: []compiler.HybridEvent{
|
ContractEvents: []compiler.HybridEvent{
|
||||||
{
|
{
|
||||||
|
|
@ -770,7 +770,7 @@ func TestForcedNotifyArgumentsConversion(t *testing.T) {
|
||||||
// type-asserted to storage.KeyValue inside a contract.
|
// type-asserted to storage.KeyValue inside a contract.
|
||||||
func TestStorageIterator_Value(t *testing.T) {
|
func TestStorageIterator_Value(t *testing.T) {
|
||||||
bc, acc := chain.NewSingle(t)
|
bc, acc := chain.NewSingle(t)
|
||||||
e := neotest.NewExecutor(t, bc, acc, acc)
|
e := tutustest.NewExecutor(t, bc, acc, acc)
|
||||||
|
|
||||||
src := `package foo
|
src := `package foo
|
||||||
|
|
||||||
|
|
@ -793,7 +793,7 @@ func Main() int {
|
||||||
return sum
|
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)
|
e.DeployContract(t, ctr, nil)
|
||||||
c := e.CommitteeInvoker(ctr.Hash)
|
c := e.CommitteeInvoker(ctr.Hash)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -39,7 +39,7 @@ func TestCreateBasicChain(t *testing.T) {
|
||||||
const saveChain = false
|
const saveChain = false
|
||||||
|
|
||||||
bc, validators, committee := chain.NewMulti(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)
|
basicchain.Init(t, "../../", e)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -23,8 +23,8 @@ import (
|
||||||
|
|
||||||
func BenchmarkBlockchain_VerifyWitness(t *testing.B) {
|
func BenchmarkBlockchain_VerifyWitness(t *testing.B) {
|
||||||
bc, acc := chain.NewSingle(t)
|
bc, acc := chain.NewSingle(t)
|
||||||
e := neotest.NewExecutor(t, bc, acc, acc)
|
e := tutustest.NewExecutor(t, bc, acc, acc)
|
||||||
tx := e.NewTx(t, []neotest.Signer{acc}, e.NativeHash(t, nativenames.Lub), "transfer", acc.ScriptHash(), acc.Script(), 1, nil)
|
tx := e.NewTx(t, []tutustest.Signer{acc}, e.NativeHash(t, nativenames.Lub), "transfer", acc.ScriptHash(), acc.Script(), 1, nil)
|
||||||
|
|
||||||
for t.Loop() {
|
for t.Loop() {
|
||||||
_, err := bc.VerifyWitness(tx.Signers[0].Account, tx, &tx.Scripts[0], 100000000)
|
_, 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)
|
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)
|
gasHash := e.NativeHash(t, nativenames.Lub)
|
||||||
|
|
||||||
acc := random.Uint160()
|
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 := transaction.New(script, int64(1100_0000*transfersPerBlock))
|
||||||
tx.NetworkFee = 1_0000_000
|
tx.NetworkFee = 1_0000_000
|
||||||
tx.ValidUntilBlock = bc.BlockHeight() + 1
|
tx.ValidUntilBlock = bc.BlockHeight() + 1
|
||||||
tx.Nonce = neotest.Nonce()
|
tx.Nonce = tutustest.Nonce()
|
||||||
tx.Signers = []transaction.Signer{{Account: from, Scopes: transaction.CalledByEntry}}
|
tx.Signers = []transaction.Signer{{Account: from, Scopes: transaction.CalledByEntry}}
|
||||||
require.NoError(t, validators.SignTx(netmode.UnitTestNet, tx))
|
require.NoError(t, validators.SignTx(netmode.UnitTestNet, tx))
|
||||||
e.AddNewBlock(t, 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)
|
bc, validators, committee := chain.NewMultiWithCustomConfigAndStore(t, nil, ps, true)
|
||||||
cfg := bc.GetConfig()
|
cfg := bc.GetConfig()
|
||||||
|
|
||||||
e := neotest.NewExecutor(t, bc, validators, committee)
|
e := tutustest.NewExecutor(t, bc, validators, committee)
|
||||||
neoHash := e.NativeHash(t, nativenames.Tutus)
|
neoHash := e.NativeHash(t, nativenames.Tutus)
|
||||||
gasHash := e.NativeHash(t, nativenames.Lub)
|
gasHash := e.NativeHash(t, nativenames.Lub)
|
||||||
neoSuperInvoker := e.NewInvoker(neoHash, validators, committee)
|
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 {
|
for i := range sz {
|
||||||
priv := voters[i].PrivateKey()
|
priv := voters[i].PrivateKey()
|
||||||
h := priv.GetScriptHash()
|
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)
|
voteTxs = append(voteTxs, voteTx)
|
||||||
}
|
}
|
||||||
e.AddNewBlock(t, voteTxs...)
|
e.AddNewBlock(t, voteTxs...)
|
||||||
|
|
|
||||||
|
|
@ -73,7 +73,7 @@ func TestBlockchain_StartFromExistingDB(t *testing.T) {
|
||||||
bc, validators, committee, err := chain.NewMultiWithCustomConfigAndStoreNoCheck(t, customConfig, ps)
|
bc, validators, committee, err := chain.NewMultiWithCustomConfigAndStoreNoCheck(t, customConfig, ps)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
go bc.Run()
|
go bc.Run()
|
||||||
e := neotest.NewExecutor(t, bc, validators, committee)
|
e := tutustest.NewExecutor(t, bc, validators, committee)
|
||||||
basicchain.Init(t, "../../", e)
|
basicchain.Init(t, "../../", e)
|
||||||
require.True(t, bc.BlockHeight() > 5, "ensure that basic chain is correctly initialised")
|
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.
|
// Create source chain, fill it with some blocks.
|
||||||
bcSpout, validators := chain.NewSingle(t)
|
bcSpout, validators := chain.NewSingle(t)
|
||||||
e := neotest.NewExecutor(t, bcSpout, validators, validators)
|
e := tutustest.NewExecutor(t, bcSpout, validators, validators)
|
||||||
e.GenerateNewBlocks(t, 3*headerBatchCount)
|
e.GenerateNewBlocks(t, 3*headerBatchCount)
|
||||||
|
|
||||||
check := func(t *testing.T, headerHeight int, trusted *block.Header) {
|
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)
|
bc, validators, committee, err := chain.NewMultiWithCustomConfigAndStoreNoCheck(t, nil, ps)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
go bc.Run()
|
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.
|
// Add at least one registered candidate to enable candidates Policy check.
|
||||||
acc := e.NewAccount(t, 10000_0000_0000) // block #1
|
acc := e.NewAccount(t, 10000_0000_0000) // block #1
|
||||||
neo := e.NewInvoker(e.NativeHash(t, nativenames.Tutus), acc)
|
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
|
// 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
|
// 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)
|
bc, validators, committee, err := chain.NewMultiWithCustomConfigAndStoreNoCheck(t, nil, ps)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
go bc.Run()
|
go bc.Run()
|
||||||
e := neotest.NewExecutor(t, bc, validators, committee)
|
e := tutustest.NewExecutor(t, bc, validators, committee)
|
||||||
cfg := e.Chain.GetConfig()
|
cfg := e.Chain.GetConfig()
|
||||||
committeeSize := cfg.GetCommitteeSize(0)
|
committeeSize := cfg.GetCommitteeSize(0)
|
||||||
validatorsCount := cfg.GetNumOfCNs(0)
|
validatorsCount := cfg.GetNumOfCNs(0)
|
||||||
|
|
@ -533,22 +533,22 @@ func TestBlockchain_InitializeNeoCache_Bug3424(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// voters vote for candidates.
|
// voters vote for candidates.
|
||||||
voters := make([]neotest.Signer, committeeSize+1)
|
voters := make([]tutustest.Signer, committeeSize+1)
|
||||||
candidates := make([]neotest.Signer, committeeSize+1)
|
candidates := make([]tutustest.Signer, committeeSize+1)
|
||||||
for i := range committeeSize + 1 {
|
for i := range committeeSize + 1 {
|
||||||
voters[i] = e.NewAccount(t, 10_0000_0000)
|
voters[i] = e.NewAccount(t, 10_0000_0000)
|
||||||
candidates[i] = e.NewAccount(t, 2000_0000_0000) // enough for one registration
|
candidates[i] = e.NewAccount(t, 2000_0000_0000) // enough for one registration
|
||||||
}
|
}
|
||||||
txes := make([]*transaction.Transaction, 0, committeeSize*3)
|
txes := make([]*transaction.Transaction, 0, committeeSize*3)
|
||||||
for i := range committeeSize + 1 {
|
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)
|
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)
|
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, 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...)
|
neoValidatorsInvoker.AddNewBlock(t, txes...)
|
||||||
for _, tx := range txes {
|
for _, tx := range txes {
|
||||||
e.CheckHalt(t, tx.Hash(), stackitem.Make(true)) // luckily, both `transfer`, `registerCandidate` and `vote` return boolean values
|
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()
|
pubs = e.Chain.ComputeNextBlockValidators()
|
||||||
sortedCandidates := make(keys.PublicKeys, validatorsCount)
|
sortedCandidates := make(keys.PublicKeys, validatorsCount)
|
||||||
for i := range candidates[: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)
|
slices.SortFunc(sortedCandidates, (*keys.PublicKey).Cmp)
|
||||||
require.EqualValues(t, sortedCandidates, keys.PublicKeys(pubs))
|
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)
|
bc, validators, committee, err := chain.NewMultiWithCustomConfigAndStoreNoCheck(t, customConfig, ps)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
go bc.Run()
|
go bc.Run()
|
||||||
e := neotest.NewExecutor(t, bc, validators, committee)
|
e := tutustest.NewExecutor(t, bc, validators, committee)
|
||||||
e.AddNewBlock(t)
|
e.AddNewBlock(t)
|
||||||
bc.Close() // Ensure persist is done and persistent store is properly closed.
|
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()
|
go bc.Run()
|
||||||
defer bc.Close()
|
defer bc.Close()
|
||||||
e = neotest.NewExecutor(t, bc, validators, committee)
|
e = tutustest.NewExecutor(t, bc, validators, committee)
|
||||||
h := e.Chain.BlockHeight()
|
h := e.Chain.BlockHeight()
|
||||||
|
|
||||||
// Notary isn't initialized yet, so accessing Notary cache should return error.
|
// 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) {
|
bc, acc := chain.NewSingleWithCustomConfig(t, func(c *config.Blockchain) {
|
||||||
c.StateRootInHeader = true
|
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 {
|
newHeader := func(t *testing.T, index uint32, prevHash util.Uint256, timestamp uint64) *block.Header {
|
||||||
b := e.NewUnsignedBlock(t)
|
b := e.NewUnsignedBlock(t)
|
||||||
|
|
@ -700,7 +700,7 @@ func TestBlockchain_AddBlockStateRoot(t *testing.T) {
|
||||||
bc, acc := chain.NewSingleWithCustomConfig(t, func(c *config.Blockchain) {
|
bc, acc := chain.NewSingleWithCustomConfig(t, func(c *config.Blockchain) {
|
||||||
c.StateRootInHeader = true
|
c.StateRootInHeader = true
|
||||||
})
|
})
|
||||||
e := neotest.NewExecutor(t, bc, acc, acc)
|
e := tutustest.NewExecutor(t, bc, acc, acc)
|
||||||
|
|
||||||
sr, err := bc.GetStateModule().GetStateRoot(bc.BlockHeight())
|
sr, err := bc.GetStateModule().GetStateRoot(bc.BlockHeight())
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
@ -729,7 +729,7 @@ func TestBlockchain_AddHeadersStateRoot(t *testing.T) {
|
||||||
bc, acc := chain.NewSingleWithCustomConfig(t, func(c *config.Blockchain) {
|
bc, acc := chain.NewSingleWithCustomConfig(t, func(c *config.Blockchain) {
|
||||||
c.StateRootInHeader = true
|
c.StateRootInHeader = true
|
||||||
})
|
})
|
||||||
e := neotest.NewExecutor(t, bc, acc, acc)
|
e := tutustest.NewExecutor(t, bc, acc, acc)
|
||||||
|
|
||||||
b := e.NewUnsignedBlock(t)
|
b := e.NewUnsignedBlock(t)
|
||||||
e.SignBlock(b)
|
e.SignBlock(b)
|
||||||
|
|
@ -766,7 +766,7 @@ func TestBlockchain_AddBadBlock(t *testing.T) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
bc, acc := chain.NewSingle(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)
|
neoHash := e.NativeHash(t, nativenames.Tutus)
|
||||||
|
|
||||||
tx := e.NewUnsignedTx(t, neoHash, "transfer", acc.ScriptHash(), util.Uint160{1, 2, 3}, 1, nil)
|
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) {
|
func TestBlockchain_GetHeader(t *testing.T) {
|
||||||
bc, acc := chain.NewSingle(t)
|
bc, acc := chain.NewSingle(t)
|
||||||
e := neotest.NewExecutor(t, bc, acc, acc)
|
e := tutustest.NewExecutor(t, bc, acc, acc)
|
||||||
|
|
||||||
block := e.AddNewBlock(t)
|
block := e.AddNewBlock(t)
|
||||||
hash := block.Hash()
|
hash := block.Hash()
|
||||||
|
|
@ -828,7 +828,7 @@ func TestBlockchain_GetHeader(t *testing.T) {
|
||||||
|
|
||||||
func TestBlockchain_GetBlock(t *testing.T) {
|
func TestBlockchain_GetBlock(t *testing.T) {
|
||||||
bc, acc := chain.NewSingle(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)
|
blocks := e.GenerateNewBlocks(t, 10)
|
||||||
neoValidatorInvoker := e.ValidatorInvoker(e.NativeHash(t, nativenames.Tutus))
|
neoValidatorInvoker := e.ValidatorInvoker(e.NativeHash(t, nativenames.Tutus))
|
||||||
|
|
||||||
|
|
@ -871,15 +871,15 @@ func TestBlockchain_GetBlock(t *testing.T) {
|
||||||
|
|
||||||
func TestBlockchain_VerifyHashAgainstScript(t *testing.T) {
|
func TestBlockchain_VerifyHashAgainstScript(t *testing.T) {
|
||||||
bc, acc := chain.NewSingle(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())
|
cs, csInvalid := contracts.GetTestContractState(t, pathToInternalContracts, 0, 1, acc.ScriptHash())
|
||||||
c1 := &neotest.Contract{
|
c1 := &tutustest.Contract{
|
||||||
Hash: cs.Hash,
|
Hash: cs.Hash,
|
||||||
NEF: &cs.NEF,
|
NEF: &cs.NEF,
|
||||||
Manifest: &cs.Manifest,
|
Manifest: &cs.Manifest,
|
||||||
}
|
}
|
||||||
c2 := &neotest.Contract{
|
c2 := &tutustest.Contract{
|
||||||
Hash: csInvalid.Hash,
|
Hash: csInvalid.Hash,
|
||||||
NEF: &csInvalid.NEF,
|
NEF: &csInvalid.NEF,
|
||||||
Manifest: &csInvalid.Manifest,
|
Manifest: &csInvalid.Manifest,
|
||||||
|
|
@ -954,12 +954,12 @@ func TestBlockchain_VerifyHashAgainstScript(t *testing.T) {
|
||||||
|
|
||||||
func TestBlockchain_IsTxStillRelevant(t *testing.T) {
|
func TestBlockchain_IsTxStillRelevant(t *testing.T) {
|
||||||
bc, acc := chain.NewSingle(t)
|
bc, acc := chain.NewSingle(t)
|
||||||
e := neotest.NewExecutor(t, bc, acc, acc)
|
e := tutustest.NewExecutor(t, bc, acc, acc)
|
||||||
|
|
||||||
mp := bc.GetMemPool()
|
mp := bc.GetMemPool()
|
||||||
|
|
||||||
t.Run("small ValidUntilBlock", func(t *testing.T) {
|
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))
|
require.True(t, bc.IsTxStillRelevant(tx, nil, false))
|
||||||
e.AddNewBlock(t)
|
e.AddNewBlock(t)
|
||||||
|
|
@ -967,7 +967,7 @@ func TestBlockchain_IsTxStillRelevant(t *testing.T) {
|
||||||
})
|
})
|
||||||
|
|
||||||
t.Run("tx is already persisted", func(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))
|
require.True(t, bc.IsTxStillRelevant(tx, nil, false))
|
||||||
e.AddNewBlock(t, tx)
|
e.AddNewBlock(t, tx)
|
||||||
|
|
@ -975,10 +975,10 @@ func TestBlockchain_IsTxStillRelevant(t *testing.T) {
|
||||||
})
|
})
|
||||||
|
|
||||||
t.Run("tx with Conflicts attribute", func(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 := transaction.New([]byte{byte(opcode.PUSH1)}, 0)
|
||||||
tx2.Nonce = neotest.Nonce()
|
tx2.Nonce = tutustest.Nonce()
|
||||||
tx2.ValidUntilBlock = e.Chain.BlockHeight() + 5
|
tx2.ValidUntilBlock = e.Chain.BlockHeight() + 5
|
||||||
tx2.Attributes = []transaction.Attribute{{
|
tx2.Attributes = []transaction.Attribute{{
|
||||||
Type: transaction.ConflictsT,
|
Type: transaction.ConflictsT,
|
||||||
|
|
@ -992,7 +992,7 @@ func TestBlockchain_IsTxStillRelevant(t *testing.T) {
|
||||||
})
|
})
|
||||||
t.Run("NotValidBefore", func(t *testing.T) {
|
t.Run("NotValidBefore", func(t *testing.T) {
|
||||||
tx3 := transaction.New([]byte{byte(opcode.PUSH1)}, 0)
|
tx3 := transaction.New([]byte{byte(opcode.PUSH1)}, 0)
|
||||||
tx3.Nonce = neotest.Nonce()
|
tx3.Nonce = tutustest.Nonce()
|
||||||
tx3.Attributes = []transaction.Attribute{{
|
tx3.Attributes = []transaction.Attribute{{
|
||||||
Type: transaction.NotValidBeforeT,
|
Type: transaction.NotValidBeforeT,
|
||||||
Value: &transaction.NotValidBefore{Height: bc.BlockHeight() + 1},
|
Value: &transaction.NotValidBefore{Height: bc.BlockHeight() + 1},
|
||||||
|
|
@ -1015,13 +1015,13 @@ func TestBlockchain_IsTxStillRelevant(t *testing.T) {
|
||||||
currentHeight := contract.Call(addr, "currentIndex", contract.ReadStates)
|
currentHeight := contract.Call(addr, "currentIndex", contract.ReadStates)
|
||||||
return currentHeight.(int) < %d
|
return currentHeight.(int) < %d
|
||||||
}`, bc.BlockHeight()+2) // deploy + next block
|
}`, 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",
|
Name: "verification_contract",
|
||||||
})
|
})
|
||||||
e.DeployContract(t, c, nil)
|
e.DeployContract(t, c, nil)
|
||||||
|
|
||||||
tx := transaction.New([]byte{byte(opcode.PUSH1)}, 0)
|
tx := transaction.New([]byte{byte(opcode.PUSH1)}, 0)
|
||||||
tx.Nonce = neotest.Nonce()
|
tx.Nonce = tutustest.Nonce()
|
||||||
tx.ValidUntilBlock = bc.BlockHeight() + 2
|
tx.ValidUntilBlock = bc.BlockHeight() + 2
|
||||||
tx.Signers = []transaction.Signer{
|
tx.Signers = []transaction.Signer{
|
||||||
{
|
{
|
||||||
|
|
@ -1042,16 +1042,16 @@ func TestBlockchain_MemPoolRemoval(t *testing.T) {
|
||||||
const added = 16
|
const added = 16
|
||||||
const notAdded = 32
|
const notAdded = 32
|
||||||
bc, acc := chain.NewSingle(t)
|
bc, acc := chain.NewSingle(t)
|
||||||
e := neotest.NewExecutor(t, bc, acc, acc)
|
e := tutustest.NewExecutor(t, bc, acc, acc)
|
||||||
|
|
||||||
addedTxes := make([]*transaction.Transaction, added)
|
addedTxes := make([]*transaction.Transaction, added)
|
||||||
notAddedTxes := make([]*transaction.Transaction, notAdded)
|
notAddedTxes := make([]*transaction.Transaction, notAdded)
|
||||||
for i := range addedTxes {
|
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]))
|
require.NoError(t, bc.PoolTx(addedTxes[i]))
|
||||||
}
|
}
|
||||||
for i := range notAddedTxes {
|
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]))
|
require.NoError(t, bc.PoolTx(notAddedTxes[i]))
|
||||||
}
|
}
|
||||||
mempool := bc.GetMemPool()
|
mempool := bc.GetMemPool()
|
||||||
|
|
@ -1066,7 +1066,7 @@ func TestBlockchain_MemPoolRemoval(t *testing.T) {
|
||||||
|
|
||||||
func TestBlockchain_HasBlock(t *testing.T) {
|
func TestBlockchain_HasBlock(t *testing.T) {
|
||||||
bc, acc := chain.NewSingle(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)
|
blocks := e.GenerateNewBlocks(t, 10)
|
||||||
|
|
||||||
|
|
@ -1079,12 +1079,12 @@ func TestBlockchain_HasBlock(t *testing.T) {
|
||||||
|
|
||||||
func TestBlockchain_GetTransaction(t *testing.T) {
|
func TestBlockchain_GetTransaction(t *testing.T) {
|
||||||
bc, acc := chain.NewSingle(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)
|
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)
|
tx2Size := io.GetVarSize(tx2)
|
||||||
b := e.AddNewBlock(t, tx2)
|
b := e.AddNewBlock(t, tx2)
|
||||||
|
|
||||||
|
|
@ -1108,7 +1108,7 @@ func TestBlockchain_GetClaimable(t *testing.T) {
|
||||||
func TestBlockchain_Close(t *testing.T) {
|
func TestBlockchain_Close(t *testing.T) {
|
||||||
st := storage.NewMemoryStore()
|
st := storage.NewMemoryStore()
|
||||||
bc, acc := chain.NewSingleWithCustomConfigAndStore(t, nil, st, false)
|
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()
|
go bc.Run()
|
||||||
e.GenerateNewBlocks(t, 10)
|
e.GenerateNewBlocks(t, 10)
|
||||||
bc.Close()
|
bc.Close()
|
||||||
|
|
@ -1130,7 +1130,7 @@ func TestBlockchain_Subscriptions(t *testing.T) {
|
||||||
executionCh := make(chan *state.AppExecResult, chBufSize)
|
executionCh := make(chan *state.AppExecResult, chBufSize)
|
||||||
|
|
||||||
bc, acc := chain.NewSingle(t)
|
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)
|
nativeGASHash := e.NativeHash(t, nativenames.Lub)
|
||||||
bc.SubscribeForBlocks(blockCh)
|
bc.SubscribeForBlocks(blockCh)
|
||||||
bc.SubscribeForTransactions(txCh)
|
bc.SubscribeForTransactions(txCh)
|
||||||
|
|
@ -1164,7 +1164,7 @@ func TestBlockchain_Subscriptions(t *testing.T) {
|
||||||
emit.Bytes(script.BinWriter, []byte("yay!"))
|
emit.Bytes(script.BinWriter, []byte("yay!"))
|
||||||
emit.Syscall(script.BinWriter, interopnames.SystemRuntimeNotify)
|
emit.Syscall(script.BinWriter, interopnames.SystemRuntimeNotify)
|
||||||
require.NoError(t, script.Err)
|
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.
|
// Reset() reuses the script buffer and we need to keep scripts.
|
||||||
script = io.NewBufBinWriter()
|
script = io.NewBufBinWriter()
|
||||||
|
|
@ -1172,13 +1172,13 @@ func TestBlockchain_Subscriptions(t *testing.T) {
|
||||||
emit.Syscall(script.BinWriter, interopnames.SystemRuntimeNotify)
|
emit.Syscall(script.BinWriter, interopnames.SystemRuntimeNotify)
|
||||||
emit.Opcodes(script.BinWriter, opcode.THROW)
|
emit.Opcodes(script.BinWriter, opcode.THROW)
|
||||||
require.NoError(t, script.Err)
|
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()
|
script = io.NewBufBinWriter()
|
||||||
emit.Bytes(script.BinWriter, []byte("yay! yay! yay!"))
|
emit.Bytes(script.BinWriter, []byte("yay! yay! yay!"))
|
||||||
emit.Syscall(script.BinWriter, interopnames.SystemRuntimeNotify)
|
emit.Syscall(script.BinWriter, interopnames.SystemRuntimeNotify)
|
||||||
require.NoError(t, script.Err)
|
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)
|
invBlock := e.AddNewBlock(t, txGood1, txBad, txGood2)
|
||||||
|
|
||||||
|
|
@ -1281,7 +1281,7 @@ func TestBlockchain_RemoveUntraceable(t *testing.T) {
|
||||||
c.GarbageCollectionPeriod = gcp
|
c.GarbageCollectionPeriod = gcp
|
||||||
c.RemoveUntraceableBlocks = true
|
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))
|
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
|
// 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.StateSyncInterval = stateSyncInterval
|
||||||
c.StateRootInHeader = true
|
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))
|
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
|
// 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) {
|
func TestBlockchain_InvalidNotification(t *testing.T) {
|
||||||
bc, acc := chain.NewSingle(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())
|
cs, _ := contracts.GetTestContractState(t, pathToInternalContracts, 0, 1, acc.ScriptHash())
|
||||||
e.DeployContract(t, &neotest.Contract{
|
e.DeployContract(t, &tutustest.Contract{
|
||||||
Hash: cs.Hash,
|
Hash: cs.Hash,
|
||||||
NEF: &cs.NEF,
|
NEF: &cs.NEF,
|
||||||
Manifest: &cs.Manifest,
|
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.
|
// Test that deletion of non-existent doesn't result in error in tx or block addition.
|
||||||
func TestBlockchain_MPTDeleteNoKey(t *testing.T) {
|
func TestBlockchain_MPTDeleteNoKey(t *testing.T) {
|
||||||
bc, acc := chain.NewSingle(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())
|
cs, _ := contracts.GetTestContractState(t, pathToInternalContracts, 0, 1, acc.ScriptHash())
|
||||||
e.DeployContract(t, &neotest.Contract{
|
e.DeployContract(t, &tutustest.Contract{
|
||||||
Hash: cs.Hash,
|
Hash: cs.Hash,
|
||||||
NEF: &cs.NEF,
|
NEF: &cs.NEF,
|
||||||
Manifest: &cs.Manifest,
|
Manifest: &cs.Manifest,
|
||||||
|
|
@ -1469,7 +1469,7 @@ func TestBlockchain_VerifyTx(t *testing.T) {
|
||||||
config.HFEchidna.String(): 0,
|
config.HFEchidna.String(): 0,
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
e := neotest.NewExecutor(t, bc, validator, committee)
|
e := tutustest.NewExecutor(t, bc, validator, committee)
|
||||||
|
|
||||||
accs := make([]*wallet.Account, 5)
|
accs := make([]*wallet.Account, 5)
|
||||||
for i := range accs {
|
for i := range accs {
|
||||||
|
|
@ -1520,7 +1520,7 @@ func TestBlockchain_VerifyTx(t *testing.T) {
|
||||||
testScript := []byte{byte(opcode.PUSH1)}
|
testScript := []byte{byte(opcode.PUSH1)}
|
||||||
newTestTx := func(t *testing.T, signer util.Uint160, script []byte) *transaction.Transaction {
|
newTestTx := func(t *testing.T, signer util.Uint160, script []byte) *transaction.Transaction {
|
||||||
tx := transaction.New(script, 1_000_000)
|
tx := transaction.New(script, 1_000_000)
|
||||||
tx.Nonce = neotest.Nonce()
|
tx.Nonce = tutustest.Nonce()
|
||||||
tx.ValidUntilBlock = e.Chain.BlockHeight() + 5
|
tx.ValidUntilBlock = e.Chain.BlockHeight() + 5
|
||||||
tx.Signers = []transaction.Signer{{
|
tx.Signers = []transaction.Signer{{
|
||||||
Account: signer,
|
Account: signer,
|
||||||
|
|
@ -1749,7 +1749,7 @@ func TestBlockchain_VerifyTx(t *testing.T) {
|
||||||
})
|
})
|
||||||
t.Run("Oracle", func(t *testing.T) {
|
t.Run("Oracle", func(t *testing.T) {
|
||||||
cs := contracts.GetOracleContractState(t, pathToInternalContracts, validator.ScriptHash(), 0)
|
cs := contracts.GetOracleContractState(t, pathToInternalContracts, validator.ScriptHash(), 0)
|
||||||
e.DeployContract(t, &neotest.Contract{
|
e.DeployContract(t, &tutustest.Contract{
|
||||||
Hash: cs.Hash,
|
Hash: cs.Hash,
|
||||||
NEF: &cs.NEF,
|
NEF: &cs.NEF,
|
||||||
Manifest: &cs.Manifest,
|
Manifest: &cs.Manifest,
|
||||||
|
|
@ -1769,7 +1769,7 @@ func TestBlockchain_VerifyTx(t *testing.T) {
|
||||||
// because hashes are cached after signing.
|
// because hashes are cached after signing.
|
||||||
getOracleTx := func(t *testing.T) *transaction.Transaction {
|
getOracleTx := func(t *testing.T) *transaction.Transaction {
|
||||||
tx := transaction.New(respScript, 1000_0000)
|
tx := transaction.New(respScript, 1000_0000)
|
||||||
tx.Nonce = neotest.Nonce()
|
tx.Nonce = tutustest.Nonce()
|
||||||
tx.ValidUntilBlock = bc.BlockHeight() + 1
|
tx.ValidUntilBlock = bc.BlockHeight() + 1
|
||||||
resp := &transaction.OracleResponse{
|
resp := &transaction.OracleResponse{
|
||||||
ID: 0,
|
ID: 0,
|
||||||
|
|
@ -1865,7 +1865,7 @@ func TestBlockchain_VerifyTx(t *testing.T) {
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
t.Run("NotValidBefore", func(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 := newTestTx(t, h, testScript)
|
||||||
tx.Attributes = append(tx.Attributes, transaction.Attribute{Type: transaction.NotValidBeforeT, Value: &transaction.NotValidBefore{Height: height}})
|
tx.Attributes = append(tx.Attributes, transaction.Attribute{Type: transaction.NotValidBeforeT, Value: &transaction.NotValidBefore{Height: height}})
|
||||||
tx.NetworkFee += 4_000_000 // multisig check
|
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) {
|
bcBad, validatorBad, committeeBad := chain.NewMultiWithCustomConfig(t, func(c *config.Blockchain) {
|
||||||
c.ReservedAttributes = false
|
c.ReservedAttributes = false
|
||||||
})
|
})
|
||||||
eBad := neotest.NewExecutor(t, bcBad, validatorBad, committeeBad)
|
eBad := tutustest.NewExecutor(t, bcBad, validatorBad, committeeBad)
|
||||||
tx := getNVBTx(eBad, bcBad.BlockHeight())
|
tx := getNVBTx(eBad, bcBad.BlockHeight())
|
||||||
err := bcBad.VerifyTx(tx)
|
err := bcBad.VerifyTx(tx)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
@ -1905,7 +1905,7 @@ func TestBlockchain_VerifyTx(t *testing.T) {
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
t.Run("Reserved", func(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 := newTestTx(t, h, testScript)
|
||||||
tx.Attributes = append(tx.Attributes, transaction.Attribute{Type: attrType, Value: &transaction.Reserved{Value: []byte{1, 2, 3}}})
|
tx.Attributes = append(tx.Attributes, transaction.Attribute{Type: attrType, Value: &transaction.Reserved{Value: []byte{1, 2, 3}}})
|
||||||
tx.NetworkFee += 4_000_000 // multisig check
|
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) {
|
bcBad, validatorBad, committeeBad := chain.NewMultiWithCustomConfig(t, func(c *config.Blockchain) {
|
||||||
c.ReservedAttributes = false
|
c.ReservedAttributes = false
|
||||||
})
|
})
|
||||||
eBad := neotest.NewExecutor(t, bcBad, validatorBad, committeeBad)
|
eBad := tutustest.NewExecutor(t, bcBad, validatorBad, committeeBad)
|
||||||
tx := getReservedTx(eBad, transaction.ReservedLowerBound+3)
|
tx := getReservedTx(eBad, transaction.ReservedLowerBound+3)
|
||||||
err := bcBad.VerifyTx(tx)
|
err := bcBad.VerifyTx(tx)
|
||||||
require.Error(t, err)
|
require.Error(t, err)
|
||||||
|
|
@ -1940,7 +1940,7 @@ func TestBlockchain_VerifyTx(t *testing.T) {
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
t.Run("Conflicts", func(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 := newTestTx(t, h, testScript)
|
||||||
tx.Attributes = make([]transaction.Attribute, len(hashes))
|
tx.Attributes = make([]transaction.Attribute, len(hashes))
|
||||||
for i, h := range 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) {
|
bcBad, validatorBad, committeeBad := chain.NewMultiWithCustomConfig(t, func(c *config.Blockchain) {
|
||||||
c.ReservedAttributes = false
|
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})
|
tx := getConflictsTx(eBad, util.Uint256{1, 2, 3})
|
||||||
err := bcBad.VerifyTx(tx)
|
err := bcBad.VerifyTx(tx)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
@ -2273,7 +2273,7 @@ func TestBlockchain_VerifyTx(t *testing.T) {
|
||||||
VerificationScript: e.Committee.Script(),
|
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 := newTestTx(t, h, testScript)
|
||||||
tx.Attributes = append(tx.Attributes, transaction.Attribute{Type: transaction.NotaryAssistedT, Value: &transaction.NotaryAssisted{
|
tx.Attributes = append(tx.Attributes, transaction.Attribute{Type: transaction.NotaryAssistedT, Value: &transaction.NotaryAssisted{
|
||||||
NKeys: signaturesCount,
|
NKeys: signaturesCount,
|
||||||
|
|
@ -2314,9 +2314,9 @@ func TestBlockchain_VerifyTx(t *testing.T) {
|
||||||
}
|
}
|
||||||
c.ReservedAttributes = false
|
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 := transaction.New(testScript, 1_000_000)
|
||||||
tx.Nonce = neotest.Nonce()
|
tx.Nonce = tutustest.Nonce()
|
||||||
tx.ValidUntilBlock = e.Chain.BlockHeight() + 5
|
tx.ValidUntilBlock = e.Chain.BlockHeight() + 5
|
||||||
tx.Attributes = append(tx.Attributes, transaction.Attribute{Type: transaction.NotaryAssistedT, Value: &transaction.NotaryAssisted{NKeys: 0}})
|
tx.Attributes = append(tx.Attributes, transaction.Attribute{Type: transaction.NotaryAssistedT, Value: &transaction.NotaryAssisted{NKeys: 0}})
|
||||||
tx.NetworkFee = 1_0000_0000
|
tx.NetworkFee = 1_0000_0000
|
||||||
|
|
@ -2559,7 +2559,7 @@ func TestBlockchain_VerifyTx(t *testing.T) {
|
||||||
|
|
||||||
func TestBlockchain_Bug1728(t *testing.T) {
|
func TestBlockchain_Bug1728(t *testing.T) {
|
||||||
bc, acc := chain.NewSingle(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))
|
managementInvoker := e.ValidatorInvoker(e.NativeHash(t, nativenames.Management))
|
||||||
|
|
||||||
src := `package example
|
src := `package example
|
||||||
|
|
@ -2568,7 +2568,7 @@ func TestBlockchain_Bug1728(t *testing.T) {
|
||||||
func _deploy(_ any, isUpdate bool) {
|
func _deploy(_ any, isUpdate bool) {
|
||||||
runtime.Log("Deploy")
|
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)
|
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) {
|
checkResetErr := func(t *testing.T, cfg func(c *config.Blockchain), h uint32, errText string) {
|
||||||
db, path := newLevelDBForTestingWithPath(t, t.TempDir())
|
db, path := newLevelDBForTestingWithPath(t, t.TempDir())
|
||||||
bc, validators, committee := chain.NewMultiWithCustomConfigAndStore(t, cfg, db, false)
|
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()
|
go bc.Run()
|
||||||
for range chainHeight {
|
for range chainHeight {
|
||||||
e.AddNewBlock(t) // get some height
|
e.AddNewBlock(t) // get some height
|
||||||
|
|
@ -2621,7 +2621,7 @@ func TestBlockchain_ResetState(t *testing.T) {
|
||||||
db, path := newLevelDBForTestingWithPath(t, t.TempDir())
|
db, path := newLevelDBForTestingWithPath(t, t.TempDir())
|
||||||
bc, validators, committee := chain.NewMultiWithCustomConfigAndStore(t, nil, db, false)
|
bc, validators, committee := chain.NewMultiWithCustomConfigAndStore(t, nil, db, false)
|
||||||
go bc.Run()
|
go bc.Run()
|
||||||
e := neotest.NewExecutor(t, bc, validators, committee)
|
e := tutustest.NewExecutor(t, bc, validators, committee)
|
||||||
basicchain.Init(t, "../../", e)
|
basicchain.Init(t, "../../", e)
|
||||||
|
|
||||||
// Gather some reference information.
|
// Gather some reference information.
|
||||||
|
|
@ -2653,7 +2653,7 @@ func TestBlockchain_ResetState(t *testing.T) {
|
||||||
rublesStaleKey := []byte("aa")
|
rublesStaleKey := []byte("aa")
|
||||||
rublesStaleValue := bc.GetStorageItem(basicchain.RublesContractID, rublesKey) // check value is there
|
rublesStaleValue := bc.GetStorageItem(basicchain.RublesContractID, rublesKey) // check value is there
|
||||||
require.Equal(t, []byte(basicchain.RublesNewTestvalue), []byte(rublesStaleValue))
|
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()
|
priv0ScriptHash := acc0.ScriptHash()
|
||||||
var (
|
var (
|
||||||
expectedNEP11t []*state.NEP11Transfer
|
expectedNEP11t []*state.NEP11Transfer
|
||||||
|
|
@ -2808,7 +2808,7 @@ func TestBlockchain_GenesisTransactionExtension(t *testing.T) {
|
||||||
SystemFee: sysFee,
|
SystemFee: sysFee,
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
e := neotest.NewExecutor(t, bc, acc, acc)
|
e := tutustest.NewExecutor(t, bc, acc, acc)
|
||||||
b := e.GetBlockByIndex(t, 0)
|
b := e.GetBlockByIndex(t, 0)
|
||||||
tx := b.Transactions[0]
|
tx := b.Transactions[0]
|
||||||
e.CheckHalt(t, tx.Hash(), stackitem.NewBool(true), stackitem.NewBool(false))
|
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.
|
// some on-chain block can be properly stored and doesn't break the database.
|
||||||
func TestBlockchain_StoreAsTransaction_ExecutableConflict(t *testing.T) {
|
func TestBlockchain_StoreAsTransaction_ExecutableConflict(t *testing.T) {
|
||||||
bc, acc := chain.NewSingleWithCustomConfig(t, nil)
|
bc, acc := chain.NewSingleWithCustomConfig(t, nil)
|
||||||
e := neotest.NewExecutor(t, bc, acc, acc)
|
e := tutustest.NewExecutor(t, bc, acc, acc)
|
||||||
genesisH := bc.GetHeaderHash(0)
|
genesisH := bc.GetHeaderHash(0)
|
||||||
currHeight := bc.BlockHeight()
|
currHeight := bc.BlockHeight()
|
||||||
|
|
||||||
|
|
@ -2885,7 +2885,7 @@ func TestEngineLimits(t *testing.T) {
|
||||||
const eArgsCount = 500
|
const eArgsCount = 500
|
||||||
|
|
||||||
bc, acc := chain.NewSingle(t)
|
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), `, `)
|
args, _ := strings.CutSuffix(strings.Repeat(`"", `, eArgsCount), `, `)
|
||||||
src := fmt.Sprintf(`package test
|
src := fmt.Sprintf(`package test
|
||||||
|
|
@ -2919,7 +2919,7 @@ func TestEngineLimits(t *testing.T) {
|
||||||
eParams[i].Name = fmt.Sprintf("str%d", i)
|
eParams[i].Name = fmt.Sprintf("str%d", i)
|
||||||
eParams[i].Type = smartcontract.ByteArrayType
|
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",
|
Name: "test_contract",
|
||||||
ContractEvents: []compiler.HybridEvent{
|
ContractEvents: []compiler.HybridEvent{
|
||||||
{
|
{
|
||||||
|
|
@ -2966,7 +2966,7 @@ func TestRuntimeNotifyRefcounting(t *testing.T) {
|
||||||
config.HFEchidna.String(): echidnaHeight,
|
config.HFEchidna.String(): echidnaHeight,
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
e := neotest.NewExecutor(t, bc, acc, acc)
|
e := tutustest.NewExecutor(t, bc, acc, acc)
|
||||||
|
|
||||||
args, _ := strings.CutSuffix(strings.Repeat(`"", `, eArgsCount), `, `)
|
args, _ := strings.CutSuffix(strings.Repeat(`"", `, eArgsCount), `, `)
|
||||||
src := fmt.Sprintf(`package test
|
src := fmt.Sprintf(`package test
|
||||||
|
|
@ -2986,7 +2986,7 @@ func TestRuntimeNotifyRefcounting(t *testing.T) {
|
||||||
eParams[i].Name = fmt.Sprintf("str%d", i)
|
eParams[i].Name = fmt.Sprintf("str%d", i)
|
||||||
eParams[i].Type = smartcontract.ByteArrayType
|
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",
|
Name: "test_contract",
|
||||||
ContractEvents: []compiler.HybridEvent{
|
ContractEvents: []compiler.HybridEvent{
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -40,7 +40,7 @@ func testDumpAndRestore(t *testing.T, dumpF, restoreF func(c *config.Blockchain)
|
||||||
}
|
}
|
||||||
|
|
||||||
bc, validators, committee := chain.NewMultiWithCustomConfig(t, dumpF)
|
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)
|
basicchain.Init(t, "../../../", e)
|
||||||
require.True(t, bc.BlockHeight() > 5) // ensure that test is valid
|
require.True(t, bc.BlockHeight() > 5) // ensure that test is valid
|
||||||
|
|
|
||||||
|
|
@ -256,6 +256,6 @@ func TestBlockchain_CustomNatives(t *testing.T) {
|
||||||
NewNatives: newCustomNatives,
|
NewNatives: newCustomNatives,
|
||||||
})
|
})
|
||||||
|
|
||||||
e := neotest.NewExecutor(t, bc, acc, acc)
|
e := tutustest.NewExecutor(t, bc, acc, acc)
|
||||||
e.AddNewBlock(t)
|
e.AddNewBlock(t)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,7 @@ import (
|
||||||
|
|
||||||
func TestCreateStandardAccount(t *testing.T) {
|
func TestCreateStandardAccount(t *testing.T) {
|
||||||
bc, acc := chain.NewSingle(t)
|
bc, acc := chain.NewSingle(t)
|
||||||
e := neotest.NewExecutor(t, bc, acc, acc)
|
e := tutustest.NewExecutor(t, bc, acc, acc)
|
||||||
w := io.NewBufBinWriter()
|
w := io.NewBufBinWriter()
|
||||||
|
|
||||||
t.Run("Good", func(t *testing.T) {
|
t.Run("Good", func(t *testing.T) {
|
||||||
|
|
@ -35,7 +35,7 @@ func TestCreateStandardAccount(t *testing.T) {
|
||||||
require.NoError(t, w.Err)
|
require.NoError(t, w.Err)
|
||||||
script := w.Bytes()
|
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.AddNewBlock(t, tx)
|
||||||
e.CheckHalt(t, tx.Hash())
|
e.CheckHalt(t, tx.Hash())
|
||||||
|
|
||||||
|
|
@ -52,7 +52,7 @@ func TestCreateStandardAccount(t *testing.T) {
|
||||||
require.NoError(t, w.Err)
|
require.NoError(t, w.Err)
|
||||||
script := w.Bytes()
|
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.AddNewBlock(t, tx)
|
||||||
e.CheckFault(t, tx.Hash(), "invalid prefix 1")
|
e.CheckFault(t, tx.Hash(), "invalid prefix 1")
|
||||||
})
|
})
|
||||||
|
|
@ -60,7 +60,7 @@ func TestCreateStandardAccount(t *testing.T) {
|
||||||
|
|
||||||
func TestCreateMultisigAccount(t *testing.T) {
|
func TestCreateMultisigAccount(t *testing.T) {
|
||||||
bc, acc := chain.NewSingle(t)
|
bc, acc := chain.NewSingle(t)
|
||||||
e := neotest.NewExecutor(t, bc, acc, acc)
|
e := tutustest.NewExecutor(t, bc, acc, acc)
|
||||||
w := io.NewBufBinWriter()
|
w := io.NewBufBinWriter()
|
||||||
|
|
||||||
createScript := func(t *testing.T, pubs []any, m int) []byte {
|
createScript := func(t *testing.T, pubs []any, m int) []byte {
|
||||||
|
|
@ -83,7 +83,7 @@ func TestCreateMultisigAccount(t *testing.T) {
|
||||||
}
|
}
|
||||||
script := createScript(t, arr, m)
|
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)
|
e.CheckHalt(t, txH)
|
||||||
res := e.GetTxExecResult(t, txH)
|
res := e.GetTxExecResult(t, txH)
|
||||||
value := res.Stack[0].Value().([]byte)
|
value := res.Stack[0].Value().([]byte)
|
||||||
|
|
@ -95,13 +95,13 @@ func TestCreateMultisigAccount(t *testing.T) {
|
||||||
})
|
})
|
||||||
t.Run("InvalidKey", func(t *testing.T) {
|
t.Run("InvalidKey", func(t *testing.T) {
|
||||||
script := createScript(t, []any{[]byte{1, 2, 3}}, 1)
|
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) {
|
t.Run("Invalid m", func(t *testing.T) {
|
||||||
pk, err := keys.NewPrivateKey()
|
pk, err := keys.NewPrivateKey()
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
script := createScript(t, []any{pk.PublicKey().Bytes()}, 2)
|
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) {
|
t.Run("m overflows int32", func(t *testing.T) {
|
||||||
pk, err := keys.NewPrivateKey()
|
pk, err := keys.NewPrivateKey()
|
||||||
|
|
@ -113,7 +113,7 @@ func TestCreateMultisigAccount(t *testing.T) {
|
||||||
emit.BigInt(w.BinWriter, m)
|
emit.BigInt(w.BinWriter, m)
|
||||||
emit.Syscall(w.BinWriter, interopnames.SystemContractCreateMultisigAccount)
|
emit.Syscall(w.BinWriter, interopnames.SystemContractCreateMultisigAccount)
|
||||||
require.NoError(t, w.Err)
|
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,
|
config.HFEchidna.String(): enabledHeight,
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
e := neotest.NewExecutor(t, bc, acc, acc)
|
e := tutustest.NewExecutor(t, bc, acc, acc)
|
||||||
|
|
||||||
priv, err := keys.NewPrivateKey()
|
priv, err := keys.NewPrivateKey()
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
@ -148,7 +148,7 @@ func TestCreateAccount_HFAspidochelone(t *testing.T) {
|
||||||
standardScript := bytes.Clone(w.Bytes())
|
standardScript := bytes.Clone(w.Bytes())
|
||||||
|
|
||||||
createAccTx := func(t *testing.T, script []byte) *transaction.Transaction {
|
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
|
return tx
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -177,14 +177,14 @@ func TestCall(t *testing.T) {
|
||||||
func TestSystemContractCall_Permissions(t *testing.T) {
|
func TestSystemContractCall_Permissions(t *testing.T) {
|
||||||
check := func(t *testing.T, cfg func(*config.Blockchain), shouldUpdateFail bool) {
|
check := func(t *testing.T, cfg func(*config.Blockchain), shouldUpdateFail bool) {
|
||||||
bc, acc := chain.NewSingleWithCustomConfig(t, cfg)
|
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.
|
// Contract A has an unsafe method.
|
||||||
srcA := `package contractA
|
srcA := `package contractA
|
||||||
func RetOne() int {
|
func RetOne() int {
|
||||||
return 1
|
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,
|
NoEventsCheck: true,
|
||||||
NoPermissionsCheck: true,
|
NoPermissionsCheck: true,
|
||||||
Name: "contractA",
|
Name: "contractA",
|
||||||
|
|
@ -216,7 +216,7 @@ func TestSystemContractCall_Permissions(t *testing.T) {
|
||||||
res := contract.Call(interop.Hash160{` + hashAStr + `}, "retOne", contract.All).(int)
|
res := contract.Call(interop.Hash160{` + hashAStr + `}, "retOne", contract.All).(int)
|
||||||
return res
|
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",
|
Name: "contractB",
|
||||||
NoEventsCheck: true,
|
NoEventsCheck: true,
|
||||||
NoPermissionsCheck: true,
|
NoPermissionsCheck: true,
|
||||||
|
|
@ -234,7 +234,7 @@ func TestSystemContractCall_Permissions(t *testing.T) {
|
||||||
ctrBInvoker := e.ValidatorInvoker(ctrB.Hash)
|
ctrBInvoker := e.ValidatorInvoker(ctrB.Hash)
|
||||||
|
|
||||||
// ctrBUpdated differs from ctrB in that it has no permission to call retOne method of ctrA
|
// 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",
|
Name: "contractB",
|
||||||
NoEventsCheck: true,
|
NoEventsCheck: true,
|
||||||
NoPermissionsCheck: true,
|
NoPermissionsCheck: true,
|
||||||
|
|
@ -287,7 +287,7 @@ func TestSystemContractCall_Permissions(t *testing.T) {
|
||||||
|
|
||||||
func TestLoadToken(t *testing.T) {
|
func TestLoadToken(t *testing.T) {
|
||||||
bc, acc := chain.NewSingle(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))
|
managementInvoker := e.ValidatorInvoker(e.NativeHash(t, nativenames.Management))
|
||||||
|
|
||||||
cs, _ := contracts.GetTestContractState(t, pathToInternalContracts, 0, 1, acc.ScriptHash())
|
cs, _ := contracts.GetTestContractState(t, pathToInternalContracts, 0, 1, acc.ScriptHash())
|
||||||
|
|
@ -314,7 +314,7 @@ func TestLoadToken(t *testing.T) {
|
||||||
|
|
||||||
func TestSnapshotIsolation_Exceptions(t *testing.T) {
|
func TestSnapshotIsolation_Exceptions(t *testing.T) {
|
||||||
bc, acc := chain.NewSingle(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.
|
// Contract A puts value in the storage, emits notifications and panics.
|
||||||
srcA := `package contractA
|
srcA := `package contractA
|
||||||
|
|
@ -355,7 +355,7 @@ func TestSnapshotIsolation_Exceptions(t *testing.T) {
|
||||||
func CheckB() bool {
|
func CheckB() bool {
|
||||||
return contract.Call(runtime.GetCallingScriptHash(), "checkStorageChanges", contract.All).(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,
|
NoEventsCheck: true,
|
||||||
NoPermissionsCheck: true,
|
NoPermissionsCheck: true,
|
||||||
Name: "contractA",
|
Name: "contractA",
|
||||||
|
|
@ -430,7 +430,7 @@ func TestSnapshotIsolation_Exceptions(t *testing.T) {
|
||||||
itm := storage.Get(c, caughtKey)
|
itm := storage.Get(c, caughtKey)
|
||||||
return itm != nil
|
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",
|
Name: "contractB",
|
||||||
NoEventsCheck: true,
|
NoEventsCheck: true,
|
||||||
NoPermissionsCheck: 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.
|
// This test is written to test nested calls with try-catch block and proper notifications handling.
|
||||||
func TestSnapshotIsolation_NestedContextException(t *testing.T) {
|
func TestSnapshotIsolation_NestedContextException(t *testing.T) {
|
||||||
bc, acc := chain.NewSingle(t)
|
bc, acc := chain.NewSingle(t)
|
||||||
e := neotest.NewExecutor(t, bc, acc, acc)
|
e := tutustest.NewExecutor(t, bc, acc, acc)
|
||||||
|
|
||||||
srcA := `package contractA
|
srcA := `package contractA
|
||||||
import (
|
import (
|
||||||
|
|
@ -497,7 +497,7 @@ func TestSnapshotIsolation_NestedContextException(t *testing.T) {
|
||||||
runtime.Notify("C")
|
runtime.Notify("C")
|
||||||
panic("exception from 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,
|
NoEventsCheck: true,
|
||||||
NoPermissionsCheck: true,
|
NoPermissionsCheck: true,
|
||||||
Name: "contractA",
|
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.
|
// This test is written to avoid https://github.com/neo-project/neo/issues/2746.
|
||||||
func TestSnapshotIsolation_CallToItself(t *testing.T) {
|
func TestSnapshotIsolation_CallToItself(t *testing.T) {
|
||||||
bc, acc := chain.NewSingle(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.
|
// Contract A calls method of self and throws if storage changes made by Do are unavailable after call to it.
|
||||||
srcA := `package contractA
|
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,
|
NoEventsCheck: true,
|
||||||
NoPermissionsCheck: true,
|
NoPermissionsCheck: true,
|
||||||
Name: "contractA",
|
Name: "contractA",
|
||||||
|
|
@ -581,7 +581,7 @@ func TestSnapshotIsolation_CallToItself(t *testing.T) {
|
||||||
// and https://github.com/neo-project/neo/pull/2745#discussion_r879167180.
|
// and https://github.com/neo-project/neo/pull/2745#discussion_r879167180.
|
||||||
func TestRET_after_FINALLY_PanicInsideVoidMethod(t *testing.T) {
|
func TestRET_after_FINALLY_PanicInsideVoidMethod(t *testing.T) {
|
||||||
bc, acc := chain.NewSingle(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.
|
// Contract A throws catchable exception. It also has a non-void method.
|
||||||
srcA := `package contractA
|
srcA := `package contractA
|
||||||
|
|
@ -591,7 +591,7 @@ func TestRET_after_FINALLY_PanicInsideVoidMethod(t *testing.T) {
|
||||||
func ReturnSomeValue() int {
|
func ReturnSomeValue() int {
|
||||||
return 5
|
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,
|
NoEventsCheck: true,
|
||||||
NoPermissionsCheck: true,
|
NoPermissionsCheck: true,
|
||||||
Name: "contractA",
|
Name: "contractA",
|
||||||
|
|
@ -620,7 +620,7 @@ func TestRET_after_FINALLY_PanicInsideVoidMethod(t *testing.T) {
|
||||||
}()
|
}()
|
||||||
contract.Call(interop.Hash160{` + hashAStr + `}, "panic", contract.All)
|
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",
|
Name: "contractB",
|
||||||
NoEventsCheck: true,
|
NoEventsCheck: true,
|
||||||
NoPermissionsCheck: 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.
|
// This test is written to check https://github.com/neo-project/neo/pull/2745#discussion_r879125733.
|
||||||
func TestRET_after_FINALLY_CallNonVoidAfterVoidMethod(t *testing.T) {
|
func TestRET_after_FINALLY_CallNonVoidAfterVoidMethod(t *testing.T) {
|
||||||
bc, acc := chain.NewSingle(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.
|
// Contract A has two methods. One of them has no return value, and the other has it.
|
||||||
srcA := `package contractA
|
srcA := `package contractA
|
||||||
|
|
@ -651,7 +651,7 @@ func TestRET_after_FINALLY_CallNonVoidAfterVoidMethod(t *testing.T) {
|
||||||
runtime.Log("ret")
|
runtime.Log("ret")
|
||||||
return 5
|
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,
|
NoEventsCheck: true,
|
||||||
NoPermissionsCheck: true,
|
NoPermissionsCheck: true,
|
||||||
Name: "contractA",
|
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 + `}, "noRet", contract.All)
|
||||||
contract.Call(interop.Hash160{` + hashAStr + `}, "hasRet", 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",
|
Name: "contractB",
|
||||||
NoEventsCheck: true,
|
NoEventsCheck: true,
|
||||||
NoPermissionsCheck: 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.
|
// This test is created to check https://github.com/neo-project/neo/pull/2755#discussion_r880087983.
|
||||||
func TestCALLL_from_VoidContext(t *testing.T) {
|
func TestCALLL_from_VoidContext(t *testing.T) {
|
||||||
bc, acc := chain.NewSingle(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`.
|
// Contract A has void method `CallHasRet` which calls non-void method `HasRet`.
|
||||||
srcA := `package contractA
|
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.
|
func HasRet() int { // CALL_L clones parent context, check that onUnload is not cloned.
|
||||||
return 5
|
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,
|
NoEventsCheck: true,
|
||||||
NoPermissionsCheck: true,
|
NoPermissionsCheck: true,
|
||||||
Name: "contractA",
|
Name: "contractA",
|
||||||
|
|
|
||||||
|
|
@ -103,9 +103,9 @@ func wrapDynamicScript(t *testing.T, script []byte, flags callflag.CallFlag, arg
|
||||||
return b.Bytes()
|
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)
|
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))
|
managementInvoker := e.ValidatorInvoker(e.NativeHash(t, nativenames.Management))
|
||||||
|
|
||||||
cs, _ := contracts.GetTestContractState(t, pathToInternalContracts, 0, 1, acc.ScriptHash())
|
cs, _ := contracts.GetTestContractState(t, pathToInternalContracts, 0, 1, acc.ScriptHash())
|
||||||
|
|
@ -402,61 +402,61 @@ func TestCheckWitness(t *testing.T) {
|
||||||
|
|
||||||
func TestLoadScript(t *testing.T) {
|
func TestLoadScript(t *testing.T) {
|
||||||
bc, acc := chain.NewSingle(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) {
|
t.Run("no ret val", func(t *testing.T) {
|
||||||
script := wrapDynamicScript(t, []byte{byte(opcode.RET)}, callflag.All)
|
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) {
|
t.Run("empty script", func(t *testing.T) {
|
||||||
script := wrapDynamicScript(t, []byte{}, callflag.All)
|
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) {
|
t.Run("bad script", func(t *testing.T) {
|
||||||
script := wrapDynamicScript(t, []byte{0xff}, callflag.All)
|
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) {
|
t.Run("ret val, no params", func(t *testing.T) {
|
||||||
script := wrapDynamicScript(t, []byte{byte(opcode.PUSH1)}, callflag.All)
|
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) {
|
t.Run("ret val with params", func(t *testing.T) {
|
||||||
script := wrapDynamicScript(t, []byte{byte(opcode.MUL)}, callflag.All, 2, 2)
|
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) {
|
t.Run("two return values", func(t *testing.T) {
|
||||||
script := wrapDynamicScript(t, []byte{byte(opcode.PUSH1), byte(opcode.PUSH1)}, callflag.All, 2, 2)
|
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) {
|
t.Run("invalid flags", func(t *testing.T) {
|
||||||
script := wrapDynamicScript(t, []byte{byte(opcode.MUL)}, callflag.CallFlag(0xff), 2, 2)
|
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) {
|
t.Run("abort", func(t *testing.T) {
|
||||||
script := wrapDynamicScript(t, []byte{byte(opcode.ABORT)}, callflag.All)
|
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) {
|
t.Run("internal call", func(t *testing.T) {
|
||||||
script, err := smartcontract.CreateCallScript(e.NativeHash(t, nativenames.Lub), "decimals")
|
script, err := smartcontract.CreateCallScript(e.NativeHash(t, nativenames.Lub), "decimals")
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
script = wrapDynamicScript(t, script, callflag.ReadOnly)
|
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) {
|
t.Run("forbidden internal call", func(t *testing.T) {
|
||||||
script, err := smartcontract.CreateCallScript(e.NativeHash(t, nativenames.Tutus), "decimals")
|
script, err := smartcontract.CreateCallScript(e.NativeHash(t, nativenames.Tutus), "decimals")
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
script = wrapDynamicScript(t, script, callflag.ReadStates)
|
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) {
|
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)
|
script, err := smartcontract.CreateCallScript(e.NativeHash(t, nativenames.Tutus), "transfer", acc.ScriptHash(), acc.ScriptHash(), 1, nil)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
script = wrapDynamicScript(t, script, callflag.All)
|
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) {
|
t.Run("exception", func(t *testing.T) {
|
||||||
script := wrapDynamicScript(t, []byte{byte(opcode.PUSH1), byte(opcode.THROW)}, callflag.ReadOnly)
|
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
|
const runtimeGasLeftPrice = 1 << 4
|
||||||
|
|
||||||
bc, acc := chain.NewSingle(t)
|
bc, acc := chain.NewSingle(t)
|
||||||
e := neotest.NewExecutor(t, bc, acc, acc)
|
e := tutustest.NewExecutor(t, bc, acc, acc)
|
||||||
w := io.NewBufBinWriter()
|
w := io.NewBufBinWriter()
|
||||||
|
|
||||||
gasLimit := 1100
|
gasLimit := 1100
|
||||||
|
|
@ -472,7 +472,7 @@ func TestGasLeft(t *testing.T) {
|
||||||
emit.Syscall(w.BinWriter, interopnames.SystemRuntimeGasLeft)
|
emit.Syscall(w.BinWriter, interopnames.SystemRuntimeGasLeft)
|
||||||
require.NoError(t, w.Err)
|
require.NoError(t, w.Err)
|
||||||
tx := transaction.New(w.Bytes(), int64(gasLimit))
|
tx := transaction.New(w.Bytes(), int64(gasLimit))
|
||||||
tx.Nonce = neotest.Nonce()
|
tx.Nonce = tutustest.Nonce()
|
||||||
tx.ValidUntilBlock = e.Chain.BlockHeight() + 1
|
tx.ValidUntilBlock = e.Chain.BlockHeight() + 1
|
||||||
e.SignTx(t, tx, int64(gasLimit), acc)
|
e.SignTx(t, tx, int64(gasLimit), acc)
|
||||||
e.AddNewBlock(t, tx)
|
e.AddNewBlock(t, tx)
|
||||||
|
|
@ -487,12 +487,12 @@ func TestGasLeft(t *testing.T) {
|
||||||
|
|
||||||
func TestGetAddressVersion(t *testing.T) {
|
func TestGetAddressVersion(t *testing.T) {
|
||||||
bc, acc := chain.NewSingle(t)
|
bc, acc := chain.NewSingle(t)
|
||||||
e := neotest.NewExecutor(t, bc, acc, acc)
|
e := tutustest.NewExecutor(t, bc, acc, acc)
|
||||||
w := io.NewBufBinWriter()
|
w := io.NewBufBinWriter()
|
||||||
|
|
||||||
emit.Syscall(w.BinWriter, interopnames.SystemRuntimeGetAddressVersion)
|
emit.Syscall(w.BinWriter, interopnames.SystemRuntimeGetAddressVersion)
|
||||||
require.NoError(t, w.Err)
|
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) {
|
func TestGetInvocationCounter(t *testing.T) {
|
||||||
|
|
@ -525,12 +525,12 @@ func TestGetInvocationCounter(t *testing.T) {
|
||||||
|
|
||||||
func TestGetNetwork(t *testing.T) {
|
func TestGetNetwork(t *testing.T) {
|
||||||
bc, acc := chain.NewSingle(t)
|
bc, acc := chain.NewSingle(t)
|
||||||
e := neotest.NewExecutor(t, bc, acc, acc)
|
e := tutustest.NewExecutor(t, bc, acc, acc)
|
||||||
w := io.NewBufBinWriter()
|
w := io.NewBufBinWriter()
|
||||||
|
|
||||||
emit.Syscall(w.BinWriter, interopnames.SystemRuntimeGetNetwork)
|
emit.Syscall(w.BinWriter, interopnames.SystemRuntimeGetNetwork)
|
||||||
require.NoError(t, w.Err)
|
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) {
|
func TestGetNotifications(t *testing.T) {
|
||||||
|
|
@ -577,15 +577,15 @@ func TestGetNotifications(t *testing.T) {
|
||||||
|
|
||||||
func TestGetRandom_DifferentTransactions(t *testing.T) {
|
func TestGetRandom_DifferentTransactions(t *testing.T) {
|
||||||
bc, acc := chain.NewSingle(t)
|
bc, acc := chain.NewSingle(t)
|
||||||
e := neotest.NewExecutor(t, bc, acc, acc)
|
e := tutustest.NewExecutor(t, bc, acc, acc)
|
||||||
|
|
||||||
w := io.NewBufBinWriter()
|
w := io.NewBufBinWriter()
|
||||||
emit.Syscall(w.BinWriter, interopnames.SystemRuntimeGetRandom)
|
emit.Syscall(w.BinWriter, interopnames.SystemRuntimeGetRandom)
|
||||||
require.NoError(t, w.Err)
|
require.NoError(t, w.Err)
|
||||||
script := w.Bytes()
|
script := w.Bytes()
|
||||||
|
|
||||||
tx1 := 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, []neotest.Signer{e.Validator}, bc.BlockHeight()+1)
|
tx2 := e.PrepareInvocation(t, script, []tutustest.Signer{e.Validator}, bc.BlockHeight()+1)
|
||||||
e.AddNewBlock(t, tx1, tx2)
|
e.AddNewBlock(t, tx1, tx2)
|
||||||
e.CheckHalt(t, tx1.Hash())
|
e.CheckHalt(t, tx1.Hash())
|
||||||
e.CheckHalt(t, tx2.Hash())
|
e.CheckHalt(t, tx2.Hash())
|
||||||
|
|
@ -701,7 +701,7 @@ func TestSystemRuntimeNotify_HFBasilisk(t *testing.T) {
|
||||||
config.HFBasilisk.String(): enabledHeight,
|
config.HFBasilisk.String(): enabledHeight,
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
e := neotest.NewExecutor(t, bc, acc, acc)
|
e := tutustest.NewExecutor(t, bc, acc, acc)
|
||||||
|
|
||||||
script := io.NewBufBinWriter()
|
script := io.NewBufBinWriter()
|
||||||
emit.Array(script.BinWriter, stackitem.Make(true)) // Boolean instead of Integer declared in manifest
|
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),
|
Hash: state.CreateContractHash(e.Validator.ScriptHash(), ne.Checksum, m.Name),
|
||||||
NEF: ne,
|
NEF: ne,
|
||||||
Manifest: m,
|
Manifest: m,
|
||||||
|
|
|
||||||
|
|
@ -344,7 +344,7 @@ func TestStorage_LocalInteropAPI(t *testing.T) {
|
||||||
config.HFFaun.String(): 6,
|
config.HFFaun.String(): 6,
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
e := neotest.NewExecutor(t, bc, acc, acc)
|
e := tutustest.NewExecutor(t, bc, acc, acc)
|
||||||
|
|
||||||
src := `package foo
|
src := `package foo
|
||||||
import (
|
import (
|
||||||
|
|
@ -368,7 +368,7 @@ func TestStorage_LocalInteropAPI(t *testing.T) {
|
||||||
return iterator.Next(storage.LocalFind([]byte("key"), storage.None))
|
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",
|
Name: "testpolicy_contract",
|
||||||
})
|
})
|
||||||
e.DeployContract(t, ctr, nil)
|
e.DeployContract(t, ctr, nil)
|
||||||
|
|
|
||||||
|
|
@ -33,7 +33,7 @@ func TestNativeContract_Invoke(t *testing.T) {
|
||||||
systemContractCallPrice = 1 << 15
|
systemContractCallPrice = 1 << 15
|
||||||
)
|
)
|
||||||
bc, validator, committee := chain.NewMulti(t)
|
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)
|
gasHash := e.NativeHash(t, nativenames.Lub)
|
||||||
|
|
||||||
baseExecFee := bc.GetBaseExecFee()
|
baseExecFee := bc.GetBaseExecFee()
|
||||||
|
|
@ -68,7 +68,7 @@ func TestNativeContract_Invoke(t *testing.T) {
|
||||||
|
|
||||||
func TestNativeContract_InvokeInternal(t *testing.T) {
|
func TestNativeContract_InvokeInternal(t *testing.T) {
|
||||||
bc, validator, committee := chain.NewMulti(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))
|
clState := bc.GetContractState(e.NativeHash(t, nativenames.CryptoLib))
|
||||||
require.NotNil(t, clState)
|
require.NotNil(t, clState)
|
||||||
md := clState.Manifest.ABI.GetMethod("ripemd160", 1)
|
md := clState.Manifest.ABI.GetMethod("ripemd160", 1)
|
||||||
|
|
@ -105,7 +105,7 @@ func TestNativeContract_InvokeInternal(t *testing.T) {
|
||||||
nativenames.CryptoLib: {1},
|
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)
|
ic, err := bcBad.GetTestVM(trigger.Application, nil, nil)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
@ -198,7 +198,7 @@ func TestNativeContract_InvokeInternal(t *testing.T) {
|
||||||
|
|
||||||
func TestNativeContract_InvokeOtherContract(t *testing.T) {
|
func TestNativeContract_InvokeOtherContract(t *testing.T) {
|
||||||
bc, validator, committee := chain.NewMulti(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))
|
managementInvoker := e.ValidatorInvoker(e.NativeHash(t, nativenames.Management))
|
||||||
gasInvoker := e.ValidatorInvoker(e.NativeHash(t, nativenames.Lub))
|
gasInvoker := e.ValidatorInvoker(e.NativeHash(t, nativenames.Lub))
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,7 @@ import (
|
||||||
func TestManagement_GetNEP17Contracts(t *testing.T) {
|
func TestManagement_GetNEP17Contracts(t *testing.T) {
|
||||||
t.Run("empty chain", func(t *testing.T) {
|
t.Run("empty chain", func(t *testing.T) {
|
||||||
bc, validators, committee := chain.NewMulti(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
|
// Native NEP17 contracts: NEO, GAS, and VTS
|
||||||
require.ElementsMatch(t, []util.Uint160{e.NativeHash(t, nativenames.Tutus),
|
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) {
|
t.Run("basic chain", func(t *testing.T) {
|
||||||
bc, validators, committee := chain.NewMulti(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)
|
basicchain.Init(t, "../../../", e)
|
||||||
|
|
||||||
// Native NEP17 contracts: NEO, GAS, VTS + deployed contract
|
// Native NEP17 contracts: NEO, GAS, VTS + deployed contract
|
||||||
|
|
@ -46,7 +46,7 @@ func TestManagement_DeployUpdate_HFBasilisk(t *testing.T) {
|
||||||
config.HFBasilisk.String(): 2,
|
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})
|
ne, err := nef.NewFile([]byte{byte(opcode.JMP), 0x05})
|
||||||
require.NoError(t, err)
|
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),
|
Hash: state.CreateContractHash(e.Validator.ScriptHash(), ne.Checksum, m.Name),
|
||||||
NEF: ne,
|
NEF: ne,
|
||||||
|
|
@ -84,7 +84,7 @@ func TestManagement_DeployUpdate_HFBasilisk(t *testing.T) {
|
||||||
func TestManagement_CallInTheSameBlock(t *testing.T) {
|
func TestManagement_CallInTheSameBlock(t *testing.T) {
|
||||||
bc, acc := chain.NewSingle(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)})
|
ne, err := nef.NewFile([]byte{byte(opcode.PUSH1)})
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
@ -120,15 +120,15 @@ func TestManagement_CallInTheSameBlock(t *testing.T) {
|
||||||
|
|
||||||
script, err := b.Script()
|
script, err := b.Script()
|
||||||
require.NoError(t, err)
|
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))
|
e.CheckHalt(t, txHash, stackitem.Make(1))
|
||||||
})
|
})
|
||||||
t.Run("next tx", func(t *testing.T) {
|
t.Run("next tx", func(t *testing.T) {
|
||||||
m.Name = "another contract"
|
m.Name = "another contract"
|
||||||
h := state.CreateContractHash(e.Validator.ScriptHash(), ne.Checksum, m.Name)
|
h := state.CreateContractHash(e.Validator.ScriptHash(), ne.Checksum, m.Name)
|
||||||
|
|
||||||
txDeploy := e.NewDeployTx(t, &neotest.Contract{Hash: h, NEF: ne, Manifest: m}, nil)
|
txDeploy := e.NewDeployTx(t, &tutustest.Contract{Hash: h, NEF: ne, Manifest: m}, nil)
|
||||||
txHasMethod := e.NewTx(t, []neotest.Signer{e.Validator}, bc.ManagementContractHash(), "hasMethod", h, "main", 0)
|
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.NewUnsignedTx(t, h, "main") // Test invocation doesn't give true GAS cost before deployment.
|
||||||
txCall = e.SignTx(t, txCall, 1_0000_0000, e.Validator)
|
txCall = e.SignTx(t, txCall, 1_0000_0000, e.Validator)
|
||||||
|
|
|
||||||
|
|
@ -70,7 +70,7 @@ func testGetSet(t *testing.T, c *tutustest.ContractInvoker, name string, default
|
||||||
|
|
||||||
switch name {
|
switch name {
|
||||||
case "LubPerBlock":
|
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.CheckHalt(t, txGet.Hash(), stackitem.Make(defaultValue))
|
||||||
c.AddNewBlock(t)
|
c.AddNewBlock(t)
|
||||||
randomInvoker.Invoke(t, v, getName)
|
randomInvoker.Invoke(t, v, getName)
|
||||||
|
|
|
||||||
|
|
@ -35,7 +35,7 @@ import (
|
||||||
"github.com/stretchr/testify/require"
|
"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) {
|
bc, validators, committee := chain.NewMultiWithCustomConfig(t, func(cfg *config.Blockchain) {
|
||||||
cfg.Hardforks = map[string]uint32{
|
cfg.Hardforks = map[string]uint32{
|
||||||
config.HFAspidochelone.String(): 0,
|
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))
|
return e.CommitteeInvoker(e.NativeHash(t, nativenames.Tutus))
|
||||||
}
|
}
|
||||||
|
|
||||||
func newNeoValidatorsClient(t *testing.T) *tutustest.ContractInvoker {
|
func newTutusValidatorsClient(t *testing.T) *tutustest.ContractInvoker {
|
||||||
c := newNeoCommitteeClient(t, 100_0000_0000)
|
c := newTutusCommitteeClient(t, 100_0000_0000)
|
||||||
return c.ValidatorInvoker(c.NativeHash(t, nativenames.Tutus))
|
return c.ValidatorInvoker(c.NativeHash(t, nativenames.Tutus))
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestNEO_GasPerBlock(t *testing.T) {
|
func TestTutus_LubPerBlock(t *testing.T) {
|
||||||
testGetSet(t, newNeoCommitteeClient(t, 100_0000_0000), "LubPerBlock", 5*native.LubFactor, 0, 10*native.LubFactor)
|
testGetSet(t, newTutusCommitteeClient(t, 100_0000_0000), "LubPerBlock", 5*native.LubFactor, 0, 10*native.LubFactor)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestNEO_GasPerBlockCache(t *testing.T) {
|
func TestTutus_LubPerBlockCache(t *testing.T) {
|
||||||
testGetSetCache(t, newNeoCommitteeClient(t, 100_0000_0000), "LubPerBlock", 5*native.LubFactor)
|
testGetSetCache(t, newTutusCommitteeClient(t, 100_0000_0000), "LubPerBlock", 5*native.LubFactor)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestNEO_RegisterPrice(t *testing.T) {
|
func TestTutus_RegisterPrice(t *testing.T) {
|
||||||
testGetSet(t, newNeoCommitteeClient(t, 100_0000_0000), "RegisterPrice", native.DefaultRegisterPrice, 1, math.MaxInt64)
|
testGetSet(t, newTutusCommitteeClient(t, 100_0000_0000), "RegisterPrice", native.DefaultRegisterPrice, 1, math.MaxInt64)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestNEO_RegisterPriceCache(t *testing.T) {
|
func TestTutus_RegisterPriceCache(t *testing.T) {
|
||||||
testGetSetCache(t, newNeoCommitteeClient(t, 100_0000_0000), "RegisterPrice", native.DefaultRegisterPrice)
|
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)
|
c := newNativeClient(t, nativenames.Tutus)
|
||||||
singleSigner := c.Signers[0].(tutustest.MultiSigner).Single(0)
|
singleSigner := c.Signers[0].(tutustest.MultiSigner).Single(0)
|
||||||
cc := c.WithSigners(c.Signers[0], singleSigner)
|
cc := c.WithSigners(c.Signers[0], singleSigner)
|
||||||
|
|
@ -130,10 +130,10 @@ func TestNEO_CandidateEvents(t *testing.T) {
|
||||||
require.Equal(t, 0, len(aer.Events))
|
require.Equal(t, 0, len(aer.Events))
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestNEO_CommitteeEvents(t *testing.T) {
|
func TestTutus_CommitteeEvents(t *testing.T) {
|
||||||
neoCommitteeInvoker := newNeoCommitteeClient(t, 100_0000_0000)
|
tutusCommitteeInvoker := newTutusCommitteeClient(t, 100_0000_0000)
|
||||||
neoValidatorsInvoker := neoCommitteeInvoker.WithSigners(neoCommitteeInvoker.Validator)
|
neoValidatorsInvoker := tutusCommitteeInvoker.WithSigners(tutusCommitteeInvoker.Validator)
|
||||||
e := neoCommitteeInvoker.Executor
|
e := tutusCommitteeInvoker.Executor
|
||||||
|
|
||||||
cfg := e.Chain.GetConfig()
|
cfg := e.Chain.GetConfig()
|
||||||
committeeSize := cfg.GetCommitteeSize(0)
|
committeeSize := cfg.GetCommitteeSize(0)
|
||||||
|
|
@ -162,7 +162,7 @@ func TestNEO_CommitteeEvents(t *testing.T) {
|
||||||
|
|
||||||
// Advance the chain to trigger committee recalculation and potential change.
|
// Advance the chain to trigger committee recalculation and potential change.
|
||||||
for (block.Index)%uint32(committeeSize) != 0 {
|
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.
|
// 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) {
|
func TestTutus_Vote(t *testing.T) {
|
||||||
neoCommitteeInvoker := newNeoCommitteeClient(t, 100_0000_0000)
|
tutusCommitteeInvoker := newTutusCommitteeClient(t, 100_0000_0000)
|
||||||
neoValidatorsInvoker := neoCommitteeInvoker.WithSigners(neoCommitteeInvoker.Validator)
|
neoValidatorsInvoker := tutusCommitteeInvoker.WithSigners(tutusCommitteeInvoker.Validator)
|
||||||
policyInvoker := neoCommitteeInvoker.CommitteeInvoker(neoCommitteeInvoker.NativeHash(t, nativenames.Policy))
|
policyInvoker := tutusCommitteeInvoker.CommitteeInvoker(tutusCommitteeInvoker.NativeHash(t, nativenames.Policy))
|
||||||
e := neoCommitteeInvoker.Executor
|
e := tutusCommitteeInvoker.Executor
|
||||||
|
|
||||||
cfg := e.Chain.GetConfig()
|
cfg := e.Chain.GetConfig()
|
||||||
committeeSize := cfg.GetCommitteeSize(0)
|
committeeSize := cfg.GetCommitteeSize(0)
|
||||||
|
|
@ -206,7 +206,7 @@ func TestNEO_Vote(t *testing.T) {
|
||||||
freq := validatorsCount + committeeSize
|
freq := validatorsCount + committeeSize
|
||||||
advanceChain := func(t *testing.T) {
|
advanceChain := func(t *testing.T) {
|
||||||
for range freq {
|
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.
|
// reward is proportional to the NEO balance.
|
||||||
voters := make([]tutustest.Signer, committeeSize+1)
|
voters := make([]tutustest.Signer, committeeSize+1)
|
||||||
// referenceAccounts perform the same actions as voters except voting, i.e. we
|
// 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
|
// GAS they receive for NEO ownership. We need these values to be able to define
|
||||||
// how much GAS voters receive for NEO ownership.
|
// how much GAS voters receive for NEO ownership.
|
||||||
referenceAccounts := make([]tutustest.Signer, committeeSize+1)
|
referenceAccounts := make([]tutustest.Signer, committeeSize+1)
|
||||||
|
|
@ -272,7 +272,7 @@ func TestNEO_Vote(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
advanceChain(t)
|
advanceChain(t)
|
||||||
pubs, err = neoCommitteeInvoker.Chain.GetNextBlockValidators()
|
pubs, err = tutusCommitteeInvoker.Chain.GetNextBlockValidators()
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
sortedCandidates := make(keys.PublicKeys, validatorsCount)
|
sortedCandidates := make(keys.PublicKeys, validatorsCount)
|
||||||
for i := range candidates[:validatorsCount] {
|
for i := range candidates[:validatorsCount] {
|
||||||
|
|
@ -281,7 +281,7 @@ func TestNEO_Vote(t *testing.T) {
|
||||||
slices.SortFunc(sortedCandidates, (*keys.PublicKey).Cmp)
|
slices.SortFunc(sortedCandidates, (*keys.PublicKey).Cmp)
|
||||||
require.EqualValues(t, sortedCandidates, keys.PublicKeys(pubs))
|
require.EqualValues(t, sortedCandidates, keys.PublicKeys(pubs))
|
||||||
|
|
||||||
pubs, err = neoCommitteeInvoker.Chain.GetNextBlockValidators()
|
pubs, err = tutusCommitteeInvoker.Chain.GetNextBlockValidators()
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
require.EqualValues(t, sortedCandidates, pubs)
|
require.EqualValues(t, sortedCandidates, pubs)
|
||||||
|
|
||||||
|
|
@ -298,13 +298,13 @@ func TestNEO_Vote(t *testing.T) {
|
||||||
neoBalance[i], _ = e.Chain.GetGoverningTokenBalance(h)
|
neoBalance[i], _ = e.Chain.GetGoverningTokenBalance(h)
|
||||||
referenceGASBalance[i] = e.Chain.GetUtilityTokenBalance(refH)
|
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)
|
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)
|
txes = append(txes, tx)
|
||||||
refTxFee = tx.SystemFee + tx.NetworkFee
|
refTxFee = tx.SystemFee + tx.NetworkFee
|
||||||
}
|
}
|
||||||
neoCommitteeInvoker.AddNewBlock(t, txes...)
|
tutusCommitteeInvoker.AddNewBlock(t, txes...)
|
||||||
for _, tx := range txes {
|
for _, tx := range txes {
|
||||||
e.CheckHalt(t, tx.Hash(), stackitem.Make(true))
|
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())
|
tutusCommitteeInvoker.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(voters[0]).Invoke(t, false, "vote", voters[0].(tutustest.SingleSigner).Account().PrivateKey().GetScriptHash(), candidates[0].(tutustest.SingleSigner).Account().PublicKey().Bytes())
|
||||||
|
|
||||||
advanceChain(t)
|
advanceChain(t)
|
||||||
|
|
||||||
|
|
@ -349,7 +349,7 @@ func TestNEO_Vote(t *testing.T) {
|
||||||
}
|
}
|
||||||
// LastGasPerVote should be 0 after unvoting
|
// LastGasPerVote should be 0 after unvoting
|
||||||
getAccountState := func(t *testing.T, account util.Uint160) *state.NEOBalance {
|
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)
|
require.NoError(t, err)
|
||||||
res := stack.Pop().Item()
|
res := stack.Pop().Item()
|
||||||
// (s *NEOBalance) FromStackItem is able to handle both 3 and 4 subitems.
|
// (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())
|
require.Equal(t, uint64(0), stateAfterUnvote.LastGasPerVote.Uint64())
|
||||||
}
|
}
|
||||||
|
|
||||||
// TestNEO_RecursiveGASMint is a test for https://github.com/tutus-one/tutus-chain/pull/2181.
|
// TestTutus_RecursiveLubMint is a test for https://github.com/tutus-one/tutus-chain/pull/2181.
|
||||||
func TestNEO_RecursiveGASMint(t *testing.T) {
|
func TestTutus_RecursiveLubMint(t *testing.T) {
|
||||||
neoCommitteeInvoker := newNeoCommitteeClient(t, 100_0000_0000)
|
tutusCommitteeInvoker := newTutusCommitteeClient(t, 100_0000_0000)
|
||||||
neoValidatorInvoker := neoCommitteeInvoker.WithSigners(neoCommitteeInvoker.Validator)
|
tutusValidatorInvoker := tutusCommitteeInvoker.WithSigners(tutusCommitteeInvoker.Validator)
|
||||||
e := neoCommitteeInvoker.Executor
|
e := tutusCommitteeInvoker.Executor
|
||||||
gasValidatorInvoker := e.ValidatorInvoker(e.NativeHash(t, nativenames.Lub))
|
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")
|
c := tutustest.CompileFile(t, e.Validator.ScriptHash(), "../../../../internal/basicchain/testdata/test_contract.go", "../../../../internal/basicchain/testdata/test_contract.yml")
|
||||||
e.DeployContract(t, c, nil)
|
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.
|
// Transfer 10 Tutus to test contract, the contract should earn some GAS by owning this Tutus.
|
||||||
neoValidatorInvoker.Invoke(t, true, "transfer", e.Validator.ScriptHash(), c.Hash, int64(10), nil)
|
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
|
// Add blocks to be able to trigger Tutus transfer from contract address to owner
|
||||||
// address inside onNEP17Payment (the contract starts NEO transfers from chain height = 100).
|
// address inside onNEP17Payment (the contract starts Tutus transfers from chain height = 100).
|
||||||
for i := e.Chain.BlockHeight(); i < 100; i++ {
|
for i := e.Chain.BlockHeight(); i < 100; i++ {
|
||||||
e.AddNewBlock(t)
|
e.AddNewBlock(t)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Transfer 1 more NEO to the contract. Transfer will trigger onNEP17Payment. OnNEP17Payment will
|
// Transfer 1 more Tutus 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 transfer of 11 Tutus to the contract owner (based on the contract code). 11 Tutus Transfer will
|
||||||
// trigger GAS distribution. GAS transfer will trigger OnNEP17Payment one more time. The recursion
|
// 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
|
// shouldn't occur here, because contract's balance LastUpdated height has already been updated in
|
||||||
// this block.
|
// 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) {
|
func TestTutus_GetCommitteeAddress(t *testing.T) {
|
||||||
neoValidatorInvoker := newNeoValidatorsClient(t)
|
tutusValidatorInvoker := newTutusValidatorsClient(t)
|
||||||
e := neoValidatorInvoker.Executor
|
e := tutusValidatorInvoker.Executor
|
||||||
cfg := neoValidatorInvoker.Chain.GetConfig()
|
cfg := tutusValidatorInvoker.Chain.GetConfig()
|
||||||
|
|
||||||
maxHardforkHeight := uint32(0)
|
maxHardforkHeight := uint32(0)
|
||||||
for _, height := range cfg.Hardforks {
|
for _, height := range cfg.Hardforks {
|
||||||
|
|
@ -419,41 +419,41 @@ func TestNEO_GetCommitteeAddress(t *testing.T) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for range maxHardforkHeight {
|
for range maxHardforkHeight {
|
||||||
neoValidatorInvoker.AddNewBlock(t)
|
tutusValidatorInvoker.AddNewBlock(t)
|
||||||
}
|
}
|
||||||
standByCommitteePublicKeys, err := keys.NewPublicKeysFromStrings(e.Chain.GetConfig().StandbyCommittee)
|
standByCommitteePublicKeys, err := keys.NewPublicKeysFromStrings(e.Chain.GetConfig().StandbyCommittee)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
slices.SortFunc(standByCommitteePublicKeys, (*keys.PublicKey).Cmp)
|
slices.SortFunc(standByCommitteePublicKeys, (*keys.PublicKey).Cmp)
|
||||||
expectedCommitteeAddress, err := smartcontract.CreateMajorityMultiSigRedeemScript(standByCommitteePublicKeys)
|
expectedCommitteeAddress, err := smartcontract.CreateMajorityMultiSigRedeemScript(standByCommitteePublicKeys)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
stack, err := neoValidatorInvoker.TestInvoke(t, "getCommitteeAddress")
|
stack, err := tutusValidatorInvoker.TestInvoke(t, "getCommitteeAddress")
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
require.Equal(t, hash.Hash160(expectedCommitteeAddress).BytesBE(), stack.Pop().Item().Value().([]byte))
|
require.Equal(t, hash.Hash160(expectedCommitteeAddress).BytesBE(), stack.Pop().Item().Value().([]byte))
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestNEO_GetAccountState(t *testing.T) {
|
func TestTutus_GetAccountState(t *testing.T) {
|
||||||
neoValidatorInvoker := newNeoValidatorsClient(t)
|
tutusValidatorInvoker := newTutusValidatorsClient(t)
|
||||||
e := neoValidatorInvoker.Executor
|
e := tutusValidatorInvoker.Executor
|
||||||
|
|
||||||
cfg := e.Chain.GetConfig()
|
cfg := e.Chain.GetConfig()
|
||||||
committeeSize := cfg.GetCommitteeSize(0)
|
committeeSize := cfg.GetCommitteeSize(0)
|
||||||
validatorSize := cfg.GetNumOfCNs(0)
|
validatorSize := cfg.GetNumOfCNs(0)
|
||||||
advanceChain := func(t *testing.T) {
|
advanceChain := func(t *testing.T) {
|
||||||
for range committeeSize {
|
for range committeeSize {
|
||||||
neoValidatorInvoker.AddNewBlock(t)
|
tutusValidatorInvoker.AddNewBlock(t)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
t.Run("empty", func(t *testing.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) {
|
t.Run("with funds", func(t *testing.T) {
|
||||||
amount := int64(1)
|
amount := int64(1)
|
||||||
acc := e.NewAccount(t)
|
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()
|
lub := e.Chain.BlockHeight()
|
||||||
neoValidatorInvoker.Invoke(t, stackitem.NewStruct([]stackitem.Item{
|
tutusValidatorInvoker.Invoke(t, stackitem.NewStruct([]stackitem.Item{
|
||||||
stackitem.Make(amount),
|
stackitem.Make(amount),
|
||||||
stackitem.Make(lub),
|
stackitem.Make(lub),
|
||||||
stackitem.Null{},
|
stackitem.Null{},
|
||||||
|
|
@ -467,7 +467,7 @@ func TestNEO_GetAccountState(t *testing.T) {
|
||||||
VoterRewardRatio = 80
|
VoterRewardRatio = 80
|
||||||
)
|
)
|
||||||
getAccountState := func(t *testing.T, account util.Uint160) *state.NEOBalance {
|
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)
|
require.NoError(t, err)
|
||||||
as := new(state.NEOBalance)
|
as := new(state.NEOBalance)
|
||||||
err = as.FromStackItem(stack.Pop().Item())
|
err = as.FromStackItem(stack.Pop().Item())
|
||||||
|
|
@ -477,18 +477,18 @@ func TestNEO_GetAccountState(t *testing.T) {
|
||||||
|
|
||||||
amount := int64(1000)
|
amount := int64(1000)
|
||||||
acc := e.NewAccount(t)
|
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())
|
as := getAccountState(t, acc.ScriptHash())
|
||||||
require.Equal(t, uint64(amount), as.Balance.Uint64())
|
require.Equal(t, uint64(amount), as.Balance.Uint64())
|
||||||
require.Equal(t, e.Chain.BlockHeight(), as.BalanceHeight)
|
require.Equal(t, e.Chain.BlockHeight(), as.BalanceHeight)
|
||||||
require.Equal(t, uint64(0), as.LastGasPerVote.Uint64())
|
require.Equal(t, uint64(0), as.LastGasPerVote.Uint64())
|
||||||
committee, _ := e.Chain.GetCommittee()
|
committee, _ := e.Chain.GetCommittee()
|
||||||
neoValidatorInvoker.WithSigners(e.Validator, e.Validator.(tutustest.MultiSigner).Single(0)).Invoke(t, true, "registerCandidate", committee[0].Bytes())
|
tutusValidatorInvoker.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(acc).Invoke(t, true, "vote", acc.ScriptHash(), committee[0].Bytes())
|
||||||
as = getAccountState(t, acc.ScriptHash())
|
as = getAccountState(t, acc.ScriptHash())
|
||||||
require.Equal(t, uint64(0), as.LastGasPerVote.Uint64())
|
require.Equal(t, uint64(0), as.LastGasPerVote.Uint64())
|
||||||
advanceChain(t)
|
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())
|
as = getAccountState(t, acc.ScriptHash())
|
||||||
expect := GasPerBlock * native.LubFactor * VoterRewardRatio / 100 * (uint64(e.Chain.BlockHeight()) / uint64(committeeSize))
|
expect := GasPerBlock * native.LubFactor * VoterRewardRatio / 100 * (uint64(e.Chain.BlockHeight()) / uint64(committeeSize))
|
||||||
expect = expect * uint64(committeeSize) / uint64(validatorSize+committeeSize) * native.TutusTotalSupply / as.Balance.Uint64()
|
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) {
|
func TestTutus_GetAccountStateInteropAPI(t *testing.T) {
|
||||||
neoValidatorInvoker := newNeoValidatorsClient(t)
|
tutusValidatorInvoker := newTutusValidatorsClient(t)
|
||||||
e := neoValidatorInvoker.Executor
|
e := tutusValidatorInvoker.Executor
|
||||||
|
|
||||||
cfg := e.Chain.GetConfig()
|
cfg := e.Chain.GetConfig()
|
||||||
committeeSize := cfg.GetCommitteeSize(0)
|
committeeSize := cfg.GetCommitteeSize(0)
|
||||||
validatorSize := cfg.GetNumOfCNs(0)
|
validatorSize := cfg.GetNumOfCNs(0)
|
||||||
advanceChain := func(t *testing.T) {
|
advanceChain := func(t *testing.T) {
|
||||||
for range committeeSize {
|
for range committeeSize {
|
||||||
neoValidatorInvoker.AddNewBlock(t)
|
tutusValidatorInvoker.AddNewBlock(t)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
amount := int64(1000)
|
amount := int64(1000)
|
||||||
acc := e.NewAccount(t)
|
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()
|
committee, _ := e.Chain.GetCommittee()
|
||||||
neoValidatorInvoker.WithSigners(e.Validator, e.Validator.(tutustest.MultiSigner).Single(0)).Invoke(t, true, "registerCandidate", committee[0].Bytes())
|
tutusValidatorInvoker.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(acc).Invoke(t, true, "vote", acc.ScriptHash(), committee[0].Bytes())
|
||||||
advanceChain(t)
|
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
|
var hashAStr strings.Builder
|
||||||
for i := range util.Uint160Size {
|
for i := range util.Uint160Size {
|
||||||
|
|
@ -553,9 +553,9 @@ func TestNEO_GetAccountStateInteropAPI(t *testing.T) {
|
||||||
ctrInvoker.Invoke(t, stackitem.Make(expect), "getLastLubPerVote")
|
ctrInvoker.Invoke(t, stackitem.Make(expect), "getLastLubPerVote")
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestNEO_CommitteeBountyOnPersist(t *testing.T) {
|
func TestTutus_CommitteeBountyOnPersist(t *testing.T) {
|
||||||
neoCommitteeInvoker := newNeoCommitteeClient(t, 0)
|
tutusCommitteeInvoker := newTutusCommitteeClient(t, 0)
|
||||||
e := neoCommitteeInvoker.Executor
|
e := tutusCommitteeInvoker.Executor
|
||||||
|
|
||||||
hs, err := keys.NewPublicKeysFromStrings(e.Chain.GetConfig().StandbyCommittee)
|
hs, err := keys.NewPublicKeysFromStrings(e.Chain.GetConfig().StandbyCommittee)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
@ -575,8 +575,8 @@ func TestNEO_CommitteeBountyOnPersist(t *testing.T) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestNEO_TransferOnPayment(t *testing.T) {
|
func TestTutus_TransferOnPayment(t *testing.T) {
|
||||||
neoValidatorsInvoker := newNeoValidatorsClient(t)
|
neoValidatorsInvoker := newTutusValidatorsClient(t)
|
||||||
e := neoValidatorsInvoker.Executor
|
e := neoValidatorsInvoker.Executor
|
||||||
managementValidatorsInvoker := e.ValidatorInvoker(e.NativeHash(t, nativenames.Management))
|
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)
|
h = neoValidatorsInvoker.Invoke(t, true, "transfer", e.Validator.ScriptHash(), cs.Hash, amount, nil)
|
||||||
aer = e.GetTxExecResult(t, h)
|
aer = e.GetTxExecResult(t, h)
|
||||||
require.Equal(t, 5, len(aer.Events)) // Now we must also have GAS claim for contract and corresponding `onPayment`.
|
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,
|
ScriptHash: cs.Hash,
|
||||||
Name: "LastPaymentNEP17",
|
Name: "LastPaymentNEP17",
|
||||||
Item: stackitem.NewArray([]stackitem.Item{
|
Item: stackitem.NewArray([]stackitem.Item{
|
||||||
|
|
@ -631,8 +631,8 @@ func TestNEO_TransferOnPayment(t *testing.T) {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestNEO_Roundtrip(t *testing.T) {
|
func TestTutus_Roundtrip(t *testing.T) {
|
||||||
neoValidatorsInvoker := newNeoValidatorsClient(t)
|
neoValidatorsInvoker := newTutusValidatorsClient(t)
|
||||||
e := neoValidatorsInvoker.Executor
|
e := neoValidatorsInvoker.Executor
|
||||||
validatorH := neoValidatorsInvoker.Validator.ScriptHash()
|
validatorH := neoValidatorsInvoker.Validator.ScriptHash()
|
||||||
|
|
||||||
|
|
@ -662,8 +662,8 @@ func TestNEO_Roundtrip(t *testing.T) {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestNEO_TransferZeroWithZeroBalance(t *testing.T) {
|
func TestTutus_TransferZeroWithZeroBalance(t *testing.T) {
|
||||||
neoValidatorsInvoker := newNeoValidatorsClient(t)
|
neoValidatorsInvoker := newTutusValidatorsClient(t)
|
||||||
e := neoValidatorsInvoker.Executor
|
e := neoValidatorsInvoker.Executor
|
||||||
|
|
||||||
check := func(t *testing.T, roundtrip bool) {
|
check := func(t *testing.T, roundtrip bool) {
|
||||||
|
|
@ -691,8 +691,8 @@ func TestNEO_TransferZeroWithZeroBalance(t *testing.T) {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestNEO_TransferZeroWithNonZeroBalance(t *testing.T) {
|
func TestTutus_TransferZeroWithNonZeroBalance(t *testing.T) {
|
||||||
neoValidatorsInvoker := newNeoValidatorsClient(t)
|
neoValidatorsInvoker := newTutusValidatorsClient(t)
|
||||||
e := neoValidatorsInvoker.Executor
|
e := neoValidatorsInvoker.Executor
|
||||||
|
|
||||||
check := func(t *testing.T, roundtrip bool) {
|
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
|
// https://github.com/tutus-one/tutus-chain/issues/3190
|
||||||
func TestNEO_TransferNonZeroWithZeroBalance(t *testing.T) {
|
func TestTutus_TransferNonZeroWithZeroBalance(t *testing.T) {
|
||||||
neoValidatorsInvoker := newNeoValidatorsClient(t)
|
neoValidatorsInvoker := newTutusValidatorsClient(t)
|
||||||
e := neoValidatorsInvoker.Executor
|
e := neoValidatorsInvoker.Executor
|
||||||
|
|
||||||
acc := neoValidatorsInvoker.WithSigners(e.NewAccount(t))
|
acc := neoValidatorsInvoker.WithSigners(e.NewAccount(t))
|
||||||
|
|
@ -740,10 +740,10 @@ func TestNEO_TransferNonZeroWithZeroBalance(t *testing.T) {
|
||||||
require.Equal(t, uint32(0), updatedHeight)
|
require.Equal(t, uint32(0), updatedHeight)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestNEO_CalculateBonus(t *testing.T) {
|
func TestTutus_CalculateBonus(t *testing.T) {
|
||||||
neoCommitteeInvoker := newNeoCommitteeClient(t, 10_0000_0000)
|
tutusCommitteeInvoker := newTutusCommitteeClient(t, 10_0000_0000)
|
||||||
e := neoCommitteeInvoker.Executor
|
e := tutusCommitteeInvoker.Executor
|
||||||
neoValidatorsInvoker := neoCommitteeInvoker.WithSigners(e.Validator)
|
neoValidatorsInvoker := tutusCommitteeInvoker.WithSigners(e.Validator)
|
||||||
|
|
||||||
acc := neoValidatorsInvoker.WithSigners(e.NewAccount(t))
|
acc := neoValidatorsInvoker.WithSigners(e.NewAccount(t))
|
||||||
accH := acc.Signers[0].ScriptHash()
|
accH := acc.Signers[0].ScriptHash()
|
||||||
|
|
@ -781,7 +781,7 @@ func TestNEO_CalculateBonus(t *testing.T) {
|
||||||
for range rewardDistance/2 - 2 {
|
for range rewardDistance/2 - 2 {
|
||||||
e.AddNewBlock(t)
|
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.
|
// Five blocks more with modified GasPerBlock value.
|
||||||
for range rewardDistance / 2 {
|
for range rewardDistance / 2 {
|
||||||
|
|
@ -792,10 +792,10 @@ func TestNEO_CalculateBonus(t *testing.T) {
|
||||||
h := acc.Invoke(t, true, "transfer", accH, accH, amount, nil)
|
h := acc.Invoke(t, true, "transfer", accH, accH, amount, nil)
|
||||||
claimTx, _ := e.GetTransaction(t, h)
|
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
|
defaultGASPerBlock * // GAS generated by a single block
|
||||||
rewardDistance / 2) // number of blocks generated with specified GasPerBlock
|
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
|
newGASPerBlock * // GAS generated by a single block after GasPerBlock update
|
||||||
rewardDistance / 2) // number of blocks generated with specified GasPerBlock
|
rewardDistance / 2) // number of blocks generated with specified GasPerBlock
|
||||||
e.CheckGASBalance(t, accH, big.NewInt(initialGASBalance.Int64()-
|
e.CheckGASBalance(t, accH, big.NewInt(initialGASBalance.Int64()-
|
||||||
|
|
@ -803,8 +803,8 @@ func TestNEO_CalculateBonus(t *testing.T) {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestNEO_UnclaimedGas(t *testing.T) {
|
func TestTutus_UnclaimedLub(t *testing.T) {
|
||||||
neoValidatorsInvoker := newNeoValidatorsClient(t)
|
neoValidatorsInvoker := newTutusValidatorsClient(t)
|
||||||
e := neoValidatorsInvoker.Executor
|
e := neoValidatorsInvoker.Executor
|
||||||
|
|
||||||
acc := neoValidatorsInvoker.WithSigners(e.NewAccount(t))
|
acc := neoValidatorsInvoker.WithSigners(e.NewAccount(t))
|
||||||
|
|
@ -832,11 +832,11 @@ func TestNEO_UnclaimedGas(t *testing.T) {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestNEO_GetCandidates(t *testing.T) {
|
func TestTutus_GetCandidates(t *testing.T) {
|
||||||
neoCommitteeInvoker := newNeoCommitteeClient(t, 100_0000_0000)
|
tutusCommitteeInvoker := newTutusCommitteeClient(t, 100_0000_0000)
|
||||||
neoValidatorsInvoker := neoCommitteeInvoker.WithSigners(neoCommitteeInvoker.Validator)
|
neoValidatorsInvoker := tutusCommitteeInvoker.WithSigners(tutusCommitteeInvoker.Validator)
|
||||||
policyInvoker := neoCommitteeInvoker.CommitteeInvoker(neoCommitteeInvoker.NativeHash(t, nativenames.Policy))
|
policyInvoker := tutusCommitteeInvoker.CommitteeInvoker(tutusCommitteeInvoker.NativeHash(t, nativenames.Policy))
|
||||||
e := neoCommitteeInvoker.Executor
|
e := tutusCommitteeInvoker.Executor
|
||||||
|
|
||||||
cfg := e.Chain.GetConfig()
|
cfg := e.Chain.GetConfig()
|
||||||
candidatesCount := cfg.GetCommitteeSize(0) - 1
|
candidatesCount := cfg.GetCommitteeSize(0) - 1
|
||||||
|
|
@ -870,18 +870,18 @@ func TestNEO_GetCandidates(t *testing.T) {
|
||||||
stackitem.NewByteArray(pub),
|
stackitem.NewByteArray(pub),
|
||||||
v,
|
v,
|
||||||
})
|
})
|
||||||
neoCommitteeInvoker.Invoke(t, v, "getCandidateVote", pub)
|
tutusCommitteeInvoker.Invoke(t, v, "getCandidateVote", pub)
|
||||||
}
|
}
|
||||||
slices.SortFunc(expected, func(a, b stackitem.Item) int {
|
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))
|
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.
|
// Check that GetAllCandidates works the same way as GetCandidates.
|
||||||
checkGetAllCandidates := func(t *testing.T, expected []stackitem.Item) {
|
checkGetAllCandidates := func(t *testing.T, expected []stackitem.Item) {
|
||||||
for i := range len(expected) + 1 {
|
for i := range len(expected) + 1 {
|
||||||
w := io.NewBufBinWriter()
|
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 {
|
for range i + 1 {
|
||||||
emit.Opcodes(w.BinWriter, opcode.DUP)
|
emit.Opcodes(w.BinWriter, opcode.DUP)
|
||||||
emit.Syscall(w.BinWriter, interopnames.SystemIteratorNext)
|
emit.Syscall(w.BinWriter, interopnames.SystemIteratorNext)
|
||||||
|
|
@ -889,7 +889,7 @@ func TestNEO_GetCandidates(t *testing.T) {
|
||||||
}
|
}
|
||||||
emit.Syscall(w.BinWriter, interopnames.SystemIteratorValue)
|
emit.Syscall(w.BinWriter, interopnames.SystemIteratorValue)
|
||||||
require.NoError(t, w.Err)
|
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) {
|
if i < len(expected) {
|
||||||
e.CheckHalt(t, h, expected[i])
|
e.CheckHalt(t, h, expected[i])
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -913,14 +913,14 @@ func TestNEO_GetCandidates(t *testing.T) {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
neoCommitteeInvoker.Invoke(t, expected, "getCandidates")
|
tutusCommitteeInvoker.Invoke(t, expected, "getCandidates")
|
||||||
checkGetAllCandidates(t, expected)
|
checkGetAllCandidates(t, expected)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestNEO_RegisterViaNEP27(t *testing.T) {
|
func TestTutus_RegisterViaNEP27(t *testing.T) {
|
||||||
neoCommitteeInvoker := newNeoCommitteeClient(t, 100_0000_0000)
|
tutusCommitteeInvoker := newTutusCommitteeClient(t, 100_0000_0000)
|
||||||
neoValidatorsInvoker := neoCommitteeInvoker.WithSigners(neoCommitteeInvoker.Validator)
|
neoValidatorsInvoker := tutusCommitteeInvoker.WithSigners(tutusCommitteeInvoker.Validator)
|
||||||
e := neoCommitteeInvoker.Executor
|
e := tutusCommitteeInvoker.Executor
|
||||||
neoHash := e.NativeHash(t, nativenames.Tutus)
|
neoHash := e.NativeHash(t, nativenames.Tutus)
|
||||||
|
|
||||||
cfg := e.Chain.GetConfig()
|
cfg := e.Chain.GetConfig()
|
||||||
|
|
@ -934,7 +934,7 @@ func TestNEO_RegisterViaNEP27(t *testing.T) {
|
||||||
candidates[i] = e.NewAccount(t, 2000_0000_0000)
|
candidates[i] = e.NewAccount(t, 2000_0000_0000)
|
||||||
}
|
}
|
||||||
|
|
||||||
stack, err := neoCommitteeInvoker.TestInvoke(t, "getRegisterPrice")
|
stack, err := tutusCommitteeInvoker.TestInvoke(t, "getRegisterPrice")
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
registrationPrice, err := stack.Pop().Item().TryInteger()
|
registrationPrice, err := stack.Pop().Item().TryInteger()
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
@ -975,14 +975,14 @@ func TestNEO_RegisterViaNEP27(t *testing.T) {
|
||||||
stackitem.NewByteArray(pub),
|
stackitem.NewByteArray(pub),
|
||||||
v,
|
v,
|
||||||
})
|
})
|
||||||
neoCommitteeInvoker.Invoke(t, v, "getCandidateVote", pub)
|
tutusCommitteeInvoker.Invoke(t, v, "getCandidateVote", pub)
|
||||||
}
|
}
|
||||||
|
|
||||||
slices.SortFunc(expected, func(a, b stackitem.Item) int {
|
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))
|
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.
|
// Invalid cases.
|
||||||
var newCand = voters[0]
|
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)
|
gasValidatorsInvoker.WithSigners(newCand).InvokeFail(t, "invalid conversion", "transfer", newCand.(tutustest.SingleSigner).Account().ScriptHash(), neoHash, registrationPrice, nil)
|
||||||
// Invalid data.
|
// Invalid data.
|
||||||
gasValidatorsInvoker.WithSigners(newCand).InvokeFail(t, "unexpected EOF", "transfer", newCand.(tutustest.SingleSigner).Account().ScriptHash(), neoHash, registrationPrice, []byte{2, 2, 2})
|
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())
|
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.
|
// Incorrect amount.
|
||||||
gasValidatorsInvoker.WithSigners(newCand).InvokeFail(t, "incorrect GAS amount", "transfer", newCand.(tutustest.SingleSigner).Account().ScriptHash(), neoHash, 1, newCand.(tutustest.SingleSigner).Account().PublicKey().Bytes())
|
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) {
|
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)
|
c.Invoke(t, stackitem.Null{}, "setLubPerBlock", 0)
|
||||||
|
|
||||||
// No GAS should be generated for this block since GasPerBlock changes are
|
// 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
|
// TestNeo_TransferNegative ensures that transfer of a negative NEO amount leads to
|
||||||
// a VM FAULT, ref. #4072.
|
// a VM FAULT, ref. #4072.
|
||||||
func TestNeo_TransferNegative(t *testing.T) {
|
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)
|
c.InvokeFail(t, "negative amount", "transfer", c.Signers[0].ScriptHash(), c.Signers[0].ScriptHash(), -1, nil)
|
||||||
}
|
}
|
||||||
|
|
@ -36,7 +36,7 @@ func TestPolicy_ExecFeeFactor(t *testing.T) {
|
||||||
|
|
||||||
func TestPolicy_StoragePrice(t *testing.T) {
|
func TestPolicy_StoragePrice(t *testing.T) {
|
||||||
bc, validators, committee := chain.NewMulti(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) {
|
t.Run("get, internal method", func(t *testing.T) {
|
||||||
e.AddNewBlock(t) // avoid default value got from Blockchain.
|
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) {
|
func TestPolicy_BlockedAccounts(t *testing.T) {
|
||||||
bc, validators, committee := chain.NewMulti(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)
|
policyHash := e.NativeHash(t, nativenames.Policy)
|
||||||
|
|
||||||
policySuperInvoker := e.NewInvoker(policyHash, validators, committee)
|
policySuperInvoker := e.NewInvoker(policyHash, validators, committee)
|
||||||
|
|
@ -77,7 +77,7 @@ func TestPolicy_GetNotaryFeePerKey(t *testing.T) {
|
||||||
config.HFEchidna.String(): echidnaHeight,
|
config.HFEchidna.String(): echidnaHeight,
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
e := neotest.NewExecutor(t, bc, acc, acc)
|
e := tutustest.NewExecutor(t, bc, acc, acc)
|
||||||
p := e.CommitteeInvoker(nativehashes.PolicyContract)
|
p := e.CommitteeInvoker(nativehashes.PolicyContract)
|
||||||
|
|
||||||
// Invoke before Echidna should fail.
|
// Invoke before Echidna should fail.
|
||||||
|
|
@ -101,7 +101,7 @@ func TestPolicy_SetNotaryFeePerKey(t *testing.T) {
|
||||||
config.HFEchidna.String(): echidnaHeight,
|
config.HFEchidna.String(): echidnaHeight,
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
e := neotest.NewExecutor(t, bc, acc, acc)
|
e := tutustest.NewExecutor(t, bc, acc, acc)
|
||||||
p := e.CommitteeInvoker(nativehashes.PolicyContract)
|
p := e.CommitteeInvoker(nativehashes.PolicyContract)
|
||||||
|
|
||||||
// Invoke before Echidna should fail.
|
// Invoke before Echidna should fail.
|
||||||
|
|
|
||||||
|
|
@ -26,7 +26,7 @@ func TestStateSyncModule_Init(t *testing.T) {
|
||||||
c.MaxTraceableBlocks = maxTraceable
|
c.MaxTraceableBlocks = maxTraceable
|
||||||
}
|
}
|
||||||
bcSpout, validators, committee := chain.NewMultiWithCustomConfig(t, spoutCfg)
|
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 {
|
for range 2*stateSyncInterval + int(maxTraceable) + 2 {
|
||||||
e.AddNewBlock(t)
|
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) {
|
t.Run("error: bolt chain is too low to start state sync process", func(t *testing.T) {
|
||||||
bcBolt, validatorsBolt, committeeBolt := chain.NewMultiWithCustomConfig(t, boltCfg)
|
bcBolt, validatorsBolt, committeeBolt := chain.NewMultiWithCustomConfig(t, boltCfg)
|
||||||
eBolt := neotest.NewExecutor(t, bcBolt, validatorsBolt, committeeBolt)
|
eBolt := tutustest.NewExecutor(t, bcBolt, validatorsBolt, committeeBolt)
|
||||||
eBolt.AddNewBlock(t)
|
eBolt.AddNewBlock(t)
|
||||||
|
|
||||||
module := bcBolt.GetStateSyncModule()
|
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) {
|
check := func(t *testing.T, boltCfg func(c *config.Blockchain), storageEnabled bool) {
|
||||||
bcBolt, validatorsBolt, committeeBolt := chain.NewMultiWithCustomConfig(t, boltCfg)
|
bcBolt, validatorsBolt, committeeBolt := chain.NewMultiWithCustomConfig(t, boltCfg)
|
||||||
eBolt := neotest.NewExecutor(t, bcBolt, validatorsBolt, committeeBolt)
|
eBolt := tutustest.NewExecutor(t, bcBolt, validatorsBolt, committeeBolt)
|
||||||
module := bcBolt.GetStateSyncModule()
|
module := bcBolt.GetStateSyncModule()
|
||||||
require.NoError(t, module.Init(bcSpout.BlockHeight()))
|
require.NoError(t, module.Init(bcSpout.BlockHeight()))
|
||||||
|
|
||||||
|
|
@ -384,7 +384,7 @@ func TestStateSyncModule_RestoreBasicChain(t *testing.T) {
|
||||||
bcSpoutStore := storage.NewMemoryStore()
|
bcSpoutStore := storage.NewMemoryStore()
|
||||||
bcSpout, validators, committee := chain.NewMultiWithCustomConfigAndStore(t, spoutCfg, bcSpoutStore, false)
|
bcSpout, validators, committee := chain.NewMultiWithCustomConfigAndStore(t, spoutCfg, bcSpoutStore, false)
|
||||||
go bcSpout.Run() // Will close it manually at the end.
|
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)
|
basicchain.Init(t, "../../../", e)
|
||||||
|
|
||||||
// make spout chain higher than latest state sync point (add several blocks up to stateSyncPoint+2),
|
// 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
|
c.MaxTraceableBlocks = maxTraceable
|
||||||
}
|
}
|
||||||
bcSpout, vals, comm := chain.NewMultiWithCustomConfig(t, spoutCfg)
|
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 {
|
for range 2*stateSyncInterval + maxTraceable + 2 {
|
||||||
e.AddNewBlock(t)
|
e.AddNewBlock(t)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -72,7 +72,7 @@ func dupNotaryRequest(t *testing.T, p *payload.P2PNotaryRequest) *payload.P2PNot
|
||||||
|
|
||||||
func TestNotary(t *testing.T) {
|
func TestNotary(t *testing.T) {
|
||||||
bc, validators, committee := chain.NewMulti(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)
|
notaryHash := e.NativeHash(t, nativenames.Notary)
|
||||||
designationSuperInvoker := e.NewInvoker(e.NativeHash(t, nativenames.Designation), validators, committee)
|
designationSuperInvoker := e.NewInvoker(e.NativeHash(t, nativenames.Designation), validators, committee)
|
||||||
gasValidatorInvoker := e.ValidatorInvoker(e.NativeHash(t, nativenames.Lub))
|
gasValidatorInvoker := e.ValidatorInvoker(e.NativeHash(t, nativenames.Lub))
|
||||||
|
|
|
||||||
|
|
@ -40,7 +40,7 @@ import (
|
||||||
|
|
||||||
var pathToInternalContracts = filepath.Join("..", "..", "..", "internal", "contracts")
|
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 {
|
url string, filter *string, cb string, userData []byte, gas int64) util.Uint256 {
|
||||||
var filtItem any
|
var filtItem any
|
||||||
if filter != nil {
|
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
|
// https://github.com/neo-project/neo-modules/blob/master/tests/Neo.Plugins.OracleService.Tests/UT_OracleService.cs#L61
|
||||||
func TestCreateResponseTx(t *testing.T) {
|
func TestCreateResponseTx(t *testing.T) {
|
||||||
bc, validator, committee := chain.NewMulti(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))
|
managementInvoker := e.ValidatorInvoker(e.NativeHash(t, nativenames.Management))
|
||||||
|
|
||||||
cs := contracts.GetOracleContractState(t, pathToInternalContracts, validator.ScriptHash(), 0)
|
cs := contracts.GetOracleContractState(t, pathToInternalContracts, validator.ScriptHash(), 0)
|
||||||
|
|
@ -143,7 +143,7 @@ func TestOracle_InvalidWallet(t *testing.T) {
|
||||||
|
|
||||||
func TestOracle(t *testing.T) {
|
func TestOracle(t *testing.T) {
|
||||||
bc, validator, committee := chain.NewMulti(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))
|
managementInvoker := e.ValidatorInvoker(e.NativeHash(t, nativenames.Management))
|
||||||
designationSuperInvoker := e.NewInvoker(e.NativeHash(t, nativenames.Designation), validator, committee)
|
designationSuperInvoker := e.NewInvoker(e.NativeHash(t, nativenames.Designation), validator, committee)
|
||||||
nativeOracleH := e.NativeHash(t, nativenames.Oracle)
|
nativeOracleH := e.NativeHash(t, nativenames.Oracle)
|
||||||
|
|
@ -366,7 +366,7 @@ func TestOracle_GenesisRole(t *testing.T) {
|
||||||
|
|
||||||
func TestOracleFull(t *testing.T) {
|
func TestOracleFull(t *testing.T) {
|
||||||
bc, validator, committee := chain.NewMultiWithCustomConfigAndStore(t, nil, nil, false)
|
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)
|
designationSuperInvoker := e.NewInvoker(e.NativeHash(t, nativenames.Designation), validator, committee)
|
||||||
|
|
||||||
acc, orc, _, _ := getTestOracle(t, bc, "./testdata/oracle2.json", "two")
|
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()})
|
int64(roles.Oracle), []any{acc.PublicKey().Bytes()})
|
||||||
|
|
||||||
cs := contracts.GetOracleContractState(t, pathToInternalContracts, validator.ScriptHash(), 0)
|
cs := contracts.GetOracleContractState(t, pathToInternalContracts, validator.ScriptHash(), 0)
|
||||||
e.DeployContract(t, &neotest.Contract{
|
e.DeployContract(t, &tutustest.Contract{
|
||||||
Hash: cs.Hash,
|
Hash: cs.Hash,
|
||||||
NEF: &cs.NEF,
|
NEF: &cs.NEF,
|
||||||
Manifest: &cs.Manifest,
|
Manifest: &cs.Manifest,
|
||||||
|
|
@ -404,7 +404,7 @@ func TestOracleFull(t *testing.T) {
|
||||||
|
|
||||||
func TestNotYetRunningOracle(t *testing.T) {
|
func TestNotYetRunningOracle(t *testing.T) {
|
||||||
bc, validator, committee := chain.NewMultiWithCustomConfigAndStore(t, nil, nil, false)
|
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)
|
designationSuperInvoker := e.NewInvoker(e.NativeHash(t, nativenames.Designation), validator, committee)
|
||||||
|
|
||||||
acc, orc, _, _ := getTestOracle(t, bc, "./testdata/oracle2.json", "two")
|
acc, orc, _, _ := getTestOracle(t, bc, "./testdata/oracle2.json", "two")
|
||||||
|
|
|
||||||
|
|
@ -79,7 +79,7 @@ func newMajorityMultisigWithGAS(t *testing.T, n int) (util.Uint160, keys.PublicK
|
||||||
|
|
||||||
func TestStateRoot(t *testing.T) {
|
func TestStateRoot(t *testing.T) {
|
||||||
bc, validator, committee := chain.NewMulti(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)
|
designationSuperInvoker := e.NewInvoker(e.NativeHash(t, nativenames.Designation), validator, committee)
|
||||||
gasValidatorInvoker := e.ValidatorInvoker(e.NativeHash(t, nativenames.Lub))
|
gasValidatorInvoker := e.ValidatorInvoker(e.NativeHash(t, nativenames.Lub))
|
||||||
|
|
||||||
|
|
@ -180,7 +180,7 @@ func TestStateRootInitNonZeroHeight(t *testing.T) {
|
||||||
var root util.Uint256
|
var root util.Uint256
|
||||||
t.Run("init", func(t *testing.T) { // this is in a separate test to do proper cleanup
|
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)
|
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)
|
designationSuperInvoker := e.NewInvoker(e.NativeHash(t, nativenames.Designation), validator, committee)
|
||||||
gasValidatorInvoker := e.ValidatorInvoker(e.NativeHash(t, nativenames.Lub))
|
gasValidatorInvoker := e.ValidatorInvoker(e.NativeHash(t, nativenames.Lub))
|
||||||
|
|
||||||
|
|
@ -231,7 +231,7 @@ func createStateRootConfig(walletPath, password string) config.StateRoot {
|
||||||
func TestStateRootFull(t *testing.T) {
|
func TestStateRootFull(t *testing.T) {
|
||||||
tmpDir := t.TempDir()
|
tmpDir := t.TempDir()
|
||||||
bc, validator, committee := chain.NewMulti(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)
|
designationSuperInvoker := e.NewInvoker(e.NativeHash(t, nativenames.Designation), validator, committee)
|
||||||
gasValidatorInvoker := e.ValidatorInvoker(e.NativeHash(t, nativenames.Lub))
|
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) {
|
bc, validators, committee := chain.NewMultiWithCustomConfig(t, func(c *config.Blockchain) {
|
||||||
c.P2PSigExtensions = true
|
c.P2PSigExtensions = true
|
||||||
})
|
})
|
||||||
e := neotest.NewExecutor(t, bc, validators, committee)
|
e := tutustest.NewExecutor(t, bc, validators, committee)
|
||||||
basicchain.Init(t, "../../../", e)
|
basicchain.Init(t, "../../../", e)
|
||||||
|
|
||||||
m := bc.GetStateModule()
|
m := bc.GetStateModule()
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,7 @@ import (
|
||||||
// TestNewMulti checks that the transaction and the block are signed correctly for multi-node setup.
|
// TestNewMulti checks that the transaction and the block are signed correctly for multi-node setup.
|
||||||
func TestNewMulti(t *testing.T) {
|
func TestNewMulti(t *testing.T) {
|
||||||
bc, vAcc, cAcc := NewMulti(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())
|
require.NotEqual(t, vAcc.ScriptHash(), cAcc.ScriptHash())
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue