Merge pull request #896 from nspcc-dev/feature/push
vm: implement new PUSH opcodes
This commit is contained in:
commit
687e30c16f
38 changed files with 489 additions and 637 deletions
|
@ -2,11 +2,11 @@
|
|||
"version": "1.0",
|
||||
"accounts": [
|
||||
{
|
||||
"address": "AQyx83BYr1PkyYhZhUAogaHdhkLVHn6htY",
|
||||
"key": "6PYKYQKRs758NBX4q5k6fSmduZDfEfQyoXMovQU5myKm2h5ArXuYpuMEaN",
|
||||
"address": "ASW1VhcukJRrukCXRipY4BE9d9zy4mAYsR",
|
||||
"key": "6PYNTeMkEZ1Q2MCqkPMgvC2kvRzH6f1sz4Sj9cGcLG4iYb43yQcpThAeap",
|
||||
"label": "",
|
||||
"contract": {
|
||||
"script": "4c2102b3622bf4017bdfe317c58aed5f4c753f206b7db896046fa7d774bbc4bf7f8dc250680a906ad4",
|
||||
"script": "0c2102b3622bf4017bdfe317c58aed5f4c753f206b7db896046fa7d774bbc4bf7f8dc20b680a906ad4",
|
||||
"parameters": [
|
||||
{
|
||||
"name": "parameter0",
|
||||
|
@ -19,11 +19,11 @@
|
|||
"isDefault": false
|
||||
},
|
||||
{
|
||||
"address": "AbHd9dXYUryuCvMgXRUfdR6zC2CJixS6Q6",
|
||||
"key": "6PYKYQKRs758NBX4q5k6fSmduZDfEfQyoXMovQU5myKm2h5ArXuYpuMEaN",
|
||||
"address": "Ad1wDxzcRiRSryvJobNV211Tv7UUiziPXy",
|
||||
"key": "6PYNTeMkEZ1Q2MCqkPMgvC2kvRzH6f1sz4Sj9cGcLG4iYb43yQcpThAeap",
|
||||
"label": "",
|
||||
"contract": {
|
||||
"script": "534c2102103a7f7dd016558597f7960d27c516a4394fd968b9e65155eb4b013e4040406e4c2102a7bc55fe8684e0119768d104ba30795bdcc86619e864add26156723ed185cd624c2102b3622bf4017bdfe317c58aed5f4c753f206b7db896046fa7d774bbc4bf7f8dc24c2103d90c07df63e690ce77912e10ab51acc944b66860237b608c4f8f8309e71ee6995450683073b3bb",
|
||||
"script": "130c2102103a7f7dd016558597f7960d27c516a4394fd968b9e65155eb4b013e4040406e0c2102a7bc55fe8684e0119768d104ba30795bdcc86619e864add26156723ed185cd620c2102b3622bf4017bdfe317c58aed5f4c753f206b7db896046fa7d774bbc4bf7f8dc20c2103d90c07df63e690ce77912e10ab51acc944b66860237b608c4f8f8309e71ee699140b683073b3bb",
|
||||
"parameters": [
|
||||
{
|
||||
"name": "parameter0",
|
||||
|
|
|
@ -2,11 +2,11 @@
|
|||
"version": "1.0",
|
||||
"accounts": [
|
||||
{
|
||||
"address": "AQyx83BYr1PkyYhZhUAogaHdhkLVHn6htY",
|
||||
"key": "6PYKYQKRs758NBX4q5k6fSmduZDfEfQyoXMovQU5myKm2h5ArXuYpuMEaN",
|
||||
"address": "ASW1VhcukJRrukCXRipY4BE9d9zy4mAYsR",
|
||||
"key": "6PYNTeMkEZ1Q2MCqkPMgvC2kvRzH6f1sz4Sj9cGcLG4iYb43yQcpThAeap",
|
||||
"label": "",
|
||||
"contract": {
|
||||
"script": "4c2102b3622bf4017bdfe317c58aed5f4c753f206b7db896046fa7d774bbc4bf7f8dc250680a906ad4",
|
||||
"script": "0c2102b3622bf4017bdfe317c58aed5f4c753f206b7db896046fa7d774bbc4bf7f8dc20b680a906ad4",
|
||||
"parameters": [
|
||||
{
|
||||
"name": "parameter0",
|
||||
|
@ -19,11 +19,11 @@
|
|||
"isDefault": false
|
||||
},
|
||||
{
|
||||
"address": "AbHd9dXYUryuCvMgXRUfdR6zC2CJixS6Q6",
|
||||
"key": "6PYKYQKRs758NBX4q5k6fSmduZDfEfQyoXMovQU5myKm2h5ArXuYpuMEaN",
|
||||
"address": "Ad1wDxzcRiRSryvJobNV211Tv7UUiziPXy",
|
||||
"key": "6PYNTeMkEZ1Q2MCqkPMgvC2kvRzH6f1sz4Sj9cGcLG4iYb43yQcpThAeap",
|
||||
"label": "",
|
||||
"contract": {
|
||||
"script": "534c2102103a7f7dd016558597f7960d27c516a4394fd968b9e65155eb4b013e4040406e4c2102a7bc55fe8684e0119768d104ba30795bdcc86619e864add26156723ed185cd624c2102b3622bf4017bdfe317c58aed5f4c753f206b7db896046fa7d774bbc4bf7f8dc24c2103d90c07df63e690ce77912e10ab51acc944b66860237b608c4f8f8309e71ee6995450683073b3bb",
|
||||
"script": "130c2102103a7f7dd016558597f7960d27c516a4394fd968b9e65155eb4b013e4040406e0c2102a7bc55fe8684e0119768d104ba30795bdcc86619e864add26156723ed185cd620c2102b3622bf4017bdfe317c58aed5f4c753f206b7db896046fa7d774bbc4bf7f8dc20c2103d90c07df63e690ce77912e10ab51acc944b66860237b608c4f8f8309e71ee699140b683073b3bb",
|
||||
"parameters": [
|
||||
{
|
||||
"name": "parameter0",
|
||||
|
@ -44,11 +44,11 @@
|
|||
"isDefault": false
|
||||
},
|
||||
{
|
||||
"address": "Ab3TJfgpa94yDr1WPeXpYQiChTRohBJ6T5",
|
||||
"key": "6PYKYQKRs758NBX4q5k6fSmduZDfEfQyoXMovQU5myKm2h5ArXuYpuMEaN",
|
||||
"address": "ANg3mmstMr7qtY8TgdKM777WSLKCNFbawM",
|
||||
"key": "6PYNTeMkEZ1Q2MCqkPMgvC2kvRzH6f1sz4Sj9cGcLG4iYb43yQcpThAeap",
|
||||
"label": "",
|
||||
"contract": {
|
||||
"script": "514c2102b3622bf4017bdfe317c58aed5f4c753f206b7db896046fa7d774bbc4bf7f8dc25150683073b3bb",
|
||||
"script": "110c2102b3622bf4017bdfe317c58aed5f4c753f206b7db896046fa7d774bbc4bf7f8dc2110b683073b3bb",
|
||||
"parameters": [
|
||||
{
|
||||
"name": "parameter0",
|
||||
|
|
|
@ -2,11 +2,11 @@
|
|||
"version": "1.0",
|
||||
"accounts": [
|
||||
{
|
||||
"address": "AdB6ayKfBRJZasiXX4JL5N2YtmxftNp1b3",
|
||||
"key": "6PYXPEFeBxeDjqMiwRrSe81LnpL1cpw1WSwENJY1p4NtgSbfZPaUFy8Kkg",
|
||||
"address": "Aaidx8VxYVjpD6knF8toWG7WquQjQFWcZB",
|
||||
"key": "6PYMZM16cgdQ9GH5ejEPFqehuZ3Lp16W4fW7LyoBdUuVyeMeom7z8wP5QV",
|
||||
"label": "",
|
||||
"contract": {
|
||||
"script": "4c2102103a7f7dd016558597f7960d27c516a4394fd968b9e65155eb4b013e4040406e50680a906ad4",
|
||||
"script": "0c2102103a7f7dd016558597f7960d27c516a4394fd968b9e65155eb4b013e4040406e0b680a906ad4",
|
||||
"parameters": [
|
||||
{
|
||||
"name": "parameter0",
|
||||
|
@ -19,11 +19,11 @@
|
|||
"isDefault": false
|
||||
},
|
||||
{
|
||||
"address": "AbHd9dXYUryuCvMgXRUfdR6zC2CJixS6Q6",
|
||||
"key": "6PYXPEFeBxeDjqMiwRrSe81LnpL1cpw1WSwENJY1p4NtgSbfZPaUFy8Kkg",
|
||||
"address": "Ad1wDxzcRiRSryvJobNV211Tv7UUiziPXy",
|
||||
"key": "6PYMZM16cgdQ9GH5ejEPFqehuZ3Lp16W4fW7LyoBdUuVyeMeom7z8wP5QV",
|
||||
"label": "",
|
||||
"contract": {
|
||||
"script": "534c2102103a7f7dd016558597f7960d27c516a4394fd968b9e65155eb4b013e4040406e4c2102a7bc55fe8684e0119768d104ba30795bdcc86619e864add26156723ed185cd624c2102b3622bf4017bdfe317c58aed5f4c753f206b7db896046fa7d774bbc4bf7f8dc24c2103d90c07df63e690ce77912e10ab51acc944b66860237b608c4f8f8309e71ee6995450683073b3bb",
|
||||
"script": "130c2102103a7f7dd016558597f7960d27c516a4394fd968b9e65155eb4b013e4040406e0c2102a7bc55fe8684e0119768d104ba30795bdcc86619e864add26156723ed185cd620c2102b3622bf4017bdfe317c58aed5f4c753f206b7db896046fa7d774bbc4bf7f8dc20c2103d90c07df63e690ce77912e10ab51acc944b66860237b608c4f8f8309e71ee699140b683073b3bb",
|
||||
"parameters": [
|
||||
{
|
||||
"name": "parameter0",
|
||||
|
|
|
@ -2,11 +2,11 @@
|
|||
"version": "1.0",
|
||||
"accounts": [
|
||||
{
|
||||
"address": "AbJTkhSMjJnm2CHZbCUe5j8w2xzjDbeWM8",
|
||||
"key": "6PYRHjZrvxYqrHLpXz1aP6dBnrFkkxQMCdYsJi7YDPoQnQddvRuTzKGxME",
|
||||
"address": "Ae6y4Jx6rjwGu6Vtf6y1piTN3dnhCs6Gp4",
|
||||
"key": "6PYSeHjvJFBn4FVccKHtaq2Hrvqa3aj9EDq5XSnWszvagRyxRmmRijqV6r",
|
||||
"label": "",
|
||||
"contract": {
|
||||
"script": "4c2103d90c07df63e690ce77912e10ab51acc944b66860237b608c4f8f8309e71ee69950680a906ad4",
|
||||
"script": "0c2103d90c07df63e690ce77912e10ab51acc944b66860237b608c4f8f8309e71ee6990b680a906ad4",
|
||||
"parameters": [
|
||||
{
|
||||
"name": "parameter0",
|
||||
|
@ -19,11 +19,11 @@
|
|||
"isDefault": false
|
||||
},
|
||||
{
|
||||
"address": "AbHd9dXYUryuCvMgXRUfdR6zC2CJixS6Q6",
|
||||
"key": "6PYRHjZrvxYqrHLpXz1aP6dBnrFkkxQMCdYsJi7YDPoQnQddvRuTzKGxME",
|
||||
"address": "Ad1wDxzcRiRSryvJobNV211Tv7UUiziPXy",
|
||||
"key": "6PYSeHjvJFBn4FVccKHtaq2Hrvqa3aj9EDq5XSnWszvagRyxRmmRijqV6r",
|
||||
"label": "",
|
||||
"contract": {
|
||||
"script": "534c2102103a7f7dd016558597f7960d27c516a4394fd968b9e65155eb4b013e4040406e4c2102a7bc55fe8684e0119768d104ba30795bdcc86619e864add26156723ed185cd624c2102b3622bf4017bdfe317c58aed5f4c753f206b7db896046fa7d774bbc4bf7f8dc24c2103d90c07df63e690ce77912e10ab51acc944b66860237b608c4f8f8309e71ee6995450683073b3bb",
|
||||
"script": "130c2102103a7f7dd016558597f7960d27c516a4394fd968b9e65155eb4b013e4040406e0c2102a7bc55fe8684e0119768d104ba30795bdcc86619e864add26156723ed185cd620c2102b3622bf4017bdfe317c58aed5f4c753f206b7db896046fa7d774bbc4bf7f8dc20c2103d90c07df63e690ce77912e10ab51acc944b66860237b608c4f8f8309e71ee699140b683073b3bb",
|
||||
"parameters": [
|
||||
{
|
||||
"name": "parameter0",
|
||||
|
|
|
@ -2,11 +2,11 @@
|
|||
"version": "1.0",
|
||||
"accounts": [
|
||||
{
|
||||
"address": "AT7C1Jno1CtJTYzA6MH8HpfYYso1RiES8q",
|
||||
"key": "6PYWscJHQ76uctwuM7GRcAp6xfGjdYDKnbMtMnT6hcXxcNn7CywbQmvfSy",
|
||||
"address": "ANysJU18KPh6jBBcrGby9bPAHxFmAeL1q3",
|
||||
"key": "6PYNWeXTgyP88XsqDLUdjnCNHypSD8wYLURE78226LU9gYNiSGL1grjFC9",
|
||||
"label": "",
|
||||
"contract": {
|
||||
"script": "4c2102a7bc55fe8684e0119768d104ba30795bdcc86619e864add26156723ed185cd6250680a906ad4",
|
||||
"script": "0c2102a7bc55fe8684e0119768d104ba30795bdcc86619e864add26156723ed185cd620b680a906ad4",
|
||||
"parameters": [
|
||||
{
|
||||
"name": "parameter0",
|
||||
|
@ -19,11 +19,11 @@
|
|||
"isDefault": false
|
||||
},
|
||||
{
|
||||
"address": "AbHd9dXYUryuCvMgXRUfdR6zC2CJixS6Q6",
|
||||
"key": "6PYWscJHQ76uctwuM7GRcAp6xfGjdYDKnbMtMnT6hcXxcNn7CywbQmvfSy",
|
||||
"address": "Ad1wDxzcRiRSryvJobNV211Tv7UUiziPXy",
|
||||
"key": "6PYNWeXTgyP88XsqDLUdjnCNHypSD8wYLURE78226LU9gYNiSGL1grjFC9",
|
||||
"label": "",
|
||||
"contract": {
|
||||
"script": "534c2102103a7f7dd016558597f7960d27c516a4394fd968b9e65155eb4b013e4040406e4c2102a7bc55fe8684e0119768d104ba30795bdcc86619e864add26156723ed185cd624c2102b3622bf4017bdfe317c58aed5f4c753f206b7db896046fa7d774bbc4bf7f8dc24c2103d90c07df63e690ce77912e10ab51acc944b66860237b608c4f8f8309e71ee6995450683073b3bb",
|
||||
"script": "130c2102103a7f7dd016558597f7960d27c516a4394fd968b9e65155eb4b013e4040406e0c2102a7bc55fe8684e0119768d104ba30795bdcc86619e864add26156723ed185cd620c2102b3622bf4017bdfe317c58aed5f4c753f206b7db896046fa7d774bbc4bf7f8dc20c2103d90c07df63e690ce77912e10ab51acc944b66860237b608c4f8f8309e71ee699140b683073b3bb",
|
||||
"parameters": [
|
||||
{
|
||||
"name": "parameter0",
|
||||
|
|
|
@ -16,9 +16,10 @@ import (
|
|||
"github.com/nspcc-dev/neo-go/pkg/core/mempool"
|
||||
"github.com/nspcc-dev/neo-go/pkg/core/transaction"
|
||||
"github.com/nspcc-dev/neo-go/pkg/crypto/keys"
|
||||
"github.com/nspcc-dev/neo-go/pkg/io"
|
||||
"github.com/nspcc-dev/neo-go/pkg/smartcontract"
|
||||
"github.com/nspcc-dev/neo-go/pkg/util"
|
||||
"github.com/nspcc-dev/neo-go/pkg/vm/opcode"
|
||||
"github.com/nspcc-dev/neo-go/pkg/vm/emit"
|
||||
"github.com/nspcc-dev/neo-go/pkg/wallet"
|
||||
"go.uber.org/zap"
|
||||
)
|
||||
|
@ -394,17 +395,16 @@ func (s *service) getBlockWitness(b *coreb.Block) *transaction.Witness {
|
|||
|
||||
sort.Sort(keys.PublicKeys(pubs))
|
||||
|
||||
var invoc []byte
|
||||
buf := io.NewBufBinWriter()
|
||||
for i, j := 0, 0; i < len(pubs) && j < m; i++ {
|
||||
if sig, ok := sigs[pubs[i]]; ok {
|
||||
invoc = append(invoc, byte(opcode.PUSHBYTES64))
|
||||
invoc = append(invoc, sig...)
|
||||
emit.Bytes(buf.BinWriter, sig)
|
||||
j++
|
||||
}
|
||||
}
|
||||
|
||||
return &transaction.Witness{
|
||||
InvocationScript: invoc,
|
||||
InvocationScript: buf.Bytes(),
|
||||
VerificationScript: verif,
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,8 +1,6 @@
|
|||
package consensus
|
||||
|
||||
import (
|
||||
"encoding/hex"
|
||||
"fmt"
|
||||
"testing"
|
||||
|
||||
"github.com/nspcc-dev/dbft/block"
|
||||
|
@ -11,13 +9,12 @@ import (
|
|||
"github.com/nspcc-dev/neo-go/pkg/core"
|
||||
"github.com/nspcc-dev/neo-go/pkg/core/storage"
|
||||
"github.com/nspcc-dev/neo-go/pkg/core/transaction"
|
||||
"github.com/nspcc-dev/neo-go/pkg/crypto/hash"
|
||||
"github.com/nspcc-dev/neo-go/pkg/crypto/keys"
|
||||
"github.com/nspcc-dev/neo-go/pkg/encoding/address"
|
||||
"github.com/nspcc-dev/neo-go/pkg/internal/testchain"
|
||||
"github.com/nspcc-dev/neo-go/pkg/io"
|
||||
"github.com/nspcc-dev/neo-go/pkg/smartcontract"
|
||||
"github.com/nspcc-dev/neo-go/pkg/util"
|
||||
"github.com/nspcc-dev/neo-go/pkg/vm/opcode"
|
||||
"github.com/nspcc-dev/neo-go/pkg/vm/emit"
|
||||
"github.com/nspcc-dev/neo-go/pkg/wallet"
|
||||
"github.com/stretchr/testify/require"
|
||||
"go.uber.org/zap/zaptest"
|
||||
|
@ -208,14 +205,6 @@ func newTestService(t *testing.T) *service {
|
|||
return srv.(*service)
|
||||
}
|
||||
|
||||
func TestExport(t *testing.T) {
|
||||
_, pub := getTestValidator(3)
|
||||
s, _ := smartcontract.CreateMultiSigRedeemScript(1, keys.PublicKeys{pub.PublicKey})
|
||||
fmt.Println(hex.EncodeToString(s))
|
||||
u := hash.Hash160(s)
|
||||
fmt.Println(address.Uint160ToString(u))
|
||||
}
|
||||
|
||||
func getTestValidator(i int) (*privateKey, *publicKey) {
|
||||
key := testchain.PrivateKey(i)
|
||||
return &privateKey{PrivateKey: key}, &publicKey{PublicKey: key.PublicKey()}
|
||||
|
@ -240,11 +229,11 @@ func (fs *feer) IsLowPriority(util.Fixed8) bool { return false
|
|||
func (fs *feer) FeePerByte(*transaction.Transaction) util.Fixed8 { return util.Fixed8(0) }
|
||||
func (fs *feer) SystemFee(*transaction.Transaction) util.Fixed8 { return util.Fixed8(0) }
|
||||
|
||||
var neoOwner = testchain.MultisigScriptHash()
|
||||
|
||||
func addSender(t *testing.T, txs ...*transaction.Transaction) {
|
||||
// multisig address which possess all NEO
|
||||
scriptHash := testchain.MultisigScriptHash()
|
||||
for _, tx := range txs {
|
||||
tx.Sender = scriptHash
|
||||
tx.Sender = neoOwner
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -261,14 +250,14 @@ func signTx(t *testing.T, txs ...*transaction.Transaction) {
|
|||
for _, tx := range txs {
|
||||
data := tx.GetSignedPart()
|
||||
|
||||
var invoc []byte
|
||||
buf := io.NewBufBinWriter()
|
||||
for _, key := range privNetKeys {
|
||||
signature := key.Sign(data)
|
||||
invoc = append(invoc, append([]byte{byte(opcode.PUSHBYTES64)}, signature...)...)
|
||||
emit.Bytes(buf.BinWriter, signature)
|
||||
}
|
||||
|
||||
tx.Scripts = []transaction.Witness{{
|
||||
InvocationScript: invoc,
|
||||
InvocationScript: buf.Bytes(),
|
||||
VerificationScript: rawScript,
|
||||
}}
|
||||
}
|
||||
|
|
|
@ -12,7 +12,7 @@ import (
|
|||
"github.com/nspcc-dev/neo-go/pkg/io"
|
||||
"github.com/nspcc-dev/neo-go/pkg/util"
|
||||
"github.com/nspcc-dev/neo-go/pkg/vm"
|
||||
"github.com/nspcc-dev/neo-go/pkg/vm/opcode"
|
||||
"github.com/nspcc-dev/neo-go/pkg/vm/emit"
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
|
@ -192,7 +192,9 @@ func (p *Payload) Sign(key *privateKey) error {
|
|||
return err
|
||||
}
|
||||
|
||||
p.Witness.InvocationScript = append([]byte{byte(opcode.PUSHBYTES64)}, sig...)
|
||||
buf := io.NewBufBinWriter()
|
||||
emit.Bytes(buf.BinWriter, sig)
|
||||
p.Witness.InvocationScript = buf.Bytes()
|
||||
p.Witness.VerificationScript = key.PublicKey().GetVerificationScript()
|
||||
|
||||
return nil
|
||||
|
|
12
pkg/consensus/testdata/wallet1.json
vendored
12
pkg/consensus/testdata/wallet1.json
vendored
|
@ -2,11 +2,11 @@
|
|||
"version": "1.0",
|
||||
"accounts": [
|
||||
{
|
||||
"address": "AQyx83BYr1PkyYhZhUAogaHdhkLVHn6htY",
|
||||
"key": "6PYKYQKRs758NBX4q5k6fSmduZDfEfQyoXMovQU5myKm2h5ArXuYpuMEaN",
|
||||
"address": "ASW1VhcukJRrukCXRipY4BE9d9zy4mAYsR",
|
||||
"key": "6PYNTeMkEZ1Q2MCqkPMgvC2kvRzH6f1sz4Sj9cGcLG4iYb43yQcpThAeap",
|
||||
"label": "",
|
||||
"contract": {
|
||||
"script": "4c2102b3622bf4017bdfe317c58aed5f4c753f206b7db896046fa7d774bbc4bf7f8dc250680a906ad4",
|
||||
"script": "0c2102b3622bf4017bdfe317c58aed5f4c753f206b7db896046fa7d774bbc4bf7f8dc20b680a906ad4",
|
||||
"parameters": [
|
||||
{
|
||||
"name": "parameter0",
|
||||
|
@ -19,11 +19,11 @@
|
|||
"isDefault": false
|
||||
},
|
||||
{
|
||||
"address": "AbHd9dXYUryuCvMgXRUfdR6zC2CJixS6Q6",
|
||||
"key": "6PYKYQKRs758NBX4q5k6fSmduZDfEfQyoXMovQU5myKm2h5ArXuYpuMEaN",
|
||||
"address": "Ad1wDxzcRiRSryvJobNV211Tv7UUiziPXy",
|
||||
"key": "6PYNTeMkEZ1Q2MCqkPMgvC2kvRzH6f1sz4Sj9cGcLG4iYb43yQcpThAeap",
|
||||
"label": "",
|
||||
"contract": {
|
||||
"script": "534c2102103a7f7dd016558597f7960d27c516a4394fd968b9e65155eb4b013e4040406e4c2102a7bc55fe8684e0119768d104ba30795bdcc86619e864add26156723ed185cd624c2102b3622bf4017bdfe317c58aed5f4c753f206b7db896046fa7d774bbc4bf7f8dc24c2103d90c07df63e690ce77912e10ab51acc944b66860237b608c4f8f8309e71ee6995450683073b3bb",
|
||||
"script": "130c2102103a7f7dd016558597f7960d27c516a4394fd968b9e65155eb4b013e4040406e0c2102a7bc55fe8684e0119768d104ba30795bdcc86619e864add26156723ed185cd620c2102b3622bf4017bdfe317c58aed5f4c753f206b7db896046fa7d774bbc4bf7f8dc20c2103d90c07df63e690ce77912e10ab51acc944b66860237b608c4f8f8309e71ee699140b683073b3bb",
|
||||
"parameters": [
|
||||
{
|
||||
"name": "parameter0",
|
||||
|
|
12
pkg/consensus/testdata/wallet2.json
vendored
12
pkg/consensus/testdata/wallet2.json
vendored
|
@ -2,11 +2,11 @@
|
|||
"version": "1.0",
|
||||
"accounts": [
|
||||
{
|
||||
"address": "AdB6ayKfBRJZasiXX4JL5N2YtmxftNp1b3",
|
||||
"key": "6PYXPEFeBxeDjqMiwRrSe81LnpL1cpw1WSwENJY1p4NtgSbfZPaUFy8Kkg",
|
||||
"address": "Aaidx8VxYVjpD6knF8toWG7WquQjQFWcZB",
|
||||
"key": "6PYMZM16cgdQ9GH5ejEPFqehuZ3Lp16W4fW7LyoBdUuVyeMeom7z8wP5QV",
|
||||
"label": "",
|
||||
"contract": {
|
||||
"script": "4c2102103a7f7dd016558597f7960d27c516a4394fd968b9e65155eb4b013e4040406e50680a906ad4",
|
||||
"script": "0c2102103a7f7dd016558597f7960d27c516a4394fd968b9e65155eb4b013e4040406e0b680a906ad4",
|
||||
"parameters": [
|
||||
{
|
||||
"name": "parameter0",
|
||||
|
@ -19,11 +19,11 @@
|
|||
"isDefault": false
|
||||
},
|
||||
{
|
||||
"address": "AbHd9dXYUryuCvMgXRUfdR6zC2CJixS6Q6",
|
||||
"key": "6PYXPEFeBxeDjqMiwRrSe81LnpL1cpw1WSwENJY1p4NtgSbfZPaUFy8Kkg",
|
||||
"address": "Ad1wDxzcRiRSryvJobNV211Tv7UUiziPXy",
|
||||
"key": "6PYMZM16cgdQ9GH5ejEPFqehuZ3Lp16W4fW7LyoBdUuVyeMeom7z8wP5QV",
|
||||
"label": "",
|
||||
"contract": {
|
||||
"script": "534c2102103a7f7dd016558597f7960d27c516a4394fd968b9e65155eb4b013e4040406e4c2102a7bc55fe8684e0119768d104ba30795bdcc86619e864add26156723ed185cd624c2102b3622bf4017bdfe317c58aed5f4c753f206b7db896046fa7d774bbc4bf7f8dc24c2103d90c07df63e690ce77912e10ab51acc944b66860237b608c4f8f8309e71ee6995450683073b3bb",
|
||||
"script": "130c2102103a7f7dd016558597f7960d27c516a4394fd968b9e65155eb4b013e4040406e0c2102a7bc55fe8684e0119768d104ba30795bdcc86619e864add26156723ed185cd620c2102b3622bf4017bdfe317c58aed5f4c753f206b7db896046fa7d774bbc4bf7f8dc20c2103d90c07df63e690ce77912e10ab51acc944b66860237b608c4f8f8309e71ee699140b683073b3bb",
|
||||
"parameters": [
|
||||
{
|
||||
"name": "parameter0",
|
||||
|
|
12
pkg/consensus/testdata/wallet3.json
vendored
12
pkg/consensus/testdata/wallet3.json
vendored
|
@ -2,11 +2,11 @@
|
|||
"version": "1.0",
|
||||
"accounts": [
|
||||
{
|
||||
"address": "AbJTkhSMjJnm2CHZbCUe5j8w2xzjDbeWM8",
|
||||
"key": "6PYRHjZrvxYqrHLpXz1aP6dBnrFkkxQMCdYsJi7YDPoQnQddvRuTzKGxME",
|
||||
"address": "Ae6y4Jx6rjwGu6Vtf6y1piTN3dnhCs6Gp4",
|
||||
"key": "6PYSeHjvJFBn4FVccKHtaq2Hrvqa3aj9EDq5XSnWszvagRyxRmmRijqV6r",
|
||||
"label": "",
|
||||
"contract": {
|
||||
"script": "4c2103d90c07df63e690ce77912e10ab51acc944b66860237b608c4f8f8309e71ee69950680a906ad4",
|
||||
"script": "0c2103d90c07df63e690ce77912e10ab51acc944b66860237b608c4f8f8309e71ee6990b680a906ad4",
|
||||
"parameters": [
|
||||
{
|
||||
"name": "parameter0",
|
||||
|
@ -19,11 +19,11 @@
|
|||
"isDefault": false
|
||||
},
|
||||
{
|
||||
"address": "AbHd9dXYUryuCvMgXRUfdR6zC2CJixS6Q6",
|
||||
"key": "6PYRHjZrvxYqrHLpXz1aP6dBnrFkkxQMCdYsJi7YDPoQnQddvRuTzKGxME",
|
||||
"address": "Ad1wDxzcRiRSryvJobNV211Tv7UUiziPXy",
|
||||
"key": "6PYSeHjvJFBn4FVccKHtaq2Hrvqa3aj9EDq5XSnWszvagRyxRmmRijqV6r",
|
||||
"label": "",
|
||||
"contract": {
|
||||
"script": "534c2102103a7f7dd016558597f7960d27c516a4394fd968b9e65155eb4b013e4040406e4c2102a7bc55fe8684e0119768d104ba30795bdcc86619e864add26156723ed185cd624c2102b3622bf4017bdfe317c58aed5f4c753f206b7db896046fa7d774bbc4bf7f8dc24c2103d90c07df63e690ce77912e10ab51acc944b66860237b608c4f8f8309e71ee6995450683073b3bb",
|
||||
"script": "130c2102103a7f7dd016558597f7960d27c516a4394fd968b9e65155eb4b013e4040406e0c2102a7bc55fe8684e0119768d104ba30795bdcc86619e864add26156723ed185cd620c2102b3622bf4017bdfe317c58aed5f4c753f206b7db896046fa7d774bbc4bf7f8dc20c2103d90c07df63e690ce77912e10ab51acc944b66860237b608c4f8f8309e71ee699140b683073b3bb",
|
||||
"parameters": [
|
||||
{
|
||||
"name": "parameter0",
|
||||
|
|
12
pkg/consensus/testdata/wallet4.json
vendored
12
pkg/consensus/testdata/wallet4.json
vendored
|
@ -2,11 +2,11 @@
|
|||
"version": "1.0",
|
||||
"accounts": [
|
||||
{
|
||||
"address": "AT7C1Jno1CtJTYzA6MH8HpfYYso1RiES8q",
|
||||
"key": "6PYWscJHQ76uctwuM7GRcAp6xfGjdYDKnbMtMnT6hcXxcNn7CywbQmvfSy",
|
||||
"address": "ANysJU18KPh6jBBcrGby9bPAHxFmAeL1q3",
|
||||
"key": "6PYNWeXTgyP88XsqDLUdjnCNHypSD8wYLURE78226LU9gYNiSGL1grjFC9",
|
||||
"label": "",
|
||||
"contract": {
|
||||
"script": "4c2102a7bc55fe8684e0119768d104ba30795bdcc86619e864add26156723ed185cd6250680a906ad4",
|
||||
"script": "0c2102a7bc55fe8684e0119768d104ba30795bdcc86619e864add26156723ed185cd620b680a906ad4",
|
||||
"parameters": [
|
||||
{
|
||||
"name": "parameter0",
|
||||
|
@ -19,11 +19,11 @@
|
|||
"isDefault": false
|
||||
},
|
||||
{
|
||||
"address": "AbHd9dXYUryuCvMgXRUfdR6zC2CJixS6Q6",
|
||||
"key": "6PYWscJHQ76uctwuM7GRcAp6xfGjdYDKnbMtMnT6hcXxcNn7CywbQmvfSy",
|
||||
"address": "Ad1wDxzcRiRSryvJobNV211Tv7UUiziPXy",
|
||||
"key": "6PYNWeXTgyP88XsqDLUdjnCNHypSD8wYLURE78226LU9gYNiSGL1grjFC9",
|
||||
"label": "",
|
||||
"contract": {
|
||||
"script": "534c2102103a7f7dd016558597f7960d27c516a4394fd968b9e65155eb4b013e4040406e4c2102a7bc55fe8684e0119768d104ba30795bdcc86619e864add26156723ed185cd624c2102b3622bf4017bdfe317c58aed5f4c753f206b7db896046fa7d774bbc4bf7f8dc24c2103d90c07df63e690ce77912e10ab51acc944b66860237b608c4f8f8309e71ee6995450683073b3bb",
|
||||
"script": "130c2102103a7f7dd016558597f7960d27c516a4394fd968b9e65155eb4b013e4040406e0c2102a7bc55fe8684e0119768d104ba30795bdcc86619e864add26156723ed185cd620c2102b3622bf4017bdfe317c58aed5f4c753f206b7db896046fa7d774bbc4bf7f8dc20c2103d90c07df63e690ce77912e10ab51acc944b66860237b608c4f8f8309e71ee699140b683073b3bb",
|
||||
"parameters": [
|
||||
{
|
||||
"name": "parameter0",
|
||||
|
|
|
@ -8,6 +8,7 @@ import (
|
|||
"github.com/nspcc-dev/neo-go/pkg/smartcontract/trigger"
|
||||
"github.com/nspcc-dev/neo-go/pkg/util"
|
||||
"github.com/nspcc-dev/neo-go/pkg/vm"
|
||||
"github.com/nspcc-dev/neo-go/pkg/vm/opcode"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
|
@ -24,13 +25,13 @@ func TestGetPrice(t *testing.T) {
|
|||
|
||||
t.Run("Neo.Asset.Create", func(t *testing.T) {
|
||||
// Neo.Asset.Create: 83c5c61f
|
||||
v.Load([]byte{0x68, 0x83, 0xc5, 0xc6, 0x1f})
|
||||
v.Load([]byte{byte(opcode.SYSCALL), 0x83, 0xc5, 0xc6, 0x1f})
|
||||
checkGas(t, util.Fixed8FromInt64(5000), v)
|
||||
})
|
||||
|
||||
t.Run("Neo.Asset.Renew", func(t *testing.T) {
|
||||
// Neo.Asset.Renew: 78849071 (requires push 09 push 09 before)
|
||||
v.Load([]byte{0x59, 0x59, 0x68, 0x78, 0x84, 0x90, 0x71})
|
||||
v.Load([]byte{byte(opcode.PUSH9), byte(opcode.PUSH9), byte(opcode.SYSCALL), 0x78, 0x84, 0x90, 0x71})
|
||||
require.NoError(t, v.StepInto()) // push 9
|
||||
require.NoError(t, v.StepInto()) // push 9
|
||||
|
||||
|
@ -39,7 +40,8 @@ func TestGetPrice(t *testing.T) {
|
|||
|
||||
t.Run("Neo.Contract.Create (no props)", func(t *testing.T) {
|
||||
// Neo.Contract.Create: f66ca56e (requires push properties on fourth position)
|
||||
v.Load([]byte{0x00, 0x00, 0x00, 0x00, 0x68, 0xf6, 0x6c, 0xa5, 0x6e})
|
||||
v.Load([]byte{byte(opcode.PUSH0), byte(opcode.PUSH0), byte(opcode.PUSH0), byte(opcode.PUSH0),
|
||||
byte(opcode.SYSCALL), 0xf6, 0x6c, 0xa5, 0x6e})
|
||||
require.NoError(t, v.StepInto()) // push 0 - ContractPropertyState.NoProperty
|
||||
require.NoError(t, v.StepInto()) // push 0
|
||||
require.NoError(t, v.StepInto()) // push 0
|
||||
|
@ -50,7 +52,8 @@ func TestGetPrice(t *testing.T) {
|
|||
|
||||
t.Run("Neo.Contract.Create (has storage)", func(t *testing.T) {
|
||||
// Neo.Contract.Create: f66ca56e (requires push properties on fourth position)
|
||||
v.Load([]byte{0x51, 0x00, 0x00, 0x00, 0x68, 0xf6, 0x6c, 0xa5, 0x6e})
|
||||
v.Load([]byte{byte(opcode.PUSH1), byte(opcode.PUSH0), byte(opcode.PUSH0), byte(opcode.PUSH0),
|
||||
byte(opcode.SYSCALL), 0xf6, 0x6c, 0xa5, 0x6e})
|
||||
require.NoError(t, v.StepInto()) // push 01 - ContractPropertyState.HasStorage
|
||||
require.NoError(t, v.StepInto()) // push 0
|
||||
require.NoError(t, v.StepInto()) // push 0
|
||||
|
@ -61,7 +64,8 @@ func TestGetPrice(t *testing.T) {
|
|||
|
||||
t.Run("Neo.Contract.Create (has dynamic invoke)", func(t *testing.T) {
|
||||
// Neo.Contract.Create: f66ca56e (requires push properties on fourth position)
|
||||
v.Load([]byte{0x52, 0x00, 0x00, 0x00, 0x68, 0xf6, 0x6c, 0xa5, 0x6e})
|
||||
v.Load([]byte{byte(opcode.PUSH2), byte(opcode.PUSH0), byte(opcode.PUSH0), byte(opcode.PUSH0),
|
||||
byte(opcode.SYSCALL), 0xf6, 0x6c, 0xa5, 0x6e})
|
||||
require.NoError(t, v.StepInto()) // push 02 - ContractPropertyState.HasDynamicInvoke
|
||||
require.NoError(t, v.StepInto()) // push 0
|
||||
require.NoError(t, v.StepInto()) // push 0
|
||||
|
@ -72,7 +76,8 @@ func TestGetPrice(t *testing.T) {
|
|||
|
||||
t.Run("Neo.Contract.Create (has both storage and dynamic invoke)", func(t *testing.T) {
|
||||
// Neo.Contract.Create: f66ca56e (requires push properties on fourth position)
|
||||
v.Load([]byte{0x53, 0x00, 0x00, 0x00, 0x68, 0xf6, 0x6c, 0xa5, 0x6e})
|
||||
v.Load([]byte{byte(opcode.PUSH3), byte(opcode.PUSH0), byte(opcode.PUSH0), byte(opcode.PUSH0),
|
||||
byte(opcode.SYSCALL), 0xf6, 0x6c, 0xa5, 0x6e})
|
||||
require.NoError(t, v.StepInto()) // push 03 - HasStorage and HasDynamicInvoke
|
||||
require.NoError(t, v.StepInto()) // push 0
|
||||
require.NoError(t, v.StepInto()) // push 0
|
||||
|
@ -83,7 +88,8 @@ func TestGetPrice(t *testing.T) {
|
|||
|
||||
t.Run("Neo.Contract.Migrate", func(t *testing.T) {
|
||||
// Neo.Contract.Migrate: 471b6290 (requires push properties on fourth position)
|
||||
v.Load([]byte{0x00, 0x00, 0x00, 0x00, 0x68, 0x47, 0x1b, 0x62, 0x90})
|
||||
v.Load([]byte{byte(opcode.PUSH0), byte(opcode.PUSH0), byte(opcode.PUSH0), byte(opcode.PUSH0),
|
||||
byte(opcode.SYSCALL), 0x47, 0x1b, 0x62, 0x90})
|
||||
require.NoError(t, v.StepInto()) // push 0 - ContractPropertyState.NoProperty
|
||||
require.NoError(t, v.StepInto()) // push 0
|
||||
require.NoError(t, v.StepInto()) // push 0
|
||||
|
@ -94,7 +100,8 @@ func TestGetPrice(t *testing.T) {
|
|||
|
||||
t.Run("System.Storage.Put", func(t *testing.T) {
|
||||
// System.Storage.Put: e63f1884 (requires push key and value)
|
||||
v.Load([]byte{0x53, 0x53, 0x00, 0x68, 0xe6, 0x3f, 0x18, 0x84})
|
||||
v.Load([]byte{byte(opcode.PUSH3), byte(opcode.PUSH3), byte(opcode.PUSH0),
|
||||
byte(opcode.SYSCALL), 0xe6, 0x3f, 0x18, 0x84})
|
||||
require.NoError(t, v.StepInto()) // push 03 (length 1)
|
||||
require.NoError(t, v.StepInto()) // push 03 (length 1)
|
||||
require.NoError(t, v.StepInto()) // push 00
|
||||
|
@ -104,7 +111,8 @@ func TestGetPrice(t *testing.T) {
|
|||
|
||||
t.Run("System.Storage.PutEx", func(t *testing.T) {
|
||||
// System.Storage.PutEx: 73e19b3a (requires push key and value)
|
||||
v.Load([]byte{0x53, 0x53, 0x00, 0x68, 0x73, 0xe1, 0x9b, 0x3a})
|
||||
v.Load([]byte{byte(opcode.PUSH3), byte(opcode.PUSH3), byte(opcode.PUSH0),
|
||||
byte(opcode.SYSCALL), 0x73, 0xe1, 0x9b, 0x3a})
|
||||
require.NoError(t, v.StepInto()) // push 03 (length 1)
|
||||
require.NoError(t, v.StepInto()) // push 03 (length 1)
|
||||
require.NoError(t, v.StepInto()) // push 00
|
||||
|
|
|
@ -29,7 +29,7 @@ import (
|
|||
)
|
||||
|
||||
// multisig address which possess all NEO
|
||||
var neoOwner = testchain.MultisigScriptHash().StringBE()
|
||||
var neoOwner = testchain.MultisigScriptHash()
|
||||
|
||||
// newTestChain should be called before newBlock invocation to properly setup
|
||||
// global state.
|
||||
|
@ -71,7 +71,7 @@ func newBlock(cfg config.ProtocolConfiguration, index uint32, prev util.Uint256,
|
|||
}
|
||||
_ = b.RebuildMerkleRoot()
|
||||
|
||||
invScript := make([]byte, 0)
|
||||
buf := io.NewBufBinWriter()
|
||||
for i := 0; i < testchain.Size(); i++ {
|
||||
pKey := testchain.PrivateKey(i)
|
||||
b := b.GetSignedPart()
|
||||
|
@ -79,10 +79,9 @@ func newBlock(cfg config.ProtocolConfiguration, index uint32, prev util.Uint256,
|
|||
if len(sig) != 64 {
|
||||
panic("wrong signature length")
|
||||
}
|
||||
invScript = append(invScript, byte(opcode.PUSHBYTES64))
|
||||
invScript = append(invScript, sig...)
|
||||
emit.Bytes(buf.BinWriter, sig)
|
||||
}
|
||||
b.Script.InvocationScript = invScript
|
||||
b.Script.InvocationScript = buf.Bytes()
|
||||
return b
|
||||
}
|
||||
|
||||
|
@ -159,7 +158,9 @@ func newDumbBlock() *block.Block {
|
|||
|
||||
func getInvocationScript(data []byte, priv *keys.PrivateKey) []byte {
|
||||
signature := priv.Sign(data)
|
||||
return append([]byte{byte(opcode.PUSHBYTES64)}, signature...)
|
||||
buf := io.NewBufBinWriter()
|
||||
emit.Bytes(buf.BinWriter, signature)
|
||||
return buf.Bytes()
|
||||
}
|
||||
|
||||
// This function generates "../rpc/testdata/testblocks.acc" file which contains data
|
||||
|
@ -211,9 +212,7 @@ func TestCreateBasicChain(t *testing.T) {
|
|||
PrevIndex: 0,
|
||||
})
|
||||
|
||||
scriptHash, err := util.Uint160DecodeStringBE(neoOwner)
|
||||
require.NoError(t, err)
|
||||
txMoveNeo.Sender = scriptHash
|
||||
txMoveNeo.Sender = neoOwner
|
||||
|
||||
priv0 := testchain.PrivateKeyByID(0)
|
||||
priv0ScriptHash := priv0.GetScriptHash()
|
||||
|
@ -226,13 +225,13 @@ func TestCreateBasicChain(t *testing.T) {
|
|||
txMoveNeo.AddOutput(&transaction.Output{
|
||||
AssetID: GoverningTokenID(),
|
||||
Amount: neoRemainder,
|
||||
ScriptHash: scriptHash,
|
||||
ScriptHash: neoOwner,
|
||||
Position: 1,
|
||||
})
|
||||
txMoveNeo.Data = new(transaction.ContractTX)
|
||||
|
||||
minerTx := nextMinerTx(validUntilBlock)
|
||||
minerTx.Sender = scriptHash
|
||||
minerTx.Sender = neoOwner
|
||||
|
||||
require.NoError(t, signTx(bc, minerTx, txMoveNeo))
|
||||
b := bc.newBlock(minerTx, txMoveNeo)
|
||||
|
@ -492,12 +491,8 @@ func newNEP5Transfer(sc, from, to util.Uint160, amount int64) *transaction.Trans
|
|||
}
|
||||
|
||||
func addSender(txs ...*transaction.Transaction) error {
|
||||
scriptHash, err := util.Uint160DecodeStringBE(neoOwner)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "can't add sender to tx")
|
||||
}
|
||||
for _, tx := range txs {
|
||||
tx.Sender = scriptHash
|
||||
tx.Sender = neoOwner
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
|
|
@ -45,7 +45,7 @@ func createGenesisBlock(cfg config.ProtocolConfiguration) (*block.Block, error)
|
|||
NextConsensus: nextConsensus,
|
||||
Script: transaction.Witness{
|
||||
InvocationScript: []byte{},
|
||||
VerificationScript: []byte{byte(opcode.PUSHT)},
|
||||
VerificationScript: []byte{byte(opcode.OLDPUSH1)},
|
||||
},
|
||||
}
|
||||
|
||||
|
@ -64,7 +64,7 @@ func createGenesisBlock(cfg config.ProtocolConfiguration) (*block.Block, error)
|
|||
issueTx := transaction.NewIssueTX()
|
||||
// TODO NEO3.0: nonce should be constant to avoid variability of genesis block
|
||||
issueTx.Nonce = 0
|
||||
issueTx.Sender = hash.Hash160([]byte{byte(opcode.PUSH1)})
|
||||
issueTx.Sender = hash.Hash160([]byte{byte(opcode.OLDPUSH1)})
|
||||
issueTx.Outputs = []transaction.Output{
|
||||
{
|
||||
AssetID: governingTokenTX.Hash(),
|
||||
|
@ -75,7 +75,7 @@ func createGenesisBlock(cfg config.ProtocolConfiguration) (*block.Block, error)
|
|||
issueTx.Scripts = []transaction.Witness{
|
||||
{
|
||||
InvocationScript: []byte{},
|
||||
VerificationScript: []byte{byte(opcode.PUSHT)},
|
||||
VerificationScript: []byte{byte(opcode.OLDPUSH1)},
|
||||
},
|
||||
}
|
||||
|
||||
|
@ -97,7 +97,7 @@ func createGenesisBlock(cfg config.ProtocolConfiguration) (*block.Block, error)
|
|||
}
|
||||
|
||||
func init() {
|
||||
admin := hash.Hash160([]byte{byte(opcode.PUSHT)})
|
||||
admin := hash.Hash160([]byte{byte(opcode.OLDPUSH1)})
|
||||
registerTX := &transaction.RegisterTX{
|
||||
AssetType: transaction.GoverningToken,
|
||||
Name: "[{\"lang\":\"zh-CN\",\"name\":\"小蚁股\"},{\"lang\":\"en\",\"name\":\"AntShare\"}]",
|
||||
|
@ -109,9 +109,9 @@ func init() {
|
|||
governingTokenTX = *transaction.NewRegisterTX(registerTX)
|
||||
// TODO NEO3.0: nonce should be constant to avoid variability of token hash
|
||||
governingTokenTX.Nonce = 0
|
||||
governingTokenTX.Sender = hash.Hash160([]byte{byte(opcode.PUSH1)})
|
||||
governingTokenTX.Sender = hash.Hash160([]byte{byte(opcode.OLDPUSH1)})
|
||||
|
||||
admin = hash.Hash160([]byte{byte(opcode.PUSHF)})
|
||||
admin = hash.Hash160([]byte{0x00})
|
||||
registerTX = &transaction.RegisterTX{
|
||||
AssetType: transaction.UtilityToken,
|
||||
Name: "[{\"lang\":\"zh-CN\",\"name\":\"小蚁币\"},{\"lang\":\"en\",\"name\":\"AntCoin\"}]",
|
||||
|
@ -122,7 +122,7 @@ func init() {
|
|||
utilityTokenTX = *transaction.NewRegisterTX(registerTX)
|
||||
// TODO NEO3.0: nonce should be constant to avoid variability of token hash
|
||||
utilityTokenTX.Nonce = 0
|
||||
utilityTokenTX.Sender = hash.Hash160([]byte{byte(opcode.PUSH1)})
|
||||
utilityTokenTX.Sender = hash.Hash160([]byte{byte(opcode.OLDPUSH1)})
|
||||
}
|
||||
|
||||
// GoverningTokenID returns the governing token (NEO) hash.
|
||||
|
|
|
@ -20,14 +20,14 @@ func TestGenesisBlockMainNet(t *testing.T) {
|
|||
// have been changed. Consequently, hash of the genesis block has been changed.
|
||||
// Update expected genesis block hash for better times.
|
||||
// Old hash is "d42561e3d30e15be6400b6df2f328e02d2bf6354c41dce433bc57687c82144bf"
|
||||
expect := "8b247d93f1f2cba80f0908c65f94c74d17bbadefc27c7afdee5b5b078ed6ed55"
|
||||
expect := "931161239581bcd90b73d092483dee6b7bf2162e66df7e15c3a276a22b4c9422"
|
||||
assert.Equal(t, expect, block.Hash().StringLE())
|
||||
}
|
||||
|
||||
func TestGetConsensusAddressMainNet(t *testing.T) {
|
||||
var (
|
||||
consensusAddr = "ASwdHjdAGfmSDuZbr641W1eYFVugjByJAS"
|
||||
consensusScript = "7a818ecc4582f8526e7c4271a690c04bd3b9e017"
|
||||
consensusAddr = "APtiVEdLi5GEmQ8CL5RcCE7BNcsPsxeXh7"
|
||||
consensusScript = "590c459950f1d83e67ee11fcef202a6ebb8b1a77"
|
||||
)
|
||||
|
||||
cfg, err := config.Load("../../config", config.ModeMainNet)
|
||||
|
|
|
@ -232,8 +232,7 @@ func (p *PublicKey) EncodeBinary(w *io.BinWriter) {
|
|||
func (p *PublicKey) GetVerificationScript() []byte {
|
||||
b := p.Bytes()
|
||||
buf := io.NewBufBinWriter()
|
||||
emit.Instruction(buf.BinWriter, opcode.PUSHDATA1, []byte{33})
|
||||
buf.BinWriter.WriteBytes(b)
|
||||
emit.Bytes(buf.BinWriter, b)
|
||||
emit.Opcode(buf.BinWriter, opcode.PUSHNULL)
|
||||
emit.Syscall(buf.BinWriter, "Neo.Crypto.ECDsaVerify")
|
||||
|
||||
|
|
|
@ -89,7 +89,7 @@ func TestPubkeyToAddress(t *testing.T) {
|
|||
pubKey, err := NewPublicKeyFromString("031ee4e73a17d8f76dc02532e2620bcb12425b33c0c9f9694cc2caa8226b68cad4")
|
||||
require.NoError(t, err)
|
||||
actual := pubKey.Address()
|
||||
expected := "Ads7RRw2vS2jfRypVbMUGt22pxaDaojJHs"
|
||||
expected := "AbjmXh5RXBMvzYcv7LCmUgrX4sWk1QBJMK"
|
||||
require.Equal(t, expected, actual)
|
||||
}
|
||||
|
||||
|
|
|
@ -14,28 +14,28 @@ type Ktype struct {
|
|||
// Arr contains a set of known keys in Ktype format.
|
||||
var Arr = []Ktype{
|
||||
{
|
||||
Address: "Ac5bo2k5rKFvYzCZaTqUG6xFe6iXuW9xQs",
|
||||
Address: "AZdm8Dt15QFTrYkMYRrZsTmpx4jbeLtPFj",
|
||||
PrivateKey: "7d128a6d096f0c14c3a25a2b0c41cf79661bfcb4a8cc95aaaea28bde4d732344",
|
||||
PublicKey: "02028a99826edc0c97d18e22b6932373d908d323aa7f92656a77ec26e8861699ef",
|
||||
Wif: "L1QqQJnpBwbsPGAuutuzPTac8piqvbR1HRjrY5qHup48TBCBFe4g",
|
||||
Passphrase: "city of zion",
|
||||
EncryptedWif: "6PYKSxMYzHGuiT3iK7kkeGqn3Q6hJnHUc3U3Hro2kb1rPC7G15Eg2GnqL7",
|
||||
EncryptedWif: "6PYRQrhDFP6hM7Pb4cqJ7T1Erh1XabLDEs42fENU4Htvsdgt6SmShDbCLR",
|
||||
},
|
||||
{
|
||||
Address: "ATKoxGh7rytJRr96XWkvs3shMM5uiiHjhg",
|
||||
Address: "AHPNXvNiGGx43DBTEs9j1z9CjYSSC11jpe",
|
||||
PrivateKey: "9ab7e154840daca3a2efadaf0df93cd3a5b51768c632f5433f86909d9b994a69",
|
||||
PublicKey: "031d8e1630ce640966967bc6d95223d21f44304133003140c3b52004dc981349c9",
|
||||
Wif: "L2QTooFoDFyRFTxmtiVHt5CfsXfVnexdbENGDkkrrgTTryiLsPMG",
|
||||
Passphrase: "我的密码",
|
||||
EncryptedWif: "6PYQYBtL2kifXe3Dv96pMoPNJ2fZz8cPv2YqpHGKdfM2g5swEBUdwJqKsu",
|
||||
EncryptedWif: "6PYKuvXj1Yq9ZjsVNVyNrAHVHrAqg6BLxUoTdpZX5NFkG5Akq79dPYYm7c",
|
||||
},
|
||||
{
|
||||
Address: "AbjLAUABpmvLAJv4brQ7pt4QG87qy8K75T",
|
||||
Address: "AGo5guykksq8uRxfWyC8dAnTMoz62yUWcn",
|
||||
PrivateKey: "3edee7036b8fd9cef91de47386b191dd76db2888a553e7736bb02808932a915b",
|
||||
PublicKey: "02232ce8d2e2063dce0451131851d47421bfc4fc1da4db116fca5302c0756462fa",
|
||||
Wif: "KyKvWLZsNwBJx5j9nurHYRwhYfdQUu9tTEDsLCUHDbYBL8cHxMiG",
|
||||
Passphrase: "MyL33tP@33w0rd",
|
||||
EncryptedWif: "6PYMbnB7h7SjueFXUMUiGptmvMXZKLALSsCnuaotBEAnmv5fXiYh7vReBA",
|
||||
EncryptedWif: "6PYQUTBmYbWZukmBTuvTkbjSmz7m5XkEzsyJBk32ZhvC7AbVUpArb1yeMv",
|
||||
},
|
||||
{
|
||||
Address: "xdf4UGKevVrMR1j3UkPsuoYKSC4ocoAkKx",
|
||||
|
@ -43,7 +43,7 @@ var Arr = []Ktype{
|
|||
PublicKey: "zz232ce8d2e2063dce0451131851d47421bfc4fc1da4db116fca5302c0756462fa",
|
||||
Wif: "zzKvWLZsNwBJx5j9nurHYRwhYfdQUu9tTEDsLCUHDbYBL8cHxMiG",
|
||||
Passphrase: "zzL33tP@33w0rd",
|
||||
EncryptedWif: "6PYMbnB7h7SjueFXUMUiGptmvMXZKLALSsCnuaotBEAnmv5fXiYh7vReBA",
|
||||
EncryptedWif: "6PYQUTBmYbWZukmBTuvTkbjSmz7m5XkEzsyJBk32ZhvC7AbVUpArb1yeMv",
|
||||
Invalid: true,
|
||||
},
|
||||
}
|
||||
|
|
|
@ -22,40 +22,40 @@ func TestInvocationScriptCreationGood(t *testing.T) {
|
|||
script: "676f459162ceeb248b071ec157d9e4f6fd26fdbe50",
|
||||
}, {
|
||||
ps: Params{{Type: StringT, Value: "transfer"}},
|
||||
script: "087472616e73666572676f459162ceeb248b071ec157d9e4f6fd26fdbe50",
|
||||
script: "0c087472616e73666572676f459162ceeb248b071ec157d9e4f6fd26fdbe50",
|
||||
}, {
|
||||
ps: Params{{Type: NumberT, Value: 42}},
|
||||
script: "023432676f459162ceeb248b071ec157d9e4f6fd26fdbe50",
|
||||
script: "0c023432676f459162ceeb248b071ec157d9e4f6fd26fdbe50",
|
||||
}, {
|
||||
ps: Params{{Type: StringT, Value: "a"}, {Type: ArrayT, Value: []Param{}}},
|
||||
script: "00c10161676f459162ceeb248b071ec157d9e4f6fd26fdbe50",
|
||||
script: "10c10c0161676f459162ceeb248b071ec157d9e4f6fd26fdbe50",
|
||||
}, {
|
||||
ps: Params{{Type: StringT, Value: "a"}, {Type: ArrayT, Value: []Param{{Type: FuncParamT, Value: FuncParam{Type: smartcontract.ByteArrayType, Value: Param{Type: StringT, Value: "50befd26fdf6e4d957c11e078b24ebce6291456f"}}}}}},
|
||||
script: "1450befd26fdf6e4d957c11e078b24ebce6291456f51c10161676f459162ceeb248b071ec157d9e4f6fd26fdbe50",
|
||||
script: "0c1450befd26fdf6e4d957c11e078b24ebce6291456f11c10c0161676f459162ceeb248b071ec157d9e4f6fd26fdbe50",
|
||||
}, {
|
||||
ps: Params{{Type: StringT, Value: "a"}, {Type: ArrayT, Value: []Param{{Type: FuncParamT, Value: FuncParam{Type: smartcontract.SignatureType, Value: Param{Type: StringT, Value: "4edf5005771de04619235d5a4c7a9a11bb78e008541f1da7725f654c33380a3c87e2959a025da706d7255cb3a3fa07ebe9c6559d0d9e6213c68049168eb1056f"}}}}}},
|
||||
script: "404edf5005771de04619235d5a4c7a9a11bb78e008541f1da7725f654c33380a3c87e2959a025da706d7255cb3a3fa07ebe9c6559d0d9e6213c68049168eb1056f51c10161676f459162ceeb248b071ec157d9e4f6fd26fdbe50",
|
||||
script: "0c404edf5005771de04619235d5a4c7a9a11bb78e008541f1da7725f654c33380a3c87e2959a025da706d7255cb3a3fa07ebe9c6559d0d9e6213c68049168eb1056f11c10c0161676f459162ceeb248b071ec157d9e4f6fd26fdbe50",
|
||||
}, {
|
||||
ps: Params{{Type: StringT, Value: "a"}, {Type: ArrayT, Value: []Param{{Type: FuncParamT, Value: FuncParam{Type: smartcontract.StringType, Value: Param{Type: StringT, Value: "50befd26fdf6e4d957c11e078b24ebce6291456f"}}}}}},
|
||||
script: "283530626566643236666466366534643935376331316530373862323465626365363239313435366651c10161676f459162ceeb248b071ec157d9e4f6fd26fdbe50",
|
||||
script: "0c283530626566643236666466366534643935376331316530373862323465626365363239313435366611c10c0161676f459162ceeb248b071ec157d9e4f6fd26fdbe50",
|
||||
}, {
|
||||
ps: Params{{Type: StringT, Value: "a"}, {Type: ArrayT, Value: []Param{{Type: FuncParamT, Value: FuncParam{Type: smartcontract.Hash160Type, Value: Param{Type: StringT, Value: "50befd26fdf6e4d957c11e078b24ebce6291456f"}}}}}},
|
||||
script: "146f459162ceeb248b071ec157d9e4f6fd26fdbe5051c10161676f459162ceeb248b071ec157d9e4f6fd26fdbe50",
|
||||
script: "0c146f459162ceeb248b071ec157d9e4f6fd26fdbe5011c10c0161676f459162ceeb248b071ec157d9e4f6fd26fdbe50",
|
||||
}, {
|
||||
ps: Params{{Type: StringT, Value: "a"}, {Type: ArrayT, Value: []Param{{Type: FuncParamT, Value: FuncParam{Type: smartcontract.Hash256Type, Value: Param{Type: StringT, Value: "602c79718b16e442de58778e148d0b1084e3b2dffd5de6b7b16cee7969282de7"}}}}}},
|
||||
script: "20e72d286979ee6cb1b7e65dfddfb2e384100b8d148e7758de42e4168b71792c6051c10161676f459162ceeb248b071ec157d9e4f6fd26fdbe50",
|
||||
script: "0c20e72d286979ee6cb1b7e65dfddfb2e384100b8d148e7758de42e4168b71792c6011c10c0161676f459162ceeb248b071ec157d9e4f6fd26fdbe50",
|
||||
}, {
|
||||
ps: Params{{Type: StringT, Value: "a"}, {Type: ArrayT, Value: []Param{{Type: FuncParamT, Value: FuncParam{Type: smartcontract.PublicKeyType, Value: Param{Type: StringT, Value: "03c089d7122b840a4935234e82e26ae5efd0c2acb627239dc9f207311337b6f2c1"}}}}}},
|
||||
script: "2103c089d7122b840a4935234e82e26ae5efd0c2acb627239dc9f207311337b6f2c151c10161676f459162ceeb248b071ec157d9e4f6fd26fdbe50",
|
||||
script: "0c2103c089d7122b840a4935234e82e26ae5efd0c2acb627239dc9f207311337b6f2c111c10c0161676f459162ceeb248b071ec157d9e4f6fd26fdbe50",
|
||||
}, {
|
||||
ps: Params{{Type: StringT, Value: "a"}, {Type: ArrayT, Value: []Param{{Type: FuncParamT, Value: FuncParam{Type: smartcontract.IntegerType, Value: Param{Type: NumberT, Value: 42}}}}}},
|
||||
script: "012a51c10161676f459162ceeb248b071ec157d9e4f6fd26fdbe50",
|
||||
script: "002a11c10c0161676f459162ceeb248b071ec157d9e4f6fd26fdbe50",
|
||||
}, {
|
||||
ps: Params{{Type: StringT, Value: "a"}, {Type: ArrayT, Value: []Param{{Type: FuncParamT, Value: FuncParam{Type: smartcontract.BoolType, Value: Param{Type: StringT, Value: "true"}}}}}},
|
||||
script: "5151c10161676f459162ceeb248b071ec157d9e4f6fd26fdbe50",
|
||||
script: "1111c10c0161676f459162ceeb248b071ec157d9e4f6fd26fdbe50",
|
||||
}, {
|
||||
ps: Params{{Type: StringT, Value: "a"}, {Type: ArrayT, Value: []Param{{Type: FuncParamT, Value: FuncParam{Type: smartcontract.BoolType, Value: Param{Type: StringT, Value: "false"}}}}}},
|
||||
script: "0051c10161676f459162ceeb248b071ec157d9e4f6fd26fdbe50",
|
||||
script: "1011c10c0161676f459162ceeb248b071ec157d9e4f6fd26fdbe50",
|
||||
}}
|
||||
for _, ps := range paramScripts {
|
||||
script, err := CreateFunctionInvocationScript(contract, ps.ps)
|
||||
|
|
|
@ -44,18 +44,18 @@ type rpcTestCase struct {
|
|||
check func(t *testing.T, e *executor, result interface{})
|
||||
}
|
||||
|
||||
const testContractHash = "1b5cbfaa2e54b584d3240e38fc4bd413a65ea40c"
|
||||
const testContractHash = "8bb068bca226bf013e7d19400b9d85c4eb865607"
|
||||
|
||||
var rpcTestCases = map[string][]rpcTestCase{
|
||||
"getapplicationlog": {
|
||||
{
|
||||
name: "positive",
|
||||
params: `["af51984d1dbec1557c9c14d8d404ff35015e53255d53e8c7f55088a74ecc399b"]`,
|
||||
params: `["66238fd4ac778326b0c151c025ee8f1c6d738e7e191820537564d2b887f3ecde"]`,
|
||||
result: func(e *executor) interface{} { return &result.ApplicationLog{} },
|
||||
check: func(t *testing.T, e *executor, acc interface{}) {
|
||||
res, ok := acc.(*result.ApplicationLog)
|
||||
require.True(t, ok)
|
||||
expectedTxHash, err := util.Uint256DecodeStringLE("af51984d1dbec1557c9c14d8d404ff35015e53255d53e8c7f55088a74ecc399b")
|
||||
expectedTxHash, err := util.Uint256DecodeStringLE("66238fd4ac778326b0c151c025ee8f1c6d738e7e191820537564d2b887f3ecde")
|
||||
require.NoError(t, err)
|
||||
assert.Equal(t, expectedTxHash, res.TxHash)
|
||||
assert.Equal(t, 1, len(res.Executions))
|
||||
|
@ -404,25 +404,25 @@ var rpcTestCases = map[string][]rpcTestCase{
|
|||
"getblockheader": {
|
||||
{
|
||||
name: "positive, no verbose",
|
||||
params: `["ad185bb609f95fd709b6a9cce9f67ee636c4acdac9afcafb26209d922a889958"]`,
|
||||
params: `["8c702625ab05236fda5763bbe168359b7747508e1387e4404217e0418846c94e"]`,
|
||||
result: func(e *executor) interface{} {
|
||||
expected := "000000003a879986b02b0f46b6a311b74799446f1fca447c1a4ae7baa804876194669cfd14aa46a5e3e62056c842d54ea5ba480fc448c498989f505bcae9ae4364436b9dd78b9d5e010000005704000000000000d60ac443bb800fb08261e75fa5925d747d48586101fd040140fd33aaf63b15fcfb1d2ad465297e35e52e26d9049c28022fd8f4a27fca573135e539852f5093d37fc3ebb669b3ad7998c250ae7b7d073ba29aa59738f5543d844003422200411a06e5ddb5d148cd16314d9f5a66ed6d91efd6abf8d8f9757487e1066016e3c333842b90509eb05fa33f2d7adf7c270d892839f68a62b037ce1ae040452ea91701a973650958337caa1e646b06dfa63d1e6357e0bbfb9ad4cb0a74e4c2fbac23f980675c26167b720717fa95552c1f795becac1f7c1ea2be20571a9a4012125e56f2d562980b833ecc9d5e8dc12b253a591a06059a8ccf1c1850b32220c310d9376b627b3c8975f88d78ff3b08d332c8d63210f8ae9c68d87181148fc894534c2102103a7f7dd016558597f7960d27c516a4394fd968b9e65155eb4b013e4040406e4c2102a7bc55fe8684e0119768d104ba30795bdcc86619e864add26156723ed185cd624c2102b3622bf4017bdfe317c58aed5f4c753f206b7db896046fa7d774bbc4bf7f8dc24c2103d90c07df63e690ce77912e10ab51acc944b66860237b608c4f8f8309e71ee6995450683073b3bb00"
|
||||
expected := "000000007654fa898eba5ced6ab7a44fe1187e48b80ddd5340499fb2d312cc2fe4a6df1bb31cada0cb85914ee5bd6d11d25289a59203bf65f40232de8ffaa2bb7517f3b50a0ca05e010000005704000000000000e903736ceceeceae1806eee0e3ec61e7cce476ce01fd08010c404def65e6b379e441fe1507d6d031c874e686b854b2afe9843fda5087f76e261e282b4db232079485dcf449678e2358a3d148835b85affba4ecd08a2bf1b556fe0c406b6218df12f8a7060379daf4eed312a85be51ea2fabee826a745547141694a3f49f8a61ac63db7ece1de7fbb54ecb9c5ac244a7fcdd794c9767b4cb2637a9c840c40ebaf64e3b76299d3ccc7e48e197a09af11cc0a80bd636cdef80312c61e24eebaace44cda90d17eb3ba85cfc08079676626966c75a48631b508c39375a8181ec40c402a77786cdaa5e93f0952c834cebdab25475beee0b60fce4263d85b7395bcde993ebee884667def21b7de494097f30c14c626357683680bdbace9667cc03b0da894130c2102103a7f7dd016558597f7960d27c516a4394fd968b9e65155eb4b013e4040406e0c2102a7bc55fe8684e0119768d104ba30795bdcc86619e864add26156723ed185cd620c2102b3622bf4017bdfe317c58aed5f4c753f206b7db896046fa7d774bbc4bf7f8dc20c2103d90c07df63e690ce77912e10ab51acc944b66860237b608c4f8f8309e71ee699140b683073b3bb00"
|
||||
return &expected
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "positive, verbose 0",
|
||||
params: `["ad185bb609f95fd709b6a9cce9f67ee636c4acdac9afcafb26209d922a889958", 0]`,
|
||||
params: `["8c702625ab05236fda5763bbe168359b7747508e1387e4404217e0418846c94e", 0]`,
|
||||
result: func(e *executor) interface{} {
|
||||
expected := "000000003a879986b02b0f46b6a311b74799446f1fca447c1a4ae7baa804876194669cfd14aa46a5e3e62056c842d54ea5ba480fc448c498989f505bcae9ae4364436b9dd78b9d5e010000005704000000000000d60ac443bb800fb08261e75fa5925d747d48586101fd040140fd33aaf63b15fcfb1d2ad465297e35e52e26d9049c28022fd8f4a27fca573135e539852f5093d37fc3ebb669b3ad7998c250ae7b7d073ba29aa59738f5543d844003422200411a06e5ddb5d148cd16314d9f5a66ed6d91efd6abf8d8f9757487e1066016e3c333842b90509eb05fa33f2d7adf7c270d892839f68a62b037ce1ae040452ea91701a973650958337caa1e646b06dfa63d1e6357e0bbfb9ad4cb0a74e4c2fbac23f980675c26167b720717fa95552c1f795becac1f7c1ea2be20571a9a4012125e56f2d562980b833ecc9d5e8dc12b253a591a06059a8ccf1c1850b32220c310d9376b627b3c8975f88d78ff3b08d332c8d63210f8ae9c68d87181148fc894534c2102103a7f7dd016558597f7960d27c516a4394fd968b9e65155eb4b013e4040406e4c2102a7bc55fe8684e0119768d104ba30795bdcc86619e864add26156723ed185cd624c2102b3622bf4017bdfe317c58aed5f4c753f206b7db896046fa7d774bbc4bf7f8dc24c2103d90c07df63e690ce77912e10ab51acc944b66860237b608c4f8f8309e71ee6995450683073b3bb00"
|
||||
expected := "000000007654fa898eba5ced6ab7a44fe1187e48b80ddd5340499fb2d312cc2fe4a6df1bb31cada0cb85914ee5bd6d11d25289a59203bf65f40232de8ffaa2bb7517f3b50a0ca05e010000005704000000000000e903736ceceeceae1806eee0e3ec61e7cce476ce01fd08010c404def65e6b379e441fe1507d6d031c874e686b854b2afe9843fda5087f76e261e282b4db232079485dcf449678e2358a3d148835b85affba4ecd08a2bf1b556fe0c406b6218df12f8a7060379daf4eed312a85be51ea2fabee826a745547141694a3f49f8a61ac63db7ece1de7fbb54ecb9c5ac244a7fcdd794c9767b4cb2637a9c840c40ebaf64e3b76299d3ccc7e48e197a09af11cc0a80bd636cdef80312c61e24eebaace44cda90d17eb3ba85cfc08079676626966c75a48631b508c39375a8181ec40c402a77786cdaa5e93f0952c834cebdab25475beee0b60fce4263d85b7395bcde993ebee884667def21b7de494097f30c14c626357683680bdbace9667cc03b0da894130c2102103a7f7dd016558597f7960d27c516a4394fd968b9e65155eb4b013e4040406e0c2102a7bc55fe8684e0119768d104ba30795bdcc86619e864add26156723ed185cd620c2102b3622bf4017bdfe317c58aed5f4c753f206b7db896046fa7d774bbc4bf7f8dc20c2103d90c07df63e690ce77912e10ab51acc944b66860237b608c4f8f8309e71ee699140b683073b3bb00"
|
||||
return &expected
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "positive, verbose !=0",
|
||||
params: `["ad185bb609f95fd709b6a9cce9f67ee636c4acdac9afcafb26209d922a889958", 2]`,
|
||||
params: `["8c702625ab05236fda5763bbe168359b7747508e1387e4404217e0418846c94e", 2]`,
|
||||
result: func(e *executor) interface{} {
|
||||
hash, err := util.Uint256DecodeStringLE("ad185bb609f95fd709b6a9cce9f67ee636c4acdac9afcafb26209d922a889958")
|
||||
hash, err := util.Uint256DecodeStringLE("8c702625ab05236fda5763bbe168359b7747508e1387e4404217e0418846c94e")
|
||||
if err != nil {
|
||||
panic("can not decode hash parameter")
|
||||
}
|
||||
|
@ -519,7 +519,7 @@ var rpcTestCases = map[string][]rpcTestCase{
|
|||
params: `["` + testchain.MultisigAddress() + `"]`,
|
||||
result: func(*executor) interface{} {
|
||||
// hash of the issueTx
|
||||
h, _ := util.Uint256DecodeStringBE("4cccf8f1a4cfa9ebd9344c312f8220199ee9000f14cb951f677601d208aa5af0")
|
||||
h, _ := util.Uint256DecodeStringBE("8a4711012932f4f79f9534803feab0ef85e7a313c52a36f5d56b9f8ec190bd92")
|
||||
amount := util.Fixed8FromInt64(1 * 8) // (endHeight - startHeight) * genAmount[0]
|
||||
return &result.ClaimableInfo{
|
||||
Spents: []result.Claimable{
|
||||
|
@ -578,7 +578,7 @@ var rpcTestCases = map[string][]rpcTestCase{
|
|||
"gettransactionheight": {
|
||||
{
|
||||
name: "positive",
|
||||
params: `["865469df8fab5f665b37c67de3beba832fa17b27675d4ac2eec0d60ce40f42fd"]`,
|
||||
params: `["5f1e841f625d52dd3d73bbf5203f8468835353b7c476a4d367161ea959944981"]`,
|
||||
result: func(e *executor) interface{} {
|
||||
h := 1
|
||||
return &h
|
||||
|
@ -693,7 +693,7 @@ var rpcTestCases = map[string][]rpcTestCase{
|
|||
check: func(t *testing.T, e *executor, inv interface{}) {
|
||||
res, ok := inv.(*result.Invoke)
|
||||
require.True(t, ok)
|
||||
assert.Equal(t, "06717765727479676f459162ceeb248b071ec157d9e4f6fd26fdbe50", res.Script)
|
||||
assert.Equal(t, "0c06717765727479676f459162ceeb248b071ec157d9e4f6fd26fdbe50", res.Script)
|
||||
assert.NotEqual(t, "", res.State)
|
||||
assert.NotEqual(t, 0, res.GasConsumed)
|
||||
},
|
||||
|
@ -790,7 +790,7 @@ var rpcTestCases = map[string][]rpcTestCase{
|
|||
"sendrawtransaction": {
|
||||
{
|
||||
name: "positive",
|
||||
params: `["8000130000006501dbe71845f26f6b4d848b034d624eeda7bbc4b00400000001d41146fbea5a066daa8ff358822fba2b5a60d0b554feccb5ee54cedbdb86315c010001f5bc5a9ac7b85a47be381260a06b5a1e7a667ce8f7d7c8baa5cfc6465571377a0030d3dec38623006501dbe71845f26f6b4d848b034d624eeda7bbc40141402ddc9a3b036932fa42df8e97f7fe713e2c673060d1d4134ce93e35da790b98bd744beb7a37d515371929f98ee2642699303856ea603d1d68fc157174aa586671294c2102b3622bf4017bdfe317c58aed5f4c753f206b7db896046fa7d774bbc4bf7f8dc250680a906ad4"]`,
|
||||
params: `["80001300000075a94799633ed955dd85a8af314a5b435ab51903b00400000001eb15931b0544cbb9a283f934ab89a23e73cf90b9ca097bb327a0bcdcddf8ce2e010001f5bc5a9ac7b85a47be381260a06b5a1e7a667ce8f7d7c8baa5cfc6465571377a0030d3dec386230075a94799633ed955dd85a8af314a5b435ab5190301420c4082632495e555507a056eae951ad1893f27163dde40505340f6cf9578e20c3d7ec0c7e00f93cb2e770a7ce3e8a2910deabdd01fd966507a7a29106dd2add583ee290c2102b3622bf4017bdfe317c58aed5f4c753f206b7db896046fa7d774bbc4bf7f8dc20b680a906ad4"]`,
|
||||
result: func(e *executor) interface{} {
|
||||
v := true
|
||||
return &v
|
||||
|
@ -821,7 +821,7 @@ var rpcTestCases = map[string][]rpcTestCase{
|
|||
{
|
||||
// If you are planning to modify test chain from `testblocks.acc`, please, update param value (first block)
|
||||
name: "empty block",
|
||||
params: `["00000000bdd51295d6e8bbfcff7d08ddfc2e8d6b509829547f8f834a259d785f88c5dd030000000000000000000000000000000000000000000000000000000000000000a78c9d5ed10000005704000000000000d60ac443bb800fb08261e75fa5925d747d48586101fd04014064132b8f90426ebc0370693a16a0bf9a334b3022fe1b0e7abbdded639892cd8ce5a222de32c90e6882b155d21da95e8b7dda4c9e2641fb605b1ea04d3b8de056405456777ba6296fe98f0c9af9364a84691f5b3c3f7a6f19ca600d02db6ba2ab019ef6cb67c0c39ee6b6c98a9e920eec592e73ac8525949fada9094368adcaa06140eb3b961953d97daedb0898da8a7d32f0a3de0eb553ef55c5ae6fe982d9442804be1b883e2d9ebcff592c4c57350acb1527a669e6bf15d560295701ed71dbaa5a4018d2accab62726b7608c8370c601f5916b5ff87e3552f1c17a06b8453037a7a20a4c3c937e002c5dbbfc1f877a9e08b401d688fca96de4aba79e92a2f7e90f9594534c2102103a7f7dd016558597f7960d27c516a4394fd968b9e65155eb4b013e4040406e4c2102a7bc55fe8684e0119768d104ba30795bdcc86619e864add26156723ed185cd624c2102b3622bf4017bdfe317c58aed5f4c753f206b7db896046fa7d774bbc4bf7f8dc24c2103d90c07df63e690ce77912e10ab51acc944b66860237b608c4f8f8309e71ee6995450683073b3bb00"]`,
|
||||
params: `["0000000007b57cc5c1902010f968adc0cb96c87e1a97005ee1ddc8510cf6272e812221820000000000000000000000000000000000000000000000000000000000000000db0ca05ed10000005704000000000000e903736ceceeceae1806eee0e3ec61e7cce476ce01fd08010c4050da0a5d3672a56ad442a1e58129e8df0ca4c3235e33e86b8332144a253c559a35742206f87866cfdb8f809cac8b4cc9bc901372161a7a577ed6490158c492a60c4007bb4e7776a3102c183ba8e5aec77b9a436e6629f67150a77689e25c32df427b5a4c77f2198f0554fbc1ef2f2e2605f3a84d5789a48e90883203d491172c3f0d0c4049b0a16bb1decc7673d9bdca2e3a613b1102a7774e405d3d1ce1fff276acb8d6d0eff980554792d21603b9d9b6dd50941ea3eda4efad4922b063571ea49108df0c401bb53c5d0fcf94beeb7c1f0d9d9998b7af5f29c906492d49f4650de250826926cfc2c7bdb6369139563a0ed74039c4fb69c0e63ced82fc2a2b74778c7287ca5694130c2102103a7f7dd016558597f7960d27c516a4394fd968b9e65155eb4b013e4040406e0c2102a7bc55fe8684e0119768d104ba30795bdcc86619e864add26156723ed185cd620c2102b3622bf4017bdfe317c58aed5f4c753f206b7db896046fa7d774bbc4bf7f8dc20c2103d90c07df63e690ce77912e10ab51acc944b66860237b608c4f8f8309e71ee699140b683073b3bb00"]`,
|
||||
fail: true,
|
||||
},
|
||||
{
|
||||
|
@ -847,7 +847,7 @@ var rpcTestCases = map[string][]rpcTestCase{
|
|||
{
|
||||
name: "positive",
|
||||
// If you are planning to modify test chain from `testblocks.acc`, please, update param value (second block)
|
||||
params: `["00000000bdd51295d6e8bbfcff7d08ddfc2e8d6b509829547f8f834a259d785f88c5dd036801125aaa2b6bdaa47414006f28316315df928520e630a702e944522720ad06a78c9d5ed10000005704000000000000d60ac443bb800fb08261e75fa5925d747d48586101fd040140caf89bf82fd25e9b3d0d0fab62fbf832df753116682e23939441da868a79c5d8cf4000066130de95d184a778053a3c41cf832009add80ecb7648621de5ad63ef4060438f3f3a7744a813c9d1ebd814a2ca5d55ea86f223a56dd7f295d9d3f355687e679311656e83c014642f78e22a9c8388d880e64080e1f07de420b280e0023a4053478c1eaac15771a07506bc97d0b6f1766b8cb0d5f98ead7e5df30555ec1bb409c7e57d4e8286beeb23221a2e01273240ad74ab7ee88474812848392fdc9f8e401391d88d7a0add6d79fa9f3c5598707fc89bcb372b3e40a76d90b57f0e615c503b10b2c648df2b79f22ca949f143aaeae3a6bd4b64f666965fbc1c286c0a6dcb94534c2102103a7f7dd016558597f7960d27c516a4394fd968b9e65155eb4b013e4040406e4c2102a7bc55fe8684e0119768d104ba30795bdcc86619e864add26156723ed185cd624c2102b3622bf4017bdfe317c58aed5f4c753f206b7db896046fa7d774bbc4bf7f8dc24c2103d90c07df63e690ce77912e10ab51acc944b66860237b608c4f8f8309e71ee6995450683073b3bb010000140000006501dbe71845f26f6b4d848b034d624eeda7bbc4b0040000000000014140acddd18b655f8692dd169c7dcf53923dc85cbe34852cf4220dffdfea284dbca19035dff2f8655245d51a4823719fef1228e40351213633c9b46aed79df2eaa4e294c2102b3622bf4017bdfe317c58aed5f4c753f206b7db896046fa7d774bbc4bf7f8dc250680a906ad4"]`,
|
||||
params: `["0000000007b57cc5c1902010f968adc0cb96c87e1a97005ee1ddc8510cf6272e81222182d13aba8fa5e27a16382d64ce3751b9ffaa3f81f634fbd4399bf048d58e7c5c7adb0ca05ed10000005704000000000000e903736ceceeceae1806eee0e3ec61e7cce476ce01fd08010c405545b3ad5912f043ed975176ba1f02f64119f10d63385a472ecaef6aa4a2b04237946e66e74e53435a19abd59fb14dfa7d64d29a39b8655c23ed87c74d2674d70c40e6880ad9677b3b28f6c0a3c9172f8ff98dcc5ad7c78768e34481799edebcf5bbcafa583740808bf0668bdd07288b004b11f52db517ef68482e8cf1f5774ef6ba0c406ea533f7f49310e9156d7c6032fbc8a63d20777e9e850fdc0a0d3e3d9c5b9340e4d22eba14a8a1446b886a34dee437e6cfd4f2b6eed9048291610330968c225a0c401a7c49e25676aabd511bcf556970c28e530df561f89dd7d12285e848ef234273eca90a9344420ace9c84df798925d4c547ea120183ae5562b6507f55acb52c7e94130c2102103a7f7dd016558597f7960d27c516a4394fd968b9e65155eb4b013e4040406e0c2102a7bc55fe8684e0119768d104ba30795bdcc86619e864add26156723ed185cd620c2102b3622bf4017bdfe317c58aed5f4c753f206b7db896046fa7d774bbc4bf7f8dc20c2103d90c07df63e690ce77912e10ab51acc944b66860237b608c4f8f8309e71ee699140b683073b3bb0100001400000075a94799633ed955dd85a8af314a5b435ab51903b004000000000001420c40b2eb026301528ce76f07caa304f26e3aaa08997e82f12a94350ec1354683d165f4a02c87f2250dae39abbf55dd9a0bd642ecbbbb17136ca2c202bc5757c1495c290c2102b3622bf4017bdfe317c58aed5f4c753f206b7db896046fa7d774bbc4bf7f8dc20b680a906ad4"]`,
|
||||
result: func(e *executor) interface{} {
|
||||
v := true
|
||||
return &v
|
||||
|
|
BIN
pkg/rpc/server/testdata/test_contract.avm
vendored
BIN
pkg/rpc/server/testdata/test_contract.avm
vendored
Binary file not shown.
BIN
pkg/rpc/server/testdata/testblocks.acc
vendored
BIN
pkg/rpc/server/testdata/testblocks.acc
vendored
Binary file not shown.
|
@ -26,8 +26,7 @@ func CreateMultiSigRedeemScript(m int, publicKeys keys.PublicKeys) ([]byte, erro
|
|||
emit.Int(buf.BinWriter, int64(m))
|
||||
sort.Sort(publicKeys)
|
||||
for _, pubKey := range publicKeys {
|
||||
emit.Instruction(buf.BinWriter, opcode.PUSHDATA1, []byte{33})
|
||||
buf.BinWriter.WriteBytes(pubKey.Bytes())
|
||||
emit.Bytes(buf.BinWriter, pubKey.Bytes())
|
||||
}
|
||||
emit.Int(buf.BinWriter, int64(len(publicKeys)))
|
||||
emit.Opcode(buf.BinWriter, opcode.PUSHNULL)
|
||||
|
|
|
@ -108,8 +108,8 @@ func (c *Context) Next() (opcode.Opcode, []byte, error) {
|
|||
case opcode.CALLE, opcode.CALLET:
|
||||
numtoread = 22
|
||||
default:
|
||||
if instr >= opcode.PUSHBYTES1 && instr <= opcode.PUSHBYTES75 {
|
||||
numtoread = int(instr)
|
||||
if instr <= opcode.PUSHINT256 {
|
||||
numtoread = 1 << instr
|
||||
} else {
|
||||
// No parameters, can just return.
|
||||
return instr, nil, nil
|
||||
|
|
|
@ -15,16 +15,15 @@ var (
|
|||
func getNumOfThingsFromInstr(instr opcode.Opcode, param []byte) (int, bool) {
|
||||
var nthings int
|
||||
|
||||
switch instr {
|
||||
case opcode.PUSH1, opcode.PUSH2, opcode.PUSH3, opcode.PUSH4,
|
||||
opcode.PUSH5, opcode.PUSH6, opcode.PUSH7, opcode.PUSH8,
|
||||
opcode.PUSH9, opcode.PUSH10, opcode.PUSH11, opcode.PUSH12,
|
||||
opcode.PUSH13, opcode.PUSH14, opcode.PUSH15, opcode.PUSH16:
|
||||
switch {
|
||||
case opcode.PUSH1 <= instr && instr <= opcode.PUSH16:
|
||||
nthings = int(instr-opcode.PUSH1) + 1
|
||||
case opcode.PUSHBYTES1:
|
||||
nthings = int(param[0])
|
||||
case opcode.PUSHBYTES2:
|
||||
nthings = int(binary.LittleEndian.Uint16(param))
|
||||
case instr <= opcode.PUSHINT256:
|
||||
n := emit.BytesToInt(param)
|
||||
if !n.IsInt64() || n.Int64() > MaxArraySize {
|
||||
return 0, false
|
||||
}
|
||||
nthings = int(n.Int64())
|
||||
default:
|
||||
return 0, false
|
||||
}
|
||||
|
|
|
@ -84,9 +84,13 @@ func getEffectiveSize(buf []byte, isNeg bool) int {
|
|||
// when n == 0. For zero is equal to empty slice in NEO3.
|
||||
// https://github.com/neo-project/neo-vm/blob/master/src/neo-vm/Types/Integer.cs#L16
|
||||
func IntToBytes(n *big.Int) []byte {
|
||||
return intToBytes(n, []byte{})
|
||||
}
|
||||
|
||||
func intToBytes(n *big.Int, data []byte) []byte {
|
||||
sign := n.Sign()
|
||||
if sign == 0 {
|
||||
return []byte{}
|
||||
return data
|
||||
}
|
||||
|
||||
var ws []big.Word
|
||||
|
@ -95,13 +99,19 @@ func IntToBytes(n *big.Int) []byte {
|
|||
} else {
|
||||
n1 := new(big.Int).Add(n, big.NewInt(1))
|
||||
if n1.Sign() == 0 { // n == -1
|
||||
return []byte{0xFF}
|
||||
return append(data, 0xFF)
|
||||
}
|
||||
|
||||
ws = n1.Bits()
|
||||
}
|
||||
|
||||
data := wordsToBytes(ws)
|
||||
lb := len(ws) * wordSizeBytes
|
||||
if c := cap(data); c < lb {
|
||||
data = make([]byte, lb, lb+1)
|
||||
} else {
|
||||
data = data[:lb]
|
||||
}
|
||||
data = wordsToBytes(ws, data)
|
||||
|
||||
size := len(data)
|
||||
for ; data[size-1] == 0; size-- {
|
||||
|
@ -122,10 +132,7 @@ func IntToBytes(n *big.Int) []byte {
|
|||
return data
|
||||
}
|
||||
|
||||
func wordsToBytes(ws []big.Word) []byte {
|
||||
lb := len(ws) * wordSizeBytes
|
||||
bs := make([]byte, lb, lb+1)
|
||||
|
||||
func wordsToBytes(ws []big.Word, bs []byte) []byte {
|
||||
if wordSizeBytes == 8 {
|
||||
for i := range ws {
|
||||
binary.LittleEndian.PutUint64(bs[i*wordSizeBytes:], uint64(ws[i]))
|
||||
|
|
|
@ -6,6 +6,7 @@ import (
|
|||
"errors"
|
||||
"fmt"
|
||||
"math/big"
|
||||
"math/bits"
|
||||
|
||||
"github.com/nspcc-dev/neo-go/pkg/io"
|
||||
"github.com/nspcc-dev/neo-go/pkg/util"
|
||||
|
@ -32,20 +33,31 @@ func Bool(w *io.BinWriter, ok bool) {
|
|||
Opcode(w, opcode.PUSHF)
|
||||
}
|
||||
|
||||
func padRight(s int, buf []byte) []byte {
|
||||
l := len(buf)
|
||||
buf = buf[:s]
|
||||
if buf[l-1]&0x80 != 0 {
|
||||
for i := l; i < s; i++ {
|
||||
buf[i] = 0xFF
|
||||
}
|
||||
}
|
||||
return buf
|
||||
}
|
||||
|
||||
// Int emits a int type to the given buffer.
|
||||
func Int(w *io.BinWriter, i int64) {
|
||||
switch {
|
||||
case i == -1:
|
||||
Opcode(w, opcode.PUSHM1)
|
||||
case i == 0:
|
||||
Opcode(w, opcode.PUSHF)
|
||||
case i > 0 && i < 16:
|
||||
case i >= 0 && i < 16:
|
||||
val := opcode.Opcode(int(opcode.PUSH1) - 1 + int(i))
|
||||
Opcode(w, val)
|
||||
default:
|
||||
bInt := big.NewInt(i)
|
||||
val := IntToBytes(bInt)
|
||||
Bytes(w, val)
|
||||
buf := intToBytes(big.NewInt(i), make([]byte, 0, 32))
|
||||
// l != 0 becase of switch
|
||||
padSize := byte(8 - bits.LeadingZeros8(byte(len(buf)-1)))
|
||||
Opcode(w, opcode.PUSHINT8+opcode.Opcode(padSize))
|
||||
w.WriteBytes(padRight(1<<padSize, buf))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -82,9 +94,6 @@ func Bytes(w *io.BinWriter, b []byte) {
|
|||
var n = len(b)
|
||||
|
||||
switch {
|
||||
case n <= int(opcode.PUSHBYTES75):
|
||||
Instruction(w, opcode.Opcode(n), b)
|
||||
return
|
||||
case n < 0x100:
|
||||
Instruction(w, opcode.PUSHDATA1, []byte{byte(n)})
|
||||
case n < 0x10000:
|
||||
|
|
|
@ -35,20 +35,49 @@ func TestEmitInt(t *testing.T) {
|
|||
assert.EqualValues(t, opcode.PUSH10, result[0])
|
||||
})
|
||||
|
||||
t.Run("big 1-byte int", func(t *testing.T) {
|
||||
buf := io.NewBufBinWriter()
|
||||
Int(buf.BinWriter, 42)
|
||||
result := buf.Bytes()
|
||||
assert.EqualValues(t, opcode.PUSHINT8, result[0])
|
||||
assert.EqualValues(t, 42, result[1])
|
||||
})
|
||||
|
||||
t.Run("2-byte int", func(t *testing.T) {
|
||||
buf := io.NewBufBinWriter()
|
||||
Int(buf.BinWriter, 100)
|
||||
Int(buf.BinWriter, 300)
|
||||
result := buf.Bytes()
|
||||
assert.EqualValues(t, opcode.PUSHBYTES1, result[0])
|
||||
assert.EqualValues(t, 100, result[1])
|
||||
assert.Equal(t, 3, len(result))
|
||||
assert.EqualValues(t, opcode.PUSHINT16, result[0])
|
||||
assert.EqualValues(t, 300, BytesToInt(result[1:]).Int64())
|
||||
})
|
||||
|
||||
t.Run("3-byte int", func(t *testing.T) {
|
||||
buf := io.NewBufBinWriter()
|
||||
Int(buf.BinWriter, 1<<20)
|
||||
result := buf.Bytes()
|
||||
assert.Equal(t, 5, len(result))
|
||||
assert.EqualValues(t, opcode.PUSHINT32, result[0])
|
||||
assert.EqualValues(t, 1<<20, BytesToInt(result[1:]).Int64())
|
||||
})
|
||||
|
||||
t.Run("4-byte int", func(t *testing.T) {
|
||||
buf := io.NewBufBinWriter()
|
||||
Int(buf.BinWriter, 1000)
|
||||
Int(buf.BinWriter, 1<<28)
|
||||
result := buf.Bytes()
|
||||
assert.EqualValues(t, opcode.PUSHBYTES2, result[0])
|
||||
assert.EqualValues(t, 1000, binary.LittleEndian.Uint16(result[1:3]))
|
||||
assert.Equal(t, 5, len(result))
|
||||
assert.EqualValues(t, opcode.PUSHINT32, result[0])
|
||||
assert.EqualValues(t, 1<<28, BytesToInt(result[1:]).Int64())
|
||||
})
|
||||
|
||||
t.Run("negative 3-byte int with padding", func(t *testing.T) {
|
||||
const num = -(1 << 23)
|
||||
buf := io.NewBufBinWriter()
|
||||
Int(buf.BinWriter, num)
|
||||
result := buf.Bytes()
|
||||
assert.Equal(t, 5, len(result))
|
||||
assert.EqualValues(t, opcode.PUSHINT32, result[0])
|
||||
assert.EqualValues(t, num, BytesToInt(result[1:]).Int64())
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -67,8 +96,9 @@ func TestBytes(t *testing.T) {
|
|||
Bytes(buf.BinWriter, []byte{0, 1, 2, 3})
|
||||
|
||||
result := buf.Bytes()
|
||||
assert.EqualValues(t, opcode.PUSHBYTES4, result[0])
|
||||
assert.EqualValues(t, []byte{0, 1, 2, 3}, result[1:])
|
||||
assert.EqualValues(t, opcode.PUSHDATA1, result[0])
|
||||
assert.EqualValues(t, 4, result[1])
|
||||
assert.EqualValues(t, []byte{0, 1, 2, 3}, result[2:])
|
||||
})
|
||||
|
||||
t.Run("slice with len <= 255", func(t *testing.T) {
|
||||
|
@ -115,19 +145,21 @@ func TestEmitArray(t *testing.T) {
|
|||
require.NoError(t, buf.Err)
|
||||
|
||||
res := buf.Bytes()
|
||||
assert.EqualValues(t, opcode.PUSHBYTES2, res[0])
|
||||
assert.EqualValues(t, []byte{0xCA, 0xFE}, res[1:3])
|
||||
assert.EqualValues(t, opcode.PUSHT, res[3])
|
||||
assert.EqualValues(t, opcode.PUSHBYTES3, res[4])
|
||||
assert.EqualValues(t, []byte("str"), res[5:8])
|
||||
assert.EqualValues(t, opcode.PUSH1, res[8])
|
||||
assert.EqualValues(t, opcode.PUSHDATA1, res[0])
|
||||
assert.EqualValues(t, 2, res[1])
|
||||
assert.EqualValues(t, []byte{0xCA, 0xFE}, res[2:4])
|
||||
assert.EqualValues(t, opcode.PUSHT, res[4])
|
||||
assert.EqualValues(t, opcode.PUSHDATA1, res[5])
|
||||
assert.EqualValues(t, 3, res[6])
|
||||
assert.EqualValues(t, []byte("str"), res[7:10])
|
||||
assert.EqualValues(t, opcode.PUSH1, res[10])
|
||||
})
|
||||
|
||||
t.Run("empty", func(t *testing.T) {
|
||||
buf := io.NewBufBinWriter()
|
||||
Array(buf.BinWriter)
|
||||
require.NoError(t, buf.Err)
|
||||
assert.EqualValues(t, []byte{0, byte(opcode.PACK)}, buf.Bytes())
|
||||
assert.EqualValues(t, []byte{byte(opcode.PUSH0), byte(opcode.PACK)}, buf.Bytes())
|
||||
})
|
||||
|
||||
t.Run("invalid type", func(t *testing.T) {
|
||||
|
@ -150,8 +182,8 @@ func TestEmitString(t *testing.T) {
|
|||
buf := io.NewBufBinWriter()
|
||||
str := "City Of Zion"
|
||||
String(buf.BinWriter, str)
|
||||
assert.Equal(t, buf.Len(), len(str)+1)
|
||||
assert.Equal(t, buf.Bytes()[1:], []byte(str))
|
||||
assert.Equal(t, buf.Len(), len(str)+2)
|
||||
assert.Equal(t, buf.Bytes()[2:], []byte(str))
|
||||
}
|
||||
|
||||
func TestEmitSyscall(t *testing.T) {
|
||||
|
|
|
@ -8,105 +8,41 @@ type Opcode byte
|
|||
// Viable list of supported instruction constants.
|
||||
const (
|
||||
// Constants
|
||||
PUSH0 Opcode = 0x00
|
||||
PUSHF Opcode = PUSH0
|
||||
PUSHBYTES1 Opcode = 0x01
|
||||
PUSHBYTES2 Opcode = 0x02
|
||||
PUSHBYTES3 Opcode = 0x03
|
||||
PUSHBYTES4 Opcode = 0x04
|
||||
PUSHBYTES5 Opcode = 0x05
|
||||
PUSHBYTES6 Opcode = 0x06
|
||||
PUSHBYTES7 Opcode = 0x07
|
||||
PUSHBYTES8 Opcode = 0x08
|
||||
PUSHBYTES9 Opcode = 0x09
|
||||
PUSHBYTES10 Opcode = 0x0A
|
||||
PUSHBYTES11 Opcode = 0x0B
|
||||
PUSHBYTES12 Opcode = 0x0C
|
||||
PUSHBYTES13 Opcode = 0x0D
|
||||
PUSHBYTES14 Opcode = 0x0E
|
||||
PUSHBYTES15 Opcode = 0x0F
|
||||
PUSHBYTES16 Opcode = 0x10
|
||||
PUSHBYTES17 Opcode = 0x11
|
||||
PUSHBYTES18 Opcode = 0x12
|
||||
PUSHBYTES19 Opcode = 0x13
|
||||
PUSHBYTES20 Opcode = 0x14
|
||||
PUSHBYTES21 Opcode = 0x15
|
||||
PUSHBYTES22 Opcode = 0x16
|
||||
PUSHBYTES23 Opcode = 0x17
|
||||
PUSHBYTES24 Opcode = 0x18
|
||||
PUSHBYTES25 Opcode = 0x19
|
||||
PUSHBYTES26 Opcode = 0x1A
|
||||
PUSHBYTES27 Opcode = 0x1B
|
||||
PUSHBYTES28 Opcode = 0x1C
|
||||
PUSHBYTES29 Opcode = 0x1D
|
||||
PUSHBYTES30 Opcode = 0x1E
|
||||
PUSHBYTES31 Opcode = 0x1F
|
||||
PUSHBYTES32 Opcode = 0x20
|
||||
PUSHBYTES33 Opcode = 0x21
|
||||
PUSHBYTES34 Opcode = 0x22
|
||||
PUSHBYTES35 Opcode = 0x23
|
||||
PUSHBYTES36 Opcode = 0x24
|
||||
PUSHBYTES37 Opcode = 0x25
|
||||
PUSHBYTES38 Opcode = 0x26
|
||||
PUSHBYTES39 Opcode = 0x27
|
||||
PUSHBYTES40 Opcode = 0x28
|
||||
PUSHBYTES41 Opcode = 0x29
|
||||
PUSHBYTES42 Opcode = 0x2A
|
||||
PUSHBYTES43 Opcode = 0x2B
|
||||
PUSHBYTES44 Opcode = 0x2C
|
||||
PUSHBYTES45 Opcode = 0x2D
|
||||
PUSHBYTES46 Opcode = 0x2E
|
||||
PUSHBYTES47 Opcode = 0x2F
|
||||
PUSHBYTES48 Opcode = 0x30
|
||||
PUSHBYTES49 Opcode = 0x31
|
||||
PUSHBYTES50 Opcode = 0x32
|
||||
PUSHBYTES51 Opcode = 0x33
|
||||
PUSHBYTES52 Opcode = 0x34
|
||||
PUSHBYTES53 Opcode = 0x35
|
||||
PUSHBYTES54 Opcode = 0x36
|
||||
PUSHBYTES55 Opcode = 0x37
|
||||
PUSHBYTES56 Opcode = 0x38
|
||||
PUSHBYTES57 Opcode = 0x39
|
||||
PUSHBYTES58 Opcode = 0x3A
|
||||
PUSHBYTES59 Opcode = 0x3B
|
||||
PUSHBYTES60 Opcode = 0x3C
|
||||
PUSHBYTES61 Opcode = 0x3D
|
||||
PUSHBYTES62 Opcode = 0x3E
|
||||
PUSHBYTES63 Opcode = 0x3F
|
||||
PUSHBYTES64 Opcode = 0x40
|
||||
PUSHBYTES65 Opcode = 0x41
|
||||
PUSHBYTES66 Opcode = 0x42
|
||||
PUSHBYTES67 Opcode = 0x43
|
||||
PUSHBYTES68 Opcode = 0x44
|
||||
PUSHBYTES69 Opcode = 0x45
|
||||
PUSHBYTES70 Opcode = 0x46
|
||||
PUSHBYTES71 Opcode = 0x47
|
||||
PUSHBYTES72 Opcode = 0x48
|
||||
PUSHBYTES73 Opcode = 0x49
|
||||
PUSHBYTES74 Opcode = 0x4A
|
||||
PUSHBYTES75 Opcode = 0x4B
|
||||
PUSHDATA1 Opcode = 0x4C
|
||||
PUSHDATA2 Opcode = 0x4D
|
||||
PUSHDATA4 Opcode = 0x4E
|
||||
PUSHM1 Opcode = 0x4F
|
||||
PUSHNULL Opcode = 0x50
|
||||
PUSH1 Opcode = 0x51
|
||||
PUSHT Opcode = PUSH1
|
||||
PUSH2 Opcode = 0x52
|
||||
PUSH3 Opcode = 0x53
|
||||
PUSH4 Opcode = 0x54
|
||||
PUSH5 Opcode = 0x55
|
||||
PUSH6 Opcode = 0x56
|
||||
PUSH7 Opcode = 0x57
|
||||
PUSH8 Opcode = 0x58
|
||||
PUSH9 Opcode = 0x59
|
||||
PUSH10 Opcode = 0x5A
|
||||
PUSH11 Opcode = 0x5B
|
||||
PUSH12 Opcode = 0x5C
|
||||
PUSH13 Opcode = 0x5D
|
||||
PUSH14 Opcode = 0x5E
|
||||
PUSH15 Opcode = 0x5F
|
||||
PUSH16 Opcode = 0x60
|
||||
PUSHINT8 Opcode = 0x00
|
||||
PUSHINT16 Opcode = 0x01
|
||||
PUSHINT32 Opcode = 0x02
|
||||
PUSHINT64 Opcode = 0x03
|
||||
PUSHINT128 Opcode = 0x04
|
||||
PUSHINT256 Opcode = 0x05
|
||||
|
||||
PUSHNULL Opcode = 0x0B
|
||||
|
||||
PUSHDATA1 Opcode = 0x0C
|
||||
PUSHDATA2 Opcode = 0x0D
|
||||
PUSHDATA4 Opcode = 0x0E
|
||||
|
||||
PUSHM1 Opcode = 0x0F
|
||||
PUSH0 Opcode = 0x10
|
||||
PUSHF Opcode = PUSH0
|
||||
PUSH1 Opcode = 0x11
|
||||
PUSHT Opcode = PUSH1
|
||||
PUSH2 Opcode = 0x12
|
||||
PUSH3 Opcode = 0x13
|
||||
PUSH4 Opcode = 0x14
|
||||
PUSH5 Opcode = 0x15
|
||||
PUSH6 Opcode = 0x16
|
||||
PUSH7 Opcode = 0x17
|
||||
PUSH8 Opcode = 0x18
|
||||
PUSH9 Opcode = 0x19
|
||||
PUSH10 Opcode = 0x1A
|
||||
PUSH11 Opcode = 0x1B
|
||||
PUSH12 Opcode = 0x1C
|
||||
PUSH13 Opcode = 0x1D
|
||||
PUSH14 Opcode = 0x1E
|
||||
PUSH15 Opcode = 0x1F
|
||||
PUSH16 Opcode = 0x20
|
||||
|
||||
OLDPUSH1 Opcode = 0x51
|
||||
|
||||
// Flow control
|
||||
NOP Opcode = 0x61
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// Code generated by "stringer -type=Opcode"; DO NOT EDIT.
|
||||
// Code generated by "stringer -type Opcode"; DO NOT EDIT.
|
||||
|
||||
package opcode
|
||||
|
||||
|
@ -8,104 +8,36 @@ func _() {
|
|||
// An "invalid array index" compiler error signifies that the constant values have changed.
|
||||
// Re-run the stringer command to generate them again.
|
||||
var x [1]struct{}
|
||||
_ = x[PUSH0-0]
|
||||
_ = x[PUSHF-0]
|
||||
_ = x[PUSHBYTES1-1]
|
||||
_ = x[PUSHBYTES2-2]
|
||||
_ = x[PUSHBYTES3-3]
|
||||
_ = x[PUSHBYTES4-4]
|
||||
_ = x[PUSHBYTES5-5]
|
||||
_ = x[PUSHBYTES6-6]
|
||||
_ = x[PUSHBYTES7-7]
|
||||
_ = x[PUSHBYTES8-8]
|
||||
_ = x[PUSHBYTES9-9]
|
||||
_ = x[PUSHBYTES10-10]
|
||||
_ = x[PUSHBYTES11-11]
|
||||
_ = x[PUSHBYTES12-12]
|
||||
_ = x[PUSHBYTES13-13]
|
||||
_ = x[PUSHBYTES14-14]
|
||||
_ = x[PUSHBYTES15-15]
|
||||
_ = x[PUSHBYTES16-16]
|
||||
_ = x[PUSHBYTES17-17]
|
||||
_ = x[PUSHBYTES18-18]
|
||||
_ = x[PUSHBYTES19-19]
|
||||
_ = x[PUSHBYTES20-20]
|
||||
_ = x[PUSHBYTES21-21]
|
||||
_ = x[PUSHBYTES22-22]
|
||||
_ = x[PUSHBYTES23-23]
|
||||
_ = x[PUSHBYTES24-24]
|
||||
_ = x[PUSHBYTES25-25]
|
||||
_ = x[PUSHBYTES26-26]
|
||||
_ = x[PUSHBYTES27-27]
|
||||
_ = x[PUSHBYTES28-28]
|
||||
_ = x[PUSHBYTES29-29]
|
||||
_ = x[PUSHBYTES30-30]
|
||||
_ = x[PUSHBYTES31-31]
|
||||
_ = x[PUSHBYTES32-32]
|
||||
_ = x[PUSHBYTES33-33]
|
||||
_ = x[PUSHBYTES34-34]
|
||||
_ = x[PUSHBYTES35-35]
|
||||
_ = x[PUSHBYTES36-36]
|
||||
_ = x[PUSHBYTES37-37]
|
||||
_ = x[PUSHBYTES38-38]
|
||||
_ = x[PUSHBYTES39-39]
|
||||
_ = x[PUSHBYTES40-40]
|
||||
_ = x[PUSHBYTES41-41]
|
||||
_ = x[PUSHBYTES42-42]
|
||||
_ = x[PUSHBYTES43-43]
|
||||
_ = x[PUSHBYTES44-44]
|
||||
_ = x[PUSHBYTES45-45]
|
||||
_ = x[PUSHBYTES46-46]
|
||||
_ = x[PUSHBYTES47-47]
|
||||
_ = x[PUSHBYTES48-48]
|
||||
_ = x[PUSHBYTES49-49]
|
||||
_ = x[PUSHBYTES50-50]
|
||||
_ = x[PUSHBYTES51-51]
|
||||
_ = x[PUSHBYTES52-52]
|
||||
_ = x[PUSHBYTES53-53]
|
||||
_ = x[PUSHBYTES54-54]
|
||||
_ = x[PUSHBYTES55-55]
|
||||
_ = x[PUSHBYTES56-56]
|
||||
_ = x[PUSHBYTES57-57]
|
||||
_ = x[PUSHBYTES58-58]
|
||||
_ = x[PUSHBYTES59-59]
|
||||
_ = x[PUSHBYTES60-60]
|
||||
_ = x[PUSHBYTES61-61]
|
||||
_ = x[PUSHBYTES62-62]
|
||||
_ = x[PUSHBYTES63-63]
|
||||
_ = x[PUSHBYTES64-64]
|
||||
_ = x[PUSHBYTES65-65]
|
||||
_ = x[PUSHBYTES66-66]
|
||||
_ = x[PUSHBYTES67-67]
|
||||
_ = x[PUSHBYTES68-68]
|
||||
_ = x[PUSHBYTES69-69]
|
||||
_ = x[PUSHBYTES70-70]
|
||||
_ = x[PUSHBYTES71-71]
|
||||
_ = x[PUSHBYTES72-72]
|
||||
_ = x[PUSHBYTES73-73]
|
||||
_ = x[PUSHBYTES74-74]
|
||||
_ = x[PUSHBYTES75-75]
|
||||
_ = x[PUSHDATA1-76]
|
||||
_ = x[PUSHDATA2-77]
|
||||
_ = x[PUSHDATA4-78]
|
||||
_ = x[PUSHM1-79]
|
||||
_ = x[PUSH1-81]
|
||||
_ = x[PUSHT-81]
|
||||
_ = x[PUSH2-82]
|
||||
_ = x[PUSH3-83]
|
||||
_ = x[PUSH4-84]
|
||||
_ = x[PUSH5-85]
|
||||
_ = x[PUSH6-86]
|
||||
_ = x[PUSH7-87]
|
||||
_ = x[PUSH8-88]
|
||||
_ = x[PUSH9-89]
|
||||
_ = x[PUSH10-90]
|
||||
_ = x[PUSH11-91]
|
||||
_ = x[PUSH12-92]
|
||||
_ = x[PUSH13-93]
|
||||
_ = x[PUSH14-94]
|
||||
_ = x[PUSH15-95]
|
||||
_ = x[PUSH16-96]
|
||||
_ = x[PUSHINT8-0]
|
||||
_ = x[PUSHINT16-1]
|
||||
_ = x[PUSHINT32-2]
|
||||
_ = x[PUSHINT64-3]
|
||||
_ = x[PUSHINT128-4]
|
||||
_ = x[PUSHINT256-5]
|
||||
_ = x[PUSHNULL-11]
|
||||
_ = x[PUSHDATA1-12]
|
||||
_ = x[PUSHDATA2-13]
|
||||
_ = x[PUSHDATA4-14]
|
||||
_ = x[PUSHM1-15]
|
||||
_ = x[PUSH0-16]
|
||||
_ = x[PUSHF-16]
|
||||
_ = x[PUSH1-17]
|
||||
_ = x[PUSHT-17]
|
||||
_ = x[PUSH2-18]
|
||||
_ = x[PUSH3-19]
|
||||
_ = x[PUSH4-20]
|
||||
_ = x[PUSH5-21]
|
||||
_ = x[PUSH6-22]
|
||||
_ = x[PUSH7-23]
|
||||
_ = x[PUSH8-24]
|
||||
_ = x[PUSH9-25]
|
||||
_ = x[PUSH10-26]
|
||||
_ = x[PUSH11-27]
|
||||
_ = x[PUSH12-28]
|
||||
_ = x[PUSH13-29]
|
||||
_ = x[PUSH14-30]
|
||||
_ = x[PUSH15-31]
|
||||
_ = x[PUSH16-32]
|
||||
_ = x[NOP-97]
|
||||
_ = x[JMP-98]
|
||||
_ = x[JMPIF-99]
|
||||
|
@ -115,6 +47,7 @@ func _() {
|
|||
_ = x[APPCALL-103]
|
||||
_ = x[SYSCALL-104]
|
||||
_ = x[TAILCALL-105]
|
||||
_ = x[ISNULL-112]
|
||||
_ = x[DUPFROMALTSTACK-106]
|
||||
_ = x[TOALTSTACK-107]
|
||||
_ = x[FROMALTSTACK-108]
|
||||
|
@ -196,193 +129,126 @@ func _() {
|
|||
_ = x[THROWIFNOT-241]
|
||||
}
|
||||
|
||||
const _Opcode_name = "PUSH0PUSHBYTES1PUSHBYTES2PUSHBYTES3PUSHBYTES4PUSHBYTES5PUSHBYTES6PUSHBYTES7PUSHBYTES8PUSHBYTES9PUSHBYTES10PUSHBYTES11PUSHBYTES12PUSHBYTES13PUSHBYTES14PUSHBYTES15PUSHBYTES16PUSHBYTES17PUSHBYTES18PUSHBYTES19PUSHBYTES20PUSHBYTES21PUSHBYTES22PUSHBYTES23PUSHBYTES24PUSHBYTES25PUSHBYTES26PUSHBYTES27PUSHBYTES28PUSHBYTES29PUSHBYTES30PUSHBYTES31PUSHBYTES32PUSHBYTES33PUSHBYTES34PUSHBYTES35PUSHBYTES36PUSHBYTES37PUSHBYTES38PUSHBYTES39PUSHBYTES40PUSHBYTES41PUSHBYTES42PUSHBYTES43PUSHBYTES44PUSHBYTES45PUSHBYTES46PUSHBYTES47PUSHBYTES48PUSHBYTES49PUSHBYTES50PUSHBYTES51PUSHBYTES52PUSHBYTES53PUSHBYTES54PUSHBYTES55PUSHBYTES56PUSHBYTES57PUSHBYTES58PUSHBYTES59PUSHBYTES60PUSHBYTES61PUSHBYTES62PUSHBYTES63PUSHBYTES64PUSHBYTES65PUSHBYTES66PUSHBYTES67PUSHBYTES68PUSHBYTES69PUSHBYTES70PUSHBYTES71PUSHBYTES72PUSHBYTES73PUSHBYTES74PUSHBYTES75PUSHDATA1PUSHDATA2PUSHDATA4PUSHM1PUSH1PUSH2PUSH3PUSH4PUSH5PUSH6PUSH7PUSH8PUSH9PUSH10PUSH11PUSH12PUSH13PUSH14PUSH15PUSH16NOPJMPJMPIFJMPIFNOTCALLRETAPPCALLSYSCALLTAILCALLDUPFROMALTSTACKTOALTSTACKFROMALTSTACKXDROPXSWAPXTUCKDEPTHDROPDUPNIPOVERPICKROLLROTSWAPTUCKCATSUBSTRLEFTRIGHTSIZEINVERTANDORXOREQUALINCDECSIGNNEGATEABSNOTNZADDSUBMULDIVMODSHLSHRBOOLANDBOOLORNUMEQUALNUMNOTEQUALLTGTLTEGTEMINMAXWITHINSHA1SHA256HASH160HASH256CHECKSIGVERIFYCHECKMULTISIGARRAYSIZEPACKUNPACKPICKITEMSETITEMNEWARRAYNEWSTRUCTNEWMAPAPPENDREVERSEREMOVEHASKEYKEYSVALUESCALLICALLECALLEDCALLETCALLEDTTHROWTHROWIFNOT"
|
||||
const _Opcode_name = "PUSHINT8PUSHINT16PUSHINT32PUSHINT64PUSHINT128PUSHINT256PUSHNULLPUSHDATA1PUSHDATA2PUSHDATA4PUSHM1PUSH0PUSH1PUSH2PUSH3PUSH4PUSH5PUSH6PUSH7PUSH8PUSH9PUSH10PUSH11PUSH12PUSH13PUSH14PUSH15PUSH16NOPJMPJMPIFJMPIFNOTCALLRETAPPCALLSYSCALLTAILCALLDUPFROMALTSTACKTOALTSTACKFROMALTSTACKXDROPISNULLXSWAPXTUCKDEPTHDROPDUPNIPOVERPICKROLLROTSWAPTUCKCATSUBSTRLEFTRIGHTSIZEINVERTANDORXOREQUALINCDECSIGNNEGATEABSNOTNZADDSUBMULDIVMODSHLSHRBOOLANDBOOLORNUMEQUALNUMNOTEQUALLTGTLTEGTEMINMAXWITHINSHA1SHA256HASH160HASH256CHECKSIGVERIFYCHECKMULTISIGARRAYSIZEPACKUNPACKPICKITEMSETITEMNEWARRAYNEWSTRUCTNEWMAPAPPENDREVERSEREMOVEHASKEYKEYSVALUESCALLICALLECALLEDCALLETCALLEDTTHROWTHROWIFNOT"
|
||||
|
||||
var _Opcode_map = map[Opcode]string{
|
||||
0: _Opcode_name[0:5],
|
||||
1: _Opcode_name[5:15],
|
||||
2: _Opcode_name[15:25],
|
||||
3: _Opcode_name[25:35],
|
||||
0: _Opcode_name[0:8],
|
||||
1: _Opcode_name[8:17],
|
||||
2: _Opcode_name[17:26],
|
||||
3: _Opcode_name[26:35],
|
||||
4: _Opcode_name[35:45],
|
||||
5: _Opcode_name[45:55],
|
||||
6: _Opcode_name[55:65],
|
||||
7: _Opcode_name[65:75],
|
||||
8: _Opcode_name[75:85],
|
||||
9: _Opcode_name[85:95],
|
||||
10: _Opcode_name[95:106],
|
||||
11: _Opcode_name[106:117],
|
||||
12: _Opcode_name[117:128],
|
||||
13: _Opcode_name[128:139],
|
||||
14: _Opcode_name[139:150],
|
||||
15: _Opcode_name[150:161],
|
||||
16: _Opcode_name[161:172],
|
||||
17: _Opcode_name[172:183],
|
||||
18: _Opcode_name[183:194],
|
||||
19: _Opcode_name[194:205],
|
||||
20: _Opcode_name[205:216],
|
||||
21: _Opcode_name[216:227],
|
||||
22: _Opcode_name[227:238],
|
||||
23: _Opcode_name[238:249],
|
||||
24: _Opcode_name[249:260],
|
||||
25: _Opcode_name[260:271],
|
||||
26: _Opcode_name[271:282],
|
||||
27: _Opcode_name[282:293],
|
||||
28: _Opcode_name[293:304],
|
||||
29: _Opcode_name[304:315],
|
||||
30: _Opcode_name[315:326],
|
||||
31: _Opcode_name[326:337],
|
||||
32: _Opcode_name[337:348],
|
||||
33: _Opcode_name[348:359],
|
||||
34: _Opcode_name[359:370],
|
||||
35: _Opcode_name[370:381],
|
||||
36: _Opcode_name[381:392],
|
||||
37: _Opcode_name[392:403],
|
||||
38: _Opcode_name[403:414],
|
||||
39: _Opcode_name[414:425],
|
||||
40: _Opcode_name[425:436],
|
||||
41: _Opcode_name[436:447],
|
||||
42: _Opcode_name[447:458],
|
||||
43: _Opcode_name[458:469],
|
||||
44: _Opcode_name[469:480],
|
||||
45: _Opcode_name[480:491],
|
||||
46: _Opcode_name[491:502],
|
||||
47: _Opcode_name[502:513],
|
||||
48: _Opcode_name[513:524],
|
||||
49: _Opcode_name[524:535],
|
||||
50: _Opcode_name[535:546],
|
||||
51: _Opcode_name[546:557],
|
||||
52: _Opcode_name[557:568],
|
||||
53: _Opcode_name[568:579],
|
||||
54: _Opcode_name[579:590],
|
||||
55: _Opcode_name[590:601],
|
||||
56: _Opcode_name[601:612],
|
||||
57: _Opcode_name[612:623],
|
||||
58: _Opcode_name[623:634],
|
||||
59: _Opcode_name[634:645],
|
||||
60: _Opcode_name[645:656],
|
||||
61: _Opcode_name[656:667],
|
||||
62: _Opcode_name[667:678],
|
||||
63: _Opcode_name[678:689],
|
||||
64: _Opcode_name[689:700],
|
||||
65: _Opcode_name[700:711],
|
||||
66: _Opcode_name[711:722],
|
||||
67: _Opcode_name[722:733],
|
||||
68: _Opcode_name[733:744],
|
||||
69: _Opcode_name[744:755],
|
||||
70: _Opcode_name[755:766],
|
||||
71: _Opcode_name[766:777],
|
||||
72: _Opcode_name[777:788],
|
||||
73: _Opcode_name[788:799],
|
||||
74: _Opcode_name[799:810],
|
||||
75: _Opcode_name[810:821],
|
||||
76: _Opcode_name[821:830],
|
||||
77: _Opcode_name[830:839],
|
||||
78: _Opcode_name[839:848],
|
||||
79: _Opcode_name[848:854],
|
||||
81: _Opcode_name[854:859],
|
||||
82: _Opcode_name[859:864],
|
||||
83: _Opcode_name[864:869],
|
||||
84: _Opcode_name[869:874],
|
||||
85: _Opcode_name[874:879],
|
||||
86: _Opcode_name[879:884],
|
||||
87: _Opcode_name[884:889],
|
||||
88: _Opcode_name[889:894],
|
||||
89: _Opcode_name[894:899],
|
||||
90: _Opcode_name[899:905],
|
||||
91: _Opcode_name[905:911],
|
||||
92: _Opcode_name[911:917],
|
||||
93: _Opcode_name[917:923],
|
||||
94: _Opcode_name[923:929],
|
||||
95: _Opcode_name[929:935],
|
||||
96: _Opcode_name[935:941],
|
||||
97: _Opcode_name[941:944],
|
||||
98: _Opcode_name[944:947],
|
||||
99: _Opcode_name[947:952],
|
||||
100: _Opcode_name[952:960],
|
||||
101: _Opcode_name[960:964],
|
||||
102: _Opcode_name[964:967],
|
||||
103: _Opcode_name[967:974],
|
||||
104: _Opcode_name[974:981],
|
||||
105: _Opcode_name[981:989],
|
||||
106: _Opcode_name[989:1004],
|
||||
107: _Opcode_name[1004:1014],
|
||||
108: _Opcode_name[1014:1026],
|
||||
109: _Opcode_name[1026:1031],
|
||||
114: _Opcode_name[1031:1036],
|
||||
115: _Opcode_name[1036:1041],
|
||||
116: _Opcode_name[1041:1046],
|
||||
117: _Opcode_name[1046:1050],
|
||||
118: _Opcode_name[1050:1053],
|
||||
119: _Opcode_name[1053:1056],
|
||||
120: _Opcode_name[1056:1060],
|
||||
121: _Opcode_name[1060:1064],
|
||||
122: _Opcode_name[1064:1068],
|
||||
123: _Opcode_name[1068:1071],
|
||||
124: _Opcode_name[1071:1075],
|
||||
125: _Opcode_name[1075:1079],
|
||||
126: _Opcode_name[1079:1082],
|
||||
127: _Opcode_name[1082:1088],
|
||||
128: _Opcode_name[1088:1092],
|
||||
129: _Opcode_name[1092:1097],
|
||||
130: _Opcode_name[1097:1101],
|
||||
131: _Opcode_name[1101:1107],
|
||||
132: _Opcode_name[1107:1110],
|
||||
133: _Opcode_name[1110:1112],
|
||||
134: _Opcode_name[1112:1115],
|
||||
135: _Opcode_name[1115:1120],
|
||||
139: _Opcode_name[1120:1123],
|
||||
140: _Opcode_name[1123:1126],
|
||||
141: _Opcode_name[1126:1130],
|
||||
143: _Opcode_name[1130:1136],
|
||||
144: _Opcode_name[1136:1139],
|
||||
145: _Opcode_name[1139:1142],
|
||||
146: _Opcode_name[1142:1144],
|
||||
147: _Opcode_name[1144:1147],
|
||||
148: _Opcode_name[1147:1150],
|
||||
149: _Opcode_name[1150:1153],
|
||||
150: _Opcode_name[1153:1156],
|
||||
151: _Opcode_name[1156:1159],
|
||||
152: _Opcode_name[1159:1162],
|
||||
153: _Opcode_name[1162:1165],
|
||||
154: _Opcode_name[1165:1172],
|
||||
155: _Opcode_name[1172:1178],
|
||||
156: _Opcode_name[1178:1186],
|
||||
158: _Opcode_name[1186:1197],
|
||||
159: _Opcode_name[1197:1199],
|
||||
160: _Opcode_name[1199:1201],
|
||||
161: _Opcode_name[1201:1204],
|
||||
162: _Opcode_name[1204:1207],
|
||||
163: _Opcode_name[1207:1210],
|
||||
164: _Opcode_name[1210:1213],
|
||||
165: _Opcode_name[1213:1219],
|
||||
167: _Opcode_name[1219:1223],
|
||||
168: _Opcode_name[1223:1229],
|
||||
169: _Opcode_name[1229:1236],
|
||||
170: _Opcode_name[1236:1243],
|
||||
172: _Opcode_name[1243:1251],
|
||||
173: _Opcode_name[1251:1257],
|
||||
174: _Opcode_name[1257:1270],
|
||||
192: _Opcode_name[1270:1279],
|
||||
193: _Opcode_name[1279:1283],
|
||||
194: _Opcode_name[1283:1289],
|
||||
195: _Opcode_name[1289:1297],
|
||||
196: _Opcode_name[1297:1304],
|
||||
197: _Opcode_name[1304:1312],
|
||||
198: _Opcode_name[1312:1321],
|
||||
199: _Opcode_name[1321:1327],
|
||||
200: _Opcode_name[1327:1333],
|
||||
201: _Opcode_name[1333:1340],
|
||||
202: _Opcode_name[1340:1346],
|
||||
203: _Opcode_name[1346:1352],
|
||||
204: _Opcode_name[1352:1356],
|
||||
205: _Opcode_name[1356:1362],
|
||||
224: _Opcode_name[1362:1367],
|
||||
225: _Opcode_name[1367:1372],
|
||||
226: _Opcode_name[1372:1378],
|
||||
227: _Opcode_name[1378:1384],
|
||||
228: _Opcode_name[1384:1391],
|
||||
240: _Opcode_name[1391:1396],
|
||||
241: _Opcode_name[1396:1406],
|
||||
11: _Opcode_name[55:63],
|
||||
12: _Opcode_name[63:72],
|
||||
13: _Opcode_name[72:81],
|
||||
14: _Opcode_name[81:90],
|
||||
15: _Opcode_name[90:96],
|
||||
16: _Opcode_name[96:101],
|
||||
17: _Opcode_name[101:106],
|
||||
18: _Opcode_name[106:111],
|
||||
19: _Opcode_name[111:116],
|
||||
20: _Opcode_name[116:121],
|
||||
21: _Opcode_name[121:126],
|
||||
22: _Opcode_name[126:131],
|
||||
23: _Opcode_name[131:136],
|
||||
24: _Opcode_name[136:141],
|
||||
25: _Opcode_name[141:146],
|
||||
26: _Opcode_name[146:152],
|
||||
27: _Opcode_name[152:158],
|
||||
28: _Opcode_name[158:164],
|
||||
29: _Opcode_name[164:170],
|
||||
30: _Opcode_name[170:176],
|
||||
31: _Opcode_name[176:182],
|
||||
32: _Opcode_name[182:188],
|
||||
97: _Opcode_name[188:191],
|
||||
98: _Opcode_name[191:194],
|
||||
99: _Opcode_name[194:199],
|
||||
100: _Opcode_name[199:207],
|
||||
101: _Opcode_name[207:211],
|
||||
102: _Opcode_name[211:214],
|
||||
103: _Opcode_name[214:221],
|
||||
104: _Opcode_name[221:228],
|
||||
105: _Opcode_name[228:236],
|
||||
106: _Opcode_name[236:251],
|
||||
107: _Opcode_name[251:261],
|
||||
108: _Opcode_name[261:273],
|
||||
109: _Opcode_name[273:278],
|
||||
112: _Opcode_name[278:284],
|
||||
114: _Opcode_name[284:289],
|
||||
115: _Opcode_name[289:294],
|
||||
116: _Opcode_name[294:299],
|
||||
117: _Opcode_name[299:303],
|
||||
118: _Opcode_name[303:306],
|
||||
119: _Opcode_name[306:309],
|
||||
120: _Opcode_name[309:313],
|
||||
121: _Opcode_name[313:317],
|
||||
122: _Opcode_name[317:321],
|
||||
123: _Opcode_name[321:324],
|
||||
124: _Opcode_name[324:328],
|
||||
125: _Opcode_name[328:332],
|
||||
126: _Opcode_name[332:335],
|
||||
127: _Opcode_name[335:341],
|
||||
128: _Opcode_name[341:345],
|
||||
129: _Opcode_name[345:350],
|
||||
130: _Opcode_name[350:354],
|
||||
131: _Opcode_name[354:360],
|
||||
132: _Opcode_name[360:363],
|
||||
133: _Opcode_name[363:365],
|
||||
134: _Opcode_name[365:368],
|
||||
135: _Opcode_name[368:373],
|
||||
139: _Opcode_name[373:376],
|
||||
140: _Opcode_name[376:379],
|
||||
141: _Opcode_name[379:383],
|
||||
143: _Opcode_name[383:389],
|
||||
144: _Opcode_name[389:392],
|
||||
145: _Opcode_name[392:395],
|
||||
146: _Opcode_name[395:397],
|
||||
147: _Opcode_name[397:400],
|
||||
148: _Opcode_name[400:403],
|
||||
149: _Opcode_name[403:406],
|
||||
150: _Opcode_name[406:409],
|
||||
151: _Opcode_name[409:412],
|
||||
152: _Opcode_name[412:415],
|
||||
153: _Opcode_name[415:418],
|
||||
154: _Opcode_name[418:425],
|
||||
155: _Opcode_name[425:431],
|
||||
156: _Opcode_name[431:439],
|
||||
158: _Opcode_name[439:450],
|
||||
159: _Opcode_name[450:452],
|
||||
160: _Opcode_name[452:454],
|
||||
161: _Opcode_name[454:457],
|
||||
162: _Opcode_name[457:460],
|
||||
163: _Opcode_name[460:463],
|
||||
164: _Opcode_name[463:466],
|
||||
165: _Opcode_name[466:472],
|
||||
167: _Opcode_name[472:476],
|
||||
168: _Opcode_name[476:482],
|
||||
169: _Opcode_name[482:489],
|
||||
170: _Opcode_name[489:496],
|
||||
172: _Opcode_name[496:504],
|
||||
173: _Opcode_name[504:510],
|
||||
174: _Opcode_name[510:523],
|
||||
192: _Opcode_name[523:532],
|
||||
193: _Opcode_name[532:536],
|
||||
194: _Opcode_name[536:542],
|
||||
195: _Opcode_name[542:550],
|
||||
196: _Opcode_name[550:557],
|
||||
197: _Opcode_name[557:565],
|
||||
198: _Opcode_name[565:574],
|
||||
199: _Opcode_name[574:580],
|
||||
200: _Opcode_name[580:586],
|
||||
201: _Opcode_name[586:593],
|
||||
202: _Opcode_name[593:599],
|
||||
203: _Opcode_name[599:605],
|
||||
204: _Opcode_name[605:609],
|
||||
205: _Opcode_name[609:615],
|
||||
224: _Opcode_name[615:620],
|
||||
225: _Opcode_name[620:625],
|
||||
226: _Opcode_name[625:631],
|
||||
227: _Opcode_name[631:637],
|
||||
228: _Opcode_name[637:644],
|
||||
240: _Opcode_name[644:649],
|
||||
241: _Opcode_name[649:659],
|
||||
}
|
||||
|
||||
func (i Opcode) String() string {
|
||||
|
|
|
@ -14,6 +14,7 @@ import (
|
|||
"github.com/nspcc-dev/neo-go/pkg/crypto/hash"
|
||||
"github.com/nspcc-dev/neo-go/pkg/crypto/keys"
|
||||
"github.com/nspcc-dev/neo-go/pkg/util"
|
||||
"github.com/nspcc-dev/neo-go/pkg/vm/emit"
|
||||
"github.com/nspcc-dev/neo-go/pkg/vm/opcode"
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
@ -535,8 +536,8 @@ func (v *VM) execute(ctx *Context, op opcode.Opcode, parameter []byte) (err erro
|
|||
}
|
||||
}
|
||||
|
||||
if op >= opcode.PUSHBYTES1 && op <= opcode.PUSHBYTES75 {
|
||||
v.estack.PushVal(parameter)
|
||||
if op <= opcode.PUSHINT256 {
|
||||
v.estack.PushVal(emit.BytesToInt(parameter))
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -549,6 +550,10 @@ func (v *VM) execute(ctx *Context, op opcode.Opcode, parameter []byte) (err erro
|
|||
val := int(op) - int(opcode.PUSH1) + 1
|
||||
v.estack.PushVal(val)
|
||||
|
||||
case opcode.OLDPUSH1:
|
||||
// FIXME remove this after Issue transactions will be removed
|
||||
v.estack.PushVal(1)
|
||||
|
||||
case opcode.PUSH0:
|
||||
v.estack.PushVal([]byte{})
|
||||
|
||||
|
|
|
@ -8,6 +8,7 @@ import (
|
|||
"math/rand"
|
||||
"testing"
|
||||
|
||||
"github.com/nspcc-dev/neo-go/pkg/internal/random"
|
||||
"github.com/nspcc-dev/neo-go/pkg/io"
|
||||
"github.com/nspcc-dev/neo-go/pkg/util"
|
||||
"github.com/nspcc-dev/neo-go/pkg/vm/emit"
|
||||
|
@ -138,13 +139,6 @@ func TestPushBytes1to75(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
func TestPushBytesNoParam(t *testing.T) {
|
||||
prog := make([]byte, 1)
|
||||
prog[0] = byte(opcode.PUSHBYTES1)
|
||||
vm := load(prog)
|
||||
checkVMFailed(t, vm)
|
||||
}
|
||||
|
||||
func runVM(t *testing.T, vm *VM) {
|
||||
err := vm.Run()
|
||||
require.NoError(t, err)
|
||||
|
@ -179,6 +173,24 @@ func TestStackLimitPUSH1Bad(t *testing.T) {
|
|||
checkVMFailed(t, v)
|
||||
}
|
||||
|
||||
func testPUSHINT(t *testing.T, op opcode.Opcode, parameter []byte, expected *big.Int) {
|
||||
prog := append([]byte{byte(op)}, parameter...)
|
||||
v := load(prog)
|
||||
runVM(t, v)
|
||||
require.Equal(t, 1, v.estack.Len())
|
||||
require.EqualValues(t, expected, v.estack.Pop().BigInt())
|
||||
}
|
||||
|
||||
func TestPUSHINT(t *testing.T) {
|
||||
for i := byte(0); i < 5; i++ {
|
||||
op := opcode.PUSHINT8 + opcode.Opcode(i)
|
||||
t.Run(op.String(), func(t *testing.T) {
|
||||
buf := random.Bytes((8 << i) / 8)
|
||||
testPUSHINT(t, op, buf, emit.BytesToInt(buf))
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestPUSHNULL(t *testing.T) {
|
||||
prog := makeProgram(opcode.PUSHNULL, opcode.PUSHNULL, opcode.EQUAL)
|
||||
v := load(prog)
|
||||
|
@ -220,7 +232,7 @@ func appendBigStruct(size uint16) []opcode.Opcode {
|
|||
}
|
||||
|
||||
return append(prog,
|
||||
opcode.PUSHBYTES2, opcode.Opcode(size), opcode.Opcode(size>>8), // LE
|
||||
opcode.PUSHINT16, opcode.Opcode(size), opcode.Opcode(size>>8), // LE
|
||||
opcode.PACK, opcode.NEWSTRUCT,
|
||||
opcode.DUP,
|
||||
opcode.PUSH0, opcode.NEWARRAY, opcode.TOALTSTACK, opcode.DUPFROMALTSTACK,
|
||||
|
@ -277,13 +289,6 @@ func TestStackLimit(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
func TestPushBytesShort(t *testing.T) {
|
||||
prog := make([]byte, 10)
|
||||
prog[0] = byte(opcode.PUSHBYTES10) // but only 9 left in the `prog`
|
||||
vm := load(prog)
|
||||
checkVMFailed(t, vm)
|
||||
}
|
||||
|
||||
func TestPushm1to16(t *testing.T) {
|
||||
var prog []byte
|
||||
for i := int(opcode.PUSHM1); i <= int(opcode.PUSH16); i++ {
|
||||
|
@ -295,14 +300,10 @@ func TestPushm1to16(t *testing.T) {
|
|||
|
||||
vm := load(prog)
|
||||
for i := int(opcode.PUSHM1); i <= int(opcode.PUSH16); i++ {
|
||||
if i == 80 {
|
||||
continue // nice opcode layout we got here.
|
||||
}
|
||||
err := vm.Step()
|
||||
require.NoError(t, err)
|
||||
|
||||
elem := vm.estack.Pop()
|
||||
assert.IsType(t, &BigIntegerItem{}, elem.value)
|
||||
val := i - int(opcode.PUSH1) + 1
|
||||
assert.Equal(t, elem.BigInt().Int64(), int64(val))
|
||||
}
|
||||
|
@ -716,7 +717,7 @@ func TestSerializeInterop(t *testing.T) {
|
|||
|
||||
func callNTimes(n uint16) []byte {
|
||||
return makeProgram(
|
||||
opcode.PUSHBYTES2, opcode.Opcode(n), opcode.Opcode(n>>8), // little-endian
|
||||
opcode.PUSHINT16, opcode.Opcode(n), opcode.Opcode(n>>8), // little-endian
|
||||
opcode.TOALTSTACK, opcode.DUPFROMALTSTACK,
|
||||
opcode.JMPIF, 0x4, 0, opcode.RET,
|
||||
opcode.FROMALTSTACK, opcode.DEC,
|
||||
|
@ -1391,7 +1392,7 @@ func TestPICKITEMDupArray(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestPICKITEMDupMap(t *testing.T) {
|
||||
prog := makeProgram(opcode.DUP, opcode.PUSHBYTES1, 42, opcode.PICKITEM, opcode.ABS)
|
||||
prog := makeProgram(opcode.DUP, opcode.PUSHINT8, 42, opcode.PICKITEM, opcode.ABS)
|
||||
vm := load(prog)
|
||||
m := NewMapItem()
|
||||
m.Add(makeStackItem([]byte{42}), makeStackItem(-1))
|
||||
|
@ -1794,12 +1795,17 @@ func TestAppCallDynamicGood(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestSimpleCall(t *testing.T) {
|
||||
progStr := "52c56b525a7c616516006c766b00527ac46203006c766b00c3616c756653c56b6c766b00527ac46c766b51527ac46203006c766b00c36c766b51c393616c7566"
|
||||
result := 12
|
||||
buf := io.NewBufBinWriter()
|
||||
w := buf.BinWriter
|
||||
emit.Opcode(w, opcode.PUSH2)
|
||||
emit.Instruction(w, opcode.CALL, []byte{04, 00})
|
||||
emit.Opcode(w, opcode.RET)
|
||||
emit.Opcode(w, opcode.PUSH10)
|
||||
emit.Opcode(w, opcode.ADD)
|
||||
emit.Opcode(w, opcode.RET)
|
||||
|
||||
prog, err := hex.DecodeString(progStr)
|
||||
require.NoError(t, err)
|
||||
vm := load(prog)
|
||||
result := 12
|
||||
vm := load(buf.Bytes())
|
||||
runVM(t, vm)
|
||||
assert.Equal(t, result, int(vm.estack.Pop().BigInt().Int64()))
|
||||
}
|
||||
|
@ -2031,12 +2037,12 @@ func TestOVERgood(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestOVERDup(t *testing.T) {
|
||||
prog := makeProgram(opcode.PUSHBYTES2, 1, 0,
|
||||
prog := makeProgram(opcode.PUSHDATA1, 2, 1, 0,
|
||||
opcode.PUSH1,
|
||||
opcode.OVER,
|
||||
opcode.PUSH1,
|
||||
opcode.LEFT,
|
||||
opcode.PUSHBYTES1, 2,
|
||||
opcode.PUSHDATA1, 1, 2,
|
||||
opcode.CAT)
|
||||
vm := load(prog)
|
||||
runVM(t, vm)
|
||||
|
@ -2674,11 +2680,11 @@ func TestDupInt(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestDupByteArray(t *testing.T) {
|
||||
prog := makeProgram(opcode.PUSHBYTES2, 1, 0,
|
||||
prog := makeProgram(opcode.PUSHDATA1, 2, 1, 0,
|
||||
opcode.DUP,
|
||||
opcode.PUSH1,
|
||||
opcode.LEFT,
|
||||
opcode.PUSHBYTES1, 2,
|
||||
opcode.PUSHDATA1, 1, 2,
|
||||
opcode.CAT)
|
||||
vm := load(prog)
|
||||
runVM(t, vm)
|
||||
|
@ -2702,7 +2708,7 @@ func TestDupBool(t *testing.T) {
|
|||
func TestSHA1(t *testing.T) {
|
||||
// 0x0100 hashes to 0e356ba505631fbf715758bed27d503f8b260e3a
|
||||
res := "0e356ba505631fbf715758bed27d503f8b260e3a"
|
||||
prog := makeProgram(opcode.PUSHBYTES2, 1, 0,
|
||||
prog := makeProgram(opcode.PUSHDATA1, 2, 1, 0,
|
||||
opcode.SHA1)
|
||||
vm := load(prog)
|
||||
runVM(t, vm)
|
||||
|
@ -2713,7 +2719,7 @@ func TestSHA1(t *testing.T) {
|
|||
func TestSHA256(t *testing.T) {
|
||||
// 0x0100 hashes to 47dc540c94ceb704a23875c11273e16bb0b8a87aed84de911f2133568115f254
|
||||
res := "47dc540c94ceb704a23875c11273e16bb0b8a87aed84de911f2133568115f254"
|
||||
prog := makeProgram(opcode.PUSHBYTES2, 1, 0,
|
||||
prog := makeProgram(opcode.PUSHDATA1, 2, 1, 0,
|
||||
opcode.SHA256)
|
||||
vm := load(prog)
|
||||
runVM(t, vm)
|
||||
|
|
|
@ -135,7 +135,7 @@ func (a *Account) SignTx(t *transaction.Transaction) error {
|
|||
sign := a.privateKey.Sign(data)
|
||||
|
||||
t.Scripts = append(t.Scripts, transaction.Witness{
|
||||
InvocationScript: append([]byte{byte(opcode.PUSHBYTES64)}, sign...),
|
||||
InvocationScript: append([]byte{byte(opcode.PUSHDATA1), 64}, sign...),
|
||||
VerificationScript: a.getVerificationScript(),
|
||||
})
|
||||
|
||||
|
|
|
@ -90,7 +90,7 @@ func TestContract_ScriptHash(t *testing.T) {
|
|||
|
||||
func TestAccount_ConvertMultisig(t *testing.T) {
|
||||
// test is based on a wallet1_solo.json accounts from neo-local
|
||||
a, err := NewAccountFromEncryptedWIF("6PYKYQKRs758NBX4q5k6fSmduZDfEfQyoXMovQU5myKm2h5ArXuYpuMEaN", "one")
|
||||
a, err := NewAccountFromWIF("KxyjQ8eUa4FHt3Gvioyt1Wz29cTUrE4eTqX3yFSk1YFCsPL8uNsY")
|
||||
require.NoError(t, err)
|
||||
|
||||
hexs := []string{
|
||||
|
@ -113,13 +113,13 @@ func TestAccount_ConvertMultisig(t *testing.T) {
|
|||
t.Run("1/1 multisig", func(t *testing.T) {
|
||||
pubs := convertPubs(t, hexs[:1])
|
||||
require.NoError(t, a.ConvertMultisig(1, pubs))
|
||||
require.Equal(t, "Ab3TJfgpa94yDr1WPeXpYQiChTRohBJ6T5", a.Address)
|
||||
require.Equal(t, "ANg3mmstMr7qtY8TgdKM777WSLKCNFbawM", a.Address)
|
||||
})
|
||||
|
||||
t.Run("3/4 multisig", func(t *testing.T) {
|
||||
pubs := convertPubs(t, hexs)
|
||||
require.NoError(t, a.ConvertMultisig(3, pubs))
|
||||
require.Equal(t, "AbHd9dXYUryuCvMgXRUfdR6zC2CJixS6Q6", a.Address)
|
||||
require.Equal(t, "Ad1wDxzcRiRSryvJobNV211Tv7UUiziPXy", a.Address)
|
||||
})
|
||||
}
|
||||
|
||||
|
|
12
pkg/wallet/testdata/wallet1.json
vendored
12
pkg/wallet/testdata/wallet1.json
vendored
|
@ -2,11 +2,11 @@
|
|||
"version": "1.0",
|
||||
"accounts": [
|
||||
{
|
||||
"address": "AQyx83BYr1PkyYhZhUAogaHdhkLVHn6htY",
|
||||
"key": "6PYKYQKRs758NBX4q5k6fSmduZDfEfQyoXMovQU5myKm2h5ArXuYpuMEaN",
|
||||
"address": "ASW1VhcukJRrukCXRipY4BE9d9zy4mAYsR",
|
||||
"key": "6PYNTeMkEZ1Q2MCqkPMgvC2kvRzH6f1sz4Sj9cGcLG4iYb43yQcpThAeap",
|
||||
"label": "",
|
||||
"contract": {
|
||||
"script": "4c2102b3622bf4017bdfe317c58aed5f4c753f206b7db896046fa7d774bbc4bf7f8dc250680a906ad4",
|
||||
"script": "0c2102b3622bf4017bdfe317c58aed5f4c753f206b7db896046fa7d774bbc4bf7f8dc20b680a906ad4",
|
||||
"parameters": [
|
||||
{
|
||||
"name": "parameter0",
|
||||
|
@ -19,11 +19,11 @@
|
|||
"isDefault": false
|
||||
},
|
||||
{
|
||||
"address": "AbHd9dXYUryuCvMgXRUfdR6zC2CJixS6Q6",
|
||||
"key": "6PYKYQKRs758NBX4q5k6fSmduZDfEfQyoXMovQU5myKm2h5ArXuYpuMEaN",
|
||||
"address": "Ad1wDxzcRiRSryvJobNV211Tv7UUiziPXy",
|
||||
"key": "6PYNTeMkEZ1Q2MCqkPMgvC2kvRzH6f1sz4Sj9cGcLG4iYb43yQcpThAeap",
|
||||
"label": "",
|
||||
"contract": {
|
||||
"script": "534c2102103a7f7dd016558597f7960d27c516a4394fd968b9e65155eb4b013e4040406e4c2102a7bc55fe8684e0119768d104ba30795bdcc86619e864add26156723ed185cd624c2102b3622bf4017bdfe317c58aed5f4c753f206b7db896046fa7d774bbc4bf7f8dc24c2103d90c07df63e690ce77912e10ab51acc944b66860237b608c4f8f8309e71ee6995450683073b3bb",
|
||||
"script": "130c2102103a7f7dd016558597f7960d27c516a4394fd968b9e65155eb4b013e4040406e0c2102a7bc55fe8684e0119768d104ba30795bdcc86619e864add26156723ed185cd620c2102b3622bf4017bdfe317c58aed5f4c753f206b7db896046fa7d774bbc4bf7f8dc20c2103d90c07df63e690ce77912e10ab51acc944b66860237b608c4f8f8309e71ee699140b683073b3bb",
|
||||
"parameters": [
|
||||
{
|
||||
"name": "parameter0",
|
||||
|
|
18
pkg/wallet/testdata/wallet2.json
vendored
18
pkg/wallet/testdata/wallet2.json
vendored
|
@ -2,11 +2,11 @@
|
|||
"version": "1.0",
|
||||
"accounts": [
|
||||
{
|
||||
"address": "AQyx83BYr1PkyYhZhUAogaHdhkLVHn6htY",
|
||||
"key": "6PYKYQKRs758NBX4q5k6fSmduZDfEfQyoXMovQU5myKm2h5ArXuYpuMEaN",
|
||||
"address": "ASW1VhcukJRrukCXRipY4BE9d9zy4mAYsR",
|
||||
"key": "6PYNTeMkEZ1Q2MCqkPMgvC2kvRzH6f1sz4Sj9cGcLG4iYb43yQcpThAeap",
|
||||
"label": "",
|
||||
"contract": {
|
||||
"script": "4c2102b3622bf4017bdfe317c58aed5f4c753f206b7db896046fa7d774bbc4bf7f8dc250680a906ad4",
|
||||
"script": "0c2102b3622bf4017bdfe317c58aed5f4c753f206b7db896046fa7d774bbc4bf7f8dc20b680a906ad4",
|
||||
"parameters": [
|
||||
{
|
||||
"name": "parameter0",
|
||||
|
@ -19,11 +19,11 @@
|
|||
"isDefault": false
|
||||
},
|
||||
{
|
||||
"address": "AbHd9dXYUryuCvMgXRUfdR6zC2CJixS6Q6",
|
||||
"key": "6PYKYQKRs758NBX4q5k6fSmduZDfEfQyoXMovQU5myKm2h5ArXuYpuMEaN",
|
||||
"address": "Ad1wDxzcRiRSryvJobNV211Tv7UUiziPXy",
|
||||
"key": "6PYNTeMkEZ1Q2MCqkPMgvC2kvRzH6f1sz4Sj9cGcLG4iYb43yQcpThAeap",
|
||||
"label": "",
|
||||
"contract": {
|
||||
"script": "534c2102103a7f7dd016558597f7960d27c516a4394fd968b9e65155eb4b013e4040406e4c2102a7bc55fe8684e0119768d104ba30795bdcc86619e864add26156723ed185cd624c2102b3622bf4017bdfe317c58aed5f4c753f206b7db896046fa7d774bbc4bf7f8dc24c2103d90c07df63e690ce77912e10ab51acc944b66860237b608c4f8f8309e71ee6995450683073b3bb",
|
||||
"script": "130c2102103a7f7dd016558597f7960d27c516a4394fd968b9e65155eb4b013e4040406e0c2102a7bc55fe8684e0119768d104ba30795bdcc86619e864add26156723ed185cd620c2102b3622bf4017bdfe317c58aed5f4c753f206b7db896046fa7d774bbc4bf7f8dc20c2103d90c07df63e690ce77912e10ab51acc944b66860237b608c4f8f8309e71ee699140b683073b3bb",
|
||||
"parameters": [
|
||||
{
|
||||
"name": "parameter0",
|
||||
|
@ -44,11 +44,11 @@
|
|||
"isDefault": false
|
||||
},
|
||||
{
|
||||
"address": "AdB6ayKfBRJZasiXX4JL5N2YtmxftNp1b3",
|
||||
"key": "6PYXPEFeBxeDjqMiwRrSe81LnpL1cpw1WSwENJY1p4NtgSbfZPaUFy8Kkg",
|
||||
"address": "Aaidx8VxYVjpD6knF8toWG7WquQjQFWcZB",
|
||||
"key": "6PYMZM16cgdQ9GH5ejEPFqehuZ3Lp16W4fW7LyoBdUuVyeMeom7z8wP5QV",
|
||||
"label": "",
|
||||
"contract": {
|
||||
"script": "4c2102103a7f7dd016558597f7960d27c516a4394fd968b9e65155eb4b013e4040406e50680a906ad4",
|
||||
"script": "0c2102103a7f7dd016558597f7960d27c516a4394fd968b9e65155eb4b013e4040406e0b680a906ad4",
|
||||
"parameters": [
|
||||
{
|
||||
"name": "parameter0",
|
||||
|
|
|
@ -181,14 +181,14 @@ func TestWalletGetChangeAddress(t *testing.T) {
|
|||
require.NoError(t, err)
|
||||
sh := w1.GetChangeAddress()
|
||||
// No default address, the first one is used.
|
||||
expected, err := address.StringToUint160("AQyx83BYr1PkyYhZhUAogaHdhkLVHn6htY")
|
||||
expected, err := address.StringToUint160("ASW1VhcukJRrukCXRipY4BE9d9zy4mAYsR")
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, expected, sh)
|
||||
w2, err := NewWalletFromFile("testdata/wallet2.json")
|
||||
require.NoError(t, err)
|
||||
sh = w2.GetChangeAddress()
|
||||
// Default address.
|
||||
expected, err = address.StringToUint160("AdB6ayKfBRJZasiXX4JL5N2YtmxftNp1b3")
|
||||
expected, err = address.StringToUint160("Aaidx8VxYVjpD6knF8toWG7WquQjQFWcZB")
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, expected, sh)
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue