2022-07-21 19:39:53 +00:00
|
|
|
package rpcclient
|
2020-03-16 13:49:56 +00:00
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
2020-06-09 09:12:56 +00:00
|
|
|
"encoding/base64"
|
2020-03-16 13:49:56 +00:00
|
|
|
"encoding/hex"
|
2020-10-14 15:13:20 +00:00
|
|
|
"encoding/json"
|
2020-07-21 07:31:45 +00:00
|
|
|
"fmt"
|
2020-07-09 14:25:26 +00:00
|
|
|
"math/big"
|
2020-03-16 13:49:56 +00:00
|
|
|
"net/http"
|
|
|
|
"net/http/httptest"
|
2020-04-29 19:51:43 +00:00
|
|
|
"strings"
|
2020-03-16 13:49:56 +00:00
|
|
|
"testing"
|
2020-04-29 19:51:43 +00:00
|
|
|
"time"
|
2020-03-16 13:49:56 +00:00
|
|
|
|
2020-04-29 19:51:43 +00:00
|
|
|
"github.com/gorilla/websocket"
|
2020-11-23 11:09:00 +00:00
|
|
|
"github.com/nspcc-dev/neo-go/internal/testserdes"
|
2023-10-12 14:54:19 +00:00
|
|
|
"github.com/nspcc-dev/neo-go/pkg/config"
|
2020-06-18 06:43:37 +00:00
|
|
|
"github.com/nspcc-dev/neo-go/pkg/config/netmode"
|
2020-03-16 13:49:56 +00:00
|
|
|
"github.com/nspcc-dev/neo-go/pkg/core/block"
|
2020-06-09 09:12:56 +00:00
|
|
|
"github.com/nspcc-dev/neo-go/pkg/core/state"
|
2020-03-16 13:49:56 +00:00
|
|
|
"github.com/nspcc-dev/neo-go/pkg/core/transaction"
|
2020-11-18 20:10:48 +00:00
|
|
|
"github.com/nspcc-dev/neo-go/pkg/crypto/hash"
|
2020-09-21 12:34:04 +00:00
|
|
|
"github.com/nspcc-dev/neo-go/pkg/crypto/keys"
|
2020-04-16 14:10:42 +00:00
|
|
|
"github.com/nspcc-dev/neo-go/pkg/encoding/address"
|
2023-03-23 09:03:22 +00:00
|
|
|
"github.com/nspcc-dev/neo-go/pkg/encoding/bigint"
|
2020-12-01 08:40:58 +00:00
|
|
|
"github.com/nspcc-dev/neo-go/pkg/encoding/fixedn"
|
2021-10-07 13:56:27 +00:00
|
|
|
"github.com/nspcc-dev/neo-go/pkg/io"
|
2022-07-22 16:09:29 +00:00
|
|
|
"github.com/nspcc-dev/neo-go/pkg/neorpc/result"
|
2022-07-21 13:21:44 +00:00
|
|
|
"github.com/nspcc-dev/neo-go/pkg/services/rpcsrv/params"
|
2020-03-16 13:49:56 +00:00
|
|
|
"github.com/nspcc-dev/neo-go/pkg/smartcontract"
|
2020-06-09 09:12:56 +00:00
|
|
|
"github.com/nspcc-dev/neo-go/pkg/smartcontract/manifest"
|
2021-01-13 12:34:10 +00:00
|
|
|
"github.com/nspcc-dev/neo-go/pkg/smartcontract/nef"
|
2020-09-03 16:58:50 +00:00
|
|
|
"github.com/nspcc-dev/neo-go/pkg/smartcontract/trigger"
|
2020-03-16 13:49:56 +00:00
|
|
|
"github.com/nspcc-dev/neo-go/pkg/util"
|
2020-06-05 09:17:16 +00:00
|
|
|
"github.com/nspcc-dev/neo-go/pkg/vm/opcode"
|
2020-07-31 12:26:28 +00:00
|
|
|
"github.com/nspcc-dev/neo-go/pkg/vm/stackitem"
|
2022-07-08 14:28:29 +00:00
|
|
|
"github.com/nspcc-dev/neo-go/pkg/vm/vmstate"
|
2020-03-16 13:49:56 +00:00
|
|
|
"github.com/stretchr/testify/assert"
|
|
|
|
"github.com/stretchr/testify/require"
|
|
|
|
)
|
|
|
|
|
|
|
|
type rpcClientTestCase struct {
|
|
|
|
name string
|
2023-04-03 10:34:24 +00:00
|
|
|
invoke func(c *Client) (any, error)
|
2020-12-14 12:23:39 +00:00
|
|
|
fails bool
|
2020-03-16 13:49:56 +00:00
|
|
|
serverResponse string
|
2023-04-03 10:34:24 +00:00
|
|
|
result func(c *Client) any
|
|
|
|
check func(t *testing.T, c *Client, result any)
|
2020-03-16 13:49:56 +00:00
|
|
|
}
|
|
|
|
|
2021-07-14 08:32:54 +00:00
|
|
|
const base64B1 = "AAAAAMSdeyVO3QCekJTbQ4D7YEEGFv2nXPd6CfO5Kn3htI8P9tVA4+VXLyyMG12BUj6qB3CZ+JIFwWCcDF+KBHH0VSjJICSkegEAAAAAAAAAAAAAAQAAAABouegejA5skHm0udEF6HinbT8iPwHGDEBg0hpK90iZlB4ZSCG7BOr7BsvPXGDax360lvqKeNFuzaGI1RYNH50/dhQLxocy90JdsIOyodd1sOJGEjZIt7ztDEAHc2avJzz6tK+FOQMIZO/FEEikJdLJX0+iZXFcsmDRpB7lo2wWMSQbcoTXNg7leuR0VeDsKJ+YdvCuTG5WbiqWDECa6Yjj+bK4te5KR5jdLF5kLt03csyozZcd/X7NPt89IsX01zpX8ec3e+B2qySJIOhEf3cK0i+5U5wyXiFcRI8xkxMMIQIQOn990BZVhZf3lg0nxRakOU/ZaLnmUVXrSwE+QEBAbgwhAqe8Vf6GhOARl2jRBLoweVvcyGYZ6GSt0mFWcj7Rhc1iDCECs2Ir9AF73+MXxYrtX0x1PyBrfbiWBG+n13S7xL9/jcIMIQPZDAffY+aQzneRLhCrUazJRLZoYCN7YIxPj4MJ5x7mmRRBntDcOgIAAgAAAMDYpwAAAAAADHlDAAAAAACwBAAAAWi56B6MDmyQebS50QXoeKdtPyI/AQBbCwIY3fUFDBTunqIsJ+NL0BSPxBCOCPdOj1BIsgwUaLnoHowObJB5tLnRBeh4p20/Ij8UwB8MCHRyYW5zZmVyDBT1Y+pAvCg9TQ4FxI6jBbPyoHNA70FifVtSOQHGDEC8InWg8rQHWjklRojobu7kn4r0xZY2xWYs15ggVX4PQyEHpNTU6vZHT2TXRdPXAOKHhgWAttO0oTvo+9VZAjIVDEBF0qvBMlvmYJIYLqSoCjhBykcSN78UXrBjO5BKL8BpHtejWCld1VT6Z7nYrEBLgySD6HeMcp/fa6vqHzU220e/DECXtm5AA1jy9GFA7t8U6a+1uPrQFk4Ufp0UyXsun0PvN0NdhrHc37xm8k9Z0dB85V/7WLtkMaLLyjVNVIKImC76kxMMIQIQOn990BZVhZf3lg0nxRakOU/ZaLnmUVXrSwE+QEBAbgwhAqe8Vf6GhOARl2jRBLoweVvcyGYZ6GSt0mFWcj7Rhc1iDCECs2Ir9AF73+MXxYrtX0x1PyBrfbiWBG+n13S7xL9/jcIMIQPZDAffY+aQzneRLhCrUazJRLZoYCN7YIxPj4MJ5x7mmRRBntDcOgADAAAAwNinAAAAAACsiEMAAAAAALAEAAABaLnoHowObJB5tLnRBeh4p20/Ij8BAF8LAwDodkgXAAAADBTunqIsJ+NL0BSPxBCOCPdOj1BIsgwUaLnoHowObJB5tLnRBeh4p20/Ij8UwB8MCHRyYW5zZmVyDBTPduKL0AYsSkeO41VhARMZ88+k0kFifVtSOQHGDEDgj/SQT84EbWRZ4ZKhyjJTuLwVPDgVlQO3CGmgacItvni9nziJvTxziZXBG/0Hqkv68ddS1EH94RtWlqLQWRCjDEAWZUeSQ8KskILSvoWPN3836xpg/TYzOGiFVoePv91CFnap4fRFxdbporBgnZ/sUsjFZ74U8f+r0riqtvkdMMyGDEDx5iho79oDVYOCwIDH3K1UeDjAT6Hq9YsD9SCfJSE1rRsAdJPh2StYxdh9Jah1lwGbW0U+Wu6zpbVFf5CS6fFckxMMIQIQOn990BZVhZf3lg0nxRakOU/ZaLnmUVXrSwE+QEBAbgwhAqe8Vf6GhOARl2jRBLoweVvcyGYZ6GSt0mFWcj7Rhc1iDCECs2Ir9AF73+MXxYrtX0x1PyBrfbiWBG+n13S7xL9/jcIMIQPZDAffY+aQzneRLhCrUazJRLZoYCN7YIxPj4MJ5x7mmRRBntDcOg=="
|
2020-06-05 09:17:16 +00:00
|
|
|
|
2021-07-14 08:32:54 +00:00
|
|
|
const base64TxMoveNeo = "AAIAAADA2KcAAAAAAAx5QwAAAAAAsAQAAAFouegejA5skHm0udEF6HinbT8iPwEAWwsCGN31BQwU7p6iLCfjS9AUj8QQjgj3To9QSLIMFGi56B6MDmyQebS50QXoeKdtPyI/FMAfDAh0cmFuc2ZlcgwU9WPqQLwoPU0OBcSOowWz8qBzQO9BYn1bUjkBxgxAvCJ1oPK0B1o5JUaI6G7u5J+K9MWWNsVmLNeYIFV+D0MhB6TU1Or2R09k10XT1wDih4YFgLbTtKE76PvVWQIyFQxARdKrwTJb5mCSGC6kqAo4QcpHEje/FF6wYzuQSi/AaR7Xo1gpXdVU+me52KxAS4Mkg+h3jHKf32ur6h81NttHvwxAl7ZuQANY8vRhQO7fFOmvtbj60BZOFH6dFMl7Lp9D7zdDXYax3N+8ZvJPWdHQfOVf+1i7ZDGiy8o1TVSCiJgu+pMTDCECEDp/fdAWVYWX95YNJ8UWpDlP2Wi55lFV60sBPkBAQG4MIQKnvFX+hoTgEZdo0QS6MHlb3MhmGehkrdJhVnI+0YXNYgwhArNiK/QBe9/jF8WK7V9MdT8ga324lgRvp9d0u8S/f43CDCED2QwH32PmkM53kS4Qq1GsyUS2aGAje2CMT4+DCece5pkUQZ7Q3Do="
|
2020-06-05 09:17:16 +00:00
|
|
|
|
2021-07-14 08:32:54 +00:00
|
|
|
const b1Verbose = `{"size":1438,"nextblockhash":"0x34c20650683940a7af1881c2798e83acf9bf98aa226025af6c1d32b5530cc900","confirmations":15,"hash":"0x88c1cbf68695f73fb7b7d185c0037ffebdf032327488ebe65e0533d269e7de9b","version":0,"previousblockhash":"0x0f8fb4e17d2ab9f3097af75ca7fd16064160fb8043db94909e00dd4e257b9dc4","merkleroot":"0x2855f471048a5f0c9c60c10592f8997007aa3e52815d1b8c2c2f57e5e340d5f6","time":1626251469001,"nonce":"0","index":1,"nextconsensus":"NVTiAjNgagDkTr5HTzDmQP9kPwPHN5BgVq","primary":0,"witnesses":[{"invocation":"DEBg0hpK90iZlB4ZSCG7BOr7BsvPXGDax360lvqKeNFuzaGI1RYNH50/dhQLxocy90JdsIOyodd1sOJGEjZIt7ztDEAHc2avJzz6tK+FOQMIZO/FEEikJdLJX0+iZXFcsmDRpB7lo2wWMSQbcoTXNg7leuR0VeDsKJ+YdvCuTG5WbiqWDECa6Yjj+bK4te5KR5jdLF5kLt03csyozZcd/X7NPt89IsX01zpX8ec3e+B2qySJIOhEf3cK0i+5U5wyXiFcRI8x","verification":"EwwhAhA6f33QFlWFl/eWDSfFFqQ5T9loueZRVetLAT5AQEBuDCECp7xV/oaE4BGXaNEEujB5W9zIZhnoZK3SYVZyPtGFzWIMIQKzYiv0AXvf4xfFiu1fTHU/IGt9uJYEb6fXdLvEv3+NwgwhA9kMB99j5pDOd5EuEKtRrMlEtmhgI3tgjE+PgwnnHuaZFEGe0Nw6"}],"tx":[{"hash":"0xf01080c50f3198f5a539c4a06d024f1b8bdc2a360a215fa7e2488f79a56d501a","size":488,"version":0,"nonce":2,"sender":"NVTiAjNgagDkTr5HTzDmQP9kPwPHN5BgVq","sysfee":"11000000","netfee":"4421900","validuntilblock":1200,"attributes":[],"signers":[{"account":"0x3f223f6da778e805d1b9b479906c0e8c1ee8b968","scopes":"CalledByEntry"}],"script":"CwIY3fUFDBTunqIsJ+NL0BSPxBCOCPdOj1BIsgwUaLnoHowObJB5tLnRBeh4p20/Ij8UwB8MCHRyYW5zZmVyDBT1Y+pAvCg9TQ4FxI6jBbPyoHNA70FifVtSOQ==","witnesses":[{"invocation":"DEC8InWg8rQHWjklRojobu7kn4r0xZY2xWYs15ggVX4PQyEHpNTU6vZHT2TXRdPXAOKHhgWAttO0oTvo+9VZAjIVDEBF0qvBMlvmYJIYLqSoCjhBykcSN78UXrBjO5BKL8BpHtejWCld1VT6Z7nYrEBLgySD6HeMcp/fa6vqHzU220e/DECXtm5AA1jy9GFA7t8U6a+1uPrQFk4Ufp0UyXsun0PvN0NdhrHc37xm8k9Z0dB85V/7WLtkMaLLyjVNVIKImC76","verification":"EwwhAhA6f33QFlWFl/eWDSfFFqQ5T9loueZRVetLAT5AQEBuDCECp7xV/oaE4BGXaNEEujB5W9zIZhnoZK3SYVZyPtGFzWIMIQKzYiv0AXvf4xfFiu1fTHU/IGt9uJYEb6fXdLvEv3+NwgwhA9kMB99j5pDOd5EuEKtRrMlEtmhgI3tgjE+PgwnnHuaZFEGe0Nw6"}]},{"hash":"0xced32af656e144f6be5d7172ed37747831456cb3eeaac4ee964d0b479b45d3a8","size":492,"version":0,"nonce":3,"sender":"NVTiAjNgagDkTr5HTzDmQP9kPwPHN5BgVq","sysfee":"11000000","netfee":"4425900","validuntilblock":1200,"attributes":[],"signers":[{"account":"0x3f223f6da778e805d1b9b479906c0e8c1ee8b968","scopes":"CalledByEntry"}],"script":"CwMA6HZIFwAAAAwU7p6iLCfjS9AUj8QQjgj3To9QSLIMFGi56B6MDmyQebS50QXoeKdtPyI/FMAfDAh0cmFuc2ZlcgwUz3bii9AGLEpHjuNVYQETGfPPpNJBYn1bUjk=","witnesses":[{"invocation":"DEDgj/SQT84EbWRZ4ZKhyjJTuLwVPDgVlQO3CGmgacItvni9nziJvTxziZXBG/0Hqkv68ddS1EH94RtWlqLQWRCjDEAWZUeSQ8KskILSvoWPN3836xpg/TYzOGiFVoePv91CFnap4fRFxdbporBgnZ/sUsjFZ74U8f+r0riqtvkdMMyGDEDx5iho79oDVYOCwIDH3K1UeDjAT6Hq9YsD9SCfJSE1rRsAdJPh2StYxdh9Jah1lwGbW0U+Wu6zpbVFf5CS6fFc","verification":"EwwhAhA6f33QFlWFl/eWDSfFFqQ5T9loueZRVetLAT5AQEBuDCECp7xV/oaE4BGXaNEEujB5W9zIZhnoZK3SYVZyPtGFzWIMIQKzYiv0AXvf4xfFiu1fTHU/IGt9uJYEb6fXdLvEv3+NwgwhA9kMB99j5pDOd5EuEKtRrMlEtmhgI3tgjE+PgwnnHuaZFEGe0Nw6"}]}]}`
|
2020-06-05 09:17:16 +00:00
|
|
|
|
2021-07-14 08:32:54 +00:00
|
|
|
const base64Header1 = "AAAAAMSdeyVO3QCekJTbQ4D7YEEGFv2nXPd6CfO5Kn3htI8P9tVA4+VXLyyMG12BUj6qB3CZ+JIFwWCcDF+KBHH0VSjJICSkegEAAAAAAAAAAAAAAQAAAABouegejA5skHm0udEF6HinbT8iPwHGDEBg0hpK90iZlB4ZSCG7BOr7BsvPXGDax360lvqKeNFuzaGI1RYNH50/dhQLxocy90JdsIOyodd1sOJGEjZIt7ztDEAHc2avJzz6tK+FOQMIZO/FEEikJdLJX0+iZXFcsmDRpB7lo2wWMSQbcoTXNg7leuR0VeDsKJ+YdvCuTG5WbiqWDECa6Yjj+bK4te5KR5jdLF5kLt03csyozZcd/X7NPt89IsX01zpX8ec3e+B2qySJIOhEf3cK0i+5U5wyXiFcRI8xkxMMIQIQOn990BZVhZf3lg0nxRakOU/ZaLnmUVXrSwE+QEBAbgwhAqe8Vf6GhOARl2jRBLoweVvcyGYZ6GSt0mFWcj7Rhc1iDCECs2Ir9AF73+MXxYrtX0x1PyBrfbiWBG+n13S7xL9/jcIMIQPZDAffY+aQzneRLhCrUazJRLZoYCN7YIxPj4MJ5x7mmRRBntDcOg=="
|
2020-06-05 09:17:16 +00:00
|
|
|
|
2021-07-14 08:32:54 +00:00
|
|
|
const header1Verbose = `{"hash":"0x88c1cbf68695f73fb7b7d185c0037ffebdf032327488ebe65e0533d269e7de9b","size":457,"version":0,"previousblockhash":"0x0f8fb4e17d2ab9f3097af75ca7fd16064160fb8043db94909e00dd4e257b9dc4","merkleroot":"0x2855f471048a5f0c9c60c10592f8997007aa3e52815d1b8c2c2f57e5e340d5f6","time":1626251469001,"index":1,"nextconsensus":"NVTiAjNgagDkTr5HTzDmQP9kPwPHN5BgVq","witnesses":[{"invocation":"DEBg0hpK90iZlB4ZSCG7BOr7BsvPXGDax360lvqKeNFuzaGI1RYNH50/dhQLxocy90JdsIOyodd1sOJGEjZIt7ztDEAHc2avJzz6tK+FOQMIZO/FEEikJdLJX0+iZXFcsmDRpB7lo2wWMSQbcoTXNg7leuR0VeDsKJ+YdvCuTG5WbiqWDECa6Yjj+bK4te5KR5jdLF5kLt03csyozZcd/X7NPt89IsX01zpX8ec3e+B2qySJIOhEf3cK0i+5U5wyXiFcRI8x","verification":"EwwhAhA6f33QFlWFl/eWDSfFFqQ5T9loueZRVetLAT5AQEBuDCECp7xV/oaE4BGXaNEEujB5W9zIZhnoZK3SYVZyPtGFzWIMIQKzYiv0AXvf4xfFiu1fTHU/IGt9uJYEb6fXdLvEv3+NwgwhA9kMB99j5pDOd5EuEKtRrMlEtmhgI3tgjE+PgwnnHuaZFEGe0Nw6"}],"confirmations":15,"nextblockhash":"0x34c20650683940a7af1881c2798e83acf9bf98aa226025af6c1d32b5530cc900"}`
|
2020-06-05 09:17:16 +00:00
|
|
|
|
2021-07-14 08:32:54 +00:00
|
|
|
const txMoveNeoVerbose = `{"blockhash":"0x88c1cbf68695f73fb7b7d185c0037ffebdf032327488ebe65e0533d269e7de9b","confirmations":15,"blocktime":1626251469001,"vmstate":"HALT","hash":"0xf01080c50f3198f5a539c4a06d024f1b8bdc2a360a215fa7e2488f79a56d501a","size":488,"version":0,"nonce":2,"sender":"NVTiAjNgagDkTr5HTzDmQP9kPwPHN5BgVq","sysfee":"11000000","netfee":"4421900","validuntilblock":1200,"attributes":[],"signers":[{"account":"0x3f223f6da778e805d1b9b479906c0e8c1ee8b968","scopes":"CalledByEntry"}],"script":"CwIY3fUFDBTunqIsJ+NL0BSPxBCOCPdOj1BIsgwUaLnoHowObJB5tLnRBeh4p20/Ij8UwB8MCHRyYW5zZmVyDBT1Y+pAvCg9TQ4FxI6jBbPyoHNA70FifVtSOQ==","witnesses":[{"invocation":"DEC8InWg8rQHWjklRojobu7kn4r0xZY2xWYs15ggVX4PQyEHpNTU6vZHT2TXRdPXAOKHhgWAttO0oTvo+9VZAjIVDEBF0qvBMlvmYJIYLqSoCjhBykcSN78UXrBjO5BKL8BpHtejWCld1VT6Z7nYrEBLgySD6HeMcp/fa6vqHzU220e/DECXtm5AA1jy9GFA7t8U6a+1uPrQFk4Ufp0UyXsun0PvN0NdhrHc37xm8k9Z0dB85V/7WLtkMaLLyjVNVIKImC76","verification":"EwwhAhA6f33QFlWFl/eWDSfFFqQ5T9loueZRVetLAT5AQEBuDCECp7xV/oaE4BGXaNEEujB5W9zIZhnoZK3SYVZyPtGFzWIMIQKzYiv0AXvf4xfFiu1fTHU/IGt9uJYEb6fXdLvEv3+NwgwhA9kMB99j5pDOd5EuEKtRrMlEtmhgI3tgjE+PgwnnHuaZFEGe0Nw6"}]}`
|
2020-06-05 09:17:16 +00:00
|
|
|
|
|
|
|
// getResultBlock1 returns data for block number 1 which is used by several tests.
|
|
|
|
func getResultBlock1() *result.Block {
|
2020-11-06 14:37:58 +00:00
|
|
|
binB, err := base64.StdEncoding.DecodeString(base64B1)
|
2020-05-14 07:29:11 +00:00
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
2021-03-25 18:46:52 +00:00
|
|
|
b := block.New(false)
|
2020-06-05 09:17:16 +00:00
|
|
|
err = testserdes.DecodeBinary(binB, b)
|
2020-05-14 07:29:11 +00:00
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
2021-07-14 08:32:54 +00:00
|
|
|
b2Hash, err := util.Uint256DecodeStringLE("34c20650683940a7af1881c2798e83acf9bf98aa226025af6c1d32b5530cc900")
|
2020-05-14 07:29:11 +00:00
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
2020-06-05 09:17:16 +00:00
|
|
|
return &result.Block{
|
2020-06-18 08:47:54 +00:00
|
|
|
Block: *b,
|
2020-06-05 09:17:16 +00:00
|
|
|
BlockMetadata: result.BlockMetadata{
|
2021-07-14 08:32:54 +00:00
|
|
|
Size: 1438,
|
2020-06-05 09:17:16 +00:00
|
|
|
NextBlockHash: &b2Hash,
|
2021-07-14 08:32:54 +00:00
|
|
|
Confirmations: 15,
|
2020-05-14 07:29:11 +00:00
|
|
|
},
|
|
|
|
}
|
2020-06-05 09:17:16 +00:00
|
|
|
}
|
2020-05-14 07:29:11 +00:00
|
|
|
|
2020-06-05 09:17:16 +00:00
|
|
|
func getTxMoveNeo() *result.TransactionOutputRaw {
|
|
|
|
b1 := getResultBlock1()
|
2020-11-06 14:37:58 +00:00
|
|
|
txBin, err := base64.StdEncoding.DecodeString(base64TxMoveNeo)
|
2020-05-14 07:29:11 +00:00
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
2021-03-25 16:18:01 +00:00
|
|
|
tx, err := transaction.NewTransactionFromBytes(txBin)
|
2020-05-14 07:29:11 +00:00
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
2020-06-05 09:17:16 +00:00
|
|
|
return &result.TransactionOutputRaw{
|
2020-06-18 08:47:54 +00:00
|
|
|
Transaction: *tx,
|
2020-06-05 09:17:16 +00:00
|
|
|
TransactionMetadata: result.TransactionMetadata{
|
|
|
|
Timestamp: b1.Timestamp,
|
|
|
|
Blockhash: b1.Block.Hash(),
|
2020-06-05 16:27:39 +00:00
|
|
|
Confirmations: int(b1.Confirmations),
|
2021-03-01 12:20:27 +00:00
|
|
|
VMState: "HALT",
|
2020-05-14 07:29:11 +00:00
|
|
|
},
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-03-16 13:49:56 +00:00
|
|
|
// rpcClientTestCases contains `serverResponse` json data fetched from examples
|
2022-04-20 18:30:09 +00:00
|
|
|
// published in the official C# JSON-RPC API v2.10.3 reference
|
2020-03-16 13:49:56 +00:00
|
|
|
// (see https://docs.neo.org/docs/en-us/reference/rpc/latest-version/api.html)
|
|
|
|
var rpcClientTestCases = map[string][]rpcClientTestCase{
|
|
|
|
"getapplicationlog": {
|
|
|
|
{
|
|
|
|
name: "positive",
|
2023-04-03 10:34:24 +00:00
|
|
|
invoke: func(c *Client) (any, error) {
|
2020-11-10 11:30:00 +00:00
|
|
|
return c.GetApplicationLog(util.Uint256{}, nil)
|
2020-03-16 13:49:56 +00:00
|
|
|
},
|
2021-02-09 08:16:18 +00:00
|
|
|
serverResponse: `{"id":1,"jsonrpc":"2.0","result":{"txid":"0x17145a039fca704fcdbeb46e6b210af98a1a9e5b9768e46ffc38f71c79ac2521","executions":[{"trigger":"Application","vmstate":"HALT","gasconsumed":"1","stack":[{"type":"Integer","value":"1"}],"notifications":[]}]}}`,
|
2023-04-03 10:34:24 +00:00
|
|
|
result: func(c *Client) any {
|
2020-03-16 13:49:56 +00:00
|
|
|
txHash, err := util.Uint256DecodeStringLE("17145a039fca704fcdbeb46e6b210af98a1a9e5b9768e46ffc38f71c79ac2521")
|
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
2020-11-11 15:43:28 +00:00
|
|
|
return &result.ApplicationLog{
|
|
|
|
Container: txHash,
|
|
|
|
Executions: []state.Execution{
|
|
|
|
{
|
|
|
|
Trigger: trigger.Application,
|
2022-07-08 14:28:29 +00:00
|
|
|
VMState: vmstate.Halt,
|
2020-11-11 15:43:28 +00:00
|
|
|
GasConsumed: 1,
|
|
|
|
Stack: []stackitem.Item{stackitem.NewBigInteger(big.NewInt(1))},
|
|
|
|
Events: []state.NotificationEvent{},
|
|
|
|
},
|
|
|
|
},
|
2020-03-16 13:49:56 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
"getbestblockhash": {
|
|
|
|
{
|
|
|
|
name: "positive",
|
2023-04-03 10:34:24 +00:00
|
|
|
invoke: func(c *Client) (any, error) {
|
2020-03-16 13:49:56 +00:00
|
|
|
return c.GetBestBlockHash()
|
|
|
|
},
|
|
|
|
serverResponse: `{"jsonrpc":"2.0","id":1,"result":"0x773dd2dae4a9c9275290f89b56e67d7363ea4826dfd4fc13cc01cf73a44b0d0e"}`,
|
2023-04-03 10:34:24 +00:00
|
|
|
result: func(c *Client) any {
|
2020-03-16 13:49:56 +00:00
|
|
|
result, err := util.Uint256DecodeStringLE("773dd2dae4a9c9275290f89b56e67d7363ea4826dfd4fc13cc01cf73a44b0d0e")
|
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
return result
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
"getblock": {
|
|
|
|
{
|
|
|
|
name: "byIndex_positive",
|
2023-04-03 10:34:24 +00:00
|
|
|
invoke: func(c *Client) (any, error) {
|
2020-06-05 09:17:16 +00:00
|
|
|
return c.GetBlockByIndex(1)
|
2020-03-16 13:49:56 +00:00
|
|
|
},
|
2020-11-06 14:37:58 +00:00
|
|
|
serverResponse: `{"id":1,"jsonrpc":"2.0","result":"` + base64B1 + `"}`,
|
2023-04-03 10:34:24 +00:00
|
|
|
result: func(c *Client) any {
|
2020-06-05 09:17:16 +00:00
|
|
|
b := getResultBlock1()
|
2020-06-18 08:47:54 +00:00
|
|
|
return &b.Block
|
2020-03-16 13:49:56 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "byIndex_verbose_positive",
|
2023-04-03 10:34:24 +00:00
|
|
|
invoke: func(c *Client) (i any, err error) {
|
2020-06-05 09:17:16 +00:00
|
|
|
return c.GetBlockByIndexVerbose(1)
|
2020-03-16 13:49:56 +00:00
|
|
|
},
|
2021-03-17 13:40:24 +00:00
|
|
|
serverResponse: `{"id":1,"jsonrpc":"2.0","result":` + b1Verbose + `}`,
|
2023-04-03 10:34:24 +00:00
|
|
|
result: func(c *Client) any {
|
2020-09-16 09:33:39 +00:00
|
|
|
res := getResultBlock1()
|
|
|
|
return res
|
2020-03-16 13:49:56 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "byHash_positive",
|
2023-04-03 10:34:24 +00:00
|
|
|
invoke: func(c *Client) (any, error) {
|
2020-06-05 09:17:16 +00:00
|
|
|
hash, err := util.Uint256DecodeStringLE("d151651e86680a7ecbc87babf3346a42e7bc9974414ce192c9c22ac4f2e9d043")
|
2020-03-16 13:49:56 +00:00
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
return c.GetBlockByHash(hash)
|
|
|
|
},
|
2020-11-06 14:37:58 +00:00
|
|
|
serverResponse: `{"id":1,"jsonrpc":"2.0","result":"` + base64B1 + `"}`,
|
2023-04-03 10:34:24 +00:00
|
|
|
result: func(c *Client) any {
|
2020-06-05 09:17:16 +00:00
|
|
|
b := getResultBlock1()
|
2020-06-18 08:47:54 +00:00
|
|
|
return &b.Block
|
2020-03-16 13:49:56 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "byHash_verbose_positive",
|
2023-04-03 10:34:24 +00:00
|
|
|
invoke: func(c *Client) (i any, err error) {
|
2020-05-08 17:54:24 +00:00
|
|
|
hash, err := util.Uint256DecodeStringLE("86fe1061140b2ea791b0739fb9732abc6e5e47de4927228a1ac41de3d93eb7cb")
|
2020-03-16 13:49:56 +00:00
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
return c.GetBlockByHashVerbose(hash)
|
|
|
|
},
|
2021-03-17 13:40:24 +00:00
|
|
|
serverResponse: `{"id":1,"jsonrpc":"2.0","result":` + b1Verbose + `}`,
|
2023-04-03 10:34:24 +00:00
|
|
|
result: func(c *Client) any {
|
2020-09-16 09:33:39 +00:00
|
|
|
res := getResultBlock1()
|
|
|
|
return res
|
2020-03-16 13:49:56 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
"getblockcount": {
|
|
|
|
{
|
|
|
|
name: "positive",
|
2023-04-03 10:34:24 +00:00
|
|
|
invoke: func(c *Client) (any, error) {
|
2020-03-16 13:49:56 +00:00
|
|
|
return c.GetBlockCount()
|
|
|
|
},
|
|
|
|
serverResponse: `{"jsonrpc":"2.0","id":1,"result":991991}`,
|
2023-04-03 10:34:24 +00:00
|
|
|
result: func(c *Client) any {
|
2020-03-16 13:49:56 +00:00
|
|
|
return uint32(991991)
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
"getblockhash": {
|
|
|
|
{
|
|
|
|
name: "positive",
|
2023-04-03 10:34:24 +00:00
|
|
|
invoke: func(c *Client) (any, error) {
|
2020-03-16 13:49:56 +00:00
|
|
|
return c.GetBlockHash(1)
|
|
|
|
},
|
|
|
|
serverResponse: `{"jsonrpc":"2.0","id":1,"result":"0x4c1e879872344349067c3b1a30781eeb4f9040d3795db7922f513f6f9660b9b2"}`,
|
2023-04-03 10:34:24 +00:00
|
|
|
result: func(c *Client) any {
|
2020-03-16 13:49:56 +00:00
|
|
|
hash, err := util.Uint256DecodeStringLE("4c1e879872344349067c3b1a30781eeb4f9040d3795db7922f513f6f9660b9b2")
|
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
return hash
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
"getblockheader": {
|
|
|
|
{
|
|
|
|
name: "positive",
|
2023-04-03 10:34:24 +00:00
|
|
|
invoke: func(c *Client) (any, error) {
|
2020-04-22 05:57:55 +00:00
|
|
|
hash, err := util.Uint256DecodeStringLE("68e4bd688b852e807eef13a0ff7da7b02223e359a35153667e88f9cb4a3b0801")
|
2020-03-16 13:49:56 +00:00
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
return c.GetBlockHeader(hash)
|
|
|
|
},
|
2020-11-06 14:37:58 +00:00
|
|
|
serverResponse: `{"id":1,"jsonrpc":"2.0","result":"` + base64Header1 + `"}`,
|
2023-04-03 10:34:24 +00:00
|
|
|
result: func(c *Client) any {
|
2020-06-05 09:17:16 +00:00
|
|
|
b := getResultBlock1()
|
2021-03-01 13:44:47 +00:00
|
|
|
return &b.Header
|
2020-03-16 13:49:56 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "verbose_positive",
|
2023-04-03 10:34:24 +00:00
|
|
|
invoke: func(c *Client) (i any, err error) {
|
2020-05-14 07:29:11 +00:00
|
|
|
hash, err := util.Uint256DecodeStringLE("cbb73ed9e31dc41a8a222749de475e6ebc2a73b99f73b091a72e0b146110fe86")
|
2020-03-16 13:49:56 +00:00
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
return c.GetBlockHeaderVerbose(hash)
|
|
|
|
},
|
2021-03-17 13:40:24 +00:00
|
|
|
serverResponse: `{"id":1,"jsonrpc":"2.0","result":` + header1Verbose + `}`,
|
2023-04-03 10:34:24 +00:00
|
|
|
result: func(c *Client) any {
|
2020-06-05 09:17:16 +00:00
|
|
|
b := getResultBlock1()
|
2020-03-16 13:49:56 +00:00
|
|
|
return &result.Header{
|
2021-09-09 13:13:59 +00:00
|
|
|
Header: b.Header,
|
|
|
|
BlockMetadata: result.BlockMetadata{
|
|
|
|
Size: 457,
|
|
|
|
NextBlockHash: b.NextBlockHash,
|
|
|
|
Confirmations: b.Confirmations,
|
|
|
|
},
|
2020-03-16 13:49:56 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2021-02-07 19:01:22 +00:00
|
|
|
"getblockheadercount": {
|
|
|
|
{
|
|
|
|
name: "positive",
|
2023-04-03 10:34:24 +00:00
|
|
|
invoke: func(c *Client) (any, error) {
|
2021-02-07 19:01:22 +00:00
|
|
|
return c.GetBlockHeaderCount()
|
|
|
|
},
|
|
|
|
serverResponse: `{"jsonrpc":"2.0","id":1,"result":2021}`,
|
2023-04-03 10:34:24 +00:00
|
|
|
result: func(c *Client) any {
|
2021-02-07 19:01:22 +00:00
|
|
|
return uint32(2021)
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2020-03-16 13:49:56 +00:00
|
|
|
"getblocksysfee": {
|
|
|
|
{
|
|
|
|
name: "positive",
|
2023-04-03 10:34:24 +00:00
|
|
|
invoke: func(c *Client) (any, error) {
|
2020-03-16 13:49:56 +00:00
|
|
|
return c.GetBlockSysFee(1)
|
|
|
|
},
|
|
|
|
serverResponse: `{"jsonrpc":"2.0","id":1,"result":"195500"}`,
|
2023-04-03 10:34:24 +00:00
|
|
|
result: func(c *Client) any {
|
2020-12-01 08:40:58 +00:00
|
|
|
return fixedn.Fixed8FromInt64(195500)
|
2020-03-16 13:49:56 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2020-09-21 12:34:04 +00:00
|
|
|
"getcommittee": {
|
|
|
|
{
|
|
|
|
name: "positive",
|
2023-04-03 10:34:24 +00:00
|
|
|
invoke: func(c *Client) (any, error) {
|
2020-09-21 12:34:04 +00:00
|
|
|
return c.GetCommittee()
|
|
|
|
},
|
|
|
|
serverResponse: `{"jsonrpc":"2.0","id":1,"result":["02103a7f7dd016558597f7960d27c516a4394fd968b9e65155eb4b013e4040406e"]}`,
|
2023-04-03 10:34:24 +00:00
|
|
|
result: func(c *Client) any {
|
2020-09-21 12:34:04 +00:00
|
|
|
member, err := keys.NewPublicKeyFromString("02103a7f7dd016558597f7960d27c516a4394fd968b9e65155eb4b013e4040406e")
|
|
|
|
if err != nil {
|
2020-09-22 06:53:35 +00:00
|
|
|
panic(fmt.Errorf("failed to decode public key: %w", err))
|
2020-09-21 12:34:04 +00:00
|
|
|
}
|
|
|
|
return keys.PublicKeys{member}
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2020-03-16 13:49:56 +00:00
|
|
|
"getconnectioncount": {
|
|
|
|
{
|
|
|
|
name: "positive",
|
2023-04-03 10:34:24 +00:00
|
|
|
invoke: func(c *Client) (any, error) {
|
2020-03-16 13:49:56 +00:00
|
|
|
return c.GetConnectionCount()
|
|
|
|
},
|
|
|
|
serverResponse: `{"jsonrpc":"2.0","id":1,"result":10}`,
|
2023-04-03 10:34:24 +00:00
|
|
|
result: func(c *Client) any {
|
2020-03-16 13:49:56 +00:00
|
|
|
return 10
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
"getcontractstate": {
|
|
|
|
{
|
2020-09-25 16:32:53 +00:00
|
|
|
name: "positive, by hash",
|
2023-04-03 10:34:24 +00:00
|
|
|
invoke: func(c *Client) (any, error) {
|
2020-06-09 09:12:56 +00:00
|
|
|
hash, err := util.Uint160DecodeStringLE("1b4357bff5a01bdf2a6581247cf9ed1e24629176")
|
2020-03-16 13:49:56 +00:00
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
2020-09-25 16:32:53 +00:00
|
|
|
return c.GetContractStateByHash(hash)
|
|
|
|
},
|
2021-04-30 14:19:52 +00:00
|
|
|
serverResponse: `{"id":1,"jsonrpc":"2.0","result":{"id":0,"nef":{"magic":860243278,"compiler":"neo-go-3.0","script":"VgJXHwIMDWNvbnRyYWN0IGNhbGx4eVMTwEEFB5IWIXhKDANQdXSXJyQAAAAQVUGEGNYNIXJqeRDOeRHOU0FSoUH1IUURQCOPAgAASgwLdG90YWxTdXBwbHmXJxEAAABFAkBCDwBAI28CAABKDAhkZWNpbWFsc5cnDQAAAEUSQCNWAgAASgwEbmFtZZcnEgAAAEUMBFJ1YmxAIzwCAABKDAZzeW1ib2yXJxEAAABFDANSVUJAIyECAABKDAliYWxhbmNlT2aXJ2IAAAAQVUGEGNYNIXN5EM50bMoAFLQnIwAAAAwPaW52YWxpZCBhZGRyZXNzEVVBNtNSBiFFENsgQGtsUEEfLnsHIXUMCWJhbGFuY2VPZmxtUxPAQQUHkhYhRW1AI7IBAABKDAh0cmFuc2ZlcpcnKwEAABBVQYQY1g0hdnkQzncHbwfKABS0JyoAAAAMFmludmFsaWQgJ2Zyb20nIGFkZHJlc3MRVUE201IGIUUQ2yBAeRHOdwhvCMoAFLQnKAAAAAwUaW52YWxpZCAndG8nIGFkZHJlc3MRVUE201IGIUUQ2yBAeRLOdwlvCRC1JyIAAAAMDmludmFsaWQgYW1vdW50EVVBNtNSBiFFENsgQG5vB1BBHy57ByF3Cm8Kbwm1JyYAAAAMEmluc3VmZmljaWVudCBmdW5kcxFVQTbTUgYhRRDbIEBvCm8Jn3cKbm8HbwpTQVKhQfUhbm8IUEEfLnsHIXcLbwtvCZ53C25vCG8LU0FSoUH1IQwIdHJhbnNmZXJvB28IbwlUFMBBBQeSFiFFEUAjewAAAEoMBGluaXSXJ1AAAAAQVUGEGNYNIXcMEFVBh8PSZCF3DQJAQg8Adw5vDG8Nbw5TQVKhQfUhDAh0cmFuc2ZlcgwA2zBvDW8OVBTAQQUHkhYhRRFAIyMAAAAMEWludmFsaWQgb3BlcmF0aW9uQTbTUgY6IwUAAABFQA==","checksum":2512077441},"manifest":{"name":"Test","abi":{"methods":[],"events":[]},"groups":[],"features":{},"permissions":[],"trusts":[],"supportedstandards":[],"safemethods":[],"extra":null},"hash":"0x1b4357bff5a01bdf2a6581247cf9ed1e24629176"}}`,
|
2023-04-03 10:34:24 +00:00
|
|
|
result: func(c *Client) any {
|
2020-09-25 16:32:53 +00:00
|
|
|
script, err := base64.StdEncoding.DecodeString("VgJXHwIMDWNvbnRyYWN0IGNhbGx4eVMTwEEFB5IWIXhKDANQdXSXJyQAAAAQVUGEGNYNIXJqeRDOeRHOU0FSoUH1IUURQCOPAgAASgwLdG90YWxTdXBwbHmXJxEAAABFAkBCDwBAI28CAABKDAhkZWNpbWFsc5cnDQAAAEUSQCNWAgAASgwEbmFtZZcnEgAAAEUMBFJ1YmxAIzwCAABKDAZzeW1ib2yXJxEAAABFDANSVUJAIyECAABKDAliYWxhbmNlT2aXJ2IAAAAQVUGEGNYNIXN5EM50bMoAFLQnIwAAAAwPaW52YWxpZCBhZGRyZXNzEVVBNtNSBiFFENsgQGtsUEEfLnsHIXUMCWJhbGFuY2VPZmxtUxPAQQUHkhYhRW1AI7IBAABKDAh0cmFuc2ZlcpcnKwEAABBVQYQY1g0hdnkQzncHbwfKABS0JyoAAAAMFmludmFsaWQgJ2Zyb20nIGFkZHJlc3MRVUE201IGIUUQ2yBAeRHOdwhvCMoAFLQnKAAAAAwUaW52YWxpZCAndG8nIGFkZHJlc3MRVUE201IGIUUQ2yBAeRLOdwlvCRC1JyIAAAAMDmludmFsaWQgYW1vdW50EVVBNtNSBiFFENsgQG5vB1BBHy57ByF3Cm8Kbwm1JyYAAAAMEmluc3VmZmljaWVudCBmdW5kcxFVQTbTUgYhRRDbIEBvCm8Jn3cKbm8HbwpTQVKhQfUhbm8IUEEfLnsHIXcLbwtvCZ53C25vCG8LU0FSoUH1IQwIdHJhbnNmZXJvB28IbwlUFMBBBQeSFiFFEUAjewAAAEoMBGluaXSXJ1AAAAAQVUGEGNYNIXcMEFVBh8PSZCF3DQJAQg8Adw5vDG8Nbw5TQVKhQfUhDAh0cmFuc2ZlcgwA2zBvDW8OVBTAQQUHkhYhRRFAIyMAAAAMEWludmFsaWQgb3BlcmF0aW9uQTbTUgY6IwUAAABFQA==")
|
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
2020-11-18 09:43:51 +00:00
|
|
|
m := manifest.NewManifest("Test")
|
2020-09-25 16:32:53 +00:00
|
|
|
cs := &state.Contract{
|
2021-02-09 09:02:38 +00:00
|
|
|
ContractBase: state.ContractBase{
|
|
|
|
ID: 0,
|
|
|
|
Hash: hash.Hash160(script),
|
|
|
|
NEF: newTestNEF(script),
|
|
|
|
Manifest: *m,
|
|
|
|
},
|
2020-09-25 16:32:53 +00:00
|
|
|
}
|
|
|
|
return cs
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "positive, by address",
|
2023-04-03 10:34:24 +00:00
|
|
|
invoke: func(c *Client) (any, error) {
|
2020-09-25 16:32:53 +00:00
|
|
|
return c.GetContractStateByAddressOrName("NWiu5oejTu925aeL9Hc1LX8SvaJhE23h15")
|
|
|
|
},
|
2021-04-30 14:19:52 +00:00
|
|
|
serverResponse: `{"id":1,"jsonrpc":"2.0","result":{"id":0,"nef":{"magic":860243278,"compiler":"neo-go-3.0","script":"VgJXHwIMDWNvbnRyYWN0IGNhbGx4eVMTwEEFB5IWIXhKDANQdXSXJyQAAAAQVUGEGNYNIXJqeRDOeRHOU0FSoUH1IUURQCOPAgAASgwLdG90YWxTdXBwbHmXJxEAAABFAkBCDwBAI28CAABKDAhkZWNpbWFsc5cnDQAAAEUSQCNWAgAASgwEbmFtZZcnEgAAAEUMBFJ1YmxAIzwCAABKDAZzeW1ib2yXJxEAAABFDANSVUJAIyECAABKDAliYWxhbmNlT2aXJ2IAAAAQVUGEGNYNIXN5EM50bMoAFLQnIwAAAAwPaW52YWxpZCBhZGRyZXNzEVVBNtNSBiFFENsgQGtsUEEfLnsHIXUMCWJhbGFuY2VPZmxtUxPAQQUHkhYhRW1AI7IBAABKDAh0cmFuc2ZlcpcnKwEAABBVQYQY1g0hdnkQzncHbwfKABS0JyoAAAAMFmludmFsaWQgJ2Zyb20nIGFkZHJlc3MRVUE201IGIUUQ2yBAeRHOdwhvCMoAFLQnKAAAAAwUaW52YWxpZCAndG8nIGFkZHJlc3MRVUE201IGIUUQ2yBAeRLOdwlvCRC1JyIAAAAMDmludmFsaWQgYW1vdW50EVVBNtNSBiFFENsgQG5vB1BBHy57ByF3Cm8Kbwm1JyYAAAAMEmluc3VmZmljaWVudCBmdW5kcxFVQTbTUgYhRRDbIEBvCm8Jn3cKbm8HbwpTQVKhQfUhbm8IUEEfLnsHIXcLbwtvCZ53C25vCG8LU0FSoUH1IQwIdHJhbnNmZXJvB28IbwlUFMBBBQeSFiFFEUAjewAAAEoMBGluaXSXJ1AAAAAQVUGEGNYNIXcMEFVBh8PSZCF3DQJAQg8Adw5vDG8Nbw5TQVKhQfUhDAh0cmFuc2ZlcgwA2zBvDW8OVBTAQQUHkhYhRRFAIyMAAAAMEWludmFsaWQgb3BlcmF0aW9uQTbTUgY6IwUAAABFQA==","checksum":2512077441},"manifest":{"name":"Test","abi":{"methods":[],"events":[]},"groups":[],"features":{},"permissions":[],"trusts":[],"supportedstandards":[],"safemethods":[],"extra":null},"hash":"0x1b4357bff5a01bdf2a6581247cf9ed1e24629176"}}`,
|
2023-04-03 10:34:24 +00:00
|
|
|
result: func(c *Client) any {
|
2020-09-25 16:32:53 +00:00
|
|
|
script, err := base64.StdEncoding.DecodeString("VgJXHwIMDWNvbnRyYWN0IGNhbGx4eVMTwEEFB5IWIXhKDANQdXSXJyQAAAAQVUGEGNYNIXJqeRDOeRHOU0FSoUH1IUURQCOPAgAASgwLdG90YWxTdXBwbHmXJxEAAABFAkBCDwBAI28CAABKDAhkZWNpbWFsc5cnDQAAAEUSQCNWAgAASgwEbmFtZZcnEgAAAEUMBFJ1YmxAIzwCAABKDAZzeW1ib2yXJxEAAABFDANSVUJAIyECAABKDAliYWxhbmNlT2aXJ2IAAAAQVUGEGNYNIXN5EM50bMoAFLQnIwAAAAwPaW52YWxpZCBhZGRyZXNzEVVBNtNSBiFFENsgQGtsUEEfLnsHIXUMCWJhbGFuY2VPZmxtUxPAQQUHkhYhRW1AI7IBAABKDAh0cmFuc2ZlcpcnKwEAABBVQYQY1g0hdnkQzncHbwfKABS0JyoAAAAMFmludmFsaWQgJ2Zyb20nIGFkZHJlc3MRVUE201IGIUUQ2yBAeRHOdwhvCMoAFLQnKAAAAAwUaW52YWxpZCAndG8nIGFkZHJlc3MRVUE201IGIUUQ2yBAeRLOdwlvCRC1JyIAAAAMDmludmFsaWQgYW1vdW50EVVBNtNSBiFFENsgQG5vB1BBHy57ByF3Cm8Kbwm1JyYAAAAMEmluc3VmZmljaWVudCBmdW5kcxFVQTbTUgYhRRDbIEBvCm8Jn3cKbm8HbwpTQVKhQfUhbm8IUEEfLnsHIXcLbwtvCZ53C25vCG8LU0FSoUH1IQwIdHJhbnNmZXJvB28IbwlUFMBBBQeSFiFFEUAjewAAAEoMBGluaXSXJ1AAAAAQVUGEGNYNIXcMEFVBh8PSZCF3DQJAQg8Adw5vDG8Nbw5TQVKhQfUhDAh0cmFuc2ZlcgwA2zBvDW8OVBTAQQUHkhYhRRFAIyMAAAAMEWludmFsaWQgb3BlcmF0aW9uQTbTUgY6IwUAAABFQA==")
|
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
2020-11-18 09:43:51 +00:00
|
|
|
m := manifest.NewManifest("Test")
|
2020-09-25 16:32:53 +00:00
|
|
|
cs := &state.Contract{
|
2021-02-09 09:02:38 +00:00
|
|
|
ContractBase: state.ContractBase{
|
|
|
|
ID: 0,
|
|
|
|
Hash: hash.Hash160(script),
|
|
|
|
NEF: newTestNEF(script),
|
|
|
|
Manifest: *m,
|
|
|
|
},
|
2020-09-25 16:32:53 +00:00
|
|
|
}
|
|
|
|
return cs
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "positive, by id",
|
2023-04-03 10:34:24 +00:00
|
|
|
invoke: func(c *Client) (any, error) {
|
2020-09-25 16:32:53 +00:00
|
|
|
return c.GetContractStateByID(0)
|
2020-03-16 13:49:56 +00:00
|
|
|
},
|
2021-04-30 14:19:52 +00:00
|
|
|
serverResponse: `{"id":1,"jsonrpc":"2.0","result":{"id":0,"nef":{"magic":860243278,"compiler":"neo-go-3.0","script":"VgJXHwIMDWNvbnRyYWN0IGNhbGx4eVMTwEEFB5IWIXhKDANQdXSXJyQAAAAQVUGEGNYNIXJqeRDOeRHOU0FSoUH1IUURQCOPAgAASgwLdG90YWxTdXBwbHmXJxEAAABFAkBCDwBAI28CAABKDAhkZWNpbWFsc5cnDQAAAEUSQCNWAgAASgwEbmFtZZcnEgAAAEUMBFJ1YmxAIzwCAABKDAZzeW1ib2yXJxEAAABFDANSVUJAIyECAABKDAliYWxhbmNlT2aXJ2IAAAAQVUGEGNYNIXN5EM50bMoAFLQnIwAAAAwPaW52YWxpZCBhZGRyZXNzEVVBNtNSBiFFENsgQGtsUEEfLnsHIXUMCWJhbGFuY2VPZmxtUxPAQQUHkhYhRW1AI7IBAABKDAh0cmFuc2ZlcpcnKwEAABBVQYQY1g0hdnkQzncHbwfKABS0JyoAAAAMFmludmFsaWQgJ2Zyb20nIGFkZHJlc3MRVUE201IGIUUQ2yBAeRHOdwhvCMoAFLQnKAAAAAwUaW52YWxpZCAndG8nIGFkZHJlc3MRVUE201IGIUUQ2yBAeRLOdwlvCRC1JyIAAAAMDmludmFsaWQgYW1vdW50EVVBNtNSBiFFENsgQG5vB1BBHy57ByF3Cm8Kbwm1JyYAAAAMEmluc3VmZmljaWVudCBmdW5kcxFVQTbTUgYhRRDbIEBvCm8Jn3cKbm8HbwpTQVKhQfUhbm8IUEEfLnsHIXcLbwtvCZ53C25vCG8LU0FSoUH1IQwIdHJhbnNmZXJvB28IbwlUFMBBBQeSFiFFEUAjewAAAEoMBGluaXSXJ1AAAAAQVUGEGNYNIXcMEFVBh8PSZCF3DQJAQg8Adw5vDG8Nbw5TQVKhQfUhDAh0cmFuc2ZlcgwA2zBvDW8OVBTAQQUHkhYhRRFAIyMAAAAMEWludmFsaWQgb3BlcmF0aW9uQTbTUgY6IwUAAABFQA==","checksum":2512077441},"manifest":{"name":"Test","abi":{"methods":[],"events":[]},"groups":[],"features":{},"permissions":[],"trusts":[],"supportedstandards":[],"safemethods":[],"extra":null},"hash":"0x1b4357bff5a01bdf2a6581247cf9ed1e24629176"}}`,
|
2023-04-03 10:34:24 +00:00
|
|
|
result: func(c *Client) any {
|
2020-06-09 09:12:56 +00:00
|
|
|
script, err := base64.StdEncoding.DecodeString("VgJXHwIMDWNvbnRyYWN0IGNhbGx4eVMTwEEFB5IWIXhKDANQdXSXJyQAAAAQVUGEGNYNIXJqeRDOeRHOU0FSoUH1IUURQCOPAgAASgwLdG90YWxTdXBwbHmXJxEAAABFAkBCDwBAI28CAABKDAhkZWNpbWFsc5cnDQAAAEUSQCNWAgAASgwEbmFtZZcnEgAAAEUMBFJ1YmxAIzwCAABKDAZzeW1ib2yXJxEAAABFDANSVUJAIyECAABKDAliYWxhbmNlT2aXJ2IAAAAQVUGEGNYNIXN5EM50bMoAFLQnIwAAAAwPaW52YWxpZCBhZGRyZXNzEVVBNtNSBiFFENsgQGtsUEEfLnsHIXUMCWJhbGFuY2VPZmxtUxPAQQUHkhYhRW1AI7IBAABKDAh0cmFuc2ZlcpcnKwEAABBVQYQY1g0hdnkQzncHbwfKABS0JyoAAAAMFmludmFsaWQgJ2Zyb20nIGFkZHJlc3MRVUE201IGIUUQ2yBAeRHOdwhvCMoAFLQnKAAAAAwUaW52YWxpZCAndG8nIGFkZHJlc3MRVUE201IGIUUQ2yBAeRLOdwlvCRC1JyIAAAAMDmludmFsaWQgYW1vdW50EVVBNtNSBiFFENsgQG5vB1BBHy57ByF3Cm8Kbwm1JyYAAAAMEmluc3VmZmljaWVudCBmdW5kcxFVQTbTUgYhRRDbIEBvCm8Jn3cKbm8HbwpTQVKhQfUhbm8IUEEfLnsHIXcLbwtvCZ53C25vCG8LU0FSoUH1IQwIdHJhbnNmZXJvB28IbwlUFMBBBQeSFiFFEUAjewAAAEoMBGluaXSXJ1AAAAAQVUGEGNYNIXcMEFVBh8PSZCF3DQJAQg8Adw5vDG8Nbw5TQVKhQfUhDAh0cmFuc2ZlcgwA2zBvDW8OVBTAQQUHkhYhRRFAIyMAAAAMEWludmFsaWQgb3BlcmF0aW9uQTbTUgY6IwUAAABFQA==")
|
2020-03-16 13:49:56 +00:00
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
2020-11-18 09:43:51 +00:00
|
|
|
m := manifest.NewManifest("Test")
|
2020-06-09 09:12:56 +00:00
|
|
|
cs := &state.Contract{
|
2021-02-09 09:02:38 +00:00
|
|
|
ContractBase: state.ContractBase{
|
|
|
|
ID: 0,
|
|
|
|
Hash: hash.Hash160(script),
|
|
|
|
NEF: newTestNEF(script),
|
|
|
|
Manifest: *m,
|
|
|
|
},
|
2020-03-16 13:49:56 +00:00
|
|
|
}
|
2020-06-09 09:12:56 +00:00
|
|
|
return cs
|
2020-03-16 13:49:56 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2021-11-17 21:08:10 +00:00
|
|
|
"getnep11balances": {
|
|
|
|
{
|
|
|
|
name: "positive",
|
2023-04-03 10:34:24 +00:00
|
|
|
invoke: func(c *Client) (any, error) {
|
2021-11-17 21:08:10 +00:00
|
|
|
hash, err := util.Uint160DecodeStringLE("1aada0032aba1ef6d1f07bbd8bec1d85f5380fb3")
|
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
return c.GetNEP11Balances(hash)
|
|
|
|
},
|
2022-07-04 14:12:42 +00:00
|
|
|
serverResponse: `{"jsonrpc":"2.0","id":1,"result":{"balance":[{"assethash":"a48b6e1291ba24211ad11bb90ae2a10bf1fcd5a8","symbol":"SOME","decimals":"42","name":"Contract","tokens":[{"tokenid":"abcdef","amount":"1","lastupdatedblock":251604}]}],"address":"NcEkNmgWmf7HQVQvzhxpengpnt4DXjmZLe"}}`,
|
2023-04-03 10:34:24 +00:00
|
|
|
result: func(c *Client) any {
|
2021-11-17 21:08:10 +00:00
|
|
|
hash, err := util.Uint160DecodeStringLE("a48b6e1291ba24211ad11bb90ae2a10bf1fcd5a8")
|
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
return &result.NEP11Balances{
|
|
|
|
Balances: []result.NEP11AssetBalance{{
|
2022-07-04 14:12:42 +00:00
|
|
|
Asset: hash,
|
|
|
|
Decimals: 42,
|
|
|
|
Name: "Contract",
|
|
|
|
Symbol: "SOME",
|
2021-11-17 21:08:10 +00:00
|
|
|
Tokens: []result.NEP11TokenBalance{{
|
|
|
|
ID: "abcdef",
|
|
|
|
Amount: "1",
|
|
|
|
LastUpdated: 251604,
|
|
|
|
}},
|
|
|
|
}},
|
|
|
|
Address: "NcEkNmgWmf7HQVQvzhxpengpnt4DXjmZLe",
|
|
|
|
}
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2020-11-24 08:14:25 +00:00
|
|
|
"getnep17balances": {
|
2020-03-16 13:49:56 +00:00
|
|
|
{
|
|
|
|
name: "positive",
|
2023-04-03 10:34:24 +00:00
|
|
|
invoke: func(c *Client) (any, error) {
|
2020-03-16 13:49:56 +00:00
|
|
|
hash, err := util.Uint160DecodeStringLE("1aada0032aba1ef6d1f07bbd8bec1d85f5380fb3")
|
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
2020-11-24 08:14:25 +00:00
|
|
|
return c.GetNEP17Balances(hash)
|
2020-03-16 13:49:56 +00:00
|
|
|
},
|
2022-07-04 14:12:42 +00:00
|
|
|
serverResponse: `{"jsonrpc":"2.0","id":1,"result":{"balance":[{"assethash":"a48b6e1291ba24211ad11bb90ae2a10bf1fcd5a8","symbol":"N17","decimals":"8","name":"Token","amount":"50000000000","lastupdatedblock":251604}],"address":"AY6eqWjsUFCzsVELG7yG72XDukKvC34p2w"}}`,
|
2023-04-03 10:34:24 +00:00
|
|
|
result: func(c *Client) any {
|
2020-03-16 13:49:56 +00:00
|
|
|
hash, err := util.Uint160DecodeStringLE("a48b6e1291ba24211ad11bb90ae2a10bf1fcd5a8")
|
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
2020-11-24 08:14:25 +00:00
|
|
|
return &result.NEP17Balances{
|
|
|
|
Balances: []result.NEP17Balance{{
|
2020-03-16 13:49:56 +00:00
|
|
|
Asset: hash,
|
2022-07-04 14:12:42 +00:00
|
|
|
Decimals: 8,
|
|
|
|
Name: "Token",
|
|
|
|
Symbol: "N17",
|
2020-03-16 13:49:56 +00:00
|
|
|
Amount: "50000000000",
|
|
|
|
LastUpdated: 251604,
|
|
|
|
}},
|
|
|
|
Address: "AY6eqWjsUFCzsVELG7yG72XDukKvC34p2w",
|
|
|
|
}
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2021-11-17 21:08:10 +00:00
|
|
|
"getnep11properties": {
|
|
|
|
{
|
|
|
|
name: "positive",
|
2023-04-03 10:34:24 +00:00
|
|
|
invoke: func(c *Client) (any, error) {
|
2021-11-17 21:08:10 +00:00
|
|
|
hash, err := util.Uint160DecodeStringLE("1aada0032aba1ef6d1f07bbd8bec1d85f5380fb3")
|
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
return c.GetNEP11Properties(hash, []byte("abcdef"))
|
|
|
|
}, // NcEkNmgWmf7HQVQvzhxpengpnt4DXjmZLe
|
|
|
|
serverResponse: `{"jsonrpc":"2.0","id":1,"result":{"name":"sometoken","field1":"c29tZXRoaW5n","field2":null}}`,
|
2023-04-03 10:34:24 +00:00
|
|
|
result: func(c *Client) any {
|
|
|
|
return map[string]any{
|
2021-11-17 21:08:10 +00:00
|
|
|
"name": "sometoken",
|
|
|
|
"field1": []byte("something"),
|
|
|
|
"field2": nil,
|
|
|
|
}
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
"getnep11transfers": {
|
|
|
|
{
|
|
|
|
name: "positive",
|
2023-04-03 10:34:24 +00:00
|
|
|
invoke: func(c *Client) (any, error) {
|
2021-11-18 14:00:48 +00:00
|
|
|
hash, err := address.StringToUint160("NcEkNmgWmf7HQVQvzhxpengpnt4DXjmZLe")
|
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
return c.GetNEP11Transfers(hash, nil, nil, nil, nil)
|
2021-11-17 21:08:10 +00:00
|
|
|
},
|
|
|
|
serverResponse: `{"jsonrpc":"2.0","id":1,"result":{"sent":[],"received":[{"timestamp":1555651816,"assethash":"600c4f5200db36177e3e8a09e9f18e2fc7d12a0f","transferaddress":"NfgHwwTi3wHAS8aFAN243C5vGbkYDpqLHP","amount":"1","tokenid":"abcdef","blockindex":436036,"transfernotifyindex":0,"txhash":"df7683ece554ecfb85cf41492c5f143215dd43ef9ec61181a28f922da06aba58"}],"address":"NcEkNmgWmf7HQVQvzhxpengpnt4DXjmZLe"}}`,
|
2023-04-03 10:34:24 +00:00
|
|
|
result: func(c *Client) any {
|
2021-11-17 21:08:10 +00:00
|
|
|
assetHash, err := util.Uint160DecodeStringLE("600c4f5200db36177e3e8a09e9f18e2fc7d12a0f")
|
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
txHash, err := util.Uint256DecodeStringLE("df7683ece554ecfb85cf41492c5f143215dd43ef9ec61181a28f922da06aba58")
|
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
return &result.NEP11Transfers{
|
|
|
|
Sent: []result.NEP11Transfer{},
|
|
|
|
Received: []result.NEP11Transfer{
|
|
|
|
{
|
|
|
|
Timestamp: 1555651816,
|
|
|
|
Asset: assetHash,
|
|
|
|
Address: "NfgHwwTi3wHAS8aFAN243C5vGbkYDpqLHP",
|
|
|
|
Amount: "1",
|
|
|
|
ID: "abcdef",
|
|
|
|
Index: 436036,
|
|
|
|
NotifyIndex: 0,
|
|
|
|
TxHash: txHash,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
Address: "NcEkNmgWmf7HQVQvzhxpengpnt4DXjmZLe",
|
|
|
|
}
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2020-11-24 08:14:25 +00:00
|
|
|
"getnep17transfers": {
|
2020-03-16 13:49:56 +00:00
|
|
|
{
|
|
|
|
name: "positive",
|
2023-04-03 10:34:24 +00:00
|
|
|
invoke: func(c *Client) (any, error) {
|
2021-11-18 14:00:48 +00:00
|
|
|
hash, err := address.StringToUint160("NcEkNmgWmf7HQVQvzhxpengpnt4DXjmZLe")
|
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
return c.GetNEP17Transfers(hash, nil, nil, nil, nil)
|
2020-03-16 13:49:56 +00:00
|
|
|
},
|
2021-11-18 14:00:48 +00:00
|
|
|
serverResponse: `{"jsonrpc":"2.0","id":1,"result":{"sent":[],"received":[{"timestamp":1555651816,"assethash":"600c4f5200db36177e3e8a09e9f18e2fc7d12a0f","transferaddress":"AYwgBNMepiv5ocGcyNT4mA8zPLTQ8pDBis","amount":"1000000","blockindex":436036,"transfernotifyindex":0,"txhash":"df7683ece554ecfb85cf41492c5f143215dd43ef9ec61181a28f922da06aba58"}],"address":"NcEkNmgWmf7HQVQvzhxpengpnt4DXjmZLe"}}`,
|
2023-04-03 10:34:24 +00:00
|
|
|
result: func(c *Client) any {
|
2020-03-16 13:49:56 +00:00
|
|
|
assetHash, err := util.Uint160DecodeStringLE("600c4f5200db36177e3e8a09e9f18e2fc7d12a0f")
|
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
txHash, err := util.Uint256DecodeStringLE("df7683ece554ecfb85cf41492c5f143215dd43ef9ec61181a28f922da06aba58")
|
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
2020-11-24 08:14:25 +00:00
|
|
|
return &result.NEP17Transfers{
|
|
|
|
Sent: []result.NEP17Transfer{},
|
|
|
|
Received: []result.NEP17Transfer{
|
2020-03-16 13:49:56 +00:00
|
|
|
{
|
|
|
|
Timestamp: 1555651816,
|
|
|
|
Asset: assetHash,
|
|
|
|
Address: "AYwgBNMepiv5ocGcyNT4mA8zPLTQ8pDBis",
|
|
|
|
Amount: "1000000",
|
|
|
|
Index: 436036,
|
|
|
|
NotifyIndex: 0,
|
|
|
|
TxHash: txHash,
|
|
|
|
},
|
|
|
|
},
|
2021-11-18 14:00:48 +00:00
|
|
|
Address: "NcEkNmgWmf7HQVQvzhxpengpnt4DXjmZLe",
|
2020-03-16 13:49:56 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
"getpeers": {
|
|
|
|
{
|
|
|
|
name: "positive",
|
2023-04-03 10:34:24 +00:00
|
|
|
invoke: func(c *Client) (any, error) {
|
2020-03-16 13:49:56 +00:00
|
|
|
return c.GetPeers()
|
|
|
|
},
|
2024-06-27 13:00:08 +00:00
|
|
|
serverResponse: `{"id":1,"jsonrpc":"2.0","result":{"unconnected":[{"address":"172.200.0.1","port":20333}],"connected":[{"address":"127.0.0.1","port":20335, "useragent":"/NEO-GO:0.106.2/", "lastknownheight":1000}],"bad":[{"address":"172.200.0.254","port":20332}]}}`,
|
2023-04-03 10:34:24 +00:00
|
|
|
result: func(c *Client) any {
|
2023-04-06 16:33:09 +00:00
|
|
|
|
2020-03-16 13:49:56 +00:00
|
|
|
return &result.GetPeers{
|
|
|
|
Unconnected: result.Peers{
|
|
|
|
{
|
|
|
|
Address: "172.200.0.1",
|
2023-04-06 16:33:09 +00:00
|
|
|
Port: 20333,
|
2020-03-16 13:49:56 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
Connected: result.Peers{
|
|
|
|
{
|
2024-06-27 09:41:59 +00:00
|
|
|
Address: "127.0.0.1",
|
|
|
|
Port: 20335,
|
|
|
|
UserAgent: "/NEO-GO:0.106.2/",
|
|
|
|
LastKnownHeight: 1000,
|
2020-03-16 13:49:56 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
Bad: result.Peers{
|
|
|
|
{
|
|
|
|
Address: "172.200.0.254",
|
2023-04-06 16:33:09 +00:00
|
|
|
Port: 20332,
|
2020-03-16 13:49:56 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
}
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
"getrawmempool": {
|
|
|
|
{
|
|
|
|
name: "positive",
|
2023-04-03 10:34:24 +00:00
|
|
|
invoke: func(c *Client) (any, error) {
|
2020-03-16 13:49:56 +00:00
|
|
|
return c.GetRawMemPool()
|
|
|
|
},
|
|
|
|
serverResponse: `{"jsonrpc":"2.0","id":1,"result":["0x9786cce0dddb524c40ddbdd5e31a41ed1f6b5c8a683c122f627ca4a007a7cf4e"]}`,
|
2023-04-03 10:34:24 +00:00
|
|
|
result: func(c *Client) any {
|
2020-03-16 13:49:56 +00:00
|
|
|
hash, err := util.Uint256DecodeStringLE("9786cce0dddb524c40ddbdd5e31a41ed1f6b5c8a683c122f627ca4a007a7cf4e")
|
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
return []util.Uint256{hash}
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
"getrawtransaction": {
|
|
|
|
{
|
|
|
|
name: "positive",
|
2023-04-03 10:34:24 +00:00
|
|
|
invoke: func(c *Client) (i any, err error) {
|
2021-03-17 13:40:24 +00:00
|
|
|
hash, err := util.Uint256DecodeStringLE("f5fbd303799f24ba247529d7544d4276cca54ea79f4b98095f2b0557313c5275")
|
2020-03-16 13:49:56 +00:00
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
return c.GetRawTransaction(hash)
|
|
|
|
},
|
2020-11-06 14:37:58 +00:00
|
|
|
serverResponse: `{"id":1,"jsonrpc":"2.0","result":"` + base64TxMoveNeo + `"}`,
|
2023-04-03 10:34:24 +00:00
|
|
|
result: func(c *Client) any {
|
2020-06-05 09:17:16 +00:00
|
|
|
tx := getTxMoveNeo()
|
2020-06-18 08:47:54 +00:00
|
|
|
return &tx.Transaction
|
2020-03-16 13:49:56 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "verbose_positive",
|
2023-04-03 10:34:24 +00:00
|
|
|
invoke: func(c *Client) (any, error) {
|
2021-03-17 13:40:24 +00:00
|
|
|
hash, err := util.Uint256DecodeStringLE("f5fbd303799f24ba247529d7544d4276cca54ea79f4b98095f2b0557313c5275")
|
2020-03-16 13:49:56 +00:00
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
2020-07-03 14:40:03 +00:00
|
|
|
out, err := c.GetRawTransactionVerbose(hash)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
out.Transaction.FeePerByte() // set fee per byte
|
|
|
|
return out, nil
|
2020-03-16 13:49:56 +00:00
|
|
|
},
|
2021-03-17 13:40:24 +00:00
|
|
|
serverResponse: `{"id":1,"jsonrpc":"2.0","result":` + txMoveNeoVerbose + `}`,
|
2023-04-03 10:34:24 +00:00
|
|
|
result: func(c *Client) any {
|
2020-06-05 09:17:16 +00:00
|
|
|
return getTxMoveNeo()
|
2020-03-16 13:49:56 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2022-01-17 08:59:13 +00:00
|
|
|
"getstateroot": {
|
|
|
|
{
|
|
|
|
name: "positive, by height",
|
2023-04-03 10:34:24 +00:00
|
|
|
invoke: func(c *Client) (any, error) {
|
2022-01-17 08:59:13 +00:00
|
|
|
return c.GetStateRootByHeight(5)
|
|
|
|
},
|
|
|
|
serverResponse: `{"id":1,"jsonrpc":"2.0","result":{"version":0,"index":5,"roothash":"0x65d19151694321e70c6d184b37a2bcf7af4a2c60c099af332a4f7815e3670686","witnesses":[]}}`,
|
2023-04-03 10:34:24 +00:00
|
|
|
result: func(c *Client) any {
|
2022-01-17 08:59:13 +00:00
|
|
|
h, err := util.Uint256DecodeStringLE("65d19151694321e70c6d184b37a2bcf7af4a2c60c099af332a4f7815e3670686")
|
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
return &state.MPTRoot{
|
|
|
|
Version: 0,
|
|
|
|
Index: 5,
|
|
|
|
Root: h,
|
|
|
|
Witness: []transaction.Witness{},
|
|
|
|
}
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "positive, by hash",
|
2023-04-03 10:34:24 +00:00
|
|
|
invoke: func(c *Client) (any, error) {
|
2022-01-17 08:59:13 +00:00
|
|
|
hash, err := util.Uint256DecodeStringLE("86fe1061140b2ea791b0739fb9732abc6e5e47de4927228a1ac41de3d93eb7cb")
|
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
return c.GetStateRootByBlockHash(hash)
|
|
|
|
},
|
|
|
|
serverResponse: `{"id":1,"jsonrpc":"2.0","result":{"version":0,"index":5,"roothash":"0x65d19151694321e70c6d184b37a2bcf7af4a2c60c099af332a4f7815e3670686","witnesses":[]}}`,
|
2023-04-03 10:34:24 +00:00
|
|
|
result: func(c *Client) any {
|
2022-01-17 08:59:13 +00:00
|
|
|
h, _ := util.Uint256DecodeStringLE("65d19151694321e70c6d184b37a2bcf7af4a2c60c099af332a4f7815e3670686")
|
|
|
|
return &state.MPTRoot{
|
|
|
|
Version: 0,
|
|
|
|
Index: 5,
|
|
|
|
Root: h,
|
|
|
|
Witness: []transaction.Witness{},
|
|
|
|
}
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2021-10-07 09:03:37 +00:00
|
|
|
"getstate": {
|
|
|
|
{
|
|
|
|
name: "positive",
|
2023-04-03 10:34:24 +00:00
|
|
|
invoke: func(c *Client) (any, error) {
|
2021-10-07 09:03:37 +00:00
|
|
|
root, _ := util.Uint256DecodeStringLE("252e9d73d49c95c7618d40650da504e05183a1b2eed0685e42c360413c329170")
|
|
|
|
cHash, _ := util.Uint160DecodeStringLE("5c9e40a12055c6b9e3f72271c9779958c842135d")
|
|
|
|
return c.GetState(root, cHash, []byte("testkey"))
|
|
|
|
},
|
|
|
|
serverResponse: `{"id":1,"jsonrpc":"2.0","result":"dGVzdHZhbHVl"}`,
|
2023-04-03 10:34:24 +00:00
|
|
|
result: func(c *Client) any {
|
2021-10-07 09:03:37 +00:00
|
|
|
return []byte("testvalue")
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2023-03-23 09:03:22 +00:00
|
|
|
"getproof": {
|
|
|
|
{
|
|
|
|
name: "positive",
|
2023-04-03 10:34:24 +00:00
|
|
|
invoke: func(c *Client) (any, error) {
|
2023-03-23 09:03:22 +00:00
|
|
|
root, _ := util.Uint256DecodeStringLE("272002b11a6a39035c719defec3e4e6a8d1f4ae37a995b44734911413fcc2ba5")
|
|
|
|
cHash, _ := util.Uint160DecodeStringLE("cc5e4edd9f5f8dba8bb65734541df7a1c081c67b")
|
|
|
|
key := []byte{10}
|
|
|
|
return c.GetProof(root, cHash, key)
|
|
|
|
},
|
|
|
|
serverResponse: `{"jsonrpc":"2.0","id":1,"result":"Bfn///8KBiQBAQ8DogBnMdiiPTEW05A6bJPmQ2TNVpuca/nB1rJRdQX7R4SyAAQEBAQEBAQDHvo5Rc9v\u002BWSpfsnMXM75ku\u002BZjvbLJhWXn/lh6L\u002B1yB0EA4k\u002Bsx4f7IgmdHNm3wRMpj5kTU4l0gChSGppo5p5wZyWA2\u002BKSFn16W6tRrGSfJob\u002BgqJukLcNDk0DBFYW2wIS2/NAzkugdLfZRXHOLqq5XJr89ElzlqyXU1o9D87l9YOcXjGBAQEA7oDTOxuU4iMAKPuhn5eJjzsM56bQrx3uORa8LKm42oDBCkBBg8PDw8PDwN96s39UOSCwMJmMQZzNjfNAPCbRRyke1B4VRKqOZ0NHlIAA2woQ13XO4Ug2aQ/cW4WBricVcUVqobFUU0dnRPtfIHeAxuYERXsV6HwdGjW\u002BhtpM0FEkw/mllbH5pyhn\u002BBx4r8wBAQEBAQEBAQEBAQEBAQEJAEBCgPXvpMqBogTeGhXjtFY4Rsn9bY/PgNX0l4iYOHMzUBQQgQCAugD"}`,
|
2023-04-03 10:34:24 +00:00
|
|
|
result: func(c *Client) any {
|
2023-03-23 09:03:22 +00:00
|
|
|
b, _ := base64.StdEncoding.DecodeString("Bfn///8KBiQBAQ8DogBnMdiiPTEW05A6bJPmQ2TNVpuca/nB1rJRdQX7R4SyAAQEBAQEBAQDHvo5Rc9v\u002BWSpfsnMXM75ku\u002BZjvbLJhWXn/lh6L\u002B1yB0EA4k\u002Bsx4f7IgmdHNm3wRMpj5kTU4l0gChSGppo5p5wZyWA2\u002BKSFn16W6tRrGSfJob\u002BgqJukLcNDk0DBFYW2wIS2/NAzkugdLfZRXHOLqq5XJr89ElzlqyXU1o9D87l9YOcXjGBAQEA7oDTOxuU4iMAKPuhn5eJjzsM56bQrx3uORa8LKm42oDBCkBBg8PDw8PDwN96s39UOSCwMJmMQZzNjfNAPCbRRyke1B4VRKqOZ0NHlIAA2woQ13XO4Ug2aQ/cW4WBricVcUVqobFUU0dnRPtfIHeAxuYERXsV6HwdGjW\u002BhtpM0FEkw/mllbH5pyhn\u002BBx4r8wBAQEBAQEBAQEBAQEBAQEJAEBCgPXvpMqBogTeGhXjtFY4Rsn9bY/PgNX0l4iYOHMzUBQQgQCAugD")
|
|
|
|
proof := &result.ProofWithKey{}
|
|
|
|
r := io.NewBinReaderFromBuf(b)
|
|
|
|
proof.DecodeBinary(r)
|
|
|
|
return proof
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "not found",
|
2023-04-03 10:34:24 +00:00
|
|
|
invoke: func(c *Client) (any, error) {
|
2023-03-23 09:03:22 +00:00
|
|
|
root, _ := util.Uint256DecodeStringLE("272002b11a6a39035c719defec3e4e6a8d1f4ae37a995b44734911413fcc2ba5")
|
|
|
|
cHash, _ := util.Uint160DecodeStringLE("cc5e4edd9f5f8dba8bb65734541df7a1c081c67b")
|
|
|
|
key := []byte{01}
|
|
|
|
return c.GetProof(root, cHash, key)
|
|
|
|
},
|
|
|
|
serverResponse: `{"id":1,"jsonrpc":"2.0","error":{"code":-32603,"message":"Internal error","data":"failed to get proof: item not found"}}`,
|
|
|
|
fails: true,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
"verifyproof": {
|
|
|
|
{
|
|
|
|
name: "positive",
|
2023-04-03 10:34:24 +00:00
|
|
|
invoke: func(c *Client) (any, error) {
|
2023-03-23 09:03:22 +00:00
|
|
|
root, _ := util.Uint256DecodeStringLE("272002b11a6a39035c719defec3e4e6a8d1f4ae37a995b44734911413fcc2ba5")
|
|
|
|
b, _ := base64.StdEncoding.DecodeString("Bfn///8KBiQBAQ8DogBnMdiiPTEW05A6bJPmQ2TNVpuca/nB1rJRdQX7R4SyAAQEBAQEBAQDHvo5Rc9v\u002BWSpfsnMXM75ku\u002BZjvbLJhWXn/lh6L\u002B1yB0EA4k\u002Bsx4f7IgmdHNm3wRMpj5kTU4l0gChSGppo5p5wZyWA2\u002BKSFn16W6tRrGSfJob\u002BgqJukLcNDk0DBFYW2wIS2/NAzkugdLfZRXHOLqq5XJr89ElzlqyXU1o9D87l9YOcXjGBAQEA7oDTOxuU4iMAKPuhn5eJjzsM56bQrx3uORa8LKm42oDBCkBBg8PDw8PDwN96s39UOSCwMJmMQZzNjfNAPCbRRyke1B4VRKqOZ0NHlIAA2woQ13XO4Ug2aQ/cW4WBricVcUVqobFUU0dnRPtfIHeAxuYERXsV6HwdGjW\u002BhtpM0FEkw/mllbH5pyhn\u002BBx4r8wBAQEBAQEBAQEBAQEBAQEJAEBCgPXvpMqBogTeGhXjtFY4Rsn9bY/PgNX0l4iYOHMzUBQQgQCAugD")
|
|
|
|
proof := &result.ProofWithKey{}
|
|
|
|
r := io.NewBinReaderFromBuf(b)
|
|
|
|
proof.DecodeBinary(r)
|
|
|
|
return c.VerifyProof(root, proof)
|
|
|
|
},
|
|
|
|
serverResponse: `{"jsonrpc":"2.0","id":1,"result":"6AM="}`,
|
2023-04-03 10:34:24 +00:00
|
|
|
result: func(c *Client) any {
|
2023-03-23 09:03:22 +00:00
|
|
|
return bigint.ToPreallocatedBytes(big.NewInt(1000), nil)
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "fail",
|
2023-04-03 10:34:24 +00:00
|
|
|
invoke: func(c *Client) (any, error) {
|
2023-03-23 09:03:22 +00:00
|
|
|
root, _ := util.Uint256DecodeStringLE("272002b11a6a39035c719defec3e4e6a8d1f4ae37a995b44734911413fcc2ba5")
|
|
|
|
b, _ := base64.StdEncoding.DecodeString("Bfn///8KBiQBAQ8DogBnMdiiPTEW05A6bJPmQ2TNVpuca/nB1rJRdQX7R4SyAAQEBAQEBAQDHvo5Rc9v\u002BWSpfsnMXM75ku\u002BZjvbLJhWXn/lh6L\u002B1yB0EA4k\u002Bsx4f7IgmdHNm3wRMpj5kTU4l0gChSGppo5p5wZyWA2\u002BKSFn16W6tRrGSfJob\u002BgqJukLcNDk0DBFYW2wIS2/NAzkugdLfZRXHOLqq5XJr89ElzlqyXU1o9D87l9YOcXjGBAQEA7oDTOxuU4iMAKPuhn5eJjzsM56bQrx3uORa8LKm42oDBCkBBg8PDw8PDwN96s39UOSCwMJmMQZzNjfNAPCbRRyke1B4VRKqOZ0NHlIAA2woQ13XO4Ug2aQ/cW4WBricVcUVqobFUU0dnRPtfIHeAxuYERXsV6HwdGjW\u002BhtpM0FEkw/mllbH5pyhn\u002BBx4r8wBAQEBAQEBAQEBAQEBAQEJAEBCgPXvpMqBogTeGhXjtFY4Rsn9bY/PgNX0l4iYOHMzUBQQgQCAugD")
|
|
|
|
proof := &result.ProofWithKey{}
|
|
|
|
r := io.NewBinReaderFromBuf(b)
|
|
|
|
proof.DecodeBinary(r)
|
|
|
|
return c.VerifyProof(root, proof)
|
|
|
|
},
|
|
|
|
serverResponse: `{"id":1,"jsonrpc":"2.0","result":"invalid"}`,
|
|
|
|
fails: true,
|
|
|
|
},
|
|
|
|
},
|
2021-10-07 13:56:27 +00:00
|
|
|
"findstates": {
|
|
|
|
{
|
|
|
|
name: "positive",
|
2023-04-03 10:34:24 +00:00
|
|
|
invoke: func(c *Client) (any, error) {
|
2021-10-07 13:56:27 +00:00
|
|
|
root, _ := util.Uint256DecodeStringLE("252e9d73d49c95c7618d40650da504e05183a1b2eed0685e42c360413c329170")
|
|
|
|
cHash, _ := util.Uint160DecodeStringLE("5c9e40a12055c6b9e3f72271c9779958c842135d")
|
|
|
|
count := 1
|
|
|
|
return c.FindStates(root, cHash, []byte("aa"), []byte("aa00"), &count)
|
|
|
|
},
|
|
|
|
serverResponse: `{"id":1,"jsonrpc":"2.0","result":{"results":[{"key":"YWExMA==","value":"djI="}],"firstProof":"CAEAAABhYTEwCXIAA5KNHjQ1+LFX4lQBLjMAhaLtTJnfuI86O7WnNdlshsYWBAQEBAQEBAQDTzD7MJp2KW6E8BNVjjjgZMTAjI/GI3ZrTmR2UUOtSeIEBAQEBAPKPqb0qnb4Ywz6gqpNKCUNQsfBmAnKc5p3dxokSQRpwgRSAAQDPplG1wee4KOfkehaF94R5uoKSgvQL1j5gkFTN4ywYaIEBAOhOyI39MZfoKc940g57XeqwRnxh7P62fKjnfEtBzQxHQQEBAQEBAQEBAQEBCkBBgAAAAAAAAM6A1UrwFYZAEMfe6go3jX25xz2sHsovQ2UO/UHqZZOXLIABAOwg7pkXyaTR85yQIvYnoGaG/OVRLRHOj+nhZnXb6dVtAQEBAPnciBUp3uspLQTajKTlAxgrNe+3tlqlbwlNRkz0eNmhQMzoMcWOFi9nCyn+eM5lA6Pq67DxzTQDlHljh8g8kRtJAPq9hxzTgreK0qDTavsethixguZYfV7wDmKfumMglnoqQQEBAQEBAM1x2dVBdf5BJ0Xvw2qqhvpKqxdHb8/HMFWiXkJj1uAAQQEJgEDAQYBA5kV2WLkgey9C5z6gZT69VLKcEuwyY8P853rNtGhT3NeUgAEBAQDiX59K9PuJ5RE7Z1uj7q/QJ8FGf8avLdWM7hwmWkVH2gEBAQEBAQEBAQEBAQD1SubX5XhFHcUOWdUzg1bXmDwWJwt+wpU3FOdFkU1PXBSAAQDHCzfEQyqwOO263EE6HER1vWDrwz8JiEHEOXfZ3kX7NYEBAQDEH++Hy8wBcniKuWVevaAwzHCh60kzncU30E5fDC3gJsEBAQEBAQEBAQEBCUBAgMAA1wt18LbxMKdYcJ+nEDMMWZbRsu550l8HGhcYhpl6DjSBAICdjI=","truncated":true}}`,
|
2023-04-03 10:34:24 +00:00
|
|
|
result: func(c *Client) any {
|
2021-10-07 13:56:27 +00:00
|
|
|
proofB, _ := base64.StdEncoding.DecodeString("CAEAAABhYTEwCXIAA5KNHjQ1+LFX4lQBLjMAhaLtTJnfuI86O7WnNdlshsYWBAQEBAQEBAQDTzD7MJp2KW6E8BNVjjjgZMTAjI/GI3ZrTmR2UUOtSeIEBAQEBAPKPqb0qnb4Ywz6gqpNKCUNQsfBmAnKc5p3dxokSQRpwgRSAAQDPplG1wee4KOfkehaF94R5uoKSgvQL1j5gkFTN4ywYaIEBAOhOyI39MZfoKc940g57XeqwRnxh7P62fKjnfEtBzQxHQQEBAQEBAQEBAQEBCkBBgAAAAAAAAM6A1UrwFYZAEMfe6go3jX25xz2sHsovQ2UO/UHqZZOXLIABAOwg7pkXyaTR85yQIvYnoGaG/OVRLRHOj+nhZnXb6dVtAQEBAPnciBUp3uspLQTajKTlAxgrNe+3tlqlbwlNRkz0eNmhQMzoMcWOFi9nCyn+eM5lA6Pq67DxzTQDlHljh8g8kRtJAPq9hxzTgreK0qDTavsethixguZYfV7wDmKfumMglnoqQQEBAQEBAM1x2dVBdf5BJ0Xvw2qqhvpKqxdHb8/HMFWiXkJj1uAAQQEJgEDAQYBA5kV2WLkgey9C5z6gZT69VLKcEuwyY8P853rNtGhT3NeUgAEBAQDiX59K9PuJ5RE7Z1uj7q/QJ8FGf8avLdWM7hwmWkVH2gEBAQEBAQEBAQEBAQD1SubX5XhFHcUOWdUzg1bXmDwWJwt+wpU3FOdFkU1PXBSAAQDHCzfEQyqwOO263EE6HER1vWDrwz8JiEHEOXfZ3kX7NYEBAQDEH++Hy8wBcniKuWVevaAwzHCh60kzncU30E5fDC3gJsEBAQEBAQEBAQEBCUBAgMAA1wt18LbxMKdYcJ+nEDMMWZbRsu550l8HGhcYhpl6DjSBAICdjI=")
|
|
|
|
proof := &result.ProofWithKey{}
|
|
|
|
r := io.NewBinReaderFromBuf(proofB)
|
|
|
|
proof.DecodeBinary(r)
|
|
|
|
return result.FindStates{
|
|
|
|
Results: []result.KeyValue{{Key: []byte("aa10"), Value: []byte("v2")}},
|
|
|
|
FirstProof: proof,
|
|
|
|
Truncated: true,
|
|
|
|
}
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2023-08-22 16:00:43 +00:00
|
|
|
"findstorage": {
|
|
|
|
{
|
|
|
|
name: "positive by hash",
|
|
|
|
invoke: func(c *Client) (any, error) {
|
|
|
|
cHash, _ := util.Uint160DecodeStringLE("5c9e40a12055c6b9e3f72271c9779958c842135d")
|
|
|
|
start := 1
|
|
|
|
return c.FindStorageByHash(cHash, []byte("aa"), &start)
|
|
|
|
},
|
|
|
|
serverResponse: `{"id":1,"jsonrpc":"2.0","result":{"results":[{"key":"YWExMA==","value":"djI="}],"truncated":true, "next": 1}}`,
|
|
|
|
result: func(c *Client) any {
|
|
|
|
return result.FindStorage{
|
|
|
|
Results: []result.KeyValue{{Key: []byte("aa10"), Value: []byte("v2")}},
|
|
|
|
Truncated: true,
|
|
|
|
Next: 1,
|
|
|
|
}
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "positive by ID",
|
|
|
|
invoke: func(c *Client) (any, error) {
|
|
|
|
start := 1
|
|
|
|
return c.FindStorageByID(1, []byte("aa"), &start)
|
|
|
|
},
|
|
|
|
serverResponse: `{"id":1,"jsonrpc":"2.0","result":{"results":[{"key":"YWExMA==","value":"djI="}],"truncated":true, "next": 1}}`,
|
|
|
|
result: func(c *Client) any {
|
|
|
|
return result.FindStorage{
|
|
|
|
Results: []result.KeyValue{{Key: []byte("aa10"), Value: []byte("v2")}},
|
|
|
|
Truncated: true,
|
|
|
|
Next: 1,
|
|
|
|
}
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
"findstoragehistoric": {
|
|
|
|
{
|
|
|
|
name: "positive by hash",
|
|
|
|
invoke: func(c *Client) (any, error) {
|
|
|
|
root, _ := util.Uint256DecodeStringLE("252e9d73d49c95c7618d40650da504e05183a1b2eed0685e42c360413c329170")
|
|
|
|
cHash, _ := util.Uint160DecodeStringLE("5c9e40a12055c6b9e3f72271c9779958c842135d")
|
|
|
|
start := 1
|
|
|
|
return c.FindStorageByHashHistoric(root, cHash, []byte("aa"), &start)
|
|
|
|
},
|
|
|
|
serverResponse: `{"id":1,"jsonrpc":"2.0","result":{"results":[{"key":"YWExMA==","value":"djI="}],"truncated":true, "next": 1}}`,
|
|
|
|
result: func(c *Client) any {
|
|
|
|
return result.FindStorage{
|
|
|
|
Results: []result.KeyValue{{Key: []byte("aa10"), Value: []byte("v2")}},
|
|
|
|
Truncated: true,
|
|
|
|
Next: 1,
|
|
|
|
}
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "positive by ID",
|
|
|
|
invoke: func(c *Client) (any, error) {
|
|
|
|
root, _ := util.Uint256DecodeStringLE("252e9d73d49c95c7618d40650da504e05183a1b2eed0685e42c360413c329170")
|
|
|
|
start := 1
|
|
|
|
return c.FindStorageByIDHistoric(root, 1, []byte("aa"), &start)
|
|
|
|
},
|
|
|
|
serverResponse: `{"id":1,"jsonrpc":"2.0","result":{"results":[{"key":"YWExMA==","value":"djI="}],"truncated":true, "next": 1}}`,
|
|
|
|
result: func(c *Client) any {
|
|
|
|
return result.FindStorage{
|
|
|
|
Results: []result.KeyValue{{Key: []byte("aa10"), Value: []byte("v2")}},
|
|
|
|
Truncated: true,
|
|
|
|
Next: 1,
|
|
|
|
}
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2021-07-22 17:02:59 +00:00
|
|
|
"getstateheight": {
|
|
|
|
{
|
|
|
|
name: "positive",
|
2023-04-03 10:34:24 +00:00
|
|
|
invoke: func(c *Client) (any, error) {
|
2021-07-22 17:02:59 +00:00
|
|
|
return c.GetStateHeight()
|
|
|
|
},
|
|
|
|
serverResponse: `{"jsonrpc":"2.0","id":1,"result":{"localrootindex":11646,"validatedrootindex":11645}}`,
|
2023-04-03 10:34:24 +00:00
|
|
|
result: func(c *Client) any {
|
2021-07-22 17:02:59 +00:00
|
|
|
return &result.StateHeight{
|
|
|
|
Local: 11646,
|
|
|
|
Validated: 11645,
|
|
|
|
}
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2020-03-16 13:49:56 +00:00
|
|
|
"getstorage": {
|
|
|
|
{
|
2020-06-23 14:27:23 +00:00
|
|
|
name: "by hash, positive",
|
2023-04-03 10:34:24 +00:00
|
|
|
invoke: func(c *Client) (any, error) {
|
2020-03-16 13:49:56 +00:00
|
|
|
hash, err := util.Uint160DecodeStringLE("03febccf81ac85e3d795bc5cbd4e84e907812aa3")
|
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
key, err := hex.DecodeString("5065746572")
|
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
2020-06-23 14:27:23 +00:00
|
|
|
return c.GetStorageByHash(hash, key)
|
|
|
|
},
|
2021-02-07 15:27:19 +00:00
|
|
|
serverResponse: `{"jsonrpc":"2.0","id":1,"result":"TGlu"}`,
|
2023-04-03 10:34:24 +00:00
|
|
|
result: func(c *Client) any {
|
2020-06-23 14:27:23 +00:00
|
|
|
value, err := hex.DecodeString("4c696e")
|
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
return value
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "by ID, positive",
|
2023-04-03 10:34:24 +00:00
|
|
|
invoke: func(c *Client) (any, error) {
|
2020-06-23 14:27:23 +00:00
|
|
|
key, err := hex.DecodeString("5065746572")
|
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
return c.GetStorageByID(-1, key)
|
2020-03-16 13:49:56 +00:00
|
|
|
},
|
2021-02-07 15:27:19 +00:00
|
|
|
serverResponse: `{"jsonrpc":"2.0","id":1,"result":"TGlu"}`,
|
2023-04-03 10:34:24 +00:00
|
|
|
result: func(c *Client) any {
|
2020-03-16 13:49:56 +00:00
|
|
|
value, err := hex.DecodeString("4c696e")
|
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
return value
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2023-08-22 16:29:22 +00:00
|
|
|
"getstoragehistoric": {
|
|
|
|
{
|
|
|
|
name: "by hash, positive",
|
|
|
|
invoke: func(c *Client) (any, error) {
|
|
|
|
root, _ := util.Uint256DecodeStringLE("252e9d73d49c95c7618d40650da504e05183a1b2eed0685e42c360413c329170")
|
|
|
|
hash, err := util.Uint160DecodeStringLE("03febccf81ac85e3d795bc5cbd4e84e907812aa3")
|
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
key, err := hex.DecodeString("5065746572")
|
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
return c.GetStorageByHashHistoric(root, hash, key)
|
|
|
|
},
|
|
|
|
serverResponse: `{"jsonrpc":"2.0","id":1,"result":"TGlu"}`,
|
|
|
|
result: func(c *Client) any {
|
|
|
|
value, err := hex.DecodeString("4c696e")
|
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
return value
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "by ID, positive",
|
|
|
|
invoke: func(c *Client) (any, error) {
|
|
|
|
root, _ := util.Uint256DecodeStringLE("252e9d73d49c95c7618d40650da504e05183a1b2eed0685e42c360413c329170")
|
|
|
|
key, err := hex.DecodeString("5065746572")
|
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
return c.GetStorageByIDHistoric(root, -1, key)
|
|
|
|
},
|
|
|
|
serverResponse: `{"jsonrpc":"2.0","id":1,"result":"TGlu"}`,
|
|
|
|
result: func(c *Client) any {
|
|
|
|
value, err := hex.DecodeString("4c696e")
|
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
return value
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2020-03-16 13:49:56 +00:00
|
|
|
"gettransactionheight": {
|
|
|
|
{
|
|
|
|
name: "positive",
|
2023-04-03 10:34:24 +00:00
|
|
|
invoke: func(c *Client) (any, error) {
|
2020-03-16 13:49:56 +00:00
|
|
|
hash, err := util.Uint256DecodeStringLE("cb6ddb5f99d6af4c94a6c396d5294472f2eebc91a2c933e0f527422296fa9fb2")
|
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
return c.GetTransactionHeight(hash)
|
|
|
|
},
|
|
|
|
serverResponse: `{"jsonrpc":"2.0","id":1,"result":1}`,
|
2023-04-03 10:34:24 +00:00
|
|
|
result: func(c *Client) any {
|
2020-03-16 13:49:56 +00:00
|
|
|
return uint32(1)
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2020-06-01 20:27:03 +00:00
|
|
|
"getunclaimedgas": {
|
2020-03-16 13:49:56 +00:00
|
|
|
{
|
|
|
|
name: "positive",
|
2023-04-03 10:34:24 +00:00
|
|
|
invoke: func(c *Client) (any, error) {
|
2020-07-09 14:25:26 +00:00
|
|
|
return c.GetUnclaimedGas("NMipL5VsNoLUBUJKPKLhxaEbPQVCZnyJyB")
|
2020-03-16 13:49:56 +00:00
|
|
|
},
|
2021-02-09 08:37:25 +00:00
|
|
|
serverResponse: `{"jsonrpc":"2.0","id":1,"result":{"address":"NMipL5VsNoLUBUJKPKLhxaEbPQVCZnyJyB","unclaimed":"897299680935"}}`,
|
2023-04-03 10:34:24 +00:00
|
|
|
result: func(c *Client) any {
|
2020-07-09 14:25:26 +00:00
|
|
|
addr, err := address.StringToUint160("NMipL5VsNoLUBUJKPKLhxaEbPQVCZnyJyB")
|
|
|
|
if err != nil {
|
2020-08-06 14:44:08 +00:00
|
|
|
panic(fmt.Errorf("failed to parse UnclaimedGas address: %w", err))
|
2020-07-09 14:25:26 +00:00
|
|
|
}
|
|
|
|
return result.UnclaimedGas{
|
|
|
|
Address: addr,
|
|
|
|
Unclaimed: *big.NewInt(897299680935),
|
|
|
|
}
|
2020-03-16 13:49:56 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2022-07-01 13:02:03 +00:00
|
|
|
"getcandidates": {
|
|
|
|
{
|
|
|
|
name: "positive",
|
2023-04-03 10:34:24 +00:00
|
|
|
invoke: func(c *Client) (any, error) {
|
2022-07-01 13:02:03 +00:00
|
|
|
return c.GetCandidates()
|
|
|
|
},
|
|
|
|
serverResponse: `{"id":1,"jsonrpc":"2.0","result":[{"publickey":"02b3622bf4017bdfe317c58aed5f4c753f206b7db896046fa7d774bbc4bf7f8dc2","votes":"0","active":true},{"publickey":"02103a7f7dd016558597f7960d27c516a4394fd968b9e65155eb4b013e4040406e","votes":"0","active":true},{"publickey":"03d90c07df63e690ce77912e10ab51acc944b66860237b608c4f8f8309e71ee699","votes":"0","active":true},{"publickey":"02a7bc55fe8684e0119768d104ba30795bdcc86619e864add26156723ed185cd62","votes":"0","active":true}]}`,
|
2023-04-03 10:34:24 +00:00
|
|
|
result: func(c *Client) any { return []result.Candidate{} },
|
|
|
|
check: func(t *testing.T, c *Client, uns any) {
|
2022-07-01 13:02:03 +00:00
|
|
|
res, ok := uns.([]result.Candidate)
|
|
|
|
require.True(t, ok)
|
|
|
|
assert.Equal(t, 4, len(res))
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2020-03-16 13:49:56 +00:00
|
|
|
"getvalidators": {
|
|
|
|
{
|
|
|
|
name: "positive",
|
2023-04-03 10:34:24 +00:00
|
|
|
invoke: func(c *Client) (any, error) {
|
2020-10-01 12:26:54 +00:00
|
|
|
return c.GetNextBlockValidators()
|
2020-03-16 13:49:56 +00:00
|
|
|
},
|
|
|
|
serverResponse: `{"id":1,"jsonrpc":"2.0","result":[{"publickey":"02b3622bf4017bdfe317c58aed5f4c753f206b7db896046fa7d774bbc4bf7f8dc2","votes":"0","active":true},{"publickey":"02103a7f7dd016558597f7960d27c516a4394fd968b9e65155eb4b013e4040406e","votes":"0","active":true},{"publickey":"03d90c07df63e690ce77912e10ab51acc944b66860237b608c4f8f8309e71ee699","votes":"0","active":true},{"publickey":"02a7bc55fe8684e0119768d104ba30795bdcc86619e864add26156723ed185cd62","votes":"0","active":true}]}`,
|
2023-04-03 10:34:24 +00:00
|
|
|
result: func(c *Client) any { return []result.Validator{} },
|
|
|
|
check: func(t *testing.T, c *Client, uns any) {
|
2020-03-16 13:49:56 +00:00
|
|
|
res, ok := uns.([]result.Validator)
|
|
|
|
require.True(t, ok)
|
|
|
|
assert.Equal(t, 4, len(res))
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
"getversion": {
|
|
|
|
{
|
|
|
|
name: "positive",
|
2023-04-03 10:34:24 +00:00
|
|
|
invoke: func(c *Client) (any, error) {
|
2020-03-16 13:49:56 +00:00
|
|
|
return c.GetVersion()
|
|
|
|
},
|
2024-04-01 14:56:17 +00:00
|
|
|
serverResponse: `{"id":1,"jsonrpc":"2.0","result":{"tcpport":20332,"wsport":20342,"nonce":2153672787,"useragent":"/NEO-GO:0.73.1-pre-273-ge381358/", "protocol": {"network": 2, "hardforks": {}}, "rpc": {"maxiteratorresultitems": 100, "sessionenabled": true}}`,
|
2023-04-03 10:34:24 +00:00
|
|
|
result: func(c *Client) any {
|
2020-03-16 13:49:56 +00:00
|
|
|
return &result.Version{
|
2020-06-10 07:01:21 +00:00
|
|
|
TCPPort: uint16(20332),
|
|
|
|
WSPort: uint16(20342),
|
2020-03-16 13:49:56 +00:00
|
|
|
Nonce: 2153672787,
|
|
|
|
UserAgent: "/NEO-GO:0.73.1-pre-273-ge381358/",
|
2022-11-10 13:32:49 +00:00
|
|
|
Protocol: result.Protocol{
|
2024-08-09 09:53:31 +00:00
|
|
|
Network: netmode.UnitTestNet,
|
|
|
|
Hardforks: map[config.Hardfork]uint32{},
|
|
|
|
StandbyCommittee: keys.PublicKeys{},
|
2022-11-10 13:32:49 +00:00
|
|
|
},
|
2024-04-01 14:56:17 +00:00
|
|
|
RPC: result.RPC{
|
|
|
|
MaxIteratorResultItems: 100,
|
|
|
|
SessionEnabled: true,
|
|
|
|
},
|
2020-03-16 13:49:56 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
"invokefunction": {
|
|
|
|
{
|
2020-09-25 16:32:53 +00:00
|
|
|
name: "positive, by scripthash",
|
2023-04-03 10:34:24 +00:00
|
|
|
invoke: func(c *Client) (any, error) {
|
2020-03-16 13:49:56 +00:00
|
|
|
hash, err := util.Uint160DecodeStringLE("91b83e96f2a7c4fdf0c1688441ec61986c7cae26")
|
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
2020-07-02 13:38:33 +00:00
|
|
|
contr, err := util.Uint160DecodeStringLE("af7c7328eee5a275a3bcaee2bf0cf662b5e739be")
|
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
return c.InvokeFunction(contr, "balanceOf", []smartcontract.Parameter{
|
2020-03-16 13:49:56 +00:00
|
|
|
{
|
|
|
|
Type: smartcontract.Hash160Type,
|
|
|
|
Value: hash,
|
|
|
|
},
|
2020-07-29 16:57:38 +00:00
|
|
|
}, []transaction.Signer{{
|
2020-06-11 08:45:17 +00:00
|
|
|
Account: util.Uint160{1, 2, 3},
|
|
|
|
}})
|
2020-03-16 13:49:56 +00:00
|
|
|
},
|
2021-02-09 08:16:18 +00:00
|
|
|
serverResponse: `{"jsonrpc":"2.0","id":1,"result":{"script":"FCaufGyYYexBhGjB8P3Ep/KWPriRUcEJYmFsYW5jZU9mZ74557Vi9gy/4q68o3Wi5e4oc3yv","state":"HALT","gasconsumed":"31100000","stack":[{"type":"ByteString","value":"JivsCEQy"}],"tx":"AAgAAACAlpgAAAAAAAIEEwAAAAAAsAQAAAGqis+FnU/kArNOZz8hVoIXlqSI6wEAVwHoAwwUqorPhZ1P5AKzTmc/IVaCF5akiOsMFOeetm08E0pKd27oB9LluEbdpP2wE8AMCHRyYW5zZmVyDBTnnrZtPBNKSndu6AfS5bhG3aT9sEFifVtSOAFCDEDYNAh3TUvYsZrocFYdBvJ0Trdnj1jRuQzy9Q6YroP2Cwgk4v7q3vbeZBikz8Q7vB+RbDPsWUy+ZiqdkkeG4XoUKQwhArNiK/QBe9/jF8WK7V9MdT8ga324lgRvp9d0u8S/f43CC0GVRA14"}}`,
|
2023-04-03 10:34:24 +00:00
|
|
|
result: func(c *Client) any {
|
2020-09-22 09:03:19 +00:00
|
|
|
return &result.Invoke{}
|
|
|
|
},
|
2023-04-03 10:34:24 +00:00
|
|
|
check: func(t *testing.T, c *Client, uns any) {
|
2020-09-22 09:03:19 +00:00
|
|
|
res, ok := uns.(*result.Invoke)
|
|
|
|
require.True(t, ok)
|
2020-03-16 13:49:56 +00:00
|
|
|
bytes, err := hex.DecodeString("262bec084432")
|
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
2020-10-14 13:46:06 +00:00
|
|
|
script, err := base64.StdEncoding.DecodeString("FCaufGyYYexBhGjB8P3Ep/KWPriRUcEJYmFsYW5jZU9mZ74557Vi9gy/4q68o3Wi5e4oc3yv")
|
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
2020-09-22 09:03:19 +00:00
|
|
|
assert.Equal(t, "HALT", res.State)
|
|
|
|
assert.Equal(t, int64(31100000), res.GasConsumed)
|
2020-10-14 13:46:06 +00:00
|
|
|
assert.Equal(t, script, res.Script)
|
2020-09-22 09:03:19 +00:00
|
|
|
assert.Equal(t, []stackitem.Item{stackitem.NewByteArray(bytes)}, res.Stack)
|
|
|
|
assert.NotNil(t, res.Transaction)
|
2020-03-16 13:49:56 +00:00
|
|
|
},
|
|
|
|
},
|
2020-10-05 13:33:20 +00:00
|
|
|
{
|
|
|
|
name: "positive, FAULT state",
|
2023-04-03 10:34:24 +00:00
|
|
|
invoke: func(c *Client) (any, error) {
|
2020-10-05 13:33:20 +00:00
|
|
|
hash, err := util.Uint160DecodeStringLE("91b83e96f2a7c4fdf0c1688441ec61986c7cae26")
|
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
contr, err := util.Uint160DecodeStringLE("af7c7328eee5a275a3bcaee2bf0cf662b5e739be")
|
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
return c.InvokeFunction(contr, "balanceOf", []smartcontract.Parameter{
|
|
|
|
{
|
|
|
|
Type: smartcontract.Hash160Type,
|
|
|
|
Value: hash,
|
|
|
|
},
|
|
|
|
}, []transaction.Signer{{
|
|
|
|
Account: util.Uint160{1, 2, 3},
|
|
|
|
}})
|
|
|
|
},
|
2021-02-09 08:16:18 +00:00
|
|
|
serverResponse: `{"jsonrpc":"2.0","id":1,"result":{"script":"FCaufGyYYexBhGjB8P3Ep/KWPriRUcEJYmFsYW5jZU9mZ74557Vi9gy/4q68o3Wi5e4oc3yv","state":"FAULT","gasconsumed":"31100000","stack":[{"type":"ByteString","value":"JivsCEQy"}],"tx":"AAgAAACAlpgAAAAAAAIEEwAAAAAAsAQAAAGqis+FnU/kArNOZz8hVoIXlqSI6wEAVwHoAwwUqorPhZ1P5AKzTmc/IVaCF5akiOsMFOeetm08E0pKd27oB9LluEbdpP2wE8AMCHRyYW5zZmVyDBTnnrZtPBNKSndu6AfS5bhG3aT9sEFifVtSOAFCDEDYNAh3TUvYsZrocFYdBvJ0Trdnj1jRuQzy9Q6YroP2Cwgk4v7q3vbeZBikz8Q7vB+RbDPsWUy+ZiqdkkeG4XoUKQwhArNiK/QBe9/jF8WK7V9MdT8ga324lgRvp9d0u8S/f43CC0GVRA14","exception":"gas limit exceeded"}}`,
|
2023-04-03 10:34:24 +00:00
|
|
|
result: func(c *Client) any {
|
2020-09-22 09:03:19 +00:00
|
|
|
return &result.Invoke{}
|
|
|
|
},
|
2023-04-03 10:34:24 +00:00
|
|
|
check: func(t *testing.T, c *Client, uns any) {
|
2020-09-22 09:03:19 +00:00
|
|
|
res, ok := uns.(*result.Invoke)
|
|
|
|
require.True(t, ok)
|
2020-10-05 13:33:20 +00:00
|
|
|
bytes, err := hex.DecodeString("262bec084432")
|
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
2020-10-14 13:46:06 +00:00
|
|
|
script, err := base64.StdEncoding.DecodeString("FCaufGyYYexBhGjB8P3Ep/KWPriRUcEJYmFsYW5jZU9mZ74557Vi9gy/4q68o3Wi5e4oc3yv")
|
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
2020-09-22 09:03:19 +00:00
|
|
|
assert.Equal(t, "FAULT", res.State)
|
|
|
|
assert.Equal(t, int64(31100000), res.GasConsumed)
|
2020-10-14 13:46:06 +00:00
|
|
|
assert.Equal(t, script, res.Script)
|
2020-09-22 09:03:19 +00:00
|
|
|
assert.Equal(t, []stackitem.Item{stackitem.NewByteArray(bytes)}, res.Stack)
|
|
|
|
assert.NotNil(t, res.Transaction)
|
2020-10-05 13:33:20 +00:00
|
|
|
},
|
|
|
|
},
|
2020-03-16 13:49:56 +00:00
|
|
|
},
|
|
|
|
"invokescript": {
|
|
|
|
{
|
|
|
|
name: "positive",
|
2023-04-03 10:34:24 +00:00
|
|
|
invoke: func(c *Client) (any, error) {
|
2020-10-14 13:46:06 +00:00
|
|
|
script, err := base64.StdEncoding.DecodeString("AARuYW1lZyQFjl4bYAiEfNZicoVJCIqe6CGR")
|
2020-07-02 13:38:33 +00:00
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
2020-07-29 16:57:38 +00:00
|
|
|
return c.InvokeScript(script, []transaction.Signer{{
|
2020-06-11 08:45:17 +00:00
|
|
|
Account: util.Uint160{1, 2, 3},
|
|
|
|
}})
|
2020-03-16 13:49:56 +00:00
|
|
|
},
|
2021-02-09 08:16:18 +00:00
|
|
|
serverResponse: `{"jsonrpc":"2.0","id":1,"result":{"script":"AARuYW1lZyQFjl4bYAiEfNZicoVJCIqe6CGR","state":"HALT","gasconsumed":"16100000","stack":[{"type":"ByteString","value":"TkVQNSBHQVM="}],"tx":null}}`,
|
2023-04-03 10:34:24 +00:00
|
|
|
result: func(c *Client) any {
|
2020-03-16 13:49:56 +00:00
|
|
|
bytes, err := hex.DecodeString("4e45503520474153")
|
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
2020-10-14 13:46:06 +00:00
|
|
|
script, err := base64.StdEncoding.DecodeString("AARuYW1lZyQFjl4bYAiEfNZicoVJCIqe6CGR")
|
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
2020-03-16 13:49:56 +00:00
|
|
|
return &result.Invoke{
|
|
|
|
State: "HALT",
|
2020-06-23 14:15:35 +00:00
|
|
|
GasConsumed: 16100000,
|
2020-10-14 13:46:06 +00:00
|
|
|
Script: script,
|
2020-07-31 12:26:28 +00:00
|
|
|
Stack: []stackitem.Item{stackitem.NewByteArray(bytes)},
|
2020-03-16 13:49:56 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2020-12-14 12:23:39 +00:00
|
|
|
"invokecontractverify": {
|
|
|
|
{
|
|
|
|
name: "positive",
|
2023-04-03 10:34:24 +00:00
|
|
|
invoke: func(c *Client) (any, error) {
|
2020-12-14 12:23:39 +00:00
|
|
|
contr, err := util.Uint160DecodeStringLE("af7c7328eee5a275a3bcaee2bf0cf662b5e739be")
|
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
return c.InvokeContractVerify(contr, nil, []transaction.Signer{{Account: util.Uint160{1, 2, 3}}}, transaction.Witness{InvocationScript: []byte{1, 2, 3}})
|
|
|
|
},
|
2021-02-09 08:16:18 +00:00
|
|
|
serverResponse: `{"jsonrpc":"2.0","id":1,"result":{"script":"FCaufGyYYexBhGjB8P3Ep/KWPriRUcEJYmFsYW5jZU9mZ74557Vi9gy/4q68o3Wi5e4oc3yv","state":"HALT","gasconsumed":"31100000","stack":[{"type":"ByteString","value":"JivsCEQy"}],"tx":"AAgAAACAlpgAAAAAAAIEEwAAAAAAsAQAAAGqis+FnU/kArNOZz8hVoIXlqSI6wEAVwHoAwwUqorPhZ1P5AKzTmc/IVaCF5akiOsMFOeetm08E0pKd27oB9LluEbdpP2wE8AMCHRyYW5zZmVyDBTnnrZtPBNKSndu6AfS5bhG3aT9sEFifVtSOAFCDEDYNAh3TUvYsZrocFYdBvJ0Trdnj1jRuQzy9Q6YroP2Cwgk4v7q3vbeZBikz8Q7vB+RbDPsWUy+ZiqdkkeG4XoUKQwhArNiK/QBe9/jF8WK7V9MdT8ga324lgRvp9d0u8S/f43CC0GVRA14"}}`,
|
2023-04-03 10:34:24 +00:00
|
|
|
result: func(c *Client) any {
|
2020-12-14 12:23:39 +00:00
|
|
|
return &result.Invoke{}
|
|
|
|
},
|
2023-04-03 10:34:24 +00:00
|
|
|
check: func(t *testing.T, c *Client, uns any) {
|
2020-12-14 12:23:39 +00:00
|
|
|
res, ok := uns.(*result.Invoke)
|
|
|
|
require.True(t, ok)
|
|
|
|
bytes, err := hex.DecodeString("262bec084432")
|
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
script, err := base64.StdEncoding.DecodeString("FCaufGyYYexBhGjB8P3Ep/KWPriRUcEJYmFsYW5jZU9mZ74557Vi9gy/4q68o3Wi5e4oc3yv")
|
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
assert.Equal(t, "HALT", res.State)
|
|
|
|
assert.Equal(t, int64(31100000), res.GasConsumed)
|
|
|
|
assert.Equal(t, script, res.Script)
|
|
|
|
assert.Equal(t, []stackitem.Item{stackitem.NewByteArray(bytes)}, res.Stack)
|
|
|
|
assert.NotNil(t, res.Transaction)
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "bad witness number",
|
2023-04-03 10:34:24 +00:00
|
|
|
invoke: func(c *Client) (any, error) {
|
2020-12-14 12:23:39 +00:00
|
|
|
return c.InvokeContractVerify(util.Uint160{}, nil, []transaction.Signer{{}}, []transaction.Witness{{}, {}}...)
|
|
|
|
},
|
|
|
|
fails: true,
|
|
|
|
},
|
|
|
|
},
|
2020-03-16 13:49:56 +00:00
|
|
|
"sendrawtransaction": {
|
|
|
|
{
|
|
|
|
name: "positive",
|
2023-04-03 10:34:24 +00:00
|
|
|
invoke: func(c *Client) (any, error) {
|
2021-03-25 16:18:01 +00:00
|
|
|
return c.SendRawTransaction(transaction.New([]byte{byte(opcode.PUSH1)}, 0))
|
2020-03-16 13:49:56 +00:00
|
|
|
},
|
2020-07-21 07:31:45 +00:00
|
|
|
serverResponse: `{"jsonrpc":"2.0","id":1,"result":{"hash":"0x72159b0cf1221110daad6e1df6ef4ff03012173b63c86910bd7134deb659c875"}}`,
|
2023-04-03 10:34:24 +00:00
|
|
|
result: func(c *Client) any {
|
2020-07-21 07:31:45 +00:00
|
|
|
h, err := util.Uint256DecodeStringLE("72159b0cf1221110daad6e1df6ef4ff03012173b63c86910bd7134deb659c875")
|
|
|
|
if err != nil {
|
2020-08-06 16:09:57 +00:00
|
|
|
panic(fmt.Errorf("can't decode `sendrawtransaction` result hash: %w", err))
|
2020-07-21 07:31:45 +00:00
|
|
|
}
|
|
|
|
return h
|
2020-03-16 13:49:56 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
"submitblock": {
|
|
|
|
{
|
|
|
|
name: "positive",
|
2023-04-03 10:34:24 +00:00
|
|
|
invoke: func(c *Client) (any, error) {
|
2020-07-21 07:41:18 +00:00
|
|
|
return c.SubmitBlock(block.Block{
|
2021-03-01 13:44:47 +00:00
|
|
|
Header: block.Header{},
|
2020-03-16 13:49:56 +00:00
|
|
|
Transactions: nil,
|
|
|
|
Trimmed: false,
|
|
|
|
})
|
|
|
|
},
|
2020-07-21 07:41:18 +00:00
|
|
|
serverResponse: `{"jsonrpc":"2.0","id":1,"result":{"hash":"0x1bdea8f80eb5bd97fade38d5e7fb93b02c9d3e01394e9f4324218132293f7ea6"}}`,
|
2023-04-03 10:34:24 +00:00
|
|
|
result: func(c *Client) any {
|
2020-07-21 07:41:18 +00:00
|
|
|
h, err := util.Uint256DecodeStringLE("1bdea8f80eb5bd97fade38d5e7fb93b02c9d3e01394e9f4324218132293f7ea6")
|
|
|
|
if err != nil {
|
2020-08-06 16:09:57 +00:00
|
|
|
panic(fmt.Errorf("can't decode `submitblock` result hash: %w", err))
|
2020-07-21 07:41:18 +00:00
|
|
|
}
|
|
|
|
return h
|
2020-03-16 13:49:56 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
"validateaddress": {
|
|
|
|
{
|
|
|
|
name: "positive",
|
2023-04-03 10:34:24 +00:00
|
|
|
invoke: func(c *Client) (any, error) {
|
2020-03-16 13:49:56 +00:00
|
|
|
return nil, c.ValidateAddress("AQVh2pG732YvtNaxEGkQUei3YA4cvo7d2i")
|
|
|
|
},
|
|
|
|
serverResponse: `{"jsonrpc":"2.0","id":1,"result":{"address":"AQVh2pG732YvtNaxEGkQUei3YA4cvo7d2i","isvalid":true}}`,
|
2023-04-03 10:34:24 +00:00
|
|
|
result: func(c *Client) any {
|
2020-03-16 13:49:56 +00:00
|
|
|
// no error expected
|
|
|
|
return nil
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2023-08-27 18:49:46 +00:00
|
|
|
"getrawnotarytransaction": {
|
|
|
|
{
|
|
|
|
name: "positive",
|
|
|
|
invoke: func(c *Client) (any, error) {
|
|
|
|
hash, err := util.Uint256DecodeStringLE("ad1c2875de823a54188949490e2d68580fd070fcc5ff409609f478d23d12355f")
|
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
return c.GetRawNotaryTransaction(hash)
|
|
|
|
},
|
|
|
|
serverResponse: `{"id":1,"jsonrpc":"2.0","result":"AAMAAAAAAAAAAAAAAAAAAAAAAAAAewAAAAHunqIsJ+NL0BSPxBCOCPdOj1BIsgABIgEBQAEDAQQHAwMGCQ=="}`,
|
|
|
|
result: func(c *Client) any {
|
|
|
|
return &transaction.Transaction{}
|
|
|
|
},
|
|
|
|
check: func(t *testing.T, c *Client, uns any) {
|
|
|
|
res, ok := uns.(*transaction.Transaction)
|
|
|
|
require.True(t, ok)
|
|
|
|
assert.NotNil(t, res)
|
|
|
|
expectHash, err := util.Uint256DecodeStringLE("ad1c2875de823a54188949490e2d68580fd070fcc5ff409609f478d23d12355f")
|
|
|
|
require.NoError(t, err)
|
|
|
|
assert.Equal(t, expectHash, res.Hash())
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "positive verbose",
|
|
|
|
invoke: func(c *Client) (any, error) {
|
|
|
|
hash, err := util.Uint256DecodeStringLE("ad1c2875de823a54188949490e2d68580fd070fcc5ff409609f478d23d12355f")
|
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
return c.GetRawNotaryTransactionVerbose(hash)
|
|
|
|
},
|
|
|
|
serverResponse: `{"id":1,"jsonrpc":"2.0","result":{"hash":"0xad1c2875de823a54188949490e2d68580fd070fcc5ff409609f478d23d12355f","size":61,"version":0,"nonce":3,"sender":"Nhfg3TbpwogLvDGVvAvqyThbsHgoSUKwtn","sysfee":"0","netfee":"0","validuntilblock":123,"attributes":[{"nkeys":1,"type":"NotaryAssisted"}],"signers":[{"account":"0xb248508f4ef7088e10c48f14d04be3272ca29eee","scopes":"None"}],"script":"QA==","witnesses":[{"invocation":"AQQH","verification":"AwYJ"}]}}`,
|
|
|
|
result: func(c *Client) any {
|
|
|
|
return &transaction.Transaction{}
|
|
|
|
},
|
|
|
|
check: func(t *testing.T, c *Client, uns any) {
|
|
|
|
res, ok := uns.(*transaction.Transaction)
|
|
|
|
require.True(t, ok)
|
|
|
|
assert.NotNil(t, res)
|
|
|
|
expectHash, err := util.Uint256DecodeStringLE("ad1c2875de823a54188949490e2d68580fd070fcc5ff409609f478d23d12355f")
|
|
|
|
require.NoError(t, err)
|
|
|
|
assert.Equal(t, expectHash, res.Hash())
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
"getrawnotarypool": {
|
|
|
|
{
|
|
|
|
name: "empty pool",
|
|
|
|
invoke: func(c *Client) (any, error) {
|
|
|
|
return c.GetRawNotaryPool()
|
|
|
|
},
|
|
|
|
serverResponse: `{"id":1,"jsonrpc":"2.0","result":{}}`,
|
|
|
|
result: func(c *Client) any {
|
|
|
|
return &result.RawNotaryPool{
|
|
|
|
Hashes: map[util.Uint256][]util.Uint256{},
|
|
|
|
}
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "nonempty pool",
|
|
|
|
invoke: func(c *Client) (any, error) {
|
|
|
|
return c.GetRawNotaryPool()
|
|
|
|
},
|
|
|
|
serverResponse: `{"id":1,"jsonrpc":"2.0","result":{"hashes":{"0xd86b5346e9bbe6dba845cc4192fa716535a3d05c4f2084431edc99dc3862a299":["0xbb0b2f1d5539dd776637f00e5011d97921a1400d3a63c02977a38446180c6d7c"]}}}`,
|
|
|
|
result: func(c *Client) any {
|
|
|
|
return &result.RawNotaryPool{
|
|
|
|
Hashes: map[util.Uint256][]util.Uint256{},
|
|
|
|
}
|
|
|
|
},
|
|
|
|
check: func(t *testing.T, c *Client, uns any) {
|
|
|
|
res, ok := uns.(*result.RawNotaryPool)
|
|
|
|
require.True(t, ok)
|
|
|
|
mainHash, err := util.Uint256DecodeStringLE("d86b5346e9bbe6dba845cc4192fa716535a3d05c4f2084431edc99dc3862a299")
|
|
|
|
require.NoError(t, err, "can't decode `mainHash` result hash")
|
|
|
|
fallbackHash, err := util.Uint256DecodeStringLE("bb0b2f1d5539dd776637f00e5011d97921a1400d3a63c02977a38446180c6d7c")
|
|
|
|
require.NoError(t, err, "can't decode `fallbackHash` result hash")
|
|
|
|
fallbacks, ok := res.Hashes[mainHash]
|
|
|
|
require.True(t, ok)
|
|
|
|
assert.Equal(t, fallbacks[0], fallbackHash)
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2020-03-16 13:49:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
type rpcClientErrorCase struct {
|
|
|
|
name string
|
2023-04-03 10:34:24 +00:00
|
|
|
invoke func(c *Client) (any, error)
|
2020-03-16 13:49:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
var rpcClientErrorCases = map[string][]rpcClientErrorCase{
|
2021-11-17 21:08:10 +00:00
|
|
|
`{"jsonrpc":"2.0","id":1,"result":{"name":"name","bad":42}}`: {
|
|
|
|
{
|
|
|
|
name: "getnep11properties_unmarshalling_error",
|
2023-04-03 10:34:24 +00:00
|
|
|
invoke: func(c *Client) (any, error) {
|
2021-11-17 21:08:10 +00:00
|
|
|
return c.GetNEP11Properties(util.Uint160{}, []byte{})
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
`{"jsonrpc":"2.0","id":1,"result":{"name":100500,"good":"c29tZXRoaW5n"}}`: {
|
|
|
|
{
|
|
|
|
name: "getnep11properties_unmarshalling_error",
|
2023-04-03 10:34:24 +00:00
|
|
|
invoke: func(c *Client) (any, error) {
|
2021-11-17 21:08:10 +00:00
|
|
|
return c.GetNEP11Properties(util.Uint160{}, []byte{})
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2020-03-16 13:49:56 +00:00
|
|
|
`{"jsonrpc":"2.0","id":1,"result":"not-a-hex-string"}`: {
|
|
|
|
{
|
|
|
|
name: "getblock_not_a_hex_response",
|
2023-04-03 10:34:24 +00:00
|
|
|
invoke: func(c *Client) (any, error) {
|
2020-03-16 13:49:56 +00:00
|
|
|
return c.GetBlockByIndex(1)
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "getblockheader_not_a_hex_response",
|
2023-04-03 10:34:24 +00:00
|
|
|
invoke: func(c *Client) (any, error) {
|
2020-03-16 13:49:56 +00:00
|
|
|
hash, err := util.Uint256DecodeStringLE("e93d17a52967f9e69314385482bf86f85260e811b46bf4d4b261a7f4135a623c")
|
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
return c.GetBlockHeader(hash)
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "getrawtransaction_not_a_hex_response",
|
2023-04-03 10:34:24 +00:00
|
|
|
invoke: func(c *Client) (any, error) {
|
2020-03-16 13:49:56 +00:00
|
|
|
hash, err := util.Uint256DecodeStringLE("e93d17a52967f9e69314385482bf86f85260e811b46bf4d4b261a7f4135a623c")
|
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
return c.GetRawTransaction(hash)
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
2020-06-23 14:27:23 +00:00
|
|
|
name: "getstoragebyhash_not_a_hex_response",
|
2023-04-03 10:34:24 +00:00
|
|
|
invoke: func(c *Client) (any, error) {
|
2020-03-16 13:49:56 +00:00
|
|
|
hash, err := util.Uint160DecodeStringLE("03febccf81ac85e3d795bc5cbd4e84e907812aa3")
|
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
key, err := hex.DecodeString("5065746572")
|
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
2020-06-23 14:27:23 +00:00
|
|
|
return c.GetStorageByHash(hash, key)
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "getstoragebyid_not_a_hex_response",
|
2023-04-03 10:34:24 +00:00
|
|
|
invoke: func(c *Client) (any, error) {
|
2020-06-23 14:27:23 +00:00
|
|
|
key, err := hex.DecodeString("5065746572")
|
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
return c.GetStorageByID(-1, key)
|
2020-03-16 13:49:56 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
`{"jsonrpc":"2.0","id":1,"result":"01"}`: {
|
|
|
|
{
|
|
|
|
name: "getblock_decodebin_error",
|
2023-04-03 10:34:24 +00:00
|
|
|
invoke: func(c *Client) (any, error) {
|
2020-03-16 13:49:56 +00:00
|
|
|
return c.GetBlockByIndex(1)
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "getheader_decodebin_err",
|
2023-04-03 10:34:24 +00:00
|
|
|
invoke: func(c *Client) (any, error) {
|
2020-03-16 13:49:56 +00:00
|
|
|
hash, err := util.Uint256DecodeStringLE("e93d17a52967f9e69314385482bf86f85260e811b46bf4d4b261a7f4135a623c")
|
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
return c.GetBlockHeader(hash)
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "getrawtransaction_decodebin_err",
|
2023-04-03 10:34:24 +00:00
|
|
|
invoke: func(c *Client) (any, error) {
|
2020-03-16 13:49:56 +00:00
|
|
|
hash, err := util.Uint256DecodeStringLE("e93d17a52967f9e69314385482bf86f85260e811b46bf4d4b261a7f4135a623c")
|
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
return c.GetRawTransaction(hash)
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
`{"jsonrpc":"2.0","id":1,"result":false}`: {
|
|
|
|
{
|
|
|
|
name: "sendrawtransaction_bad_server_answer",
|
2023-04-03 10:34:24 +00:00
|
|
|
invoke: func(c *Client) (any, error) {
|
2021-03-25 16:18:01 +00:00
|
|
|
return c.SendRawTransaction(transaction.New([]byte{byte(opcode.PUSH1)}, 0))
|
2020-03-16 13:49:56 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "submitblock_bad_server_answer",
|
2023-04-03 10:34:24 +00:00
|
|
|
invoke: func(c *Client) (any, error) {
|
2020-07-21 07:41:18 +00:00
|
|
|
return c.SubmitBlock(block.Block{
|
2021-03-01 13:44:47 +00:00
|
|
|
Header: block.Header{},
|
2020-03-16 13:49:56 +00:00
|
|
|
Transactions: nil,
|
|
|
|
Trimmed: false,
|
|
|
|
})
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "validateaddress_bad_server_answer",
|
2023-04-03 10:34:24 +00:00
|
|
|
invoke: func(c *Client) (any, error) {
|
2020-03-16 13:49:56 +00:00
|
|
|
return nil, c.ValidateAddress("AQVh2pG732YvtNaxEGkQUei3YA4cvo7d2i")
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2023-11-13 17:27:37 +00:00
|
|
|
`{"id":1,"jsonrpc":"2.0","error":{"code":-32602,"message":"Invalid params"}}`: {
|
2020-03-16 13:49:56 +00:00
|
|
|
{
|
|
|
|
name: "getapplicationlog_invalid_params_error",
|
2023-04-03 10:34:24 +00:00
|
|
|
invoke: func(c *Client) (any, error) {
|
2020-11-10 11:30:00 +00:00
|
|
|
return c.GetApplicationLog(util.Uint256{}, nil)
|
2020-03-16 13:49:56 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "getbestblockhash_invalid_params_error",
|
2023-04-03 10:34:24 +00:00
|
|
|
invoke: func(c *Client) (any, error) {
|
2020-03-16 13:49:56 +00:00
|
|
|
return c.GetBestBlockHash()
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "getblock_byindex_invalid_params_error",
|
2023-04-03 10:34:24 +00:00
|
|
|
invoke: func(c *Client) (any, error) {
|
2020-03-16 13:49:56 +00:00
|
|
|
return c.GetBlockByIndex(1)
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "getblock_byindex_verbose_invalid_params_error",
|
2023-04-03 10:34:24 +00:00
|
|
|
invoke: func(c *Client) (any, error) {
|
2020-03-16 13:49:56 +00:00
|
|
|
return c.GetBlockByIndexVerbose(1)
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "getblock_byhash_invalid_params_error",
|
2023-04-03 10:34:24 +00:00
|
|
|
invoke: func(c *Client) (any, error) {
|
2020-03-16 13:49:56 +00:00
|
|
|
return c.GetBlockByHash(util.Uint256{})
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "getblock_byhash_verbose_invalid_params_error",
|
2023-04-03 10:34:24 +00:00
|
|
|
invoke: func(c *Client) (any, error) {
|
2020-03-16 13:49:56 +00:00
|
|
|
return c.GetBlockByHashVerbose(util.Uint256{})
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "getblockhash_invalid_params_error",
|
2023-04-03 10:34:24 +00:00
|
|
|
invoke: func(c *Client) (any, error) {
|
2020-03-16 13:49:56 +00:00
|
|
|
return c.GetBlockHash(0)
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "getblockheader_invalid_params_error",
|
2023-04-03 10:34:24 +00:00
|
|
|
invoke: func(c *Client) (any, error) {
|
2020-03-16 13:49:56 +00:00
|
|
|
return c.GetBlockHeader(util.Uint256{})
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "getblockheader_verbose_invalid_params_error",
|
2023-04-03 10:34:24 +00:00
|
|
|
invoke: func(c *Client) (any, error) {
|
2020-03-16 13:49:56 +00:00
|
|
|
return c.GetBlockHeaderVerbose(util.Uint256{})
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "getblocksysfee_invalid_params_error",
|
2023-04-03 10:34:24 +00:00
|
|
|
invoke: func(c *Client) (any, error) {
|
2020-03-16 13:49:56 +00:00
|
|
|
return c.GetBlockSysFee(1)
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "getconnectioncount_invalid_params_error",
|
2023-04-03 10:34:24 +00:00
|
|
|
invoke: func(c *Client) (any, error) {
|
2020-03-16 13:49:56 +00:00
|
|
|
return c.GetConnectionCount()
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "getcontractstate_invalid_params_error",
|
2023-04-03 10:34:24 +00:00
|
|
|
invoke: func(c *Client) (any, error) {
|
2020-09-25 16:32:53 +00:00
|
|
|
return c.GetContractStateByHash(util.Uint160{})
|
2020-03-16 13:49:56 +00:00
|
|
|
},
|
|
|
|
},
|
2021-11-17 21:08:10 +00:00
|
|
|
{
|
|
|
|
name: "getnep11balances_invalid_params_error",
|
2023-04-03 10:34:24 +00:00
|
|
|
invoke: func(c *Client) (any, error) {
|
2021-11-17 21:08:10 +00:00
|
|
|
return c.GetNEP11Balances(util.Uint160{})
|
|
|
|
},
|
|
|
|
},
|
2020-03-16 13:49:56 +00:00
|
|
|
{
|
2020-11-24 08:14:25 +00:00
|
|
|
name: "getnep17balances_invalid_params_error",
|
2023-04-03 10:34:24 +00:00
|
|
|
invoke: func(c *Client) (any, error) {
|
2020-11-24 08:14:25 +00:00
|
|
|
return c.GetNEP17Balances(util.Uint160{})
|
2020-03-16 13:49:56 +00:00
|
|
|
},
|
|
|
|
},
|
2021-11-17 21:08:10 +00:00
|
|
|
{
|
|
|
|
name: "getnep11properties_invalid_params_error",
|
2023-04-03 10:34:24 +00:00
|
|
|
invoke: func(c *Client) (any, error) {
|
2021-11-17 21:08:10 +00:00
|
|
|
return c.GetNEP11Properties(util.Uint160{}, []byte{})
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "getnep11transfers_invalid_params_error",
|
2023-04-03 10:34:24 +00:00
|
|
|
invoke: func(c *Client) (any, error) {
|
2021-11-18 14:00:48 +00:00
|
|
|
return c.GetNEP11Transfers(util.Uint160{}, nil, nil, nil, nil)
|
2021-11-17 21:08:10 +00:00
|
|
|
},
|
|
|
|
},
|
2020-03-16 13:49:56 +00:00
|
|
|
{
|
2020-11-24 08:14:25 +00:00
|
|
|
name: "getnep17transfers_invalid_params_error",
|
2023-04-03 10:34:24 +00:00
|
|
|
invoke: func(c *Client) (any, error) {
|
2021-11-18 14:00:48 +00:00
|
|
|
return c.GetNEP17Transfers(util.Uint160{}, nil, nil, nil, nil)
|
2020-09-14 19:12:49 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
2020-11-24 08:14:25 +00:00
|
|
|
name: "getnep17transfers_invalid_params_error 2",
|
2023-04-03 10:34:24 +00:00
|
|
|
invoke: func(c *Client) (any, error) {
|
2021-10-11 13:56:20 +00:00
|
|
|
var stop uint64
|
2021-11-18 14:00:48 +00:00
|
|
|
return c.GetNEP17Transfers(util.Uint160{}, nil, &stop, nil, nil)
|
2020-09-14 19:12:49 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
2020-11-24 08:14:25 +00:00
|
|
|
name: "getnep17transfers_invalid_params_error 3",
|
2023-04-03 10:34:24 +00:00
|
|
|
invoke: func(c *Client) (any, error) {
|
2021-10-11 13:56:20 +00:00
|
|
|
var start uint64
|
2020-09-14 19:12:49 +00:00
|
|
|
var limit int
|
2021-11-18 14:00:48 +00:00
|
|
|
return c.GetNEP17Transfers(util.Uint160{}, &start, nil, &limit, nil)
|
2020-09-14 19:12:49 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
2020-11-24 08:14:25 +00:00
|
|
|
name: "getnep17transfers_invalid_params_error 4",
|
2023-04-03 10:34:24 +00:00
|
|
|
invoke: func(c *Client) (any, error) {
|
2021-10-11 13:56:20 +00:00
|
|
|
var start, stop uint64
|
2020-09-14 19:12:49 +00:00
|
|
|
var page int
|
2021-11-18 14:00:48 +00:00
|
|
|
return c.GetNEP17Transfers(util.Uint160{}, &start, &stop, nil, &page)
|
2020-03-16 13:49:56 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "getrawtransaction_invalid_params_error",
|
2023-04-03 10:34:24 +00:00
|
|
|
invoke: func(c *Client) (any, error) {
|
2020-03-16 13:49:56 +00:00
|
|
|
return c.GetRawTransaction(util.Uint256{})
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "getrawtransaction_verbose_invalid_params_error",
|
2023-04-03 10:34:24 +00:00
|
|
|
invoke: func(c *Client) (any, error) {
|
2020-03-16 13:49:56 +00:00
|
|
|
return c.GetRawTransactionVerbose(util.Uint256{})
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
2020-06-23 14:27:23 +00:00
|
|
|
name: "getstoragebyhash_invalid_params_error",
|
2023-04-03 10:34:24 +00:00
|
|
|
invoke: func(c *Client) (any, error) {
|
2020-06-23 14:27:23 +00:00
|
|
|
return c.GetStorageByHash(util.Uint160{}, []byte{})
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "getstoragebyid_invalid_params_error",
|
2023-04-03 10:34:24 +00:00
|
|
|
invoke: func(c *Client) (any, error) {
|
2020-06-23 14:27:23 +00:00
|
|
|
return c.GetStorageByID(-1, []byte{})
|
2020-03-16 13:49:56 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "gettransactionheight_invalid_params_error",
|
2023-04-03 10:34:24 +00:00
|
|
|
invoke: func(c *Client) (any, error) {
|
2020-03-16 13:49:56 +00:00
|
|
|
return c.GetTransactionHeight(util.Uint256{})
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
2020-06-01 20:27:03 +00:00
|
|
|
name: "getunclaimedgas_invalid_params_error",
|
2023-04-03 10:34:24 +00:00
|
|
|
invoke: func(c *Client) (any, error) {
|
2020-06-01 20:27:03 +00:00
|
|
|
return c.GetUnclaimedGas("")
|
2020-03-16 13:49:56 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "invokefunction_invalid_params_error",
|
2023-04-03 10:34:24 +00:00
|
|
|
invoke: func(c *Client) (any, error) {
|
2020-07-02 13:38:33 +00:00
|
|
|
return c.InvokeFunction(util.Uint160{}, "", []smartcontract.Parameter{}, nil)
|
2020-03-16 13:49:56 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "invokescript_invalid_params_error",
|
2023-04-03 10:34:24 +00:00
|
|
|
invoke: func(c *Client) (any, error) {
|
2020-07-02 13:38:33 +00:00
|
|
|
return c.InvokeScript([]byte{}, nil)
|
2020-03-16 13:49:56 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "sendrawtransaction_invalid_params_error",
|
2023-04-03 10:34:24 +00:00
|
|
|
invoke: func(c *Client) (any, error) {
|
2020-07-21 07:31:45 +00:00
|
|
|
return c.SendRawTransaction(&transaction.Transaction{})
|
2020-03-16 13:49:56 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "submitblock_invalid_params_error",
|
2023-04-03 10:34:24 +00:00
|
|
|
invoke: func(c *Client) (any, error) {
|
2020-07-21 07:41:18 +00:00
|
|
|
return c.SubmitBlock(block.Block{})
|
2020-03-16 13:49:56 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "validateaddress_invalid_params_error",
|
2023-04-03 10:34:24 +00:00
|
|
|
invoke: func(c *Client) (any, error) {
|
2020-03-16 13:49:56 +00:00
|
|
|
return nil, c.ValidateAddress("")
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
`{}`: {
|
|
|
|
{
|
|
|
|
name: "getapplicationlog_unmarshalling_error",
|
2023-04-03 10:34:24 +00:00
|
|
|
invoke: func(c *Client) (any, error) {
|
2020-11-10 11:30:00 +00:00
|
|
|
return c.GetApplicationLog(util.Uint256{}, nil)
|
2020-03-16 13:49:56 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "getbestblockhash_unmarshalling_error",
|
2023-04-03 10:34:24 +00:00
|
|
|
invoke: func(c *Client) (any, error) {
|
2020-03-16 13:49:56 +00:00
|
|
|
return c.GetBestBlockHash()
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "getblock_byindex_unmarshalling_error",
|
2023-04-03 10:34:24 +00:00
|
|
|
invoke: func(c *Client) (any, error) {
|
2020-03-16 13:49:56 +00:00
|
|
|
return c.GetBlockByIndex(1)
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "getblock_byindex_verbose_unmarshalling_error",
|
2023-04-03 10:34:24 +00:00
|
|
|
invoke: func(c *Client) (any, error) {
|
2020-03-16 13:49:56 +00:00
|
|
|
return c.GetBlockByIndexVerbose(1)
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "getblock_byhash_unmarshalling_error",
|
2023-04-03 10:34:24 +00:00
|
|
|
invoke: func(c *Client) (any, error) {
|
2020-03-16 13:49:56 +00:00
|
|
|
return c.GetBlockByHash(util.Uint256{})
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "getblock_byhash_verbose_unmarshalling_error",
|
2023-04-03 10:34:24 +00:00
|
|
|
invoke: func(c *Client) (any, error) {
|
2020-03-16 13:49:56 +00:00
|
|
|
return c.GetBlockByHashVerbose(util.Uint256{})
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "getblockcount_unmarshalling_error",
|
2023-04-03 10:34:24 +00:00
|
|
|
invoke: func(c *Client) (any, error) {
|
2020-03-16 13:49:56 +00:00
|
|
|
return c.GetBlockCount()
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "getblockhash_unmarshalling_error",
|
2023-04-03 10:34:24 +00:00
|
|
|
invoke: func(c *Client) (any, error) {
|
2020-03-16 13:49:56 +00:00
|
|
|
return c.GetBlockHash(1)
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "getblockheader_unmarshalling_error",
|
2023-04-03 10:34:24 +00:00
|
|
|
invoke: func(c *Client) (any, error) {
|
2020-03-16 13:49:56 +00:00
|
|
|
return c.GetBlockHeader(util.Uint256{})
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "getblockheader_verbose_unmarshalling_error",
|
2023-04-03 10:34:24 +00:00
|
|
|
invoke: func(c *Client) (any, error) {
|
2020-03-16 13:49:56 +00:00
|
|
|
return c.GetBlockHeaderVerbose(util.Uint256{})
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "getblocksysfee_unmarshalling_error",
|
2023-04-03 10:34:24 +00:00
|
|
|
invoke: func(c *Client) (any, error) {
|
2020-03-16 13:49:56 +00:00
|
|
|
return c.GetBlockSysFee(1)
|
|
|
|
},
|
|
|
|
},
|
2020-09-21 12:34:04 +00:00
|
|
|
{
|
|
|
|
name: "getcommittee_unmarshalling_error",
|
2023-04-03 10:34:24 +00:00
|
|
|
invoke: func(c *Client) (any, error) {
|
2020-09-21 12:34:04 +00:00
|
|
|
return c.GetCommittee()
|
|
|
|
},
|
|
|
|
},
|
2020-03-16 13:49:56 +00:00
|
|
|
{
|
|
|
|
name: "getconnectioncount_unmarshalling_error",
|
2023-04-03 10:34:24 +00:00
|
|
|
invoke: func(c *Client) (any, error) {
|
2020-03-16 13:49:56 +00:00
|
|
|
return c.GetConnectionCount()
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "getcontractstate_unmarshalling_error",
|
2023-04-03 10:34:24 +00:00
|
|
|
invoke: func(c *Client) (any, error) {
|
2020-09-25 16:32:53 +00:00
|
|
|
return c.GetContractStateByHash(util.Uint160{})
|
2020-03-16 13:49:56 +00:00
|
|
|
},
|
|
|
|
},
|
2021-11-17 21:08:10 +00:00
|
|
|
{
|
|
|
|
name: "getnep11balances_unmarshalling_error",
|
2023-04-03 10:34:24 +00:00
|
|
|
invoke: func(c *Client) (any, error) {
|
2021-11-17 21:08:10 +00:00
|
|
|
return c.GetNEP11Balances(util.Uint160{})
|
|
|
|
},
|
|
|
|
},
|
2020-03-16 13:49:56 +00:00
|
|
|
{
|
2020-11-24 08:14:25 +00:00
|
|
|
name: "getnep17balances_unmarshalling_error",
|
2023-04-03 10:34:24 +00:00
|
|
|
invoke: func(c *Client) (any, error) {
|
2020-11-24 08:14:25 +00:00
|
|
|
return c.GetNEP17Balances(util.Uint160{})
|
2020-03-16 13:49:56 +00:00
|
|
|
},
|
|
|
|
},
|
2021-11-17 21:08:10 +00:00
|
|
|
{
|
|
|
|
name: "getnep11transfers_unmarshalling_error",
|
2023-04-03 10:34:24 +00:00
|
|
|
invoke: func(c *Client) (any, error) {
|
2021-11-18 14:00:48 +00:00
|
|
|
return c.GetNEP11Transfers(util.Uint160{}, nil, nil, nil, nil)
|
2021-11-17 21:08:10 +00:00
|
|
|
},
|
|
|
|
},
|
2020-03-16 13:49:56 +00:00
|
|
|
{
|
2020-11-24 08:14:25 +00:00
|
|
|
name: "getnep17transfers_unmarshalling_error",
|
2023-04-03 10:34:24 +00:00
|
|
|
invoke: func(c *Client) (any, error) {
|
2021-11-18 14:00:48 +00:00
|
|
|
return c.GetNEP17Transfers(util.Uint160{}, nil, nil, nil, nil)
|
2020-03-16 13:49:56 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "getpeers_unmarshalling_error",
|
2023-04-03 10:34:24 +00:00
|
|
|
invoke: func(c *Client) (any, error) {
|
2020-03-16 13:49:56 +00:00
|
|
|
return c.GetPeers()
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "getrawmempool_unmarshalling_error",
|
2023-04-03 10:34:24 +00:00
|
|
|
invoke: func(c *Client) (any, error) {
|
2020-03-16 13:49:56 +00:00
|
|
|
return c.GetRawMemPool()
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "getrawtransaction_unmarshalling_error",
|
2023-04-03 10:34:24 +00:00
|
|
|
invoke: func(c *Client) (any, error) {
|
2020-03-16 13:49:56 +00:00
|
|
|
return c.GetRawTransaction(util.Uint256{})
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "getrawtransaction_verbose_unmarshalling_error",
|
2023-04-03 10:34:24 +00:00
|
|
|
invoke: func(c *Client) (any, error) {
|
2020-03-16 13:49:56 +00:00
|
|
|
return c.GetRawTransactionVerbose(util.Uint256{})
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
2020-06-23 14:27:23 +00:00
|
|
|
name: "getstoragebyhash_unmarshalling_error",
|
2023-04-03 10:34:24 +00:00
|
|
|
invoke: func(c *Client) (any, error) {
|
2020-06-23 14:27:23 +00:00
|
|
|
return c.GetStorageByHash(util.Uint160{}, []byte{})
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "getstoragebyid_unmarshalling_error",
|
2023-04-03 10:34:24 +00:00
|
|
|
invoke: func(c *Client) (any, error) {
|
2020-06-23 14:27:23 +00:00
|
|
|
return c.GetStorageByID(-1, []byte{})
|
2020-03-16 13:49:56 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "gettransactionheight_unmarshalling_error",
|
2023-04-03 10:34:24 +00:00
|
|
|
invoke: func(c *Client) (any, error) {
|
2020-03-16 13:49:56 +00:00
|
|
|
return c.GetTransactionHeight(util.Uint256{})
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
2020-06-01 20:27:03 +00:00
|
|
|
name: "getunclaimedgas_unmarshalling_error",
|
2023-04-03 10:34:24 +00:00
|
|
|
invoke: func(c *Client) (any, error) {
|
2020-06-01 20:27:03 +00:00
|
|
|
return c.GetUnclaimedGas("")
|
2020-03-16 13:49:56 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
2022-07-01 13:02:03 +00:00
|
|
|
name: "getcandidates_unmarshalling_error",
|
2023-04-03 10:34:24 +00:00
|
|
|
invoke: func(c *Client) (any, error) {
|
2022-07-01 13:02:03 +00:00
|
|
|
return c.GetCandidates()
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
2020-03-16 13:49:56 +00:00
|
|
|
name: "getvalidators_unmarshalling_error",
|
2023-04-03 10:34:24 +00:00
|
|
|
invoke: func(c *Client) (any, error) {
|
2020-10-01 12:26:54 +00:00
|
|
|
return c.GetNextBlockValidators()
|
2020-03-16 13:49:56 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "invokefunction_unmarshalling_error",
|
2023-04-03 10:34:24 +00:00
|
|
|
invoke: func(c *Client) (any, error) {
|
2020-07-02 13:38:33 +00:00
|
|
|
return c.InvokeFunction(util.Uint160{}, "", []smartcontract.Parameter{}, nil)
|
2020-03-16 13:49:56 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "invokescript_unmarshalling_error",
|
2023-04-03 10:34:24 +00:00
|
|
|
invoke: func(c *Client) (any, error) {
|
2020-07-02 13:38:33 +00:00
|
|
|
return c.InvokeScript([]byte{}, nil)
|
2020-03-16 13:49:56 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "sendrawtransaction_unmarshalling_error",
|
2023-04-03 10:34:24 +00:00
|
|
|
invoke: func(c *Client) (any, error) {
|
2021-03-25 16:18:01 +00:00
|
|
|
return c.SendRawTransaction(transaction.New([]byte{byte(opcode.PUSH1)}, 0))
|
2020-03-16 13:49:56 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "submitblock_unmarshalling_error",
|
2023-04-03 10:34:24 +00:00
|
|
|
invoke: func(c *Client) (any, error) {
|
2020-07-21 07:41:18 +00:00
|
|
|
return c.SubmitBlock(block.Block{
|
2021-03-01 13:44:47 +00:00
|
|
|
Header: block.Header{},
|
2020-03-16 13:49:56 +00:00
|
|
|
Transactions: nil,
|
|
|
|
Trimmed: false,
|
|
|
|
})
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "validateaddress_unmarshalling_error",
|
2023-04-03 10:34:24 +00:00
|
|
|
invoke: func(c *Client) (any, error) {
|
2020-03-16 13:49:56 +00:00
|
|
|
return nil, c.ValidateAddress("")
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
2020-04-29 19:51:43 +00:00
|
|
|
func TestRPCClients(t *testing.T) {
|
|
|
|
t.Run("Client", func(t *testing.T) {
|
|
|
|
testRPCClient(t, func(ctx context.Context, endpoint string, opts Options) (*Client, error) {
|
2020-10-14 15:13:20 +00:00
|
|
|
c, err := New(ctx, endpoint, opts)
|
|
|
|
require.NoError(t, err)
|
2022-02-18 17:28:13 +00:00
|
|
|
c.getNextRequestID = getTestRequestID
|
2020-10-14 15:13:20 +00:00
|
|
|
require.NoError(t, c.Init())
|
|
|
|
return c, nil
|
2020-04-29 19:51:43 +00:00
|
|
|
})
|
|
|
|
})
|
|
|
|
t.Run("WSClient", func(t *testing.T) {
|
|
|
|
testRPCClient(t, func(ctx context.Context, endpoint string, opts Options) (*Client, error) {
|
2023-04-21 14:14:47 +00:00
|
|
|
wsc, err := NewWS(ctx, httpURLtoWS(endpoint), WSOptions{Options: opts})
|
2020-04-29 19:51:43 +00:00
|
|
|
require.NoError(t, err)
|
2022-02-18 17:28:13 +00:00
|
|
|
wsc.getNextRequestID = getTestRequestID
|
2020-10-14 15:13:20 +00:00
|
|
|
require.NoError(t, wsc.Init())
|
2020-04-29 19:51:43 +00:00
|
|
|
return &wsc.Client, nil
|
|
|
|
})
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
func testRPCClient(t *testing.T, newClient func(context.Context, string, Options) (*Client, error)) {
|
2020-03-16 13:49:56 +00:00
|
|
|
for method, testBatch := range rpcClientTestCases {
|
|
|
|
t.Run(method, func(t *testing.T) {
|
|
|
|
for _, testCase := range testBatch {
|
|
|
|
t.Run(testCase.name, func(t *testing.T) {
|
|
|
|
srv := initTestServer(t, testCase.serverResponse)
|
|
|
|
|
|
|
|
endpoint := srv.URL
|
2020-10-14 15:13:20 +00:00
|
|
|
opts := Options{}
|
2020-04-29 19:51:43 +00:00
|
|
|
c, err := newClient(context.TODO(), endpoint, opts)
|
2020-03-16 13:49:56 +00:00
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
2022-02-18 17:28:13 +00:00
|
|
|
c.getNextRequestID = getTestRequestID
|
2020-03-16 13:49:56 +00:00
|
|
|
|
|
|
|
actual, err := testCase.invoke(c)
|
2020-12-14 12:23:39 +00:00
|
|
|
if testCase.fails {
|
|
|
|
assert.Error(t, err)
|
2020-03-16 13:49:56 +00:00
|
|
|
} else {
|
2020-12-14 12:23:39 +00:00
|
|
|
assert.NoError(t, err)
|
|
|
|
|
|
|
|
expected := testCase.result(c)
|
|
|
|
if testCase.check == nil {
|
|
|
|
assert.Equal(t, expected, actual)
|
|
|
|
} else {
|
|
|
|
testCase.check(t, c, actual)
|
|
|
|
}
|
2020-03-16 13:49:56 +00:00
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
|
|
|
for serverResponse, testBatch := range rpcClientErrorCases {
|
|
|
|
srv := initTestServer(t, serverResponse)
|
|
|
|
|
|
|
|
endpoint := srv.URL
|
2020-10-14 15:13:20 +00:00
|
|
|
opts := Options{}
|
2020-03-16 13:49:56 +00:00
|
|
|
for _, testCase := range testBatch {
|
|
|
|
t.Run(testCase.name, func(t *testing.T) {
|
2022-02-18 17:28:13 +00:00
|
|
|
c, err := newClient(context.TODO(), endpoint, opts)
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
c.getNextRequestID = getTestRequestID
|
|
|
|
_, err = testCase.invoke(c)
|
2020-03-16 13:49:56 +00:00
|
|
|
assert.Error(t, err)
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-04-29 19:51:43 +00:00
|
|
|
func httpURLtoWS(url string) string {
|
|
|
|
return "ws" + strings.TrimPrefix(url, "http") + "/ws"
|
|
|
|
}
|
|
|
|
|
2020-03-16 13:49:56 +00:00
|
|
|
func initTestServer(t *testing.T, resp string) *httptest.Server {
|
|
|
|
srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) {
|
2020-04-29 19:51:43 +00:00
|
|
|
if req.URL.Path == "/ws" && req.Method == "GET" {
|
|
|
|
var upgrader = websocket.Upgrader{}
|
|
|
|
ws, err := upgrader.Upgrade(w, req, nil)
|
|
|
|
require.NoError(t, err)
|
|
|
|
for {
|
2024-04-02 07:31:38 +00:00
|
|
|
err = ws.SetReadDeadline(time.Now().Add(5 * time.Second))
|
2021-05-12 18:34:07 +00:00
|
|
|
require.NoError(t, err)
|
2020-10-14 15:13:20 +00:00
|
|
|
_, p, err := ws.ReadMessage()
|
2020-04-29 19:51:43 +00:00
|
|
|
if err != nil {
|
|
|
|
break
|
|
|
|
}
|
2022-07-07 14:41:01 +00:00
|
|
|
r := params.NewIn()
|
2020-10-14 15:13:20 +00:00
|
|
|
err = json.Unmarshal(p, r)
|
|
|
|
if err != nil {
|
|
|
|
t.Fatalf("Cannot decode request body: %s", req.Body)
|
|
|
|
}
|
2020-09-25 16:32:53 +00:00
|
|
|
response := wrapInitResponse(r, resp)
|
2024-04-02 07:31:38 +00:00
|
|
|
err = ws.SetWriteDeadline(time.Now().Add(5 * time.Second))
|
2021-05-12 18:34:07 +00:00
|
|
|
require.NoError(t, err)
|
2020-10-14 15:13:20 +00:00
|
|
|
err = ws.WriteMessage(1, []byte(response))
|
2020-04-29 19:51:43 +00:00
|
|
|
if err != nil {
|
|
|
|
break
|
|
|
|
}
|
|
|
|
}
|
|
|
|
ws.Close()
|
|
|
|
return
|
|
|
|
}
|
2022-07-07 14:41:01 +00:00
|
|
|
r := params.NewRequest()
|
2020-10-14 15:13:20 +00:00
|
|
|
err := r.DecodeData(req.Body)
|
|
|
|
if err != nil {
|
|
|
|
t.Fatalf("Cannot decode request body: %s", req.Body)
|
|
|
|
}
|
2020-10-26 17:22:20 +00:00
|
|
|
requestHandler(t, r.In, w, resp)
|
2020-03-16 13:49:56 +00:00
|
|
|
}))
|
|
|
|
|
2021-03-01 11:14:15 +00:00
|
|
|
t.Cleanup(srv.Close)
|
|
|
|
|
2020-03-16 13:49:56 +00:00
|
|
|
return srv
|
|
|
|
}
|
|
|
|
|
2022-07-07 14:41:01 +00:00
|
|
|
func requestHandler(t *testing.T, r *params.In, w http.ResponseWriter, resp string) {
|
2020-03-16 13:49:56 +00:00
|
|
|
w.Header().Set("Content-Type", "application/json; charset=utf-8")
|
2020-09-25 16:32:53 +00:00
|
|
|
response := wrapInitResponse(r, resp)
|
|
|
|
_, err := w.Write([]byte(response))
|
|
|
|
if err != nil {
|
|
|
|
t.Fatalf("Error writing response: %s", err.Error())
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-07-07 14:41:01 +00:00
|
|
|
func wrapInitResponse(r *params.In, resp string) string {
|
2020-10-14 15:13:20 +00:00
|
|
|
var response string
|
2020-09-25 16:32:53 +00:00
|
|
|
switch r.Method {
|
2020-10-14 15:13:20 +00:00
|
|
|
case "getversion":
|
2024-04-01 14:56:17 +00:00
|
|
|
response = `{"id":1,"jsonrpc":"2.0","result":{"protocol":{"network":42},"tcpport":20332,"wsport":20342,"nonce":2153672787,"useragent":"/NEO-GO:0.73.1-pre-273-ge381358/", "rpc": {"maxiteratorresultitems": 100, "sessionenabled": true}}}`
|
2022-05-06 10:56:09 +00:00
|
|
|
case "getnativecontracts":
|
|
|
|
response = `{"jsonrpc":"2.0","id":1,"result":[{"id":-1,"hash":"0xfffdc93764dbaddd97c48f252a53ea4643faa3fd","nef":{"magic":860243278,"compiler":"neo-core-v3.0","source":"","tokens":[],"script":"EEEa93tnQBBBGvd7Z0AQQRr3e2dAEEEa93tnQBBBGvd7Z0AQQRr3e2dAEEEa93tnQBBBGvd7Z0A=","checksum":1110259869},"manifest":{"name":"ContractManagement","groups":[],"features":{},"supportedstandards":[],"abi":{"methods":[{"name":"deploy","parameters":[{"name":"nefFile","type":"ByteArray"},{"name":"manifest","type":"ByteArray"}],"returntype":"Array","offset":0,"safe":false},{"name":"deploy","parameters":[{"name":"nefFile","type":"ByteArray"},{"name":"manifest","type":"ByteArray"},{"name":"data","type":"Any"}],"returntype":"Array","offset":7,"safe":false},{"name":"destroy","parameters":[],"returntype":"Void","offset":14,"safe":false},{"name":"getContract","parameters":[{"name":"hash","type":"Hash160"}],"returntype":"Array","offset":21,"safe":true},{"name":"getMinimumDeploymentFee","parameters":[],"returntype":"Integer","offset":28,"safe":true},{"name":"setMinimumDeploymentFee","parameters":[{"name":"value","type":"Integer"}],"returntype":"Void","offset":35,"safe":false},{"name":"update","parameters":[{"name":"nefFile","type":"ByteArray"},{"name":"manifest","type":"ByteArray"}],"returntype":"Void","offset":42,"safe":false},{"name":"update","parameters":[{"name":"nefFile","type":"ByteArray"},{"name":"manifest","type":"ByteArray"},{"name":"data","type":"Any"}],"returntype":"Void","offset":49,"safe":false}],"events":[{"name":"Deploy","parameters":[{"name":"Hash","type":"Hash160"}]},{"name":"Update","parameters":[{"name":"Hash","type":"Hash160"}]},{"name":"Destroy","parameters":[{"name":"Hash","type":"Hash160"}]}]},"permissions":[{"contract":"*","methods":"*"}],"trusts":[],"extra":null},"updatehistory":[0]},{"id":-2,"hash":"0xacce6fd80d44e1796aa0c2c625e9e4e0ce39efc0","nef":{"magic":860243278,"compiler":"neo-core-v3.0","source":"","tokens":[],"script":"EEEa93tnQBBBGvd7Z0AQQRr3e2dAEEEa93tnQBBBGvd7Z0AQQRr3e2dAEEEa93tnQBBBGvd7Z0AQQRr3e2dAEEEa93tnQBBBGvd7Z0AQQRr3e2dAEEEa93tnQBBBGvd7Z0AQQRr3e2dAEEEa93tnQBBBGvd7Z0AQQRr3e2dAEEEa93tnQBBBGvd7Z0A=","checksum":1325686241},"manifest":{"name":"StdLib","groups":[],"features":{},"supportedstandards":[],"abi":{"methods":[{"name":"atoi","parameters":[{"name":"value","type":"String"}],"returntype":"Integer","offset":0,"safe":true},{"name":"atoi","parameters":[{"name":"value","type":"String"},{"name":"base","type":"Integer"}],"returntype":"Integer","offset":7,"safe":true},{"name":"base58CheckDecode","parameters":[{"name":"s","type":"String"}],"returntype":"ByteArray","offset":14,"safe":true},{"name":"base58CheckEncode","parameters":[{"name":"data","type":"ByteArray"}],"returntype":"String","offset":21,"safe":true},{"name":"base58Decode","parameters":[{"name":"s","type":"String"}],"returntype":"ByteArray","offset":28,"safe":true},{"name":"base58Encode","parameters":[{"name":"data","type":"ByteArray"}],"returntype":"String","offset":35,"safe":true},{"name":"base64Decode","parameters":[{"name":"s","type":"String"}],"returntype":"ByteArray","offset":42,"safe":true},{"name":"base64Encode","parameters":[{"name":"data","type":"ByteArray"}],"returntype":"String","offset":49,"safe":true},{"name":"deserialize","parameters":[{"name":"data","type":"ByteArray"}],"returntype":"Any","offset":56,"safe":true},{"name":"itoa","parameters":[{"name":"value","type":"Integer"}],"returntype":"String","offset":63,"safe":true},{"name":"itoa","parameters":[{"name":"value","type":"Integer"},{"name":"base","type":"Integer"}],"returntype":"String","offset":70,"safe":true},{"name":"jsonDeserialize","parameters":[{"name":"json","type":"ByteArray"}],"returntype":"Any","offset":77,"safe":true},{"name":"jsonSerialize","parameters":[{"name":"item","type":"Any"}],"returntype":"ByteArray","offset":84,"safe":true},{"name":"memoryCompare","parameters":[{"name":"str1","type":"ByteArray"},{"name":"str2","type":"ByteArray"}],"returntype":"Integer","offset":91,"safe":true},{"name":"memorySearch","parameters":[{"name":"mem","type":"ByteArray"},{"name":"value","
|
2020-09-25 16:32:53 +00:00
|
|
|
case "getcontractstate":
|
2022-07-07 14:41:01 +00:00
|
|
|
p := params.Params(r.RawParams)
|
2021-10-28 11:10:18 +00:00
|
|
|
name, _ := p.Value(0).GetString()
|
2020-09-25 16:32:53 +00:00
|
|
|
switch name {
|
2020-12-13 18:25:04 +00:00
|
|
|
case "NeoToken":
|
2020-11-20 08:02:58 +00:00
|
|
|
response = `{"id":1,"jsonrpc":"2.0","result":{"id":-1,"script":"DANORU9Ba2d4Cw==","manifest":{"name":"NEO","abi":{"hash":"0xde5f57d430d3dece511cf975a8d37848cb9e0525","methods":[{"name":"name","offset":0,"parameters":null,"returntype":"String"},{"name":"symbol","offset":0,"parameters":null,"returntype":"String"},{"name":"decimals","offset":0,"parameters":null,"returntype":"Integer"},{"name":"totalSupply","offset":0,"parameters":null,"returntype":"Integer"},{"name":"balanceOf","offset":0,"parameters":[{"name":"account","type":"Hash160"}],"returntype":"Integer"},{"name":"transfer","offset":0,"parameters":[{"name":"from","type":"Hash160"},{"name":"to","type":"Hash160"},{"name":"amount","type":"Integer"}],"returntype":"Boolean"},{"name":"onPersist","offset":0,"parameters":null,"returntype":"Void"},{"name":"postPersist","offset":0,"parameters":null,"returntype":"Void"},{"name":"unclaimedGas","offset":0,"parameters":[{"name":"account","type":"Hash160"},{"name":"end","type":"Integer"}],"returntype":"Integer"},{"name":"registerCandidate","offset":0,"parameters":[{"name":"pubkey","type":"PublicKey"}],"returntype":"Boolean"},{"name":"unregisterCandidate","offset":0,"parameters":[{"name":"pubkey","type":"PublicKey"}],"returntype":"Boolean"},{"name":"vote","offset":0,"parameters":[{"name":"account","type":"Hash160"},{"name":"pubkey","type":"PublicKey"}],"returntype":"Boolean"},{"name":"getCandidates","offset":0,"parameters":null,"returntype":"Array"},{"name":"getСommittee","offset":0,"parameters":null,"returntype":"Array"},{"name":"getNextBlockValidators","offset":0,"parameters":null,"returntype":"Array"},{"name":"getGasPerBlock","offset":0,"parameters":null,"returntype":"Integer"},{"name":"setGasPerBlock","offset":0,"parameters":[{"name":"gasPerBlock","type":"Integer"}],"returntype":"Boolean"}],"events":[{"name":"Transfer","parameters":null}]},"groups":[],"permissions":[{"contract":"*","methods":"*"}],"supportedstandards":["NEP-5"],"trusts":[],"safemethods":["name","symbol","decimals","totalSupply","balanceOf","unclaimedGas","getCandidates","getСommittee","getNextBlockValidators"],"extra":null},"hash":"0xde5f57d430d3dece511cf975a8d37848cb9e0525"}}`
|
2020-12-13 18:25:04 +00:00
|
|
|
case "GasToken":
|
2020-11-20 08:02:58 +00:00
|
|
|
response = `{"id":1,"jsonrpc":"2.0","result":{"id":-2,"script":"DANHQVNBa2d4Cw==","manifest":{"name":"GAS","abi":{"hash":"0x668e0c1f9d7b70a99dd9e06eadd4c784d641afbc","methods":[{"name":"name","offset":0,"parameters":null,"returntype":"String"},{"name":"symbol","offset":0,"parameters":null,"returntype":"String"},{"name":"decimals","offset":0,"parameters":null,"returntype":"Integer"},{"name":"totalSupply","offset":0,"parameters":null,"returntype":"Integer"},{"name":"balanceOf","offset":0,"parameters":[{"name":"account","type":"Hash160"}],"returntype":"Integer"},{"name":"transfer","offset":0,"parameters":[{"name":"from","type":"Hash160"},{"name":"to","type":"Hash160"},{"name":"amount","type":"Integer"}],"returntype":"Boolean"},{"name":"onPersist","offset":0,"parameters":null,"returntype":"Void"},{"name":"postPersist","offset":0,"parameters":null,"returntype":"Void"}],"events":[{"name":"Transfer","parameters":null}]},"groups":[],"permissions":[{"contract":"*","methods":"*"}],"supportedstandards":["NEP-5"],"trusts":[],"safemethods":["name","symbol","decimals","totalSupply","balanceOf"],"extra":null},"hash":"0x668e0c1f9d7b70a99dd9e06eadd4c784d641afbc"}}`
|
2020-12-13 18:25:04 +00:00
|
|
|
case "PolicyContract":
|
2020-12-13 16:08:47 +00:00
|
|
|
response = `{"id":1,"jsonrpc":"2.0","result":{"id":-3,"updatecounter":0,"hash":"0xac593e6183643940a9193f87c64ccf55ef19c529","script":"DAZQb2xpY3lBGvd7Zw==","manifest":{"name":"Policy","abi":{"methods":[{"name":"getMaxTransactionsPerBlock","offset":0,"parameters":null,"returntype":"Integer"},{"name":"getMaxBlockSize","offset":0,"parameters":null,"returntype":"Integer"},{"name":"getFeePerByte","offset":0,"parameters":null,"returntype":"Integer"},{"name":"isBlocked","offset":0,"parameters":[{"name":"account","type":"Hash160"}],"returntype":"Boolean"},{"name":"getMaxBlockSystemFee","offset":0,"parameters":null,"returntype":"Integer"},{"name":"setMaxBlockSize","offset":0,"parameters":[{"name":"value","type":"Integer"}],"returntype":"Boolean"},{"name":"setMaxTransactionsPerBlock","offset":0,"parameters":[{"name":"value","type":"Integer"}],"returntype":"Boolean"},{"name":"setFeePerByte","offset":0,"parameters":[{"name":"value","type":"Integer"}],"returntype":"Boolean"},{"name":"setMaxBlockSystemFee","offset":0,"parameters":[{"name":"value","type":"Integer"}],"returntype":"Boolean"},{"name":"blockAccount","offset":0,"parameters":[{"name":"account","type":"Hash160"}],"returntype":"Boolean"},{"name":"unblockAccount","offset":0,"parameters":[{"name":"account","type":"Hash160"}],"returntype":"Boolean"}],"events":[]},"groups":[],"permissions":[{"contract":"*","methods":"*"}],"supportedstandards":[],"trusts":[],"safemethods":["getMaxTransactionsPerBlock","getMaxBlockSize","getFeePerByte","isBlocked","getMaxBlockSystemFee"],"extra":null}}}`
|
2020-09-25 16:32:53 +00:00
|
|
|
default:
|
|
|
|
response = resp
|
|
|
|
}
|
2020-10-14 15:13:20 +00:00
|
|
|
default:
|
|
|
|
response = resp
|
|
|
|
}
|
2020-09-25 16:32:53 +00:00
|
|
|
return response
|
2020-03-16 13:49:56 +00:00
|
|
|
}
|
2020-04-15 06:50:13 +00:00
|
|
|
|
2020-12-13 16:08:47 +00:00
|
|
|
func TestUninitedClient(t *testing.T) {
|
|
|
|
srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) {
|
2022-07-07 14:41:01 +00:00
|
|
|
r := params.NewRequest()
|
2020-12-13 16:08:47 +00:00
|
|
|
err := r.DecodeData(req.Body)
|
|
|
|
require.NoErrorf(t, err, "Cannot decode request body: %s", req.Body)
|
|
|
|
// request handler already have `getversion` response wrapper
|
|
|
|
requestHandler(t, r.In, w, "")
|
|
|
|
}))
|
2021-03-01 11:14:15 +00:00
|
|
|
t.Cleanup(srv.Close)
|
2020-12-13 16:08:47 +00:00
|
|
|
endpoint := srv.URL
|
|
|
|
opts := Options{}
|
|
|
|
|
|
|
|
c, err := New(context.TODO(), endpoint, opts)
|
|
|
|
require.NoError(t, err)
|
2022-02-18 17:28:13 +00:00
|
|
|
c.getNextRequestID = getTestRequestID
|
2020-12-13 16:08:47 +00:00
|
|
|
|
|
|
|
_, err = c.GetBlockByIndex(0)
|
|
|
|
require.Error(t, err)
|
|
|
|
_, err = c.GetBlockByIndexVerbose(0)
|
|
|
|
require.Error(t, err)
|
|
|
|
_, err = c.GetBlockHeader(util.Uint256{})
|
|
|
|
require.Error(t, err)
|
|
|
|
_, err = c.GetRawTransaction(util.Uint256{})
|
|
|
|
require.Error(t, err)
|
|
|
|
_, err = c.GetRawTransactionVerbose(util.Uint256{})
|
|
|
|
require.Error(t, err)
|
|
|
|
}
|
2021-01-13 12:34:10 +00:00
|
|
|
|
|
|
|
func newTestNEF(script []byte) nef.File {
|
|
|
|
var ne nef.File
|
|
|
|
ne.Header.Magic = nef.Magic
|
2021-01-19 08:08:34 +00:00
|
|
|
ne.Header.Compiler = "neo-go-3.0"
|
2021-01-13 12:34:10 +00:00
|
|
|
ne.Script = script
|
|
|
|
ne.Checksum = ne.CalculateChecksum()
|
|
|
|
return ne
|
|
|
|
}
|
2022-02-18 17:28:13 +00:00
|
|
|
|
|
|
|
func getTestRequestID() uint64 {
|
|
|
|
return 1
|
|
|
|
}
|