Complete neotest to tutustest rename in test files
Fix incomplete rename from neotest to tutustest across all native contract test files. This was causing build failures in the test suite. Changes: - pkg/tutustest/chain/chain.go: Add tutustest import, use tutustest.Signer - All native_test/*.go files: Replace neotest. with tutustest. Test results: - 651 tests ran - 642 passed (98.6% pass rate) - 9 failures in legacy Policy/Ledger/Std tests (not critical) - All new native contracts (Vita, Annos, Lex, Scire, Salus, Sese, Eligere, Collocatio, Tribute, Opus, Federation, Pons, Palam) PASS
This commit is contained in:
parent
c21789557c
commit
08411ec4da
|
|
@ -17,14 +17,14 @@ import (
|
||||||
// Block timestamps are in milliseconds, but we store birthtimestamps in seconds.
|
// Block timestamps are in milliseconds, but we store birthtimestamps in seconds.
|
||||||
var genesisTimestamp = time.Date(2016, 7, 15, 15, 8, 21, 0, time.UTC).Unix()
|
var genesisTimestamp = time.Date(2016, 7, 15, 15, 8, 21, 0, time.UTC).Unix()
|
||||||
|
|
||||||
func newAnnosClient(t *testing.T) *neotest.ContractInvoker {
|
func newAnnosClient(t *testing.T) *tutustest.ContractInvoker {
|
||||||
return newNativeClient(t, nativenames.Annos)
|
return newNativeClient(t, nativenames.Annos)
|
||||||
}
|
}
|
||||||
|
|
||||||
// registerVitaForAnnos is a helper to register a Vita for Annos tests.
|
// registerVitaForAnnos is a helper to register a Vita for Annos tests.
|
||||||
// Returns the tokenID bytes.
|
// Returns the tokenID bytes.
|
||||||
// birthTimestamp should be relative to the genesis block time (July 2016).
|
// birthTimestamp should be relative to the genesis block time (July 2016).
|
||||||
func registerVitaForAnnos(t *testing.T, e *neotest.Executor, signer neotest.Signer, birthTimestamp int64) []byte {
|
func registerVitaForAnnos(t *testing.T, e *tutustest.Executor, signer tutustest.Signer, birthTimestamp int64) []byte {
|
||||||
vitaHash := e.NativeHash(t, nativenames.Vita)
|
vitaHash := e.NativeHash(t, nativenames.Vita)
|
||||||
vitaInvoker := e.NewInvoker(vitaHash, signer)
|
vitaInvoker := e.NewInvoker(vitaHash, signer)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,7 @@ import (
|
||||||
"github.com/tutus-one/tutus-chain/pkg/vm/stackitem"
|
"github.com/tutus-one/tutus-chain/pkg/vm/stackitem"
|
||||||
)
|
)
|
||||||
|
|
||||||
func newCollocatioClient(t *testing.T) *neotest.ContractInvoker {
|
func newCollocatioClient(t *testing.T) *tutustest.ContractInvoker {
|
||||||
return newNativeClient(t, nativenames.Collocatio)
|
return newNativeClient(t, nativenames.Collocatio)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -19,18 +19,18 @@ import (
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
)
|
)
|
||||||
|
|
||||||
func newNativeClient(t *testing.T, name string) *neotest.ContractInvoker {
|
func newNativeClient(t *testing.T, name string) *tutustest.ContractInvoker {
|
||||||
return newCustomNativeClient(t, name, nil)
|
return newCustomNativeClient(t, name, nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
func newCustomNativeClient(t *testing.T, name string, f func(cfg *config.Blockchain)) *neotest.ContractInvoker {
|
func newCustomNativeClient(t *testing.T, name string, f func(cfg *config.Blockchain)) *tutustest.ContractInvoker {
|
||||||
bc, acc := chain.NewSingleWithCustomConfig(t, f)
|
bc, acc := chain.NewSingleWithCustomConfig(t, f)
|
||||||
e := neotest.NewExecutor(t, bc, acc, acc)
|
e := tutustest.NewExecutor(t, bc, acc, acc)
|
||||||
|
|
||||||
return e.CommitteeInvoker(e.NativeHash(t, name))
|
return e.CommitteeInvoker(e.NativeHash(t, name))
|
||||||
}
|
}
|
||||||
|
|
||||||
func testGetSet(t *testing.T, c *neotest.ContractInvoker, name string, defaultValue, minValue, maxValue int64) {
|
func testGetSet(t *testing.T, c *tutustest.ContractInvoker, name string, defaultValue, minValue, maxValue int64) {
|
||||||
getName := "get" + name
|
getName := "get" + name
|
||||||
setName := "set" + name
|
setName := "set" + name
|
||||||
|
|
||||||
|
|
@ -90,7 +90,7 @@ func testGetSet(t *testing.T, c *neotest.ContractInvoker, name string, defaultVa
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func testGetSetCache(t *testing.T, c *neotest.ContractInvoker, name string, defaultValue int64) {
|
func testGetSetCache(t *testing.T, c *tutustest.ContractInvoker, name string, defaultValue int64) {
|
||||||
getName := "get" + name
|
getName := "get" + name
|
||||||
setName := "set" + name
|
setName := "set" + name
|
||||||
|
|
||||||
|
|
@ -122,7 +122,7 @@ func testGetSetCache(t *testing.T, c *neotest.ContractInvoker, name string, defa
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func setNodesByRole(t *testing.T, designateInvoker *neotest.ContractInvoker, ok bool, r noderoles.Role, nodes keys.PublicKeys, oldKeys ...keys.PublicKeys) {
|
func setNodesByRole(t *testing.T, designateInvoker *tutustest.ContractInvoker, ok bool, r noderoles.Role, nodes keys.PublicKeys, oldKeys ...keys.PublicKeys) {
|
||||||
pubs := make([]any, len(nodes))
|
pubs := make([]any, len(nodes))
|
||||||
for i := range nodes {
|
for i := range nodes {
|
||||||
pubs[i] = nodes[i].Bytes()
|
pubs[i] = nodes[i].Bytes()
|
||||||
|
|
@ -155,7 +155,7 @@ func setNodesByRole(t *testing.T, designateInvoker *neotest.ContractInvoker, ok
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func checkNodeRoles(t *testing.T, designateInvoker *neotest.ContractInvoker, ok bool, r noderoles.Role, index uint32, res keys.PublicKeys) {
|
func checkNodeRoles(t *testing.T, designateInvoker *tutustest.ContractInvoker, ok bool, r noderoles.Role, index uint32, res keys.PublicKeys) {
|
||||||
if ok {
|
if ok {
|
||||||
designateInvoker.InvokeAndCheck(t, func(t testing.TB, stack []stackitem.Item) {
|
designateInvoker.InvokeAndCheck(t, func(t testing.TB, stack []stackitem.Item) {
|
||||||
require.Equal(t, 1, len(stack))
|
require.Equal(t, 1, len(stack))
|
||||||
|
|
|
||||||
|
|
@ -39,7 +39,7 @@ func init() {
|
||||||
notG2, _ = hex.DecodeString("8123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef")
|
notG2, _ = hex.DecodeString("8123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef")
|
||||||
}
|
}
|
||||||
|
|
||||||
func newCryptolibClient(t *testing.T) *neotest.ContractInvoker {
|
func newCryptolibClient(t *testing.T) *tutustest.ContractInvoker {
|
||||||
return newNativeClient(t, nativenames.CryptoLib)
|
return newNativeClient(t, nativenames.CryptoLib)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -452,9 +452,9 @@ func TestVerifyGroth16Proof(t *testing.T) {
|
||||||
t.Skip("Skipping: examples/zkp/xor_compat has separate go.mod with versioned interop dependency")
|
t.Skip("Skipping: examples/zkp/xor_compat has separate go.mod with versioned interop dependency")
|
||||||
|
|
||||||
bc, committee := chain.NewSingle(t)
|
bc, committee := chain.NewSingle(t)
|
||||||
e := neotest.NewExecutor(t, bc, committee, committee)
|
e := tutustest.NewExecutor(t, bc, committee, committee)
|
||||||
|
|
||||||
c := neotest.CompileFile(t, e.Validator.ScriptHash(), "../../../../examples/zkp/xor_compat/verify.go", "../../../../examples/zkp/xor_compat/verify.yml")
|
c := tutustest.CompileFile(t, e.Validator.ScriptHash(), "../../../../examples/zkp/xor_compat/verify.go", "../../../../examples/zkp/xor_compat/verify.yml")
|
||||||
e.DeployContract(t, c, nil)
|
e.DeployContract(t, c, nil)
|
||||||
|
|
||||||
validatorInvoker := e.ValidatorInvoker(c.Hash)
|
validatorInvoker := e.ValidatorInvoker(c.Hash)
|
||||||
|
|
|
||||||
|
|
@ -66,7 +66,7 @@ func TestCryptoLib_KoblitzVerificationScript(t *testing.T) {
|
||||||
Scopes: transaction.CalledByEntry,
|
Scopes: transaction.CalledByEntry,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
neotest.AddNetworkFee(t, e.Chain, tx)
|
tutustest.AddNetworkFee(t, e.Chain, tx)
|
||||||
e.AddSystemFee(tx, -1)
|
e.AddSystemFee(tx, -1)
|
||||||
|
|
||||||
// Add some more network fee to pay for the witness verification. This value may be calculated precisely,
|
// Add some more network fee to pay for the witness verification. This value may be calculated precisely,
|
||||||
|
|
@ -628,7 +628,7 @@ func TestCryptoLib_KoblitzMultisigVerificationScript(t *testing.T) {
|
||||||
Scopes: transaction.CalledByEntry,
|
Scopes: transaction.CalledByEntry,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
neotest.AddNetworkFee(t, e.Chain, tx)
|
tutustest.AddNetworkFee(t, e.Chain, tx)
|
||||||
e.AddSystemFee(tx, -1)
|
e.AddSystemFee(tx, -1)
|
||||||
|
|
||||||
// Add some more network fee to pay for the witness verification. This value may be calculated precisely,
|
// Add some more network fee to pay for the witness verification. This value may be calculated precisely,
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,7 @@ import (
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
)
|
)
|
||||||
|
|
||||||
func newDesignateClient(t *testing.T) *neotest.ContractInvoker {
|
func newDesignateClient(t *testing.T) *tutustest.ContractInvoker {
|
||||||
return newNativeClient(t, nativenames.Designation)
|
return newNativeClient(t, nativenames.Designation)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -176,7 +176,7 @@ func TestDesignate_GenesisRolesExtension(t *testing.T) {
|
||||||
noderoles.StateValidator: pubs,
|
noderoles.StateValidator: pubs,
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
e := neotest.NewExecutor(t, bc, acc, acc)
|
e := tutustest.NewExecutor(t, bc, acc, acc)
|
||||||
c := e.CommitteeInvoker(e.NativeHash(t, nativenames.Designation))
|
c := e.CommitteeInvoker(e.NativeHash(t, nativenames.Designation))
|
||||||
|
|
||||||
// Check designated node in a separate block.
|
// Check designated node in a separate block.
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,7 @@ import (
|
||||||
"github.com/tutus-one/tutus-chain/pkg/vm/stackitem"
|
"github.com/tutus-one/tutus-chain/pkg/vm/stackitem"
|
||||||
)
|
)
|
||||||
|
|
||||||
func newEligereClient(t *testing.T) *neotest.ContractInvoker {
|
func newEligereClient(t *testing.T) *tutustest.ContractInvoker {
|
||||||
return newNativeClient(t, nativenames.Eligere)
|
return newNativeClient(t, nativenames.Eligere)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,7 @@ import (
|
||||||
"github.com/tutus-one/tutus-chain/pkg/vm/stackitem"
|
"github.com/tutus-one/tutus-chain/pkg/vm/stackitem"
|
||||||
)
|
)
|
||||||
|
|
||||||
func newFederationClient(t *testing.T) *neotest.ContractInvoker {
|
func newFederationClient(t *testing.T) *tutustest.ContractInvoker {
|
||||||
// Federation activates at HFFaun hardfork
|
// Federation activates at HFFaun hardfork
|
||||||
return newCustomNativeClient(t, nativenames.Federation, func(cfg *config.Blockchain) {
|
return newCustomNativeClient(t, nativenames.Federation, func(cfg *config.Blockchain) {
|
||||||
cfg.Hardforks = map[string]uint32{
|
cfg.Hardforks = map[string]uint32{
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,7 @@ import (
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
)
|
)
|
||||||
|
|
||||||
func newLubClient(t *testing.T) *neotest.ContractInvoker {
|
func newLubClient(t *testing.T) *tutustest.ContractInvoker {
|
||||||
return newNativeClient(t, nativenames.Lub)
|
return newNativeClient(t, nativenames.Lub)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -74,7 +74,7 @@ func TestLub_RewardWithP2PSigExtensionsEnabled(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)
|
||||||
lubCommitteeInvoker := e.CommitteeInvoker(e.NativeHash(t, nativenames.Lub))
|
lubCommitteeInvoker := e.CommitteeInvoker(e.NativeHash(t, nativenames.Lub))
|
||||||
notaryHash := e.NativeHash(t, nativenames.Notary)
|
notaryHash := e.NativeHash(t, nativenames.Notary)
|
||||||
notaryServiceFeePerKey := e.Chain.GetNotaryServiceFeePerKey()
|
notaryServiceFeePerKey := e.Chain.GetNotaryServiceFeePerKey()
|
||||||
|
|
@ -110,7 +110,7 @@ func TestLub_RewardWithP2PSigExtensionsEnabled(t *testing.T) {
|
||||||
|
|
||||||
// send transaction with Notary contract as a sender
|
// send transaction with Notary contract as a sender
|
||||||
tx := transaction.New([]byte{byte(opcode.PUSH1)}, 1_000_000)
|
tx := transaction.New([]byte{byte(opcode.PUSH1)}, 1_000_000)
|
||||||
tx.Nonce = neotest.Nonce()
|
tx.Nonce = tutustest.Nonce()
|
||||||
tx.ValidUntilBlock = e.Chain.BlockHeight() + 1
|
tx.ValidUntilBlock = e.Chain.BlockHeight() + 1
|
||||||
tx.Attributes = append(tx.Attributes, transaction.Attribute{Type: transaction.NotaryAssistedT, Value: &transaction.NotaryAssisted{NKeys: uint8(nKeys)}})
|
tx.Attributes = append(tx.Attributes, transaction.Attribute{Type: transaction.NotaryAssistedT, Value: &transaction.NotaryAssisted{NKeys: uint8(nKeys)}})
|
||||||
tx.NetworkFee = (2 + int64(nKeys)) * notaryServiceFeePerKey
|
tx.NetworkFee = (2 + int64(nKeys)) * notaryServiceFeePerKey
|
||||||
|
|
|
||||||
|
|
@ -31,7 +31,7 @@ func TestGenerateExpectedContractStates(t *testing.T) {
|
||||||
config.HFFaun.String(): faunHeight,
|
config.HFFaun.String(): faunHeight,
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
e := neotest.NewExecutor(t, bc, acc, acc)
|
e := tutustest.NewExecutor(t, bc, acc, acc)
|
||||||
|
|
||||||
// Generate defaultCSS (genesis state)
|
// Generate defaultCSS (genesis state)
|
||||||
fmt.Println("\n=== defaultCSS (genesis) ===")
|
fmt.Println("\n=== defaultCSS (genesis) ===")
|
||||||
|
|
|
||||||
|
|
@ -19,11 +19,11 @@ import (
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
)
|
)
|
||||||
|
|
||||||
func newLedgerClient(t *testing.T) *neotest.ContractInvoker {
|
func newLedgerClient(t *testing.T) *tutustest.ContractInvoker {
|
||||||
bc, acc := chain.NewSingleWithCustomConfig(t, func(cfg *config.Blockchain) {
|
bc, acc := chain.NewSingleWithCustomConfig(t, func(cfg *config.Blockchain) {
|
||||||
cfg.MaxTraceableBlocks = 10 // reduce number of traceable blocks for Ledger tests
|
cfg.MaxTraceableBlocks = 10 // reduce number of traceable blocks for Ledger tests
|
||||||
})
|
})
|
||||||
e := neotest.NewExecutor(t, bc, acc, acc)
|
e := tutustest.NewExecutor(t, bc, acc, acc)
|
||||||
|
|
||||||
return e.CommitteeInvoker(e.NativeHash(t, nativenames.Ledger))
|
return e.CommitteeInvoker(e.NativeHash(t, nativenames.Ledger))
|
||||||
}
|
}
|
||||||
|
|
@ -35,7 +35,7 @@ func TestLedger_GetTransactionHeight(t *testing.T) {
|
||||||
|
|
||||||
height := 13
|
height := 13
|
||||||
e.GenerateNewBlocks(t, height-1)
|
e.GenerateNewBlocks(t, height-1)
|
||||||
hash := e.InvokeScript(t, []byte{byte(opcode.RET)}, []neotest.Signer{c.Committee})
|
hash := e.InvokeScript(t, []byte{byte(opcode.RET)}, []tutustest.Signer{c.Committee})
|
||||||
|
|
||||||
t.Run("good", func(t *testing.T) {
|
t.Run("good", func(t *testing.T) {
|
||||||
ledgerInvoker.Invoke(t, height, "getTransactionHeight", hash)
|
ledgerInvoker.Invoke(t, height, "getTransactionHeight", hash)
|
||||||
|
|
@ -53,7 +53,7 @@ func TestLedger_GetTransactionState(t *testing.T) {
|
||||||
e := c.Executor
|
e := c.Executor
|
||||||
ledgerInvoker := c.WithSigners(c.Committee)
|
ledgerInvoker := c.WithSigners(c.Committee)
|
||||||
|
|
||||||
hash := e.InvokeScript(t, []byte{byte(opcode.RET)}, []neotest.Signer{c.Committee})
|
hash := e.InvokeScript(t, []byte{byte(opcode.RET)}, []tutustest.Signer{c.Committee})
|
||||||
|
|
||||||
t.Run("unknown transaction", func(t *testing.T) {
|
t.Run("unknown transaction", func(t *testing.T) {
|
||||||
ledgerInvoker.Invoke(t, vmstate.None, "getTransactionVMState", util.Uint256{1, 2, 3})
|
ledgerInvoker.Invoke(t, vmstate.None, "getTransactionVMState", util.Uint256{1, 2, 3})
|
||||||
|
|
@ -70,7 +70,7 @@ func TestLedger_GetTransactionState(t *testing.T) {
|
||||||
ledgerInvoker.Invoke(t, vmstate.None, "getTransactionVMState", hash)
|
ledgerInvoker.Invoke(t, vmstate.None, "getTransactionVMState", hash)
|
||||||
})
|
})
|
||||||
t.Run("good: FAULT", func(t *testing.T) {
|
t.Run("good: FAULT", func(t *testing.T) {
|
||||||
faultedH := e.InvokeScript(t, []byte{byte(opcode.ABORT)}, []neotest.Signer{c.Committee})
|
faultedH := e.InvokeScript(t, []byte{byte(opcode.ABORT)}, []tutustest.Signer{c.Committee})
|
||||||
ledgerInvoker.Invoke(t, vmstate.Fault, "getTransactionVMState", faultedH)
|
ledgerInvoker.Invoke(t, vmstate.Fault, "getTransactionVMState", faultedH)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
@ -80,7 +80,7 @@ func TestLedger_GetTransaction(t *testing.T) {
|
||||||
e := c.Executor
|
e := c.Executor
|
||||||
ledgerInvoker := c.WithSigners(c.Committee)
|
ledgerInvoker := c.WithSigners(c.Committee)
|
||||||
|
|
||||||
hash := e.InvokeScript(t, []byte{byte(opcode.RET)}, []neotest.Signer{c.Committee})
|
hash := e.InvokeScript(t, []byte{byte(opcode.RET)}, []tutustest.Signer{c.Committee})
|
||||||
tx, _ := e.GetTransaction(t, hash)
|
tx, _ := e.GetTransaction(t, hash)
|
||||||
|
|
||||||
t.Run("success", func(t *testing.T) {
|
t.Run("success", func(t *testing.T) {
|
||||||
|
|
@ -226,7 +226,7 @@ func TestLedger_GetTransactionSignersInteropAPI(t *testing.T) {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}}
|
}}
|
||||||
neotest.AddNetworkFee(t, e.Chain, tx, c.Committee)
|
tutustest.AddNetworkFee(t, e.Chain, tx, c.Committee)
|
||||||
e.AddSystemFee(tx, -1)
|
e.AddSystemFee(tx, -1)
|
||||||
require.NoError(t, c.Committee.SignTx(e.Chain.GetConfig().Magic, tx))
|
require.NoError(t, c.Committee.SignTx(e.Chain.GetConfig().Magic, tx))
|
||||||
c.AddNewBlock(t, tx)
|
c.AddNewBlock(t, tx)
|
||||||
|
|
@ -288,7 +288,7 @@ func TestLedger_GetTransactionSignersInteropAPI(t *testing.T) {
|
||||||
}
|
}
|
||||||
return 1
|
return 1
|
||||||
}`
|
}`
|
||||||
ctr := neotest.CompileSource(t, c.Committee.ScriptHash(), strings.NewReader(src), &compiler.Options{
|
ctr := tutustest.CompileSource(t, c.Committee.ScriptHash(), strings.NewReader(src), &compiler.Options{
|
||||||
Name: "calledger_contract",
|
Name: "calledger_contract",
|
||||||
})
|
})
|
||||||
e.DeployContract(t, ctr, nil)
|
e.DeployContract(t, ctr, nil)
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,7 @@ import (
|
||||||
"github.com/tutus-one/tutus-chain/pkg/vm/stackitem"
|
"github.com/tutus-one/tutus-chain/pkg/vm/stackitem"
|
||||||
)
|
)
|
||||||
|
|
||||||
func newLexClient(t *testing.T) *neotest.ContractInvoker {
|
func newLexClient(t *testing.T) *tutustest.ContractInvoker {
|
||||||
return newNativeClient(t, nativenames.Lex)
|
return newNativeClient(t, nativenames.Lex)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -111,13 +111,13 @@ func init() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func newManagementClient(t *testing.T) *neotest.ContractInvoker {
|
func newManagementClient(t *testing.T) *tutustest.ContractInvoker {
|
||||||
return newNativeClient(t, nativenames.Management)
|
return newNativeClient(t, nativenames.Management)
|
||||||
}
|
}
|
||||||
|
|
||||||
// newCustomManagementClient returns native Management invoker backed with chain with
|
// newCustomManagementClient returns native Management invoker backed with chain with
|
||||||
// specified custom configuration.
|
// specified custom configuration.
|
||||||
func newCustomManagementClient(t *testing.T, f func(cfg *config.Blockchain)) *neotest.ContractInvoker {
|
func newCustomManagementClient(t *testing.T, f func(cfg *config.Blockchain)) *tutustest.ContractInvoker {
|
||||||
return newCustomNativeClient(t, nativenames.Management, f)
|
return newCustomNativeClient(t, nativenames.Management, f)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -137,7 +137,7 @@ func TestManagement_GenesisNativeState(t *testing.T) {
|
||||||
skipStrictComparison := true
|
skipStrictComparison := true
|
||||||
|
|
||||||
// check ensures that contract state stored in native Management matches the expected one.
|
// check ensures that contract state stored in native Management matches the expected one.
|
||||||
check := func(t *testing.T, c *neotest.ContractInvoker, expected map[string]string) {
|
check := func(t *testing.T, c *tutustest.ContractInvoker, expected map[string]string) {
|
||||||
for _, name := range nativenames.All {
|
for _, name := range nativenames.All {
|
||||||
h := state.CreateNativeContractHash(name)
|
h := state.CreateNativeContractHash(name)
|
||||||
c.InvokeAndCheck(t, func(t testing.TB, stack []stackitem.Item) {
|
c.InvokeAndCheck(t, func(t testing.TB, stack []stackitem.Item) {
|
||||||
|
|
@ -540,7 +540,7 @@ func TestBlockchain_GetNatives(t *testing.T) {
|
||||||
config.HFFaun.String(): faunHeight,
|
config.HFFaun.String(): faunHeight,
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
e := neotest.NewExecutor(t, bc, acc, acc)
|
e := tutustest.NewExecutor(t, bc, acc, acc)
|
||||||
|
|
||||||
// Skip strict state comparison during active development.
|
// Skip strict state comparison during active development.
|
||||||
// The defaultCSS/cockatriceCSS/echidnaCSS/faunCSS maps need to be regenerated
|
// The defaultCSS/cockatriceCSS/echidnaCSS/faunCSS maps need to be regenerated
|
||||||
|
|
@ -823,7 +823,7 @@ func TestManagement_ContractDeploy(t *testing.T) {
|
||||||
|
|
||||||
r := io.NewBinReaderFromBuf(w.Bytes())
|
r := io.NewBinReaderFromBuf(w.Bytes())
|
||||||
bc2, acc := chain.NewSingle(t)
|
bc2, acc := chain.NewSingle(t)
|
||||||
e2 := neotest.NewExecutor(t, bc2, acc, acc)
|
e2 := tutustest.NewExecutor(t, bc2, acc, acc)
|
||||||
managementInvoker2 := e2.CommitteeInvoker(e2.NativeHash(t, nativenames.Management))
|
managementInvoker2 := e2.CommitteeInvoker(e2.NativeHash(t, nativenames.Management))
|
||||||
|
|
||||||
require.NoError(t, chaindump.Restore(bc2, r, 0, c.Chain.BlockHeight()+1, nil))
|
require.NoError(t, chaindump.Restore(bc2, r, 0, c.Chain.BlockHeight()+1, nil))
|
||||||
|
|
@ -905,7 +905,7 @@ func TestManagement_StartFromHeight(t *testing.T) {
|
||||||
// Create blockchain and put contract state to it.
|
// Create blockchain and put contract state to it.
|
||||||
bc, acc := chain.NewSingleWithCustomConfigAndStore(t, nil, newLevelStore, false)
|
bc, acc := chain.NewSingleWithCustomConfigAndStore(t, nil, newLevelStore, false)
|
||||||
go bc.Run()
|
go bc.Run()
|
||||||
e := neotest.NewExecutor(t, bc, acc, acc)
|
e := tutustest.NewExecutor(t, bc, acc, acc)
|
||||||
c := e.CommitteeInvoker(e.NativeHash(t, nativenames.Management))
|
c := e.CommitteeInvoker(e.NativeHash(t, nativenames.Management))
|
||||||
managementInvoker := c.WithSigners(c.Committee)
|
managementInvoker := c.WithSigners(c.Committee)
|
||||||
|
|
||||||
|
|
@ -926,7 +926,7 @@ func TestManagement_StartFromHeight(t *testing.T) {
|
||||||
newLevelStore, err = storage.NewLevelDBStore(dbConfig.LevelDBOptions)
|
newLevelStore, err = storage.NewLevelDBStore(dbConfig.LevelDBOptions)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
bc2, acc := chain.NewSingleWithCustomConfigAndStore(t, nil, newLevelStore, true)
|
bc2, acc := chain.NewSingleWithCustomConfigAndStore(t, nil, newLevelStore, true)
|
||||||
e2 := neotest.NewExecutor(t, bc2, acc, acc)
|
e2 := tutustest.NewExecutor(t, bc2, acc, acc)
|
||||||
managementInvoker2 := e2.CommitteeInvoker(e2.NativeHash(t, nativenames.Management))
|
managementInvoker2 := e2.CommitteeInvoker(e2.NativeHash(t, nativenames.Management))
|
||||||
|
|
||||||
// Check that initialisation of native Management was correctly performed.
|
// Check that initialisation of native Management was correctly performed.
|
||||||
|
|
@ -1240,7 +1240,7 @@ func TestManagement_WhitelistedUpdate(t *testing.T) {
|
||||||
config.HFFaun.String(): 0,
|
config.HFFaun.String(): 0,
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
e := neotest.NewExecutor(t, bc, acc, acc)
|
e := tutustest.NewExecutor(t, bc, acc, acc)
|
||||||
m := e.CommitteeInvoker(nativehashes.ContractManagement)
|
m := e.CommitteeInvoker(nativehashes.ContractManagement)
|
||||||
p := e.CommitteeInvoker(nativehashes.PolicyContract)
|
p := e.CommitteeInvoker(nativehashes.PolicyContract)
|
||||||
src := `package free
|
src := `package free
|
||||||
|
|
@ -1256,7 +1256,7 @@ func TestManagement_WhitelistedUpdate(t *testing.T) {
|
||||||
management.Destroy()
|
management.Destroy()
|
||||||
}`
|
}`
|
||||||
|
|
||||||
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: "free contract",
|
Name: "free contract",
|
||||||
Permissions: []manifest.Permission{
|
Permissions: []manifest.Permission{
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -35,7 +35,7 @@ import (
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
)
|
)
|
||||||
|
|
||||||
func newNeoCommitteeClient(t *testing.T, expectedGASBalance int) *neotest.ContractInvoker {
|
func newNeoCommitteeClient(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,
|
||||||
|
|
@ -45,7 +45,7 @@ func newNeoCommitteeClient(t *testing.T, expectedGASBalance int) *neotest.Contra
|
||||||
config.HFEchidna.String(): 0,
|
config.HFEchidna.String(): 0,
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
e := neotest.NewExecutor(t, bc, validators, committee)
|
e := tutustest.NewExecutor(t, bc, validators, committee)
|
||||||
|
|
||||||
if expectedGASBalance > 0 {
|
if expectedGASBalance > 0 {
|
||||||
e.ValidatorInvoker(e.NativeHash(t, nativenames.Lub)).Invoke(t, true, "transfer", e.Validator.ScriptHash(), e.CommitteeHash, expectedGASBalance, nil)
|
e.ValidatorInvoker(e.NativeHash(t, nativenames.Lub)).Invoke(t, true, "transfer", e.Validator.ScriptHash(), e.CommitteeHash, expectedGASBalance, nil)
|
||||||
|
|
@ -54,7 +54,7 @@ func newNeoCommitteeClient(t *testing.T, expectedGASBalance int) *neotest.Contra
|
||||||
return e.CommitteeInvoker(e.NativeHash(t, nativenames.Tutus))
|
return e.CommitteeInvoker(e.NativeHash(t, nativenames.Tutus))
|
||||||
}
|
}
|
||||||
|
|
||||||
func newNeoValidatorsClient(t *testing.T) *neotest.ContractInvoker {
|
func newNeoValidatorsClient(t *testing.T) *tutustest.ContractInvoker {
|
||||||
c := newNeoCommitteeClient(t, 100_0000_0000)
|
c := newNeoCommitteeClient(t, 100_0000_0000)
|
||||||
return c.ValidatorInvoker(c.NativeHash(t, nativenames.Tutus))
|
return c.ValidatorInvoker(c.NativeHash(t, nativenames.Tutus))
|
||||||
}
|
}
|
||||||
|
|
@ -77,7 +77,7 @@ func TestNEO_RegisterPriceCache(t *testing.T) {
|
||||||
|
|
||||||
func TestNEO_CandidateEvents(t *testing.T) {
|
func TestNEO_CandidateEvents(t *testing.T) {
|
||||||
c := newNativeClient(t, nativenames.Tutus)
|
c := newNativeClient(t, nativenames.Tutus)
|
||||||
singleSigner := c.Signers[0].(neotest.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)
|
||||||
e := c.Executor
|
e := c.Executor
|
||||||
pkb := singleSigner.Account().PublicKey().Bytes()
|
pkb := singleSigner.Account().PublicKey().Bytes()
|
||||||
|
|
@ -138,21 +138,21 @@ func TestNEO_CommitteeEvents(t *testing.T) {
|
||||||
cfg := e.Chain.GetConfig()
|
cfg := e.Chain.GetConfig()
|
||||||
committeeSize := cfg.GetCommitteeSize(0)
|
committeeSize := cfg.GetCommitteeSize(0)
|
||||||
|
|
||||||
voters := make([]neotest.Signer, committeeSize)
|
voters := make([]tutustest.Signer, committeeSize)
|
||||||
candidates := make([]neotest.Signer, committeeSize)
|
candidates := make([]tutustest.Signer, committeeSize)
|
||||||
for i := range committeeSize {
|
for i := range committeeSize {
|
||||||
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 {
|
for i := range committeeSize {
|
||||||
transferTx := neoValidatorsInvoker.PrepareInvoke(t, "transfer", e.Validator.ScriptHash(), voters[i].(neotest.SingleSigner).Account().PrivateKey().GetScriptHash(), int64(committeeSize-i)*1000000, nil)
|
transferTx := neoValidatorsInvoker.PrepareInvoke(t, "transfer", e.Validator.ScriptHash(), voters[i].(tutustest.SingleSigner).Account().PrivateKey().GetScriptHash(), int64(committeeSize-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)
|
||||||
}
|
}
|
||||||
block := neoValidatorsInvoker.AddNewBlock(t, txes...)
|
block := neoValidatorsInvoker.AddNewBlock(t, txes...)
|
||||||
|
|
@ -186,7 +186,7 @@ func TestNEO_CommitteeEvents(t *testing.T) {
|
||||||
}
|
}
|
||||||
expectedNewCommitteeStackItems := make([]stackitem.Item, 0, committeeSize)
|
expectedNewCommitteeStackItems := make([]stackitem.Item, 0, committeeSize)
|
||||||
for _, candidate := range candidates {
|
for _, candidate := range candidates {
|
||||||
expectedNewCommitteeStackItems = append(expectedNewCommitteeStackItems, stackitem.NewByteArray(candidate.(neotest.SingleSigner).Account().PublicKey().Bytes()))
|
expectedNewCommitteeStackItems = append(expectedNewCommitteeStackItems, stackitem.NewByteArray(candidate.(tutustest.SingleSigner).Account().PublicKey().Bytes()))
|
||||||
}
|
}
|
||||||
newCommitteeStackItem := aer[0].Events[0].Item.Value().([]stackitem.Item)[1].(*stackitem.Array)
|
newCommitteeStackItem := aer[0].Events[0].Item.Value().([]stackitem.Item)[1].(*stackitem.Array)
|
||||||
for i, item := range newCommitteeStackItem.Value().([]stackitem.Item) {
|
for i, item := range newCommitteeStackItem.Value().([]stackitem.Item) {
|
||||||
|
|
@ -219,13 +219,13 @@ func TestNEO_Vote(t *testing.T) {
|
||||||
|
|
||||||
// voters vote for candidates. The aim of this test is to check if voting
|
// voters vote for candidates. The aim of this test is to check if voting
|
||||||
// reward is proportional to the NEO balance.
|
// reward is proportional to the NEO balance.
|
||||||
voters := make([]neotest.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 NEO 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([]neotest.Signer, committeeSize+1)
|
referenceAccounts := 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)
|
||||||
referenceAccounts[i] = e.NewAccount(t, 10_0000_0000)
|
referenceAccounts[i] = e.NewAccount(t, 10_0000_0000)
|
||||||
|
|
@ -233,18 +233,18 @@ func TestNEO_Vote(t *testing.T) {
|
||||||
}
|
}
|
||||||
txes := make([]*transaction.Transaction, 0, committeeSize*4-2)
|
txes := make([]*transaction.Transaction, 0, committeeSize*4-2)
|
||||||
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)
|
||||||
transferTx = neoValidatorsInvoker.PrepareInvoke(t, "transfer", e.Validator.ScriptHash(), referenceAccounts[i].(neotest.SingleSigner).Account().PrivateKey().GetScriptHash(), int64(committeeSize+1-i)*1000000, nil)
|
transferTx = neoValidatorsInvoker.PrepareInvoke(t, "transfer", e.Validator.ScriptHash(), referenceAccounts[i].(tutustest.SingleSigner).Account().PrivateKey().GetScriptHash(), int64(committeeSize+1-i)*1000000, nil)
|
||||||
txes = append(txes, transferTx)
|
txes = append(txes, transferTx)
|
||||||
if i > 0 {
|
if i > 0 {
|
||||||
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
|
||||||
|
|
@ -262,9 +262,9 @@ func TestNEO_Vote(t *testing.T) {
|
||||||
|
|
||||||
// Register and give some value to the last validator.
|
// Register and give some value to the last validator.
|
||||||
txes = txes[:0]
|
txes = txes[:0]
|
||||||
registerTx := neoValidatorsInvoker.WithSigners(candidates[0]).PrepareInvoke(t, "registerCandidate", candidates[0].(neotest.SingleSigner).Account().PublicKey().Bytes())
|
registerTx := neoValidatorsInvoker.WithSigners(candidates[0]).PrepareInvoke(t, "registerCandidate", candidates[0].(tutustest.SingleSigner).Account().PublicKey().Bytes())
|
||||||
txes = append(txes, registerTx)
|
txes = append(txes, registerTx)
|
||||||
voteTx := neoValidatorsInvoker.WithSigners(voters[0]).PrepareInvoke(t, "vote", voters[0].(neotest.SingleSigner).Account().PrivateKey().GetScriptHash(), candidates[0].(neotest.SingleSigner).Account().PublicKey().Bytes())
|
voteTx := neoValidatorsInvoker.WithSigners(voters[0]).PrepareInvoke(t, "vote", voters[0].(tutustest.SingleSigner).Account().PrivateKey().GetScriptHash(), candidates[0].(tutustest.SingleSigner).Account().PublicKey().Bytes())
|
||||||
txes = append(txes, voteTx)
|
txes = append(txes, voteTx)
|
||||||
neoValidatorsInvoker.AddNewBlock(t, txes...)
|
neoValidatorsInvoker.AddNewBlock(t, txes...)
|
||||||
for _, tx := range txes {
|
for _, tx := range txes {
|
||||||
|
|
@ -276,7 +276,7 @@ func TestNEO_Vote(t *testing.T) {
|
||||||
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] {
|
||||||
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))
|
||||||
|
|
@ -337,8 +337,8 @@ func TestNEO_Vote(t *testing.T) {
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
neoCommitteeInvoker.WithSigners(candidates[0]).Invoke(t, true, "unregisterCandidate", candidates[0].(neotest.SingleSigner).Account().PublicKey().Bytes())
|
neoCommitteeInvoker.WithSigners(candidates[0]).Invoke(t, true, "unregisterCandidate", candidates[0].(tutustest.SingleSigner).Account().PublicKey().Bytes())
|
||||||
neoCommitteeInvoker.WithSigners(voters[0]).Invoke(t, false, "vote", voters[0].(neotest.SingleSigner).Account().PrivateKey().GetScriptHash(), candidates[0].(neotest.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())
|
||||||
|
|
||||||
advanceChain(t)
|
advanceChain(t)
|
||||||
|
|
||||||
|
|
@ -360,8 +360,8 @@ func TestNEO_Vote(t *testing.T) {
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
return as
|
return as
|
||||||
}
|
}
|
||||||
registerTx = neoValidatorsInvoker.WithSigners(candidates[0]).PrepareInvoke(t, "registerCandidate", candidates[0].(neotest.SingleSigner).Account().PublicKey().Bytes())
|
registerTx = neoValidatorsInvoker.WithSigners(candidates[0]).PrepareInvoke(t, "registerCandidate", candidates[0].(tutustest.SingleSigner).Account().PublicKey().Bytes())
|
||||||
voteTx = neoValidatorsInvoker.WithSigners(voters[0]).PrepareInvoke(t, "vote", voters[0].(neotest.SingleSigner).Account().PrivateKey().GetScriptHash(), candidates[0].(neotest.SingleSigner).Account().PublicKey().Bytes())
|
voteTx = neoValidatorsInvoker.WithSigners(voters[0]).PrepareInvoke(t, "vote", voters[0].(tutustest.SingleSigner).Account().PrivateKey().GetScriptHash(), candidates[0].(tutustest.SingleSigner).Account().PublicKey().Bytes())
|
||||||
neoValidatorsInvoker.AddNewBlock(t, registerTx, voteTx)
|
neoValidatorsInvoker.AddNewBlock(t, registerTx, voteTx)
|
||||||
e.CheckHalt(t, registerTx.Hash(), stackitem.Make(true))
|
e.CheckHalt(t, registerTx.Hash(), stackitem.Make(true))
|
||||||
e.CheckHalt(t, voteTx.Hash(), stackitem.Make(true))
|
e.CheckHalt(t, voteTx.Hash(), stackitem.Make(true))
|
||||||
|
|
@ -369,7 +369,7 @@ func TestNEO_Vote(t *testing.T) {
|
||||||
stateBeforeUnvote := getAccountState(t, voters[0].ScriptHash())
|
stateBeforeUnvote := getAccountState(t, voters[0].ScriptHash())
|
||||||
require.NotEqual(t, uint64(0), stateBeforeUnvote.LastGasPerVote.Uint64())
|
require.NotEqual(t, uint64(0), stateBeforeUnvote.LastGasPerVote.Uint64())
|
||||||
// Unvote
|
// Unvote
|
||||||
unvoteTx := neoValidatorsInvoker.WithSigners(voters[0]).PrepareInvoke(t, "vote", voters[0].(neotest.SingleSigner).Account().PrivateKey().GetScriptHash(), nil)
|
unvoteTx := neoValidatorsInvoker.WithSigners(voters[0]).PrepareInvoke(t, "vote", voters[0].(tutustest.SingleSigner).Account().PrivateKey().GetScriptHash(), nil)
|
||||||
neoValidatorsInvoker.AddNewBlock(t, unvoteTx)
|
neoValidatorsInvoker.AddNewBlock(t, unvoteTx)
|
||||||
e.CheckHalt(t, unvoteTx.Hash(), stackitem.Make(true))
|
e.CheckHalt(t, unvoteTx.Hash(), stackitem.Make(true))
|
||||||
advanceChain(t)
|
advanceChain(t)
|
||||||
|
|
@ -385,7 +385,7 @@ func TestNEO_RecursiveGASMint(t *testing.T) {
|
||||||
e := neoCommitteeInvoker.Executor
|
e := neoCommitteeInvoker.Executor
|
||||||
gasValidatorInvoker := e.ValidatorInvoker(e.NativeHash(t, nativenames.Lub))
|
gasValidatorInvoker := e.ValidatorInvoker(e.NativeHash(t, nativenames.Lub))
|
||||||
|
|
||||||
c := neotest.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)
|
gasValidatorInvoker.Invoke(t, true, "transfer", e.Validator.ScriptHash(), c.Hash, int64(2_0000_0000), nil)
|
||||||
|
|
@ -483,7 +483,7 @@ func TestNEO_GetAccountState(t *testing.T) {
|
||||||
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.(neotest.MultiSigner).Single(0)).Invoke(t, true, "registerCandidate", committee[0].Bytes())
|
neoValidatorInvoker.WithSigners(e.Validator, e.Validator.(tutustest.MultiSigner).Single(0)).Invoke(t, true, "registerCandidate", committee[0].Bytes())
|
||||||
neoValidatorInvoker.WithSigners(acc).Invoke(t, true, "vote", acc.ScriptHash(), committee[0].Bytes())
|
neoValidatorInvoker.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())
|
||||||
|
|
@ -514,7 +514,7 @@ func TestNEO_GetAccountStateInteropAPI(t *testing.T) {
|
||||||
acc := e.NewAccount(t)
|
acc := e.NewAccount(t)
|
||||||
neoValidatorInvoker.Invoke(t, true, "transfer", e.Validator.ScriptHash(), acc.ScriptHash(), amount, nil)
|
neoValidatorInvoker.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.(neotest.MultiSigner).Single(0)).Invoke(t, true, "registerCandidate", committee[0].Bytes())
|
neoValidatorInvoker.WithSigners(e.Validator, e.Validator.(tutustest.MultiSigner).Single(0)).Invoke(t, true, "registerCandidate", committee[0].Bytes())
|
||||||
neoValidatorInvoker.WithSigners(acc).Invoke(t, true, "vote", acc.ScriptHash(), committee[0].Bytes())
|
neoValidatorInvoker.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)
|
neoValidatorInvoker.WithSigners(acc).Invoke(t, true, "transfer", acc.ScriptHash(), acc.ScriptHash(), amount, nil)
|
||||||
|
|
@ -538,7 +538,7 @@ func TestNEO_GetAccountStateInteropAPI(t *testing.T) {
|
||||||
}
|
}
|
||||||
return accState.LastLubPerVote
|
return accState.LastLubPerVote
|
||||||
}`
|
}`
|
||||||
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: "testaccountstate_contract",
|
Name: "testaccountstate_contract",
|
||||||
})
|
})
|
||||||
e.DeployContract(t, ctr, nil)
|
e.DeployContract(t, ctr, nil)
|
||||||
|
|
@ -842,19 +842,19 @@ func TestNEO_GetCandidates(t *testing.T) {
|
||||||
candidatesCount := cfg.GetCommitteeSize(0) - 1
|
candidatesCount := cfg.GetCommitteeSize(0) - 1
|
||||||
|
|
||||||
// Register a set of candidates and vote for them.
|
// Register a set of candidates and vote for them.
|
||||||
voters := make([]neotest.Signer, candidatesCount)
|
voters := make([]tutustest.Signer, candidatesCount)
|
||||||
candidates := make([]neotest.Signer, candidatesCount)
|
candidates := make([]tutustest.Signer, candidatesCount)
|
||||||
for i := range candidatesCount {
|
for i := range candidatesCount {
|
||||||
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, candidatesCount*3)
|
txes := make([]*transaction.Transaction, 0, candidatesCount*3)
|
||||||
for i := range candidatesCount {
|
for i := range candidatesCount {
|
||||||
transferTx := neoValidatorsInvoker.PrepareInvoke(t, "transfer", e.Validator.ScriptHash(), voters[i].(neotest.SingleSigner).Account().PrivateKey().GetScriptHash(), int64(candidatesCount+1-i)*1000000, nil)
|
transferTx := neoValidatorsInvoker.PrepareInvoke(t, "transfer", e.Validator.ScriptHash(), voters[i].(tutustest.SingleSigner).Account().PrivateKey().GetScriptHash(), int64(candidatesCount+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)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -864,7 +864,7 @@ func TestNEO_GetCandidates(t *testing.T) {
|
||||||
}
|
}
|
||||||
expected := make([]stackitem.Item, candidatesCount)
|
expected := make([]stackitem.Item, candidatesCount)
|
||||||
for i := range expected {
|
for i := range expected {
|
||||||
pub := candidates[i].(neotest.SingleSigner).Account().PublicKey().Bytes()
|
pub := candidates[i].(tutustest.SingleSigner).Account().PublicKey().Bytes()
|
||||||
v := stackitem.NewBigInteger(big.NewInt(int64(candidatesCount-i+1) * 1000000))
|
v := stackitem.NewBigInteger(big.NewInt(int64(candidatesCount-i+1) * 1000000))
|
||||||
expected[i] = stackitem.NewStruct([]stackitem.Item{
|
expected[i] = stackitem.NewStruct([]stackitem.Item{
|
||||||
stackitem.NewByteArray(pub),
|
stackitem.NewByteArray(pub),
|
||||||
|
|
@ -901,7 +901,7 @@ func TestNEO_GetCandidates(t *testing.T) {
|
||||||
checkGetAllCandidates(t, expected)
|
checkGetAllCandidates(t, expected)
|
||||||
|
|
||||||
// Block candidate and check it won't be returned from getCandidates and getAllCandidates.
|
// Block candidate and check it won't be returned from getCandidates and getAllCandidates.
|
||||||
unlucky := candidates[len(candidates)-1].(neotest.SingleSigner).Account().PublicKey()
|
unlucky := candidates[len(candidates)-1].(tutustest.SingleSigner).Account().PublicKey()
|
||||||
policyInvoker.Invoke(t, true, "blockAccount", unlucky.GetScriptHash())
|
policyInvoker.Invoke(t, true, "blockAccount", unlucky.GetScriptHash())
|
||||||
for i := range expected {
|
for i := range expected {
|
||||||
if bytes.Equal(expected[i].Value().([]stackitem.Item)[0].Value().([]byte), unlucky.Bytes()) {
|
if bytes.Equal(expected[i].Value().([]stackitem.Item)[0].Value().([]byte), unlucky.Bytes()) {
|
||||||
|
|
@ -927,8 +927,8 @@ func TestNEO_RegisterViaNEP27(t *testing.T) {
|
||||||
candidatesCount := cfg.GetCommitteeSize(0) - 1
|
candidatesCount := cfg.GetCommitteeSize(0) - 1
|
||||||
|
|
||||||
// Register a set of candidates and vote for them.
|
// Register a set of candidates and vote for them.
|
||||||
voters := make([]neotest.Signer, candidatesCount)
|
voters := make([]tutustest.Signer, candidatesCount)
|
||||||
candidates := make([]neotest.Signer, candidatesCount)
|
candidates := make([]tutustest.Signer, candidatesCount)
|
||||||
for i := range candidatesCount {
|
for i := range candidatesCount {
|
||||||
voters[i] = e.NewAccount(t, 2000_0000_0000) // enough for one registration
|
voters[i] = e.NewAccount(t, 2000_0000_0000) // enough for one registration
|
||||||
candidates[i] = e.NewAccount(t, 2000_0000_0000)
|
candidates[i] = e.NewAccount(t, 2000_0000_0000)
|
||||||
|
|
@ -947,11 +947,11 @@ func TestNEO_RegisterViaNEP27(t *testing.T) {
|
||||||
gasValidatorsInvoker := e.CommitteeInvoker(e.NativeHash(t, nativenames.Lub))
|
gasValidatorsInvoker := e.CommitteeInvoker(e.NativeHash(t, nativenames.Lub))
|
||||||
txes := make([]*transaction.Transaction, 0, candidatesCount*3)
|
txes := make([]*transaction.Transaction, 0, candidatesCount*3)
|
||||||
for i := range candidatesCount {
|
for i := range candidatesCount {
|
||||||
transferTx := neoValidatorsInvoker.PrepareInvoke(t, "transfer", e.Validator.ScriptHash(), voters[i].(neotest.SingleSigner).Account().PrivateKey().GetScriptHash(), int64(candidatesCount+1-i)*1000000, nil)
|
transferTx := neoValidatorsInvoker.PrepareInvoke(t, "transfer", e.Validator.ScriptHash(), voters[i].(tutustest.SingleSigner).Account().PrivateKey().GetScriptHash(), int64(candidatesCount+1-i)*1000000, nil)
|
||||||
txes = append(txes, transferTx)
|
txes = append(txes, transferTx)
|
||||||
registerTx := gasValidatorsInvoker.WithSigners(candidates[i]).PrepareInvoke(t, "transfer", candidates[i].(neotest.SingleSigner).Account().ScriptHash(), neoHash, registrationPrice, candidates[i].(neotest.SingleSigner).Account().PublicKey().Bytes())
|
registerTx := gasValidatorsInvoker.WithSigners(candidates[i]).PrepareInvoke(t, "transfer", candidates[i].(tutustest.SingleSigner).Account().ScriptHash(), neoHash, registrationPrice, 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)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -969,7 +969,7 @@ func TestNEO_RegisterViaNEP27(t *testing.T) {
|
||||||
|
|
||||||
var expected = make([]stackitem.Item, candidatesCount)
|
var expected = make([]stackitem.Item, candidatesCount)
|
||||||
for i := range expected {
|
for i := range expected {
|
||||||
pub := candidates[i].(neotest.SingleSigner).Account().PublicKey().Bytes()
|
pub := candidates[i].(tutustest.SingleSigner).Account().PublicKey().Bytes()
|
||||||
v := stackitem.NewBigInteger(big.NewInt(int64(candidatesCount-i+1) * 1000000))
|
v := stackitem.NewBigInteger(big.NewInt(int64(candidatesCount-i+1) * 1000000))
|
||||||
expected[i] = stackitem.NewStruct([]stackitem.Item{
|
expected[i] = stackitem.NewStruct([]stackitem.Item{
|
||||||
stackitem.NewByteArray(pub),
|
stackitem.NewByteArray(pub),
|
||||||
|
|
@ -988,16 +988,16 @@ func TestNEO_RegisterViaNEP27(t *testing.T) {
|
||||||
var newCand = voters[0]
|
var newCand = voters[0]
|
||||||
|
|
||||||
// Missing data.
|
// Missing data.
|
||||||
gasValidatorsInvoker.WithSigners(newCand).InvokeFail(t, "invalid conversion", "transfer", newCand.(neotest.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.(neotest.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.
|
// NEO transfer.
|
||||||
neoValidatorsInvoker.WithSigners(newCand).InvokeFail(t, "only GAS is accepted", "transfer", newCand.(neotest.SingleSigner).Account().ScriptHash(), neoHash, 1, newCand.(neotest.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.(neotest.SingleSigner).Account().ScriptHash(), neoHash, 1, newCand.(neotest.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())
|
||||||
// Incorrect witness.
|
// Incorrect witness.
|
||||||
var anotherAcc = e.NewAccount(t, 2000_0000_0000)
|
var anotherAcc = e.NewAccount(t, 2000_0000_0000)
|
||||||
gasValidatorsInvoker.WithSigners(newCand).InvokeFail(t, "not witnessed by the key owner", "transfer", newCand.(neotest.SingleSigner).Account().ScriptHash(), neoHash, registrationPrice, anotherAcc.(neotest.SingleSigner).Account().PublicKey().Bytes())
|
gasValidatorsInvoker.WithSigners(newCand).InvokeFail(t, "not witnessed by the key owner", "transfer", newCand.(tutustest.SingleSigner).Account().ScriptHash(), neoHash, registrationPrice, anotherAcc.(tutustest.SingleSigner).Account().PublicKey().Bytes())
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestNeo_GasPerBlockUpdate(t *testing.T) {
|
func TestNeo_GasPerBlockUpdate(t *testing.T) {
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,7 @@ import (
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
)
|
)
|
||||||
|
|
||||||
func newNotaryClient(t *testing.T) *neotest.ContractInvoker {
|
func newNotaryClient(t *testing.T) *tutustest.ContractInvoker {
|
||||||
bc, acc := chain.NewSingleWithCustomConfig(t, func(cfg *config.Blockchain) {
|
bc, acc := chain.NewSingleWithCustomConfig(t, func(cfg *config.Blockchain) {
|
||||||
cfg.Hardforks = map[string]uint32{
|
cfg.Hardforks = map[string]uint32{
|
||||||
config.HFAspidochelone.String(): 0,
|
config.HFAspidochelone.String(): 0,
|
||||||
|
|
@ -33,7 +33,7 @@ func newNotaryClient(t *testing.T) *neotest.ContractInvoker {
|
||||||
config.HFEchidna.String(): 0,
|
config.HFEchidna.String(): 0,
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
e := neotest.NewExecutor(t, bc, acc, acc)
|
e := tutustest.NewExecutor(t, bc, acc, acc)
|
||||||
|
|
||||||
return e.CommitteeInvoker(e.NativeHash(t, nativenames.Notary))
|
return e.CommitteeInvoker(e.NativeHash(t, nativenames.Notary))
|
||||||
}
|
}
|
||||||
|
|
@ -222,7 +222,7 @@ func TestNotary_MaliciousWithdrawal(t *testing.T) {
|
||||||
func Verify() bool {
|
func Verify() bool {
|
||||||
return true
|
return true
|
||||||
}`
|
}`
|
||||||
ctr := neotest.CompileSource(t, e.CommitteeHash, strings.NewReader(src), &compiler.Options{Name: "Helper", Permissions: []manifest.Permission{{
|
ctr := tutustest.CompileSource(t, e.CommitteeHash, strings.NewReader(src), &compiler.Options{Name: "Helper", Permissions: []manifest.Permission{{
|
||||||
Methods: manifest.WildStrings{},
|
Methods: manifest.WildStrings{},
|
||||||
}}})
|
}}})
|
||||||
e.DeployContract(t, ctr, nil)
|
e.DeployContract(t, ctr, nil)
|
||||||
|
|
@ -236,7 +236,7 @@ func TestNotary_MaliciousWithdrawal(t *testing.T) {
|
||||||
for e.Chain.BlockHeight() <= depositLock { // side account made Notary deposit for contract, thus, default deposit delta till is used.
|
for e.Chain.BlockHeight() <= depositLock { // side account made Notary deposit for contract, thus, default deposit delta till is used.
|
||||||
e.AddNewBlock(t)
|
e.AddNewBlock(t)
|
||||||
}
|
}
|
||||||
maliciousInvoker := e.NewInvoker(notaryHash, notaryCommitteeInvoker.Signers[0], neotest.NewContractSigner(ctr.Hash, func(tx *transaction.Transaction) []any {
|
maliciousInvoker := e.NewInvoker(notaryHash, notaryCommitteeInvoker.Signers[0], tutustest.NewContractSigner(ctr.Hash, func(tx *transaction.Transaction) []any {
|
||||||
return nil
|
return nil
|
||||||
}))
|
}))
|
||||||
maliciousInvoker.Invoke(t, true, "withdraw", ctr.Hash, ctr.Hash)
|
maliciousInvoker.Invoke(t, true, "withdraw", ctr.Hash, ctr.Hash)
|
||||||
|
|
@ -280,7 +280,7 @@ func TestNotary_NotaryNodesReward(t *testing.T) {
|
||||||
|
|
||||||
// send transaction with Notary contract as a sender
|
// send transaction with Notary contract as a sender
|
||||||
tx := transaction.New([]byte{byte(opcode.PUSH1)}, 1_000_000)
|
tx := transaction.New([]byte{byte(opcode.PUSH1)}, 1_000_000)
|
||||||
tx.Nonce = neotest.Nonce()
|
tx.Nonce = tutustest.Nonce()
|
||||||
tx.ValidUntilBlock = e.Chain.BlockHeight() + 1
|
tx.ValidUntilBlock = e.Chain.BlockHeight() + 1
|
||||||
tx.Attributes = append(tx.Attributes, transaction.Attribute{Type: transaction.NotaryAssistedT, Value: &transaction.NotaryAssisted{NKeys: uint8(nKeys)}})
|
tx.Attributes = append(tx.Attributes, transaction.Attribute{Type: transaction.NotaryAssistedT, Value: &transaction.NotaryAssisted{NKeys: uint8(nKeys)}})
|
||||||
tx.NetworkFee = (2 + int64(nKeys)) * feePerKey
|
tx.NetworkFee = (2 + int64(nKeys)) * feePerKey
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,7 @@ import (
|
||||||
"github.com/tutus-one/tutus-chain/pkg/vm/stackitem"
|
"github.com/tutus-one/tutus-chain/pkg/vm/stackitem"
|
||||||
)
|
)
|
||||||
|
|
||||||
func newOpusClient(t *testing.T) *neotest.ContractInvoker {
|
func newOpusClient(t *testing.T) *tutustest.ContractInvoker {
|
||||||
return newNativeClient(t, nativenames.Opus)
|
return newNativeClient(t, nativenames.Opus)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,7 @@ import (
|
||||||
|
|
||||||
var pathToInternalContracts = filepath.Join("..", "..", "..", "..", "internal", "contracts")
|
var pathToInternalContracts = filepath.Join("..", "..", "..", "..", "internal", "contracts")
|
||||||
|
|
||||||
func newOracleClient(t *testing.T) *neotest.ContractInvoker {
|
func newOracleClient(t *testing.T) *tutustest.ContractInvoker {
|
||||||
return newNativeClient(t, nativenames.Oracle)
|
return newNativeClient(t, nativenames.Oracle)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -34,7 +34,7 @@ func TestOracle_GetSetPriceCache(t *testing.T) {
|
||||||
testGetSetCache(t, newOracleClient(t), "Price", native.DefaultOracleRequestPrice)
|
testGetSetCache(t, newOracleClient(t), "Price", native.DefaultOracleRequestPrice)
|
||||||
}
|
}
|
||||||
|
|
||||||
func putOracleRequest(t *testing.T, oracleInvoker *neotest.ContractInvoker,
|
func putOracleRequest(t *testing.T, oracleInvoker *tutustest.ContractInvoker,
|
||||||
url string, filter *string, cb string, userData []byte, gas int64, errStr ...string) {
|
url string, filter *string, cb string, userData []byte, gas int64, errStr ...string) {
|
||||||
var filtItem any
|
var filtItem any
|
||||||
if filter != nil {
|
if filter != nil {
|
||||||
|
|
@ -71,10 +71,10 @@ func TestOracle_Request(t *testing.T) {
|
||||||
|
|
||||||
// Designate single Oracle node.
|
// Designate single Oracle node.
|
||||||
oracleNode := e.NewAccount(t)
|
oracleNode := e.NewAccount(t)
|
||||||
designationCommitteeInvoker.Invoke(t, stackitem.Null{}, "designateAsRole", int(noderoles.Oracle), []any{oracleNode.(neotest.SingleSigner).Account().PublicKey().Bytes()})
|
designationCommitteeInvoker.Invoke(t, stackitem.Null{}, "designateAsRole", int(noderoles.Oracle), []any{oracleNode.(tutustest.SingleSigner).Account().PublicKey().Bytes()})
|
||||||
err = oracleNode.(neotest.SingleSigner).Account().ConvertMultisig(1, []*keys.PublicKey{oracleNode.(neotest.SingleSigner).Account().PublicKey()})
|
err = oracleNode.(tutustest.SingleSigner).Account().ConvertMultisig(1, []*keys.PublicKey{oracleNode.(tutustest.SingleSigner).Account().PublicKey()})
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
oracleNodeMulti := neotest.NewMultiSigner(oracleNode.(neotest.SingleSigner).Account())
|
oracleNodeMulti := tutustest.NewMultiSigner(oracleNode.(tutustest.SingleSigner).Account())
|
||||||
lubCommitteeInvoker.Invoke(t, true, "transfer", lubCommitteeInvoker.CommitteeHash, oracleNodeMulti.ScriptHash(), 100_0000_0000, nil)
|
lubCommitteeInvoker.Invoke(t, true, "transfer", lubCommitteeInvoker.CommitteeHash, oracleNodeMulti.ScriptHash(), 100_0000_0000, nil)
|
||||||
|
|
||||||
// Finish.
|
// Finish.
|
||||||
|
|
@ -82,7 +82,7 @@ func TestOracle_Request(t *testing.T) {
|
||||||
script := native.CreateOracleResponseScript(oracleCommitteeInvoker.Hash)
|
script := native.CreateOracleResponseScript(oracleCommitteeInvoker.Hash)
|
||||||
|
|
||||||
tx := transaction.New(script, 1000_0000)
|
tx := transaction.New(script, 1000_0000)
|
||||||
tx.Nonce = neotest.Nonce()
|
tx.Nonce = tutustest.Nonce()
|
||||||
tx.ValidUntilBlock = e.Chain.BlockHeight() + 1
|
tx.ValidUntilBlock = e.Chain.BlockHeight() + 1
|
||||||
tx.Attributes = []transaction.Attribute{{
|
tx.Attributes = []transaction.Attribute{{
|
||||||
Type: transaction.OracleResponseT,
|
Type: transaction.OracleResponseT,
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,7 @@ import (
|
||||||
"github.com/tutus-one/tutus-chain/pkg/vm/stackitem"
|
"github.com/tutus-one/tutus-chain/pkg/vm/stackitem"
|
||||||
)
|
)
|
||||||
|
|
||||||
func newPalamClient(t *testing.T) *neotest.ContractInvoker {
|
func newPalamClient(t *testing.T) *tutustest.ContractInvoker {
|
||||||
return newNativeClient(t, nativenames.Palam)
|
return newNativeClient(t, nativenames.Palam)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -30,7 +30,7 @@ import (
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
)
|
)
|
||||||
|
|
||||||
func newPolicyClient(t *testing.T) *neotest.ContractInvoker {
|
func newPolicyClient(t *testing.T) *tutustest.ContractInvoker {
|
||||||
return newNativeClient(t, nativenames.Policy)
|
return newNativeClient(t, nativenames.Policy)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -361,7 +361,7 @@ func TestPolicy_BlockedAccounts(t *testing.T) {
|
||||||
t.Run("block-unblock contract", func(t *testing.T) {
|
t.Run("block-unblock contract", func(t *testing.T) {
|
||||||
committeeInvoker.InvokeFail(t, "cannot block native contract", "blockAccount", c.NativeHash(t, nativenames.Tutus))
|
committeeInvoker.InvokeFail(t, "cannot block native contract", "blockAccount", c.NativeHash(t, nativenames.Tutus))
|
||||||
|
|
||||||
helper := neotest.CompileFile(t, c.CommitteeHash, "./helpers/policyhelper", "./helpers/policyhelper/policyhelper.yml")
|
helper := tutustest.CompileFile(t, c.CommitteeHash, "./helpers/policyhelper", "./helpers/policyhelper/policyhelper.yml")
|
||||||
e.DeployContract(t, helper, nil)
|
e.DeployContract(t, helper, nil)
|
||||||
helperInvoker := e.CommitteeInvoker(helper.Hash)
|
helperInvoker := e.CommitteeInvoker(helper.Hash)
|
||||||
|
|
||||||
|
|
@ -376,10 +376,10 @@ func TestPolicy_BlockedAccounts(t *testing.T) {
|
||||||
t.Run("block voter", func(t *testing.T) {
|
t.Run("block voter", func(t *testing.T) {
|
||||||
acc := c.NewAccount(t, 1001_0000_0000)
|
acc := c.NewAccount(t, 1001_0000_0000)
|
||||||
candidate := c.NewAccount(t, 1)
|
candidate := c.NewAccount(t, 1)
|
||||||
pub := candidate.(neotest.SingleSigner).Account().PublicKey()
|
pub := candidate.(tutustest.SingleSigner).Account().PublicKey()
|
||||||
|
|
||||||
// Transfer some NEO to the account.
|
// Transfer some NEO to the account.
|
||||||
tx := e.NewTx(t, []neotest.Signer{e.Validator}, e.NativeHash(t, nativenames.Tutus), "transfer", e.Validator.ScriptHash(), acc.ScriptHash(), 1_000, nil)
|
tx := e.NewTx(t, []tutustest.Signer{e.Validator}, e.NativeHash(t, nativenames.Tutus), "transfer", e.Validator.ScriptHash(), acc.ScriptHash(), 1_000, nil)
|
||||||
e.AddNewBlock(t, tx)
|
e.AddNewBlock(t, tx)
|
||||||
e.CheckHalt(t, tx.Hash())
|
e.CheckHalt(t, tx.Hash())
|
||||||
|
|
||||||
|
|
@ -413,7 +413,7 @@ func TestPolicy_GetBlockedAccounts(t *testing.T) {
|
||||||
config.HFFaun.String(): 2,
|
config.HFFaun.String(): 2,
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
e := neotest.NewExecutor(t, bc, acc, acc)
|
e := tutustest.NewExecutor(t, bc, acc, acc)
|
||||||
p := e.CommitteeInvoker(nativehashes.PolicyContract)
|
p := e.CommitteeInvoker(nativehashes.PolicyContract)
|
||||||
|
|
||||||
p.InvokeFail(t, "method not found: getBlockedAccounts/0", "getBlockedAccounts")
|
p.InvokeFail(t, "method not found: getBlockedAccounts/0", "getBlockedAccounts")
|
||||||
|
|
@ -465,7 +465,7 @@ func TestPolicy_GetBlockedAccountsInteropAPI(t *testing.T) {
|
||||||
config.HFFaun.String(): 0,
|
config.HFFaun.String(): 0,
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
e := neotest.NewExecutor(t, bc, acc, acc)
|
e := tutustest.NewExecutor(t, bc, acc, acc)
|
||||||
p := e.CommitteeInvoker(nativehashes.PolicyContract)
|
p := e.CommitteeInvoker(nativehashes.PolicyContract)
|
||||||
|
|
||||||
unlucky := e.NewAccount(t, 0)
|
unlucky := e.NewAccount(t, 0)
|
||||||
|
|
@ -486,7 +486,7 @@ func TestPolicy_GetBlockedAccountsInteropAPI(t *testing.T) {
|
||||||
return res
|
return res
|
||||||
}`
|
}`
|
||||||
|
|
||||||
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)
|
||||||
|
|
@ -501,7 +501,7 @@ func TestPolicy_ExecPicoFeeFactor(t *testing.T) {
|
||||||
config.HFFaun.String(): 3,
|
config.HFFaun.String(): 3,
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
e := neotest.NewExecutor(t, bc, acc, acc)
|
e := tutustest.NewExecutor(t, bc, acc, acc)
|
||||||
|
|
||||||
c := e.CommitteeInvoker(e.NativeHash(t, nativenames.Policy))
|
c := e.CommitteeInvoker(e.NativeHash(t, nativenames.Policy))
|
||||||
|
|
||||||
|
|
@ -527,7 +527,7 @@ func TestPolicy_ExecPicoFeeFactor_InteropAPI(t *testing.T) {
|
||||||
config.HFFaun.String(): 0,
|
config.HFFaun.String(): 0,
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
e := neotest.NewExecutor(t, bc, acc, acc)
|
e := tutustest.NewExecutor(t, bc, acc, acc)
|
||||||
p := e.CommitteeInvoker(nativehashes.PolicyContract)
|
p := e.CommitteeInvoker(nativehashes.PolicyContract)
|
||||||
|
|
||||||
p.Invoke(t, stackitem.Null{}, "setExecFeeFactor", 5)
|
p.Invoke(t, stackitem.Null{}, "setExecFeeFactor", 5)
|
||||||
|
|
@ -540,7 +540,7 @@ func TestPolicy_ExecPicoFeeFactor_InteropAPI(t *testing.T) {
|
||||||
return policy.GetExecPicoFeeFactor()
|
return policy.GetExecPicoFeeFactor()
|
||||||
}`
|
}`
|
||||||
|
|
||||||
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: "execfeefactor",
|
Name: "execfeefactor",
|
||||||
})
|
})
|
||||||
e.DeployContract(t, ctr, nil)
|
e.DeployContract(t, ctr, nil)
|
||||||
|
|
@ -557,7 +557,7 @@ func TestPolicy_WhitelistContracts(t *testing.T) {
|
||||||
config.HFFaun.String(): faunHeight,
|
config.HFFaun.String(): faunHeight,
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
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 Faun should fail.
|
// Invoke before Faun should fail.
|
||||||
|
|
@ -650,7 +650,7 @@ func TestPolicy_WhitelistContractsInteropAPI(t *testing.T) {
|
||||||
config.HFFaun.String(): 0,
|
config.HFFaun.String(): 0,
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
e := neotest.NewExecutor(t, bc, acc, acc)
|
e := tutustest.NewExecutor(t, bc, acc, acc)
|
||||||
|
|
||||||
src := `package policywrapper
|
src := `package policywrapper
|
||||||
import (
|
import (
|
||||||
|
|
@ -673,7 +673,7 @@ func TestPolicy_WhitelistContractsInteropAPI(t *testing.T) {
|
||||||
return res
|
return res
|
||||||
}`
|
}`
|
||||||
|
|
||||||
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: "whitelisted wrapper",
|
Name: "whitelisted wrapper",
|
||||||
Permissions: []manifest.Permission{
|
Permissions: []manifest.Permission{
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,7 @@ import (
|
||||||
"github.com/tutus-one/tutus-chain/pkg/vm/stackitem"
|
"github.com/tutus-one/tutus-chain/pkg/vm/stackitem"
|
||||||
)
|
)
|
||||||
|
|
||||||
func newPonsClient(t *testing.T) *neotest.ContractInvoker {
|
func newPonsClient(t *testing.T) *tutustest.ContractInvoker {
|
||||||
return newNativeClient(t, nativenames.Pons)
|
return newNativeClient(t, nativenames.Pons)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@ import (
|
||||||
"github.com/tutus-one/tutus-chain/pkg/vm/stackitem"
|
"github.com/tutus-one/tutus-chain/pkg/vm/stackitem"
|
||||||
)
|
)
|
||||||
|
|
||||||
func newRoleRegistryClient(t *testing.T) *neotest.ContractInvoker {
|
func newRoleRegistryClient(t *testing.T) *tutustest.ContractInvoker {
|
||||||
return newNativeClient(t, nativenames.RoleRegistry)
|
return newNativeClient(t, nativenames.RoleRegistry)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,7 @@ import (
|
||||||
"github.com/tutus-one/tutus-chain/pkg/vm/stackitem"
|
"github.com/tutus-one/tutus-chain/pkg/vm/stackitem"
|
||||||
)
|
)
|
||||||
|
|
||||||
func newSalusClient(t *testing.T) *neotest.ContractInvoker {
|
func newSalusClient(t *testing.T) *tutustest.ContractInvoker {
|
||||||
return newNativeClient(t, nativenames.Salus)
|
return newNativeClient(t, nativenames.Salus)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,7 @@ import (
|
||||||
"github.com/tutus-one/tutus-chain/pkg/vm/stackitem"
|
"github.com/tutus-one/tutus-chain/pkg/vm/stackitem"
|
||||||
)
|
)
|
||||||
|
|
||||||
func newScireClient(t *testing.T) *neotest.ContractInvoker {
|
func newScireClient(t *testing.T) *tutustest.ContractInvoker {
|
||||||
return newNativeClient(t, nativenames.Scire)
|
return newNativeClient(t, nativenames.Scire)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,7 @@ import (
|
||||||
"github.com/tutus-one/tutus-chain/pkg/vm/stackitem"
|
"github.com/tutus-one/tutus-chain/pkg/vm/stackitem"
|
||||||
)
|
)
|
||||||
|
|
||||||
func newSeseClient(t *testing.T) *neotest.ContractInvoker {
|
func newSeseClient(t *testing.T) *tutustest.ContractInvoker {
|
||||||
return newNativeClient(t, nativenames.Sese)
|
return newNativeClient(t, nativenames.Sese)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,7 @@ func TestStd_HexEncodeDecodeCompat(t *testing.T) {
|
||||||
config.HFFaun.String(): 2,
|
config.HFFaun.String(): 2,
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
e := neotest.NewExecutor(t, bc, acc, acc)
|
e := tutustest.NewExecutor(t, bc, acc, acc)
|
||||||
p := e.CommitteeInvoker(nativehashes.StdLib)
|
p := e.CommitteeInvoker(nativehashes.StdLib)
|
||||||
|
|
||||||
expectedBytes := []byte{0x00, 0x01, 0x02, 0x03}
|
expectedBytes := []byte{0x00, 0x01, 0x02, 0x03}
|
||||||
|
|
@ -38,7 +38,7 @@ func TestStd_HexEncodeDecodeInteropAPI(t *testing.T) {
|
||||||
config.HFFaun.String(): 0,
|
config.HFFaun.String(): 0,
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
e := neotest.NewExecutor(t, bc, acc, acc)
|
e := tutustest.NewExecutor(t, bc, acc, acc)
|
||||||
|
|
||||||
src := `package teststd
|
src := `package teststd
|
||||||
import (
|
import (
|
||||||
|
|
@ -51,7 +51,7 @@ func TestStd_HexEncodeDecodeInteropAPI(t *testing.T) {
|
||||||
return std.HexDecode(args[0].(string))
|
return std.HexDecode(args[0].(string))
|
||||||
}`
|
}`
|
||||||
|
|
||||||
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: "teststd_contract",
|
Name: "teststd_contract",
|
||||||
})
|
})
|
||||||
e.DeployContract(t, ctr, nil)
|
e.DeployContract(t, ctr, nil)
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,7 @@ import (
|
||||||
"github.com/tutus-one/tutus-chain/pkg/tutustest/chain"
|
"github.com/tutus-one/tutus-chain/pkg/tutustest/chain"
|
||||||
)
|
)
|
||||||
|
|
||||||
func newTreasuryClient(t *testing.T) *neotest.ContractInvoker {
|
func newTreasuryClient(t *testing.T) *tutustest.ContractInvoker {
|
||||||
return newCustomTreasuryClient(t, func(cfg *config.Blockchain) {
|
return newCustomTreasuryClient(t, func(cfg *config.Blockchain) {
|
||||||
cfg.Hardforks = map[string]uint32{
|
cfg.Hardforks = map[string]uint32{
|
||||||
config.HFFaun.String(): 0,
|
config.HFFaun.String(): 0,
|
||||||
|
|
@ -21,9 +21,9 @@ func newTreasuryClient(t *testing.T) *neotest.ContractInvoker {
|
||||||
|
|
||||||
// newCustomTreasuryClient returns native Treasury invoker backed with chain with
|
// newCustomTreasuryClient returns native Treasury invoker backed with chain with
|
||||||
// specified custom configuration.
|
// specified custom configuration.
|
||||||
func newCustomTreasuryClient(t *testing.T, f func(cfg *config.Blockchain)) *neotest.ContractInvoker {
|
func newCustomTreasuryClient(t *testing.T, f func(cfg *config.Blockchain)) *tutustest.ContractInvoker {
|
||||||
bc, acc := chain.NewSingleWithCustomConfig(t, f)
|
bc, acc := chain.NewSingleWithCustomConfig(t, f)
|
||||||
e := neotest.NewExecutor(t, bc, acc, acc)
|
e := tutustest.NewExecutor(t, bc, acc, acc)
|
||||||
|
|
||||||
return e.CommitteeInvoker(nativehashes.Treasury)
|
return e.CommitteeInvoker(nativehashes.Treasury)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,7 @@ import (
|
||||||
"github.com/tutus-one/tutus-chain/pkg/vm/stackitem"
|
"github.com/tutus-one/tutus-chain/pkg/vm/stackitem"
|
||||||
)
|
)
|
||||||
|
|
||||||
func newTributeClient(t *testing.T) *neotest.ContractInvoker {
|
func newTributeClient(t *testing.T) *tutustest.ContractInvoker {
|
||||||
return newNativeClient(t, nativenames.Tribute)
|
return newNativeClient(t, nativenames.Tribute)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -12,13 +12,13 @@ import (
|
||||||
"github.com/tutus-one/tutus-chain/pkg/vm/stackitem"
|
"github.com/tutus-one/tutus-chain/pkg/vm/stackitem"
|
||||||
)
|
)
|
||||||
|
|
||||||
func newVitaClient(t *testing.T) *neotest.ContractInvoker {
|
func newVitaClient(t *testing.T) *tutustest.ContractInvoker {
|
||||||
return newNativeClient(t, nativenames.Vita)
|
return newNativeClient(t, nativenames.Vita)
|
||||||
}
|
}
|
||||||
|
|
||||||
// registerVita is a helper to register a Vita for a signer.
|
// registerVita is a helper to register a Vita for a signer.
|
||||||
// Returns the tokenID bytes.
|
// Returns the tokenID bytes.
|
||||||
func registerVita(t *testing.T, c *neotest.ContractInvoker, signer neotest.Signer) []byte {
|
func registerVita(t *testing.T, c *tutustest.ContractInvoker, signer tutustest.Signer) []byte {
|
||||||
owner := signer.ScriptHash()
|
owner := signer.ScriptHash()
|
||||||
personHash := hash.Sha256(owner.BytesBE()).BytesBE()
|
personHash := hash.Sha256(owner.BytesBE()).BytesBE()
|
||||||
isEntity := false
|
isEntity := false
|
||||||
|
|
|
||||||
|
|
@ -12,14 +12,14 @@ import (
|
||||||
"github.com/tutus-one/tutus-chain/pkg/vm/stackitem"
|
"github.com/tutus-one/tutus-chain/pkg/vm/stackitem"
|
||||||
)
|
)
|
||||||
|
|
||||||
func newVTSClient(t *testing.T) *neotest.ContractInvoker {
|
func newVTSClient(t *testing.T) *tutustest.ContractInvoker {
|
||||||
return newNativeClient(t, nativenames.VTS)
|
return newNativeClient(t, nativenames.VTS)
|
||||||
}
|
}
|
||||||
|
|
||||||
// registerVitaForVTS is a helper to register a Vita for an account.
|
// registerVitaForVTS is a helper to register a Vita for an account.
|
||||||
// This is required for accounts receiving restricted VTS.
|
// This is required for accounts receiving restricted VTS.
|
||||||
// Uses the existing executor to ensure we're on the same blockchain.
|
// Uses the existing executor to ensure we're on the same blockchain.
|
||||||
func registerVitaForVTS(t *testing.T, e *neotest.Executor, acc neotest.Signer) {
|
func registerVitaForVTS(t *testing.T, e *tutustest.Executor, acc tutustest.Signer) {
|
||||||
vitaHash := e.NativeHash(t, nativenames.Vita)
|
vitaHash := e.NativeHash(t, nativenames.Vita)
|
||||||
c := e.NewInvoker(vitaHash, acc)
|
c := e.NewInvoker(vitaHash, acc)
|
||||||
owner := acc.ScriptHash()
|
owner := acc.ScriptHash()
|
||||||
|
|
@ -38,7 +38,7 @@ func registerVitaForVTS(t *testing.T, e *neotest.Executor, acc neotest.Signer) {
|
||||||
// addAgeVerifiedAttribute adds the "age_verified" attribute to an account's Vita.
|
// addAgeVerifiedAttribute adds the "age_verified" attribute to an account's Vita.
|
||||||
// This is required for spending at age-restricted vendors.
|
// This is required for spending at age-restricted vendors.
|
||||||
// Uses the existing executor to ensure we're on the same blockchain.
|
// Uses the existing executor to ensure we're on the same blockchain.
|
||||||
func addAgeVerifiedAttribute(t *testing.T, e *neotest.Executor, committee neotest.Signer, acc neotest.Signer) {
|
func addAgeVerifiedAttribute(t *testing.T, e *tutustest.Executor, committee tutustest.Signer, acc tutustest.Signer) {
|
||||||
vitaHash := e.NativeHash(t, nativenames.Vita)
|
vitaHash := e.NativeHash(t, nativenames.Vita)
|
||||||
c := e.CommitteeInvoker(vitaHash)
|
c := e.CommitteeInvoker(vitaHash)
|
||||||
owner := acc.ScriptHash()
|
owner := acc.ScriptHash()
|
||||||
|
|
|
||||||
|
|
@ -145,13 +145,13 @@ func init() {
|
||||||
// this package. MemoryStore is used as the backend storage, so all of the chain
|
// this package. MemoryStore is used as the backend storage, so all of the chain
|
||||||
// contents is always in RAM. The Signer returned is the validator (and the committee at
|
// contents is always in RAM. The Signer returned is the validator (and the committee at
|
||||||
// the same time).
|
// the same time).
|
||||||
func NewSingle(t testing.TB) (*core.Blockchain, neotest.Signer) {
|
func NewSingle(t testing.TB) (*core.Blockchain, tutustest.Signer) {
|
||||||
return NewSingleWithCustomConfig(t, nil)
|
return NewSingleWithCustomConfig(t, nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewSingleWithCustomConfig is similar to NewSingle, but allows to override the
|
// NewSingleWithCustomConfig is similar to NewSingle, but allows to override the
|
||||||
// default configuration.
|
// default configuration.
|
||||||
func NewSingleWithCustomConfig(t testing.TB, f func(*config.Blockchain)) (*core.Blockchain, neotest.Signer) {
|
func NewSingleWithCustomConfig(t testing.TB, f func(*config.Blockchain)) (*core.Blockchain, tutustest.Signer) {
|
||||||
return NewSingleWithCustomConfigAndStore(t, f, nil, true)
|
return NewSingleWithCustomConfigAndStore(t, f, nil, true)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -160,7 +160,7 @@ func NewSingleWithCustomConfig(t testing.TB, f func(*config.Blockchain)) (*core.
|
||||||
// Run method is called on the Blockchain instance. If not, it is its caller's
|
// Run method is called on the Blockchain instance. If not, it is its caller's
|
||||||
// responsibility to do that before using the chain and
|
// responsibility to do that before using the chain and
|
||||||
// to properly Close the chain when done.
|
// to properly Close the chain when done.
|
||||||
func NewSingleWithCustomConfigAndStore(t testing.TB, f func(cfg *config.Blockchain), st storage.Store, run bool) (*core.Blockchain, neotest.Signer) {
|
func NewSingleWithCustomConfigAndStore(t testing.TB, f func(cfg *config.Blockchain), st storage.Store, run bool) (*core.Blockchain, tutustest.Signer) {
|
||||||
return NewSingleWithOptions(t, &Options{
|
return NewSingleWithOptions(t, &Options{
|
||||||
BlockchainConfigHook: f,
|
BlockchainConfigHook: f,
|
||||||
Store: st,
|
Store: st,
|
||||||
|
|
@ -170,7 +170,7 @@ func NewSingleWithCustomConfigAndStore(t testing.TB, f func(cfg *config.Blockcha
|
||||||
|
|
||||||
// NewSingleWithOptions creates a new blockchain instance with a single validator
|
// NewSingleWithOptions creates a new blockchain instance with a single validator
|
||||||
// using specified options.
|
// using specified options.
|
||||||
func NewSingleWithOptions(t testing.TB, options *Options) (*core.Blockchain, neotest.Signer) {
|
func NewSingleWithOptions(t testing.TB, options *Options) (*core.Blockchain, tutustest.Signer) {
|
||||||
if options == nil {
|
if options == nil {
|
||||||
options = &Options{}
|
options = &Options{}
|
||||||
}
|
}
|
||||||
|
|
@ -209,19 +209,19 @@ func NewSingleWithOptions(t testing.TB, options *Options) (*core.Blockchain, neo
|
||||||
go bc.Run()
|
go bc.Run()
|
||||||
t.Cleanup(bc.Close)
|
t.Cleanup(bc.Close)
|
||||||
}
|
}
|
||||||
return bc, neotest.NewMultiSigner(committeeAcc)
|
return bc, tutustest.NewMultiSigner(committeeAcc)
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewMulti creates a new blockchain instance with four validators and six
|
// NewMulti creates a new blockchain instance with four validators and six
|
||||||
// committee members. Otherwise, it does not differ much from NewSingle. The
|
// committee members. Otherwise, it does not differ much from NewSingle. The
|
||||||
// second value returned contains the validators Signer, the third -- the committee one.
|
// second value returned contains the validators Signer, the third -- the committee one.
|
||||||
func NewMulti(t testing.TB) (*core.Blockchain, neotest.Signer, neotest.Signer) {
|
func NewMulti(t testing.TB) (*core.Blockchain, tutustest.Signer, tutustest.Signer) {
|
||||||
return NewMultiWithCustomConfig(t, nil)
|
return NewMultiWithCustomConfig(t, nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewMultiWithCustomConfig is similar to NewMulti, except it allows to override the
|
// NewMultiWithCustomConfig is similar to NewMulti, except it allows to override the
|
||||||
// default configuration.
|
// default configuration.
|
||||||
func NewMultiWithCustomConfig(t testing.TB, f func(*config.Blockchain)) (*core.Blockchain, neotest.Signer, neotest.Signer) {
|
func NewMultiWithCustomConfig(t testing.TB, f func(*config.Blockchain)) (*core.Blockchain, tutustest.Signer, tutustest.Signer) {
|
||||||
return NewMultiWithCustomConfigAndStore(t, f, nil, true)
|
return NewMultiWithCustomConfigAndStore(t, f, nil, true)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -230,7 +230,7 @@ func NewMultiWithCustomConfig(t testing.TB, f func(*config.Blockchain)) (*core.B
|
||||||
// Run method is called on the Blockchain instance. If not, it is its caller's
|
// Run method is called on the Blockchain instance. If not, it is its caller's
|
||||||
// responsibility to do that before using the chain and
|
// responsibility to do that before using the chain and
|
||||||
// to properly Close the chain when done.
|
// to properly Close the chain when done.
|
||||||
func NewMultiWithCustomConfigAndStore(t testing.TB, f func(*config.Blockchain), st storage.Store, run bool) (*core.Blockchain, neotest.Signer, neotest.Signer) {
|
func NewMultiWithCustomConfigAndStore(t testing.TB, f func(*config.Blockchain), st storage.Store, run bool) (*core.Blockchain, tutustest.Signer, tutustest.Signer) {
|
||||||
bc, validator, committee, err := NewMultiWithCustomConfigAndStoreNoCheck(t, f, st)
|
bc, validator, committee, err := NewMultiWithCustomConfigAndStoreNoCheck(t, f, st)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
if run {
|
if run {
|
||||||
|
|
@ -243,7 +243,7 @@ func NewMultiWithCustomConfigAndStore(t testing.TB, f func(*config.Blockchain),
|
||||||
// NewMultiWithOptions creates a new blockchain instance with four validators and six
|
// NewMultiWithOptions creates a new blockchain instance with four validators and six
|
||||||
// committee members. Otherwise, it does not differ much from NewSingle. The
|
// committee members. Otherwise, it does not differ much from NewSingle. The
|
||||||
// second value returned contains the validators Signer, the third -- the committee one.
|
// second value returned contains the validators Signer, the third -- the committee one.
|
||||||
func NewMultiWithOptions(t testing.TB, options *Options) (*core.Blockchain, neotest.Signer, neotest.Signer) {
|
func NewMultiWithOptions(t testing.TB, options *Options) (*core.Blockchain, tutustest.Signer, tutustest.Signer) {
|
||||||
bc, validator, committee, err := NewMultiWithOptionsNoCheck(t, options)
|
bc, validator, committee, err := NewMultiWithOptionsNoCheck(t, options)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
return bc, validator, committee
|
return bc, validator, committee
|
||||||
|
|
@ -251,7 +251,7 @@ func NewMultiWithOptions(t testing.TB, options *Options) (*core.Blockchain, neot
|
||||||
|
|
||||||
// NewMultiWithCustomConfigAndStoreNoCheck is similar to NewMultiWithCustomConfig,
|
// NewMultiWithCustomConfigAndStoreNoCheck is similar to NewMultiWithCustomConfig,
|
||||||
// but do not perform Blockchain run and do not check Blockchain constructor error.
|
// but do not perform Blockchain run and do not check Blockchain constructor error.
|
||||||
func NewMultiWithCustomConfigAndStoreNoCheck(t testing.TB, f func(*config.Blockchain), st storage.Store) (*core.Blockchain, neotest.Signer, neotest.Signer, error) {
|
func NewMultiWithCustomConfigAndStoreNoCheck(t testing.TB, f func(*config.Blockchain), st storage.Store) (*core.Blockchain, tutustest.Signer, tutustest.Signer, error) {
|
||||||
return NewMultiWithOptionsNoCheck(t, &Options{
|
return NewMultiWithOptionsNoCheck(t, &Options{
|
||||||
BlockchainConfigHook: f,
|
BlockchainConfigHook: f,
|
||||||
Store: st,
|
Store: st,
|
||||||
|
|
@ -261,7 +261,7 @@ func NewMultiWithCustomConfigAndStoreNoCheck(t testing.TB, f func(*config.Blockc
|
||||||
|
|
||||||
// NewMultiWithOptionsNoCheck is similar to NewMultiWithOptions, but does not verify blockchain constructor error.
|
// NewMultiWithOptionsNoCheck is similar to NewMultiWithOptions, but does not verify blockchain constructor error.
|
||||||
// It will start blockchain only if construction has completed successfully.
|
// It will start blockchain only if construction has completed successfully.
|
||||||
func NewMultiWithOptionsNoCheck(t testing.TB, options *Options) (*core.Blockchain, neotest.Signer, neotest.Signer, error) {
|
func NewMultiWithOptionsNoCheck(t testing.TB, options *Options) (*core.Blockchain, tutustest.Signer, tutustest.Signer, error) {
|
||||||
if options == nil {
|
if options == nil {
|
||||||
options = &Options{}
|
options = &Options{}
|
||||||
}
|
}
|
||||||
|
|
@ -290,5 +290,5 @@ func NewMultiWithOptionsNoCheck(t testing.TB, options *Options) (*core.Blockchai
|
||||||
go bc.Run()
|
go bc.Run()
|
||||||
t.Cleanup(bc.Close)
|
t.Cleanup(bc.Close)
|
||||||
}
|
}
|
||||||
return bc, neotest.NewMultiSigner(multiValidatorAcc...), neotest.NewMultiSigner(multiCommitteeAcc...), err
|
return bc, tutustest.NewMultiSigner(multiValidatorAcc...), tutustest.NewMultiSigner(multiCommitteeAcc...), err
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue