<commit_before>// 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 package so we can mock up structs
package btcws

import (
	"github.com/conformal/btcdb"
	"github.com/conformal/btcjson"
	"github.com/davecgh/go-spew/spew"
	"reflect"
	"testing"
)

var cmdtests = []struct {
	name   string
	f      func() (btcjson.Cmd, error)
	result btcjson.Cmd // after marshal and unmarshal
}{
	{
		name: "createencryptedwallet",
		f: func() (btcjson.Cmd, error) {
			return NewCreateEncryptedWalletCmd(
				float64(1),
				"banana"), nil
		},
		result: &CreateEncryptedWalletCmd{
			id:         float64(1),
			Passphrase: "<PASSWORD>",
		},
	},
	{
		name: "getaddressbalance no optargs",
		f: func() (btcjson.Cmd, error) {
			return NewGetAddressBalanceCmd(
				float64(1),
				"17XhEvq9Nahdj7Xe1nv6oRe1tEmaHUuynH")
		},
		result: &GetAddressBalanceCmd{
			id:      float64(1),
			Address: "17XhEvq9Nahdj7Xe1nv6oRe1tEmaHUuynH",
			Minconf: 1,
		},
	},
	{
		name: "getaddressbalance one optarg",
		f: func() (btcjson.Cmd, error) {
			return NewGetAddressBalanceCmd(
				float64(1),
				"17XhEvq9Nahdj7Xe1nv6oRe1tEmaHUuynH",
				0)
		},
		result: &GetAddressBalanceCmd{
			id:      float64(1),
			Address: "17XhEvq9Nahdj7Xe1nv6oRe1tEmaHUuynH",
			Minconf: 0,
		},
	},
	{
		name: "getbestblock",
		f: func() (btcjson.Cmd, error) {
			return NewGetBestBlockCmd(float64(1)), nil
		},
		result: &GetBestBlockCmd{
			id: float64(1),
		},
	},
	{
		name: "getcurrentnet",
		f: func() (btcjson.Cmd, error) {
			return NewGetCurrentNetCmd(float64(1)), nil
		},
		result: &GetCurrentNetCmd{
			id: float64(1),
		},
	},
	{
		name: "getunconfirmedbalance no optargs",
		f: func() (btcjson.Cmd, error) {
			return NewGetUnconfirmedBalanceCmd(float64(1))
		},
		result: &GetUnconfirmedBalanceCmd{
			id:      float64(1),
			Account: "",
		},
	},
	{
		name: "getunconfirmedbalance one optarg",
		f: func() (btcjson.Cmd, error) {
			return NewGetUnconfirmedBalanceCmd(float64(1),
				"abcde")
		},
		result: &GetUnconfirmedBalanceCmd{
			id:      float64(1),
			Account: "abcde",
		},
	},
	{
		name: "listaddresstransactions no optargs",
		f: func() (btcjson.Cmd, error) {
			addrs := []string{
				"<KEY>",
			}
			return NewListAddressTransactionsCmd(
				float64(1),
				addrs)
		},
		result: &ListAddressTransactionsCmd{
			id:      float64(1),
			Account: "",
			Addresses: []string{
				"<KEY>",
			},
		},
	},
	{
		name: "listaddresstransactions one optarg",
		f: func() (btcjson.Cmd, error) {
			addrs := []string{
				"<KEY>",
			}
			return NewListAddressTransactionsCmd(
				float64(1),
				addrs,
				"abcde")
		},
		result: &ListAddressTransactionsCmd{
			id:      float64(1),
			Account: "abcde",
			Addresses: []string{
				"<KEY>",
			},
		},
	},
	{
		name: "listalltransactions no optargs",
		f: func() (btcjson.Cmd, error) {
			return NewListAllTransactionsCmd(float64(1))
		},
		result: &ListAllTransactionsCmd{
			id:      float64(1),
			Account: "",
		},
	},
	{
		name: "listalltransactions one optarg",
		f: func() (btcjson.Cmd, error) {
			return NewListAllTransactionsCmd(
				float64(1),
				"abcde")
		},
		result: &ListAllTransactionsCmd{
			id:      float64(1),
			Account: "abcde",
		},
	},
	{
		name: "notifynewtxs",
		f: func() (btcjson.Cmd, error) {
			addrs := []string{
				"<KEY>",
			}
			return NewNotifyNewTXsCmd(
				float64(1),
				addrs), nil
		},
		result: &NotifyNewTXsCmd{
			id: float64(1),
			Addresses: []string{
				"<KEY>",
			},
		},
	},
	{
		name: "notifyallnewtxs",
		f: func() (btcjson.Cmd, error) {
			return NewNotifyAllNewTXsCmd(
				float64(1),
				true)
		},
		result: &NotifyAllNewTXsCmd{
			id:      float64(1),
			Verbose: true,
		},
	},
	{
		name: "notifyspent",
		f: func() (btcjson.Cmd, error) {
			op := &OutPoint{
				Hash: "000102030405060708091011121314" +
					"1516171819202122232425262728" +
					"293031",
				Index: 1,<commit_msg>Update tests for notifynewtxs -> notifyreceived.<commit_after>// 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 package so we can mock up structs
package btcws

import (
	"github.com/conformal/btcdb"
	"github.com/conformal/btcjson"
	"github.com/davecgh/go-spew/spew"
	"reflect"
	"testing"
)

var cmdtests = []struct {
	name   string
	f      func() (btcjson.Cmd, error)
	result btcjson.Cmd // after marshal and unmarshal
}{
	{
		name: "createencryptedwallet",
		f: func() (btcjson.Cmd, error) {
			return NewCreateEncryptedWalletCmd(
				float64(1),
				"banana"), nil
		},
		result: &CreateEncryptedWalletCmd{
			id:         float64(1),
			Passphrase: "<PASSWORD>",
		},
	},
	{
		name: "getaddressbalance no optargs",
		f: func() (btcjson.Cmd, error) {
			return NewGetAddressBalanceCmd(
				float64(1),
				"17XhEvq9Nahdj7Xe1nv6oRe1tEmaHUuynH")
		},
		result: &GetAddressBalanceCmd{
			id:      float64(1),
			Address: "17XhEvq9Nahdj7Xe1nv6oRe1tEmaHUuynH",
			Minconf: 1,
		},
	},
	{
		name: "getaddressbalance one optarg",
		f: func() (btcjson.Cmd, error) {
			return NewGetAddressBalanceCmd(
				float64(1),
				"17XhEvq9Nahdj7Xe1nv6oRe1tEmaHUuynH",
				0)
		},
		result: &GetAddressBalanceCmd{
			id:      float64(1),
			Address: "17XhEvq9Nahdj7Xe1nv6oRe1tEmaHUuynH",
			Minconf: 0,
		},
	},
	{
		name: "getbestblock",
		f: func() (btcjson.Cmd, error) {
			return NewGetBestBlockCmd(float64(1)), nil
		},
		result: &GetBestBlockCmd{
			id: float64(1),
		},
	},
	{
		name: "getcurrentnet",
		f: func() (btcjson.Cmd, error) {
			return NewGetCurrentNetCmd(float64(1)), nil
		},
		result: &GetCurrentNetCmd{
			id: float64(1),
		},
	},
	{
		name: "getunconfirmedbalance no optargs",
		f: func() (btcjson.Cmd, error) {
			return NewGetUnconfirmedBalanceCmd(float64(1))
		},
		result: &GetUnconfirmedBalanceCmd{
			id:      float64(1),
			Account: "",
		},
	},
	{
		name: "getunconfirmedbalance one optarg",
		f: func() (btcjson.Cmd, error) {
			return NewGetUnconfirmedBalanceCmd(float64(1),
				"abcde")
		},
		result: &GetUnconfirmedBalanceCmd{
			id:      float64(1),
			Account: "abcde",
		},
	},
	{
		name: "listaddresstransactions no optargs",
		f: func() (btcjson.Cmd, error) {
			addrs := []string{
				"<KEY>",
			}
			return NewListAddressTransactionsCmd(
				float64(1),
				addrs)
		},
		result: &ListAddressTransactionsCmd{
			id:      float64(1),
			Account: "",
			Addresses: []string{
				"<KEY>",
			},
		},
	},
	{
		name: "listaddresstransactions one optarg",
		f: func() (btcjson.Cmd, error) {
			addrs := []string{
				"<KEY>",
			}
			return NewListAddressTransactionsCmd(
				float64(1),
				addrs,
				"abcde")
		},
		result: &ListAddressTransactionsCmd{
			id:      float64(1),
			Account: "abcde",
			Addresses: []string{
				"<KEY>",
			},
		},
	},
	{
		name: "listalltransactions no optargs",
		f: func() (btcjson.Cmd, error) {
			return NewListAllTransactionsCmd(float64(1))
		},
		result: &ListAllTransactionsCmd{
			id:      float64(1),
			Account: "",
		},
	},
	{
		name: "listalltransactions one optarg",
		f: func() (btcjson.Cmd, error) {
			return NewListAllTransactionsCmd(
				float64(1),
				"abcde")
		},
		result: &ListAllTransactionsCmd{
			id:      float64(1),
			Account: "abcde",
		},
	},
	{
		name: "notifyreceived",
		f: func() (btcjson.Cmd, error) {
			addrs := []string{
				"17XhEvq9Nahdj7Xe1nv6oRe1tEmaHUuynH",
			}
			return NewNotifyReceivedCmd(
				float64(1),
				addrs), nil
		},
		result: &NotifyReceivedCmd{
			id: float64(1),
			Addresses: []string{
				"17XhEvq9Nahdj7Xe1nv6oRe1tEmaHUuynH",
			},
		},
	},
	{
		name: "notifyallnewtxs",
		f: func() (btcjson.Cmd, error) {
			return NewNotifyAllNewTXsCmd(
				float64(1),
				true)
		},
		result: &NotifyAllNewTXsCmd{
			id:      float64(1),
			Verbose: true,
		},
	},
	{
		name: "notifyspent",
		f: func() (btcjson.Cmd, error) {
			op := &OutPoint{
				Hash: "000102030405060708091011121314" +
					"1516171819202122232425262728" +
					"293031",
				Index: 1,
{'fraction_non_alphanumeric': 0.1505256648113791, 'fraction_numerical': 0.045763760049474335, 'mean_word_length': 3.269271383315734, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 16, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3980880', 'n_tokens_mistral': 3958, 'n_tokens_neox': 3273, 'n_words': 625}