2013-10-22 16:12:12 +02:00
|
|
|
// Copyright (c) 2013 Conformal Systems LLC.
|
|
|
|
// Use of this source code is governed by an ISC
|
|
|
|
// license that can be found in the LICENSE file.
|
|
|
|
|
|
|
|
// this has to be in the real json subpackage so we can mock up structs
|
|
|
|
package btcjson
|
|
|
|
|
|
|
|
import (
|
|
|
|
"encoding/json"
|
|
|
|
"github.com/davecgh/go-spew/spew"
|
|
|
|
"reflect"
|
|
|
|
"testing"
|
|
|
|
)
|
|
|
|
|
2014-01-03 23:50:17 +01:00
|
|
|
var testId = float64(1)
|
|
|
|
|
2013-10-22 16:12:12 +02:00
|
|
|
var jsoncmdtests = []struct {
|
|
|
|
name string
|
|
|
|
f func() (Cmd, error)
|
|
|
|
result Cmd // after marshal and unmarshal
|
|
|
|
}{
|
|
|
|
{
|
|
|
|
name: "basic addmultisigaddress",
|
|
|
|
f: func() (Cmd, error) {
|
2014-01-03 23:50:17 +01:00
|
|
|
return NewAddMultisigAddressCmd(testId, 1,
|
2013-10-22 16:12:12 +02:00
|
|
|
[]string{"foo", "bar"})
|
|
|
|
},
|
|
|
|
result: &AddMultisigAddressCmd{
|
2014-01-03 23:50:17 +01:00
|
|
|
id: testId,
|
2013-10-22 16:12:12 +02:00
|
|
|
NRequired: 1,
|
|
|
|
Keys: []string{"foo", "bar"},
|
|
|
|
Account: "",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "addmultisigaddress + optional",
|
|
|
|
f: func() (Cmd, error) {
|
2014-01-03 23:50:17 +01:00
|
|
|
return NewAddMultisigAddressCmd(testId, 1,
|
2013-10-22 16:12:12 +02:00
|
|
|
[]string{"foo", "bar"}, "address")
|
|
|
|
},
|
|
|
|
result: &AddMultisigAddressCmd{
|
2014-01-03 23:50:17 +01:00
|
|
|
id: testId,
|
2013-10-22 16:12:12 +02:00
|
|
|
NRequired: 1,
|
|
|
|
Keys: []string{"foo", "bar"},
|
|
|
|
Account: "address",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
// TODO(oga) Too many arguments to newaddmultisigaddress
|
|
|
|
{
|
|
|
|
name: "basic addnode add",
|
|
|
|
f: func() (Cmd, error) {
|
2014-01-03 23:50:17 +01:00
|
|
|
return NewAddNodeCmd(testId, "address",
|
2013-10-22 16:12:12 +02:00
|
|
|
"add")
|
|
|
|
},
|
|
|
|
result: &AddNodeCmd{
|
2014-01-03 23:50:17 +01:00
|
|
|
id: testId,
|
2013-10-22 16:12:12 +02:00
|
|
|
Addr: "address",
|
|
|
|
SubCmd: "add",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
2013-10-25 19:07:45 +02:00
|
|
|
name: "basic addnode remove",
|
2013-10-22 16:12:12 +02:00
|
|
|
f: func() (Cmd, error) {
|
2014-01-03 23:50:17 +01:00
|
|
|
return NewAddNodeCmd(testId, "address",
|
2013-10-22 16:12:12 +02:00
|
|
|
"remove")
|
|
|
|
},
|
|
|
|
result: &AddNodeCmd{
|
2014-01-03 23:50:17 +01:00
|
|
|
id: testId,
|
2013-10-22 16:12:12 +02:00
|
|
|
Addr: "address",
|
|
|
|
SubCmd: "remove",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "basic addnode onetry",
|
|
|
|
f: func() (Cmd, error) {
|
2014-01-03 23:50:17 +01:00
|
|
|
return NewAddNodeCmd(testId, "address",
|
2013-10-22 16:12:12 +02:00
|
|
|
"onetry")
|
|
|
|
},
|
|
|
|
result: &AddNodeCmd{
|
2014-01-03 23:50:17 +01:00
|
|
|
id: testId,
|
2013-10-22 16:12:12 +02:00
|
|
|
Addr: "address",
|
|
|
|
SubCmd: "onetry",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
// TODO(oga) try invalid subcmds
|
|
|
|
{
|
|
|
|
name: "basic backupwallet",
|
|
|
|
f: func() (Cmd, error) {
|
2014-01-03 23:50:17 +01:00
|
|
|
return NewBackupWalletCmd(testId, "destination")
|
2013-10-22 16:12:12 +02:00
|
|
|
},
|
|
|
|
result: &BackupWalletCmd{
|
2014-01-03 23:50:17 +01:00
|
|
|
id: testId,
|
2013-10-22 16:12:12 +02:00
|
|
|
Destination: "destination",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "basic createmultisig",
|
|
|
|
f: func() (Cmd, error) {
|
2014-01-03 23:50:17 +01:00
|
|
|
return NewCreateMultisigCmd(testId, 1,
|
2013-10-22 16:12:12 +02:00
|
|
|
[]string{"key1", "key2", "key3"})
|
|
|
|
},
|
|
|
|
result: &CreateMultisigCmd{
|
2014-01-03 23:50:17 +01:00
|
|
|
id: testId,
|
2013-10-22 16:12:12 +02:00
|
|
|
NRequired: 1,
|
|
|
|
Keys: []string{"key1", "key2", "key3"},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "basic createrawtransaction",
|
|
|
|
f: func() (Cmd, error) {
|
2014-01-03 23:50:17 +01:00
|
|
|
return NewCreateRawTransactionCmd(testId,
|
2013-10-22 16:12:12 +02:00
|
|
|
[]TransactionInput{
|
|
|
|
TransactionInput{Txid: "tx1", Vout: 1},
|
|
|
|
TransactionInput{Txid: "tx2", Vout: 3}},
|
|
|
|
map[string]int64{"bob": 1, "bill": 2})
|
|
|
|
},
|
|
|
|
result: &CreateRawTransactionCmd{
|
2014-01-03 23:50:17 +01:00
|
|
|
id: testId,
|
2013-10-22 16:12:12 +02:00
|
|
|
Inputs: []TransactionInput{
|
|
|
|
TransactionInput{Txid: "tx1", Vout: 1},
|
|
|
|
TransactionInput{Txid: "tx2", Vout: 3},
|
|
|
|
},
|
|
|
|
Amounts: map[string]int64{
|
|
|
|
"bob": 1,
|
|
|
|
"bill": 2,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2013-11-22 17:01:41 +01:00
|
|
|
{
|
|
|
|
name: "basic debuglevel",
|
|
|
|
f: func() (Cmd, error) {
|
2014-01-03 23:50:17 +01:00
|
|
|
return NewDebugLevelCmd(testId, "debug")
|
2013-11-22 17:01:41 +01:00
|
|
|
},
|
|
|
|
result: &DebugLevelCmd{
|
2014-01-03 23:50:17 +01:00
|
|
|
id: testId,
|
2013-11-22 17:01:41 +01:00
|
|
|
LevelSpec: "debug",
|
|
|
|
},
|
|
|
|
},
|
2013-10-25 18:22:07 +02:00
|
|
|
{
|
|
|
|
name: "basic decoderawtransaction",
|
|
|
|
f: func() (Cmd, error) {
|
2014-01-03 23:50:17 +01:00
|
|
|
return NewDecodeRawTransactionCmd(testId,
|
2013-10-25 18:22:07 +02:00
|
|
|
"thisisahexidecimaltransaction")
|
|
|
|
},
|
|
|
|
result: &DecodeRawTransactionCmd{
|
2014-01-03 23:50:17 +01:00
|
|
|
id: testId,
|
2013-10-25 18:22:07 +02:00
|
|
|
HexTx: "thisisahexidecimaltransaction",
|
|
|
|
},
|
|
|
|
},
|
2013-10-31 21:37:14 +01:00
|
|
|
{
|
|
|
|
name: "basic decodescript",
|
|
|
|
f: func() (Cmd, error) {
|
2014-01-03 23:50:17 +01:00
|
|
|
return NewDecodeScriptCmd(testId,
|
2013-10-31 21:37:14 +01:00
|
|
|
"a bunch of hex")
|
|
|
|
},
|
|
|
|
result: &DecodeScriptCmd{
|
2014-01-03 23:50:17 +01:00
|
|
|
id: testId,
|
2013-10-31 21:37:14 +01:00
|
|
|
HexScript: "a bunch of hex",
|
|
|
|
},
|
|
|
|
},
|
2013-10-25 18:47:11 +02:00
|
|
|
{
|
|
|
|
name: "basic dumpprivkey",
|
|
|
|
f: func() (Cmd, error) {
|
2014-01-03 23:50:17 +01:00
|
|
|
return NewDumpPrivKeyCmd(testId,
|
2013-10-25 18:47:11 +02:00
|
|
|
"address")
|
|
|
|
},
|
|
|
|
result: &DumpPrivKeyCmd{
|
2014-01-03 23:50:17 +01:00
|
|
|
id: testId,
|
2013-10-25 18:47:11 +02:00
|
|
|
Address: "address",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "basic dumpwallet",
|
|
|
|
f: func() (Cmd, error) {
|
2014-01-03 23:50:17 +01:00
|
|
|
return NewDumpWalletCmd(testId,
|
2013-10-25 18:47:11 +02:00
|
|
|
"filename")
|
|
|
|
},
|
|
|
|
result: &DumpWalletCmd{
|
2014-01-03 23:50:17 +01:00
|
|
|
id: testId,
|
2013-10-25 18:47:11 +02:00
|
|
|
Filename: "filename",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "basic encryptwallet",
|
|
|
|
f: func() (Cmd, error) {
|
2014-01-03 23:50:17 +01:00
|
|
|
return NewEncryptWalletCmd(testId,
|
2013-10-25 18:47:11 +02:00
|
|
|
"passphrase")
|
|
|
|
},
|
|
|
|
result: &EncryptWalletCmd{
|
2014-01-03 23:50:17 +01:00
|
|
|
id: testId,
|
2013-10-25 18:47:11 +02:00
|
|
|
Passphrase: "passphrase",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "basic getaccount",
|
|
|
|
f: func() (Cmd, error) {
|
2014-01-03 23:50:17 +01:00
|
|
|
return NewGetAccountCmd(testId,
|
2013-10-25 18:47:11 +02:00
|
|
|
"address")
|
|
|
|
},
|
|
|
|
result: &GetAccountCmd{
|
2014-01-03 23:50:17 +01:00
|
|
|
id: testId,
|
2013-10-25 18:47:11 +02:00
|
|
|
Address: "address",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "basic getaccountaddress",
|
|
|
|
f: func() (Cmd, error) {
|
2014-01-03 23:50:17 +01:00
|
|
|
return NewGetAccountAddressCmd(testId,
|
2013-10-25 18:47:11 +02:00
|
|
|
"account")
|
|
|
|
},
|
|
|
|
result: &GetAccountAddressCmd{
|
2014-01-03 23:50:17 +01:00
|
|
|
id: testId,
|
2013-10-25 18:47:11 +02:00
|
|
|
Account: "account",
|
|
|
|
},
|
|
|
|
},
|
2013-10-25 19:23:28 +02:00
|
|
|
{
|
|
|
|
name: "basic getaddednodeinfo true",
|
|
|
|
f: func() (Cmd, error) {
|
2014-01-03 23:50:17 +01:00
|
|
|
return NewGetAddedNodeInfoCmd(testId, true)
|
2013-10-25 19:23:28 +02:00
|
|
|
},
|
|
|
|
result: &GetAddedNodeInfoCmd{
|
2014-01-03 23:50:17 +01:00
|
|
|
id: testId,
|
2013-10-25 19:23:28 +02:00
|
|
|
Dns: true,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "basic getaddednodeinfo false",
|
|
|
|
f: func() (Cmd, error) {
|
2014-01-03 23:50:17 +01:00
|
|
|
return NewGetAddedNodeInfoCmd(testId, false)
|
2013-10-25 19:23:28 +02:00
|
|
|
},
|
|
|
|
result: &GetAddedNodeInfoCmd{
|
2014-01-03 23:50:17 +01:00
|
|
|
id: testId,
|
2013-10-25 19:23:28 +02:00
|
|
|
Dns: false,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "basic getaddednodeinfo withnode",
|
|
|
|
f: func() (Cmd, error) {
|
2014-01-03 23:50:17 +01:00
|
|
|
return NewGetAddedNodeInfoCmd(testId, true,
|
2013-10-25 19:23:28 +02:00
|
|
|
"thisisanode")
|
|
|
|
},
|
|
|
|
result: &GetAddedNodeInfoCmd{
|
2014-01-03 23:50:17 +01:00
|
|
|
id: testId,
|
2013-10-25 19:23:53 +02:00
|
|
|
Dns: true,
|
2013-10-25 19:23:28 +02:00
|
|
|
Node: "thisisanode",
|
|
|
|
},
|
|
|
|
},
|
2013-10-25 19:32:51 +02:00
|
|
|
{
|
|
|
|
name: "basic getaddressesbyaccount",
|
|
|
|
f: func() (Cmd, error) {
|
2014-01-03 23:50:17 +01:00
|
|
|
return NewGetAddressesByAccountCmd(testId,
|
2013-10-25 19:32:51 +02:00
|
|
|
"account")
|
|
|
|
},
|
|
|
|
result: &GetAddressesByAccountCmd{
|
2014-01-03 23:50:17 +01:00
|
|
|
id: testId,
|
2013-10-25 19:32:51 +02:00
|
|
|
Account: "account",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "basic getbalance",
|
|
|
|
f: func() (Cmd, error) {
|
2014-01-03 23:50:17 +01:00
|
|
|
return NewGetBalanceCmd(testId)
|
2013-10-25 19:32:51 +02:00
|
|
|
},
|
|
|
|
result: &GetBalanceCmd{
|
2014-01-03 23:50:17 +01:00
|
|
|
id: testId,
|
2013-10-25 21:41:23 +02:00
|
|
|
MinConf: 1, // the default
|
2013-10-25 19:32:51 +02:00
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "basic getbalance + account",
|
|
|
|
f: func() (Cmd, error) {
|
2014-01-03 23:50:17 +01:00
|
|
|
return NewGetBalanceCmd(testId, "account")
|
2013-10-25 19:32:51 +02:00
|
|
|
},
|
|
|
|
result: &GetBalanceCmd{
|
2014-01-03 23:50:17 +01:00
|
|
|
id: testId,
|
2013-10-25 19:32:51 +02:00
|
|
|
Account: "account",
|
2013-10-25 21:41:23 +02:00
|
|
|
MinConf: 1, // the default
|
2013-10-25 19:32:51 +02:00
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "basic getbalance + minconf",
|
|
|
|
f: func() (Cmd, error) {
|
2014-01-03 23:50:17 +01:00
|
|
|
return NewGetBalanceCmd(testId, "", 2)
|
2013-10-25 19:32:51 +02:00
|
|
|
},
|
|
|
|
result: &GetBalanceCmd{
|
2014-01-03 23:50:17 +01:00
|
|
|
id: testId,
|
2013-10-25 21:41:23 +02:00
|
|
|
MinConf: 2,
|
2013-10-25 19:32:51 +02:00
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "basic getbalance + account + minconf",
|
|
|
|
f: func() (Cmd, error) {
|
2014-01-03 23:50:17 +01:00
|
|
|
return NewGetBalanceCmd(testId, "account", 2)
|
2013-10-25 19:32:51 +02:00
|
|
|
},
|
|
|
|
result: &GetBalanceCmd{
|
2014-01-03 23:50:17 +01:00
|
|
|
id: testId,
|
2013-10-25 19:32:51 +02:00
|
|
|
Account: "account",
|
2013-10-25 21:41:23 +02:00
|
|
|
MinConf: 2,
|
2013-10-25 19:32:51 +02:00
|
|
|
},
|
|
|
|
},
|
2013-10-22 16:12:12 +02:00
|
|
|
{
|
2013-10-25 19:36:27 +02:00
|
|
|
name: "basic getbestblockhash",
|
2013-10-22 16:12:12 +02:00
|
|
|
f: func() (Cmd, error) {
|
2014-01-03 23:50:17 +01:00
|
|
|
return NewGetBestBlockHashCmd(testId)
|
2013-10-22 16:12:12 +02:00
|
|
|
},
|
2013-10-25 19:36:27 +02:00
|
|
|
result: &GetBestBlockHashCmd{
|
2014-01-03 23:50:17 +01:00
|
|
|
id: testId,
|
2013-10-22 16:12:12 +02:00
|
|
|
},
|
|
|
|
},
|
2013-10-25 19:36:27 +02:00
|
|
|
{
|
|
|
|
name: "basic getblock",
|
|
|
|
f: func() (Cmd, error) {
|
2014-01-03 23:50:17 +01:00
|
|
|
return NewGetBlockCmd(testId,
|
2013-10-25 19:36:27 +02:00
|
|
|
"somehash")
|
|
|
|
},
|
|
|
|
result: &GetBlockCmd{
|
2014-01-03 23:50:17 +01:00
|
|
|
id: testId,
|
2013-12-11 00:13:42 +01:00
|
|
|
Hash: "somehash",
|
|
|
|
Verbose: true,
|
2013-10-25 19:36:27 +02:00
|
|
|
},
|
|
|
|
},
|
2013-10-22 16:12:12 +02:00
|
|
|
{
|
|
|
|
name: "basic getblockcount",
|
|
|
|
f: func() (Cmd, error) {
|
2014-01-03 23:50:17 +01:00
|
|
|
return NewGetBlockCountCmd(testId)
|
2013-10-22 16:12:12 +02:00
|
|
|
},
|
|
|
|
result: &GetBlockCountCmd{
|
2014-01-03 23:50:17 +01:00
|
|
|
id: testId,
|
2013-10-22 16:12:12 +02:00
|
|
|
},
|
|
|
|
},
|
2013-10-25 20:00:33 +02:00
|
|
|
{
|
|
|
|
name: "basic getblockhash",
|
|
|
|
f: func() (Cmd, error) {
|
2014-01-03 23:50:17 +01:00
|
|
|
return NewGetBlockHashCmd(testId, 1234)
|
2013-10-25 20:00:33 +02:00
|
|
|
},
|
|
|
|
result: &GetBlockHashCmd{
|
2014-01-03 23:50:17 +01:00
|
|
|
id: testId,
|
2013-10-25 20:00:33 +02:00
|
|
|
Index: 1234,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "basic getblocktemplate",
|
|
|
|
f: func() (Cmd, error) {
|
2014-01-03 23:50:17 +01:00
|
|
|
return NewGetBlockTemplateCmd(testId)
|
2013-10-25 20:00:33 +02:00
|
|
|
},
|
|
|
|
result: &GetBlockTemplateCmd{
|
2014-01-03 23:50:17 +01:00
|
|
|
id: testId,
|
2013-10-25 20:00:33 +02:00
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "basic getblocktemplate + request",
|
|
|
|
f: func() (Cmd, error) {
|
2014-01-03 23:50:17 +01:00
|
|
|
return NewGetBlockTemplateCmd(testId,
|
2013-10-25 20:50:39 +02:00
|
|
|
&TemplateRequest{Mode: "mode",
|
|
|
|
Capabilities: []string{"one", "two", "three"}})
|
2013-10-25 20:00:33 +02:00
|
|
|
},
|
|
|
|
result: &GetBlockTemplateCmd{
|
2014-01-03 23:50:17 +01:00
|
|
|
id: testId,
|
2013-10-25 20:50:39 +02:00
|
|
|
Request: &TemplateRequest{
|
|
|
|
Mode: "mode",
|
2013-10-25 20:00:33 +02:00
|
|
|
Capabilities: []string{
|
|
|
|
"one",
|
|
|
|
"two",
|
|
|
|
"three",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "basic getblocktemplate + request no mode",
|
|
|
|
f: func() (Cmd, error) {
|
2014-01-03 23:50:17 +01:00
|
|
|
return NewGetBlockTemplateCmd(testId,
|
2013-10-25 20:00:33 +02:00
|
|
|
&TemplateRequest{
|
2013-10-25 20:50:39 +02:00
|
|
|
Capabilities: []string{"one", "two", "three"}})
|
2013-10-25 20:00:33 +02:00
|
|
|
},
|
|
|
|
result: &GetBlockTemplateCmd{
|
2014-01-03 23:50:17 +01:00
|
|
|
id: testId,
|
2013-10-25 20:50:39 +02:00
|
|
|
Request: &TemplateRequest{
|
2013-10-25 20:00:33 +02:00
|
|
|
Capabilities: []string{
|
|
|
|
"one",
|
|
|
|
"two",
|
|
|
|
"three",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2013-10-25 20:42:25 +02:00
|
|
|
{
|
|
|
|
name: "basic getconectioncount",
|
|
|
|
f: func() (Cmd, error) {
|
2014-01-03 23:50:17 +01:00
|
|
|
return NewGetConnectionCountCmd(testId)
|
2013-10-25 20:42:25 +02:00
|
|
|
},
|
|
|
|
result: &GetConnectionCountCmd{
|
2014-01-03 23:50:17 +01:00
|
|
|
id: testId,
|
2013-10-25 20:42:25 +02:00
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "basic getdifficulty",
|
|
|
|
f: func() (Cmd, error) {
|
2014-01-03 23:50:17 +01:00
|
|
|
return NewGetDifficultyCmd(testId)
|
2013-10-25 20:42:25 +02:00
|
|
|
},
|
|
|
|
result: &GetDifficultyCmd{
|
2014-01-03 23:50:17 +01:00
|
|
|
id: testId,
|
2013-10-25 20:42:25 +02:00
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "basic getgeneratecmd",
|
|
|
|
f: func() (Cmd, error) {
|
2014-01-03 23:50:17 +01:00
|
|
|
return NewGetGenerateCmd(testId)
|
2013-10-25 20:42:25 +02:00
|
|
|
},
|
|
|
|
result: &GetGenerateCmd{
|
2014-01-03 23:50:17 +01:00
|
|
|
id: testId,
|
2013-10-25 20:42:25 +02:00
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "basic gethashespersec",
|
|
|
|
f: func() (Cmd, error) {
|
2014-01-03 23:50:17 +01:00
|
|
|
return NewGetHashesPerSecCmd(testId)
|
2013-10-25 20:42:25 +02:00
|
|
|
},
|
|
|
|
result: &GetHashesPerSecCmd{
|
2014-01-03 23:50:17 +01:00
|
|
|
id: testId,
|
2013-10-25 20:42:25 +02:00
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "basic getinfo",
|
|
|
|
f: func() (Cmd, error) {
|
2014-01-03 23:50:17 +01:00
|
|
|
return NewGetInfoCmd(testId)
|
2013-10-25 20:42:25 +02:00
|
|
|
},
|
|
|
|
result: &GetInfoCmd{
|
2014-01-03 23:50:17 +01:00
|
|
|
id: testId,
|
2013-10-25 20:42:25 +02:00
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "basic getinfo",
|
|
|
|
f: func() (Cmd, error) {
|
2014-01-03 23:50:17 +01:00
|
|
|
return NewGetInfoCmd(testId)
|
2013-10-25 20:42:25 +02:00
|
|
|
},
|
|
|
|
result: &GetInfoCmd{
|
2014-01-03 23:50:17 +01:00
|
|
|
id: testId,
|
2013-10-25 20:42:25 +02:00
|
|
|
},
|
|
|
|
},
|
2013-10-25 21:02:13 +02:00
|
|
|
{
|
|
|
|
name: "basic getmininginfo",
|
|
|
|
f: func() (Cmd, error) {
|
2014-01-03 23:50:17 +01:00
|
|
|
return NewGetMiningInfoCmd(testId)
|
2013-10-25 21:02:13 +02:00
|
|
|
},
|
|
|
|
result: &GetMiningInfoCmd{
|
2014-01-03 23:50:17 +01:00
|
|
|
id: testId,
|
2013-10-25 21:02:13 +02:00
|
|
|
},
|
|
|
|
},
|
2013-10-25 20:42:25 +02:00
|
|
|
{
|
|
|
|
name: "basic getnettotals",
|
|
|
|
f: func() (Cmd, error) {
|
2014-01-03 23:50:17 +01:00
|
|
|
return NewGetNetTotalsCmd(testId)
|
2013-10-25 20:42:25 +02:00
|
|
|
},
|
|
|
|
result: &GetNetTotalsCmd{
|
2014-01-03 23:50:17 +01:00
|
|
|
id: testId,
|
2013-10-25 20:42:25 +02:00
|
|
|
},
|
|
|
|
},
|
2013-10-25 20:50:39 +02:00
|
|
|
{
|
|
|
|
name: "basic getnetworkhashps",
|
|
|
|
f: func() (Cmd, error) {
|
2014-01-03 23:50:17 +01:00
|
|
|
return NewGetNetworkHashPSCmd(testId)
|
2013-10-25 20:50:39 +02:00
|
|
|
},
|
|
|
|
result: &GetNetworkHashPSCmd{
|
2014-01-03 23:50:17 +01:00
|
|
|
id: testId,
|
2013-10-25 20:50:39 +02:00
|
|
|
Blocks: 120,
|
|
|
|
Height: -1,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "basic getnetworkhashps + blocks",
|
|
|
|
f: func() (Cmd, error) {
|
2014-01-03 23:50:17 +01:00
|
|
|
return NewGetNetworkHashPSCmd(testId, 5000)
|
2013-10-25 20:50:39 +02:00
|
|
|
},
|
|
|
|
result: &GetNetworkHashPSCmd{
|
2014-01-03 23:50:17 +01:00
|
|
|
id: testId,
|
2013-10-25 20:50:39 +02:00
|
|
|
Blocks: 5000,
|
|
|
|
Height: -1,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "basic getnetworkhashps + blocks + height",
|
|
|
|
f: func() (Cmd, error) {
|
2014-01-03 23:50:17 +01:00
|
|
|
return NewGetNetworkHashPSCmd(testId, 5000, 1000)
|
2013-10-25 20:50:39 +02:00
|
|
|
},
|
|
|
|
result: &GetNetworkHashPSCmd{
|
2014-01-03 23:50:17 +01:00
|
|
|
id: testId,
|
2013-10-25 20:50:39 +02:00
|
|
|
Blocks: 5000,
|
|
|
|
Height: 1000,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
2013-10-25 21:02:13 +02:00
|
|
|
name: "basic getnewaddress",
|
2013-10-25 20:50:39 +02:00
|
|
|
f: func() (Cmd, error) {
|
2014-01-03 23:50:17 +01:00
|
|
|
return NewGetNewAddressCmd(testId, "account")
|
2013-10-25 20:50:39 +02:00
|
|
|
},
|
2013-10-25 21:02:13 +02:00
|
|
|
result: &GetNewAddressCmd{
|
2014-01-03 23:50:17 +01:00
|
|
|
id: testId,
|
2013-11-12 18:36:57 +01:00
|
|
|
Account: "account",
|
2013-10-25 21:02:13 +02:00
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "basic getpeerinfo",
|
|
|
|
f: func() (Cmd, error) {
|
2014-01-03 23:50:17 +01:00
|
|
|
return NewGetPeerInfoCmd(testId)
|
2013-10-25 21:02:13 +02:00
|
|
|
},
|
|
|
|
result: &GetPeerInfoCmd{
|
2014-01-03 23:50:17 +01:00
|
|
|
id: testId,
|
2013-10-25 20:50:39 +02:00
|
|
|
},
|
|
|
|
},
|
2013-10-31 14:31:32 +01:00
|
|
|
{
|
|
|
|
name: "basic getrawmchangeaddress",
|
|
|
|
f: func() (Cmd, error) {
|
2014-01-03 23:50:17 +01:00
|
|
|
return NewGetRawChangeAddressCmd(testId)
|
2013-10-31 14:31:32 +01:00
|
|
|
},
|
|
|
|
result: &GetRawChangeAddressCmd{
|
2014-01-03 23:50:17 +01:00
|
|
|
id: testId,
|
2013-10-31 14:31:32 +01:00
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "basic getrawmchangeaddress + account",
|
|
|
|
f: func() (Cmd, error) {
|
2014-01-03 23:50:17 +01:00
|
|
|
return NewGetRawChangeAddressCmd(testId,
|
2013-10-31 14:31:32 +01:00
|
|
|
"accountname")
|
|
|
|
},
|
|
|
|
result: &GetRawChangeAddressCmd{
|
2014-01-03 23:50:17 +01:00
|
|
|
id: testId,
|
2013-10-31 14:31:32 +01:00
|
|
|
Account: "accountname",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "basic getrawmempool",
|
|
|
|
f: func() (Cmd, error) {
|
2014-01-03 23:50:17 +01:00
|
|
|
return NewGetRawMempoolCmd(testId)
|
2013-10-31 14:31:32 +01:00
|
|
|
},
|
|
|
|
result: &GetRawMempoolCmd{
|
2014-01-03 23:50:17 +01:00
|
|
|
id: testId,
|
2013-10-31 14:31:32 +01:00
|
|
|
},
|
|
|
|
},
|
2013-12-11 09:44:26 +01:00
|
|
|
{
|
|
|
|
name: "basic getrawmempool noverbose",
|
|
|
|
f: func() (Cmd, error) {
|
2014-01-03 23:50:17 +01:00
|
|
|
return NewGetRawMempoolCmd(testId, false)
|
2013-12-11 09:44:26 +01:00
|
|
|
},
|
|
|
|
result: &GetRawMempoolCmd{
|
2014-01-03 23:50:17 +01:00
|
|
|
id: testId,
|
2013-12-11 09:44:26 +01:00
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "basic getrawmempool verbose",
|
|
|
|
f: func() (Cmd, error) {
|
2014-01-03 23:50:17 +01:00
|
|
|
return NewGetRawMempoolCmd(testId, true)
|
2013-12-11 09:44:26 +01:00
|
|
|
},
|
|
|
|
result: &GetRawMempoolCmd{
|
2014-01-03 23:50:17 +01:00
|
|
|
id: testId,
|
2013-12-11 09:44:26 +01:00
|
|
|
Verbose: true,
|
|
|
|
},
|
|
|
|
},
|
2013-10-31 14:31:32 +01:00
|
|
|
{
|
|
|
|
name: "basic getrawtransaction",
|
|
|
|
f: func() (Cmd, error) {
|
2014-01-03 23:50:17 +01:00
|
|
|
return NewGetRawTransactionCmd(testId,
|
2013-10-31 14:31:32 +01:00
|
|
|
"sometxid")
|
|
|
|
},
|
|
|
|
result: &GetRawTransactionCmd{
|
2014-01-03 23:50:17 +01:00
|
|
|
id: testId,
|
2013-10-31 14:31:32 +01:00
|
|
|
Txid: "sometxid",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "basic getrawtransaction + verbose",
|
|
|
|
f: func() (Cmd, error) {
|
2014-01-03 23:50:17 +01:00
|
|
|
return NewGetRawTransactionCmd(testId,
|
2013-10-31 14:31:32 +01:00
|
|
|
"sometxid",
|
|
|
|
true)
|
|
|
|
},
|
|
|
|
result: &GetRawTransactionCmd{
|
2014-01-03 23:50:17 +01:00
|
|
|
id: testId,
|
2013-10-31 14:31:32 +01:00
|
|
|
Txid: "sometxid",
|
|
|
|
Verbose: true,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "basic getreceivedbyaccount",
|
|
|
|
f: func() (Cmd, error) {
|
2014-01-03 23:50:17 +01:00
|
|
|
return NewGetReceivedByAccountCmd(testId,
|
2013-10-31 14:31:32 +01:00
|
|
|
"abtcaccount",
|
|
|
|
1)
|
|
|
|
},
|
|
|
|
result: &GetReceivedByAccountCmd{
|
2014-01-03 23:50:17 +01:00
|
|
|
id: testId,
|
2013-10-31 14:31:32 +01:00
|
|
|
Account: "abtcaccount",
|
|
|
|
MinConf: 1,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "basic getreceivedbyaddress",
|
|
|
|
f: func() (Cmd, error) {
|
2014-01-03 23:50:17 +01:00
|
|
|
return NewGetReceivedByAddressCmd(testId,
|
2013-10-31 14:31:32 +01:00
|
|
|
"abtcaddress",
|
|
|
|
1)
|
|
|
|
},
|
|
|
|
result: &GetReceivedByAddressCmd{
|
2014-01-03 23:50:17 +01:00
|
|
|
id: testId,
|
2013-10-31 14:31:32 +01:00
|
|
|
Address: "abtcaddress",
|
|
|
|
MinConf: 1,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "basic gettransaction",
|
|
|
|
f: func() (Cmd, error) {
|
2014-01-03 23:50:17 +01:00
|
|
|
return NewGetTransactionCmd(testId,
|
2013-10-31 14:31:32 +01:00
|
|
|
"atxid")
|
|
|
|
},
|
|
|
|
result: &GetTransactionCmd{
|
2014-01-03 23:50:17 +01:00
|
|
|
id: testId,
|
2013-10-31 14:31:32 +01:00
|
|
|
Txid: "atxid",
|
|
|
|
},
|
|
|
|
},
|
2013-10-30 14:58:57 +01:00
|
|
|
{
|
|
|
|
name: "basic gettxout",
|
|
|
|
f: func() (Cmd, error) {
|
2014-01-03 23:50:17 +01:00
|
|
|
return NewGetTxOutCmd(testId,
|
2013-10-30 14:58:57 +01:00
|
|
|
"sometx",
|
|
|
|
10)
|
|
|
|
},
|
|
|
|
result: &GetTxOutCmd{
|
2014-01-03 23:50:17 +01:00
|
|
|
id: testId,
|
2013-10-30 14:58:57 +01:00
|
|
|
Txid: "sometx",
|
|
|
|
Output: 10,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "basic gettxout + optional",
|
|
|
|
f: func() (Cmd, error) {
|
2014-01-03 23:50:17 +01:00
|
|
|
return NewGetTxOutCmd(testId,
|
2013-10-30 14:58:57 +01:00
|
|
|
"sometx",
|
|
|
|
10,
|
|
|
|
false)
|
|
|
|
},
|
|
|
|
result: &GetTxOutCmd{
|
2014-01-03 23:50:17 +01:00
|
|
|
id: testId,
|
2013-10-30 14:58:57 +01:00
|
|
|
Txid: "sometx",
|
|
|
|
Output: 10,
|
|
|
|
IncludeMempool: false,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "basic gettxsetoutinfo",
|
|
|
|
f: func() (Cmd, error) {
|
2014-01-03 23:50:17 +01:00
|
|
|
return NewGetTxOutSetInfoCmd(testId)
|
2013-10-30 14:58:57 +01:00
|
|
|
},
|
|
|
|
result: &GetTxOutSetInfoCmd{
|
2014-01-03 23:50:17 +01:00
|
|
|
id: testId,
|
2013-10-30 14:58:57 +01:00
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "basic getwork",
|
|
|
|
f: func() (Cmd, error) {
|
2014-01-03 23:50:17 +01:00
|
|
|
return NewGetWorkCmd(testId,
|
2013-10-30 14:58:57 +01:00
|
|
|
WorkRequest{
|
|
|
|
Data: "some data",
|
|
|
|
Target: "our target",
|
|
|
|
Algorithm: "algo",
|
|
|
|
})
|
|
|
|
},
|
|
|
|
result: &GetWorkCmd{
|
2014-01-03 23:50:17 +01:00
|
|
|
id: testId,
|
2013-10-30 14:58:57 +01:00
|
|
|
Request: WorkRequest{
|
|
|
|
Data: "some data",
|
|
|
|
Target: "our target",
|
|
|
|
Algorithm: "algo",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "basic help",
|
|
|
|
f: func() (Cmd, error) {
|
2014-01-03 23:50:17 +01:00
|
|
|
return NewHelpCmd(testId)
|
2013-10-30 14:58:57 +01:00
|
|
|
},
|
|
|
|
result: &HelpCmd{
|
2014-01-03 23:50:17 +01:00
|
|
|
id: testId,
|
2013-10-30 14:58:57 +01:00
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "basic help + optional cmd",
|
|
|
|
f: func() (Cmd, error) {
|
2014-01-03 23:50:17 +01:00
|
|
|
return NewHelpCmd(testId,
|
2013-10-30 14:58:57 +01:00
|
|
|
"getinfo")
|
|
|
|
},
|
|
|
|
result: &HelpCmd{
|
2014-01-03 23:50:17 +01:00
|
|
|
id: testId,
|
2013-10-30 14:58:57 +01:00
|
|
|
Command: "getinfo",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "basic importprivkey",
|
|
|
|
f: func() (Cmd, error) {
|
2014-01-03 23:50:17 +01:00
|
|
|
return NewImportPrivKeyCmd(testId,
|
2013-10-30 14:58:57 +01:00
|
|
|
"somereallongprivatekey")
|
|
|
|
},
|
|
|
|
result: &ImportPrivKeyCmd{
|
2014-01-03 23:50:17 +01:00
|
|
|
id: testId,
|
2013-10-30 14:58:57 +01:00
|
|
|
PrivKey: "somereallongprivatekey",
|
2013-11-19 21:26:47 +01:00
|
|
|
Rescan: true,
|
2013-10-30 14:58:57 +01:00
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
2013-11-20 17:08:20 +01:00
|
|
|
name: "basic importprivkey + 1 opt",
|
|
|
|
f: func() (Cmd, error) {
|
2014-01-03 23:50:17 +01:00
|
|
|
return NewImportPrivKeyCmd(testId,
|
2013-11-20 17:08:20 +01:00
|
|
|
"somereallongprivatekey",
|
|
|
|
"some text")
|
|
|
|
},
|
|
|
|
result: &ImportPrivKeyCmd{
|
2014-01-03 23:50:17 +01:00
|
|
|
id: testId,
|
2013-11-20 17:08:20 +01:00
|
|
|
PrivKey: "somereallongprivatekey",
|
|
|
|
Label: "some text",
|
|
|
|
Rescan: true,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "basic importprivkey + 2 opts",
|
2013-10-30 14:58:57 +01:00
|
|
|
f: func() (Cmd, error) {
|
2014-01-03 23:50:17 +01:00
|
|
|
return NewImportPrivKeyCmd(testId,
|
2013-10-30 14:58:57 +01:00
|
|
|
"somereallongprivatekey",
|
|
|
|
"some text",
|
|
|
|
false)
|
|
|
|
},
|
|
|
|
result: &ImportPrivKeyCmd{
|
2014-01-03 23:50:17 +01:00
|
|
|
id: testId,
|
2013-10-30 14:58:57 +01:00
|
|
|
PrivKey: "somereallongprivatekey",
|
|
|
|
Label: "some text",
|
2013-11-18 15:13:02 +01:00
|
|
|
Rescan: false,
|
2013-10-30 14:58:57 +01:00
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "basic importwallet",
|
|
|
|
f: func() (Cmd, error) {
|
2014-01-03 23:50:17 +01:00
|
|
|
return NewImportWalletCmd(testId,
|
2013-10-30 14:58:57 +01:00
|
|
|
"walletfilename.dat")
|
|
|
|
},
|
|
|
|
result: &ImportWalletCmd{
|
2014-01-03 23:50:17 +01:00
|
|
|
id: testId,
|
2013-10-30 14:58:57 +01:00
|
|
|
Filename: "walletfilename.dat",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "basic keypoolrefill",
|
|
|
|
f: func() (Cmd, error) {
|
2014-01-03 23:50:17 +01:00
|
|
|
return NewKeyPoolRefillCmd(testId)
|
2013-10-30 14:58:57 +01:00
|
|
|
},
|
|
|
|
result: &KeyPoolRefillCmd{
|
2014-01-03 23:50:17 +01:00
|
|
|
id: testId,
|
2013-10-30 14:58:57 +01:00
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "basic listaccounts",
|
|
|
|
f: func() (Cmd, error) {
|
2014-01-03 23:50:17 +01:00
|
|
|
return NewListAccountsCmd(testId, 1)
|
2013-10-30 14:58:57 +01:00
|
|
|
},
|
|
|
|
result: &ListAccountsCmd{
|
2014-01-03 23:50:17 +01:00
|
|
|
id: testId,
|
2013-10-30 14:58:57 +01:00
|
|
|
MinConf: 1,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "basic listaddressgroupings",
|
|
|
|
f: func() (Cmd, error) {
|
2014-01-03 23:50:17 +01:00
|
|
|
return NewListAddressGroupingsCmd(testId)
|
2013-10-30 14:58:57 +01:00
|
|
|
},
|
|
|
|
result: &ListAddressGroupingsCmd{
|
2014-01-03 23:50:17 +01:00
|
|
|
id: testId,
|
2013-10-30 14:58:57 +01:00
|
|
|
},
|
|
|
|
},
|
2013-11-07 20:11:50 +01:00
|
|
|
{
|
|
|
|
name: "basic listlockunspent",
|
|
|
|
f: func() (Cmd, error) {
|
2014-01-03 23:50:17 +01:00
|
|
|
return NewListLockUnspentCmd(testId)
|
2013-11-07 20:11:50 +01:00
|
|
|
},
|
|
|
|
result: &ListLockUnspentCmd{
|
2014-01-03 23:50:17 +01:00
|
|
|
id: testId,
|
2013-11-07 20:11:50 +01:00
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "basic listreceivedbyaccount",
|
|
|
|
f: func() (Cmd, error) {
|
2014-01-03 23:50:17 +01:00
|
|
|
return NewListReceivedByAccountCmd(testId)
|
2013-11-07 20:11:50 +01:00
|
|
|
},
|
|
|
|
result: &ListReceivedByAccountCmd{
|
2014-01-03 23:50:17 +01:00
|
|
|
id: testId,
|
2013-11-07 20:11:50 +01:00
|
|
|
MinConf: 1,
|
|
|
|
},
|
|
|
|
},
|
2013-11-26 22:08:31 +01:00
|
|
|
{
|
|
|
|
name: "basic listtransactions",
|
|
|
|
f: func() (Cmd, error) {
|
2014-01-03 23:50:17 +01:00
|
|
|
return NewListTransactionsCmd(testId)
|
2013-11-26 22:08:31 +01:00
|
|
|
},
|
|
|
|
result: &ListTransactionsCmd{
|
2014-01-03 23:50:17 +01:00
|
|
|
id: testId,
|
2013-11-26 22:08:31 +01:00
|
|
|
Account: "",
|
|
|
|
Count: 10,
|
|
|
|
From: 0,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "listtransactions 1 optarg",
|
|
|
|
f: func() (Cmd, error) {
|
2014-01-03 23:50:17 +01:00
|
|
|
return NewListTransactionsCmd(testId, "abcde")
|
2013-11-26 22:08:31 +01:00
|
|
|
},
|
|
|
|
result: &ListTransactionsCmd{
|
2014-01-03 23:50:17 +01:00
|
|
|
id: testId,
|
2013-11-26 22:08:31 +01:00
|
|
|
Account: "abcde",
|
|
|
|
Count: 10,
|
|
|
|
From: 0,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "listtransactions 2 optargs",
|
|
|
|
f: func() (Cmd, error) {
|
2014-01-03 23:50:17 +01:00
|
|
|
return NewListTransactionsCmd(testId, "abcde", 123)
|
2013-11-26 22:08:31 +01:00
|
|
|
},
|
|
|
|
result: &ListTransactionsCmd{
|
2014-01-03 23:50:17 +01:00
|
|
|
id: testId,
|
2013-11-26 22:08:31 +01:00
|
|
|
Account: "abcde",
|
|
|
|
Count: 123,
|
|
|
|
From: 0,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "listtransactions 3 optargs",
|
|
|
|
f: func() (Cmd, error) {
|
2014-01-03 23:50:17 +01:00
|
|
|
return NewListTransactionsCmd(testId, "abcde", 123, 456)
|
2013-11-26 22:08:31 +01:00
|
|
|
},
|
|
|
|
result: &ListTransactionsCmd{
|
2014-01-03 23:50:17 +01:00
|
|
|
id: testId,
|
2013-11-26 22:08:31 +01:00
|
|
|
Account: "abcde",
|
|
|
|
Count: 123,
|
|
|
|
From: 456,
|
|
|
|
},
|
|
|
|
},
|
2013-11-07 20:11:50 +01:00
|
|
|
{
|
|
|
|
name: "basic listunspent",
|
|
|
|
f: func() (Cmd, error) {
|
2014-01-03 23:50:17 +01:00
|
|
|
return NewListUnspentCmd(testId)
|
2013-11-07 20:11:50 +01:00
|
|
|
},
|
|
|
|
result: &ListUnspentCmd{
|
2014-01-03 23:50:17 +01:00
|
|
|
id: testId,
|
2013-11-07 20:11:50 +01:00
|
|
|
MinConf: 1,
|
|
|
|
MaxConf: 999999,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "basic listunspent + opts",
|
|
|
|
f: func() (Cmd, error) {
|
2014-01-03 23:50:17 +01:00
|
|
|
return NewListUnspentCmd(testId, 0, 6)
|
2013-11-07 20:11:50 +01:00
|
|
|
},
|
|
|
|
result: &ListUnspentCmd{
|
2014-01-03 23:50:17 +01:00
|
|
|
id: testId,
|
2013-11-07 20:11:50 +01:00
|
|
|
MinConf: 0,
|
|
|
|
MaxConf: 6,
|
|
|
|
},
|
|
|
|
},
|
2013-10-30 14:58:57 +01:00
|
|
|
{
|
|
|
|
name: "basic lockunspent",
|
|
|
|
f: func() (Cmd, error) {
|
2014-01-03 23:50:17 +01:00
|
|
|
return NewLockUnspentCmd(testId, true)
|
2013-10-30 14:58:57 +01:00
|
|
|
},
|
|
|
|
result: &LockUnspentCmd{
|
2014-01-03 23:50:17 +01:00
|
|
|
id: testId,
|
2013-10-30 14:58:57 +01:00
|
|
|
Unlock: true,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "basic move",
|
|
|
|
f: func() (Cmd, error) {
|
2014-01-03 23:50:17 +01:00
|
|
|
return NewMoveCmd(testId,
|
2013-10-30 14:58:57 +01:00
|
|
|
"account1",
|
|
|
|
"account2",
|
|
|
|
12,
|
|
|
|
1)
|
|
|
|
},
|
|
|
|
result: &MoveCmd{
|
2014-01-03 23:50:17 +01:00
|
|
|
id: testId,
|
2013-10-30 14:58:57 +01:00
|
|
|
FromAccount: "account1",
|
|
|
|
ToAccount: "account2",
|
|
|
|
Amount: 12,
|
|
|
|
MinConf: 1, // the default
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "basic move + optionals",
|
|
|
|
f: func() (Cmd, error) {
|
2014-01-03 23:50:17 +01:00
|
|
|
return NewMoveCmd(testId,
|
2013-10-30 14:58:57 +01:00
|
|
|
"account1",
|
|
|
|
"account2",
|
|
|
|
12,
|
|
|
|
1,
|
|
|
|
"some comment")
|
|
|
|
},
|
|
|
|
result: &MoveCmd{
|
2014-01-03 23:50:17 +01:00
|
|
|
id: testId,
|
2013-10-30 14:58:57 +01:00
|
|
|
FromAccount: "account1",
|
|
|
|
ToAccount: "account2",
|
|
|
|
Amount: 12,
|
|
|
|
MinConf: 1, // the default
|
|
|
|
Comment: "some comment",
|
|
|
|
},
|
|
|
|
},
|
2013-10-22 16:12:12 +02:00
|
|
|
{
|
2013-10-25 19:36:27 +02:00
|
|
|
name: "basic ping",
|
2013-10-22 16:12:12 +02:00
|
|
|
f: func() (Cmd, error) {
|
2014-01-03 23:50:17 +01:00
|
|
|
return NewPingCmd(testId)
|
2013-10-22 16:12:12 +02:00
|
|
|
},
|
2013-10-25 19:36:27 +02:00
|
|
|
result: &PingCmd{
|
2014-01-03 23:50:17 +01:00
|
|
|
id: testId,
|
2013-10-22 16:12:12 +02:00
|
|
|
},
|
|
|
|
},
|
2013-10-25 21:41:23 +02:00
|
|
|
{
|
|
|
|
name: "basic sendfrom",
|
|
|
|
f: func() (Cmd, error) {
|
2014-01-03 23:50:17 +01:00
|
|
|
return NewSendFromCmd(testId,
|
2013-10-25 21:41:23 +02:00
|
|
|
"account",
|
|
|
|
"address",
|
|
|
|
12,
|
|
|
|
1)
|
|
|
|
},
|
|
|
|
result: &SendFromCmd{
|
2014-01-03 23:50:17 +01:00
|
|
|
id: testId,
|
2013-10-25 21:41:23 +02:00
|
|
|
FromAccount: "account",
|
|
|
|
ToAddress: "address",
|
|
|
|
Amount: 12,
|
|
|
|
MinConf: 1, // the default
|
|
|
|
},
|
|
|
|
},
|
2013-10-30 14:58:57 +01:00
|
|
|
{
|
|
|
|
name: "basic sendfrom + options",
|
|
|
|
f: func() (Cmd, error) {
|
2014-01-03 23:50:17 +01:00
|
|
|
return NewSendFromCmd(testId,
|
2013-10-30 14:58:57 +01:00
|
|
|
"account",
|
|
|
|
"address",
|
|
|
|
12,
|
|
|
|
1,
|
|
|
|
"a comment",
|
|
|
|
"comment to")
|
|
|
|
},
|
|
|
|
result: &SendFromCmd{
|
2014-01-03 23:50:17 +01:00
|
|
|
id: testId,
|
2013-10-30 14:58:57 +01:00
|
|
|
FromAccount: "account",
|
|
|
|
ToAddress: "address",
|
|
|
|
Amount: 12,
|
|
|
|
MinConf: 1, // the default
|
|
|
|
Comment: "a comment",
|
|
|
|
CommentTo: "comment to",
|
|
|
|
},
|
|
|
|
},
|
2013-11-28 01:27:46 +01:00
|
|
|
{
|
|
|
|
name: "basic sendmany",
|
|
|
|
f: func() (Cmd, error) {
|
|
|
|
pairs := map[string]int64{
|
|
|
|
"address A": 1000,
|
|
|
|
"address B": 2000,
|
|
|
|
"address C": 3000,
|
|
|
|
}
|
2014-01-03 23:50:17 +01:00
|
|
|
return NewSendManyCmd(testId,
|
2013-11-28 01:27:46 +01:00
|
|
|
"account",
|
|
|
|
pairs)
|
|
|
|
},
|
|
|
|
result: &SendManyCmd{
|
2014-01-03 23:50:17 +01:00
|
|
|
id: testId,
|
2013-11-28 01:27:46 +01:00
|
|
|
FromAccount: "account",
|
|
|
|
Amounts: map[string]int64{
|
|
|
|
"address A": 1000,
|
|
|
|
"address B": 2000,
|
|
|
|
"address C": 3000,
|
|
|
|
},
|
|
|
|
MinConf: 1, // the default
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "sendmany + options",
|
|
|
|
f: func() (Cmd, error) {
|
|
|
|
pairs := map[string]int64{
|
|
|
|
"address A": 1000,
|
|
|
|
"address B": 2000,
|
|
|
|
"address C": 3000,
|
|
|
|
}
|
2014-01-03 23:50:17 +01:00
|
|
|
return NewSendManyCmd(testId,
|
2013-11-28 01:27:46 +01:00
|
|
|
"account",
|
|
|
|
pairs,
|
|
|
|
10,
|
|
|
|
"comment")
|
|
|
|
},
|
|
|
|
result: &SendManyCmd{
|
2014-01-03 23:50:17 +01:00
|
|
|
id: testId,
|
2013-11-28 01:27:46 +01:00
|
|
|
FromAccount: "account",
|
|
|
|
Amounts: map[string]int64{
|
|
|
|
"address A": 1000,
|
|
|
|
"address B": 2000,
|
|
|
|
"address C": 3000,
|
|
|
|
},
|
|
|
|
MinConf: 10,
|
|
|
|
Comment: "comment",
|
|
|
|
},
|
|
|
|
},
|
2013-10-25 21:41:23 +02:00
|
|
|
{
|
|
|
|
name: "basic sendrawtransaction",
|
|
|
|
f: func() (Cmd, error) {
|
2014-01-03 23:50:17 +01:00
|
|
|
return NewSendRawTransactionCmd(testId,
|
2013-10-25 21:41:23 +02:00
|
|
|
"hexstringofatx")
|
|
|
|
},
|
|
|
|
result: &SendRawTransactionCmd{
|
2014-01-03 23:50:17 +01:00
|
|
|
id: testId,
|
2013-10-25 21:41:23 +02:00
|
|
|
HexTx: "hexstringofatx",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "basic sendtoaddress",
|
|
|
|
f: func() (Cmd, error) {
|
2014-01-03 23:50:17 +01:00
|
|
|
return NewSendToAddressCmd(testId,
|
2013-10-25 21:41:23 +02:00
|
|
|
"somebtcaddress",
|
|
|
|
1)
|
|
|
|
},
|
|
|
|
result: &SendToAddressCmd{
|
2014-01-03 23:50:17 +01:00
|
|
|
id: testId,
|
2013-10-25 21:41:23 +02:00
|
|
|
Address: "somebtcaddress",
|
|
|
|
Amount: 1,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "basic sendtoaddress plus optional",
|
|
|
|
f: func() (Cmd, error) {
|
2014-01-03 23:50:17 +01:00
|
|
|
return NewSendToAddressCmd(testId,
|
2013-10-25 21:41:23 +02:00
|
|
|
"somebtcaddress",
|
|
|
|
1,
|
|
|
|
"a comment",
|
|
|
|
"comment to")
|
|
|
|
},
|
|
|
|
result: &SendToAddressCmd{
|
2014-01-03 23:50:17 +01:00
|
|
|
id: testId,
|
2013-10-25 21:41:23 +02:00
|
|
|
Address: "somebtcaddress",
|
|
|
|
Amount: 1,
|
|
|
|
Comment: "a comment",
|
|
|
|
CommentTo: "comment to",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "basic setaccount",
|
|
|
|
f: func() (Cmd, error) {
|
2014-01-03 23:50:17 +01:00
|
|
|
return NewSetAccountCmd(testId,
|
2013-10-25 21:41:23 +02:00
|
|
|
"somebtcaddress",
|
|
|
|
"account name")
|
|
|
|
},
|
|
|
|
result: &SetAccountCmd{
|
2014-01-03 23:50:17 +01:00
|
|
|
id: testId,
|
2013-10-25 21:41:23 +02:00
|
|
|
Address: "somebtcaddress",
|
|
|
|
Account: "account name",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "basic setgenerate",
|
|
|
|
f: func() (Cmd, error) {
|
2014-01-03 23:50:17 +01:00
|
|
|
return NewSetGenerateCmd(testId, true)
|
2013-10-25 21:41:23 +02:00
|
|
|
},
|
|
|
|
result: &SetGenerateCmd{
|
2014-01-03 23:50:17 +01:00
|
|
|
id: testId,
|
2013-10-25 21:41:23 +02:00
|
|
|
Generate: true,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "basic setgenerate + optional",
|
|
|
|
f: func() (Cmd, error) {
|
2014-01-03 23:50:17 +01:00
|
|
|
return NewSetGenerateCmd(testId, true, 10)
|
2013-10-25 21:41:23 +02:00
|
|
|
},
|
|
|
|
result: &SetGenerateCmd{
|
2014-01-03 23:50:17 +01:00
|
|
|
id: testId,
|
2013-10-25 21:41:23 +02:00
|
|
|
Generate: true,
|
|
|
|
GenProcLimit: 10,
|
|
|
|
},
|
|
|
|
},
|
2013-10-30 14:58:57 +01:00
|
|
|
{
|
2013-10-25 21:41:23 +02:00
|
|
|
name: "basic settxfee",
|
|
|
|
f: func() (Cmd, error) {
|
2014-01-03 23:50:17 +01:00
|
|
|
return NewSetTxFeeCmd(testId, 10)
|
2013-10-25 21:41:23 +02:00
|
|
|
},
|
|
|
|
result: &SetTxFeeCmd{
|
2014-01-03 23:50:17 +01:00
|
|
|
id: testId,
|
2013-10-30 14:58:57 +01:00
|
|
|
Amount: 10,
|
2013-10-25 21:41:23 +02:00
|
|
|
},
|
2013-10-30 14:58:57 +01:00
|
|
|
},
|
2013-11-05 22:51:37 +01:00
|
|
|
{
|
|
|
|
name: "basic signmessage",
|
|
|
|
f: func() (Cmd, error) {
|
2014-01-03 23:50:17 +01:00
|
|
|
return NewSignMessageCmd(testId,
|
2013-11-05 22:51:37 +01:00
|
|
|
"btcaddress",
|
|
|
|
"a message")
|
|
|
|
},
|
|
|
|
result: &SignMessageCmd{
|
2014-01-03 23:50:17 +01:00
|
|
|
id: testId,
|
2013-11-05 22:51:37 +01:00
|
|
|
Address: "btcaddress",
|
|
|
|
Message: "a message",
|
|
|
|
},
|
|
|
|
},
|
2013-10-25 21:41:23 +02:00
|
|
|
{
|
|
|
|
name: "basic signrawtransaction",
|
|
|
|
f: func() (Cmd, error) {
|
2014-01-03 23:50:17 +01:00
|
|
|
return NewSignRawTransactionCmd(testId,
|
2013-10-25 21:41:23 +02:00
|
|
|
"sometxstring")
|
|
|
|
},
|
|
|
|
result: &SignRawTransactionCmd{
|
2014-01-03 23:50:17 +01:00
|
|
|
id: testId,
|
2013-10-25 21:41:23 +02:00
|
|
|
RawTx: "sometxstring",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
/* {
|
|
|
|
name: "basic signrawtransaction with optional",
|
|
|
|
f: func() (Cmd, error) {
|
2014-01-03 23:50:17 +01:00
|
|
|
return NewSignRawTransactionCmd(testId,
|
2013-10-25 21:41:23 +02:00
|
|
|
"sometxstring",
|
|
|
|
[]RawTxInput{
|
|
|
|
RawTxInput{
|
|
|
|
Txid: "test",
|
|
|
|
Vout: 1,
|
|
|
|
ScriptPubKey: "test",
|
|
|
|
RedeemScript: "test",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
[]string{"aprivatekey", "privkey2"},
|
|
|
|
"flags")
|
|
|
|
},
|
|
|
|
result: &SignRawTransactionCmd{
|
2014-01-03 23:50:17 +01:00
|
|
|
id: testId,
|
2013-10-25 21:41:23 +02:00
|
|
|
RawTx: "sometxstring",
|
|
|
|
Inputs: []RawTxInput{
|
|
|
|
RawTxInput{
|
|
|
|
Txid: "test",
|
|
|
|
Vout: 1,
|
|
|
|
ScriptPubKey: "test",
|
|
|
|
RedeemScript: "test",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
PrivKeys: []string{"aprivatekey", "privkey2"},
|
|
|
|
Flags: "flags",
|
|
|
|
},
|
|
|
|
},*/
|
|
|
|
{
|
|
|
|
name: "basic stop",
|
|
|
|
f: func() (Cmd, error) {
|
2014-01-03 23:50:17 +01:00
|
|
|
return NewStopCmd(testId)
|
2013-10-25 21:41:23 +02:00
|
|
|
},
|
|
|
|
result: &StopCmd{
|
2014-01-03 23:50:17 +01:00
|
|
|
id: testId,
|
2013-10-25 21:41:23 +02:00
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "basic submitblock",
|
|
|
|
f: func() (Cmd, error) {
|
2014-01-03 23:50:17 +01:00
|
|
|
return NewSubmitBlockCmd(testId,
|
2013-10-25 21:41:23 +02:00
|
|
|
"lotsofhex")
|
|
|
|
},
|
|
|
|
result: &SubmitBlockCmd{
|
2014-01-03 23:50:17 +01:00
|
|
|
id: testId,
|
2013-10-25 21:41:23 +02:00
|
|
|
HexBlock: "lotsofhex",
|
|
|
|
},
|
|
|
|
},
|
2013-10-31 21:37:14 +01:00
|
|
|
{
|
|
|
|
name: "submitblock with optional object",
|
|
|
|
f: func() (Cmd, error) {
|
2014-01-03 23:50:17 +01:00
|
|
|
return NewSubmitBlockCmd(testId,
|
2013-10-31 21:37:14 +01:00
|
|
|
"lotsofhex",
|
|
|
|
&SubmitBlockOptions{WorkId: "otherstuff"})
|
|
|
|
},
|
|
|
|
result: &SubmitBlockCmd{
|
2014-01-03 23:50:17 +01:00
|
|
|
id: testId,
|
2013-10-31 21:37:14 +01:00
|
|
|
HexBlock: "lotsofhex",
|
|
|
|
Options: &SubmitBlockOptions{WorkId: "otherstuff"},
|
|
|
|
},
|
|
|
|
},
|
2013-10-25 21:41:23 +02:00
|
|
|
{
|
|
|
|
name: "basic validateaddress",
|
|
|
|
f: func() (Cmd, error) {
|
2014-01-03 23:50:17 +01:00
|
|
|
return NewValidateAddressCmd(testId,
|
2013-10-25 21:41:23 +02:00
|
|
|
"somebtcaddress")
|
|
|
|
},
|
|
|
|
result: &ValidateAddressCmd{
|
2014-01-03 23:50:17 +01:00
|
|
|
id: testId,
|
2013-10-25 21:41:23 +02:00
|
|
|
Address: "somebtcaddress",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "basic verifychain",
|
|
|
|
f: func() (Cmd, error) {
|
2014-01-03 23:50:17 +01:00
|
|
|
return NewVerifyChainCmd(testId)
|
2013-10-25 21:41:23 +02:00
|
|
|
},
|
|
|
|
result: &VerifyChainCmd{
|
2014-01-03 23:50:17 +01:00
|
|
|
id: testId,
|
2013-10-25 21:41:23 +02:00
|
|
|
CheckLevel: 3,
|
|
|
|
CheckDepth: 288,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "basic verifychain + optional",
|
|
|
|
f: func() (Cmd, error) {
|
2014-01-03 23:50:17 +01:00
|
|
|
return NewVerifyChainCmd(testId, 4, 1)
|
2013-10-25 21:41:23 +02:00
|
|
|
},
|
|
|
|
result: &VerifyChainCmd{
|
2014-01-03 23:50:17 +01:00
|
|
|
id: testId,
|
2013-10-25 21:41:23 +02:00
|
|
|
CheckLevel: 4,
|
|
|
|
CheckDepth: 1,
|
|
|
|
},
|
|
|
|
},
|
2013-10-25 19:07:45 +02:00
|
|
|
{
|
|
|
|
name: "basic verifymessage",
|
|
|
|
f: func() (Cmd, error) {
|
2014-01-03 23:50:17 +01:00
|
|
|
return NewVerifyMessageCmd(testId,
|
2013-10-25 19:07:45 +02:00
|
|
|
"someaddress",
|
|
|
|
"somesig",
|
|
|
|
"a message")
|
|
|
|
},
|
|
|
|
result: &VerifyMessageCmd{
|
2014-01-03 23:50:17 +01:00
|
|
|
id: testId,
|
2013-10-25 19:07:45 +02:00
|
|
|
Address: "someaddress",
|
|
|
|
Signature: "somesig",
|
|
|
|
Message: "a message",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "basic walletlock",
|
|
|
|
f: func() (Cmd, error) {
|
2014-01-03 23:50:17 +01:00
|
|
|
return NewWalletLockCmd(testId)
|
2013-10-25 19:07:45 +02:00
|
|
|
},
|
|
|
|
result: &WalletLockCmd{
|
2014-01-03 23:50:17 +01:00
|
|
|
id: testId,
|
2013-10-25 19:07:45 +02:00
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "basic walletpassphrase",
|
|
|
|
f: func() (Cmd, error) {
|
2014-01-03 23:50:17 +01:00
|
|
|
return NewWalletPassphraseCmd(testId,
|
2013-10-25 19:07:45 +02:00
|
|
|
"phrase1",
|
|
|
|
10)
|
|
|
|
},
|
|
|
|
result: &WalletPassphraseCmd{
|
2014-01-03 23:50:17 +01:00
|
|
|
id: testId,
|
2013-10-25 19:07:45 +02:00
|
|
|
Passphrase: "phrase1",
|
|
|
|
Timeout: 10,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "basic walletpassphrasechange",
|
|
|
|
f: func() (Cmd, error) {
|
2014-01-03 23:50:17 +01:00
|
|
|
return NewWalletPassphraseChangeCmd(testId,
|
2013-10-25 19:07:45 +02:00
|
|
|
"phrase1", "phrase2")
|
|
|
|
},
|
|
|
|
result: &WalletPassphraseChangeCmd{
|
2014-01-03 23:50:17 +01:00
|
|
|
id: testId,
|
2013-10-25 19:07:45 +02:00
|
|
|
OldPassphrase: "phrase1",
|
|
|
|
NewPassphrase: "phrase2",
|
|
|
|
},
|
|
|
|
},
|
2013-10-22 16:12:12 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
func TestCmds(t *testing.T) {
|
|
|
|
for _, test := range jsoncmdtests {
|
|
|
|
c, err := test.f()
|
|
|
|
if err != nil {
|
|
|
|
t.Errorf("%s: failed to run func: %v",
|
|
|
|
test.name, err)
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
|
|
|
|
msg, err := json.Marshal(c)
|
|
|
|
if err != nil {
|
|
|
|
t.Errorf("%s: failed to marshal cmd: %v",
|
|
|
|
test.name, err)
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
|
|
|
|
c2, err := ParseMarshaledCmd(msg)
|
|
|
|
if err != nil {
|
|
|
|
t.Errorf("%s: failed to ummarshal cmd: %v",
|
|
|
|
test.name, err)
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
|
2014-01-03 23:50:17 +01:00
|
|
|
id, ok := (c.Id()).(float64)
|
|
|
|
if !ok || id != testId {
|
|
|
|
t.Errorf("%s: id not returned properly", test.name)
|
|
|
|
}
|
|
|
|
|
2013-10-22 16:12:12 +02:00
|
|
|
if !reflect.DeepEqual(test.result, c2) {
|
|
|
|
t.Errorf("%s: unmarshal not as expected. "+
|
|
|
|
"got %v wanted %v", test.name, spew.Sdump(c2),
|
|
|
|
spew.Sdump(test.result))
|
|
|
|
}
|
|
|
|
if !reflect.DeepEqual(c, c2) {
|
|
|
|
t.Errorf("%s: unmarshal not as we started with. "+
|
|
|
|
"got %v wanted %v", test.name, spew.Sdump(c2),
|
|
|
|
spew.Sdump(c))
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|