From 8cb250885c37baa5f2cd17bfae47bba41b54d3ee Mon Sep 17 00:00:00 2001 From: Nathan Wilcox Date: Tue, 19 Jan 2016 10:09:58 -0800 Subject: [PATCH] Replace magic 2s in rpcwallet and change > to != for arity checks. Replace magic 2's with named constants in test cases. --- src/test/transaction_tests.cpp | 5 +++-- src/wallet/rpcwallet.cpp | 9 +++++---- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/test/transaction_tests.cpp b/src/test/transaction_tests.cpp index 91b03f7ff..523bd790e 100644 --- a/src/test/transaction_tests.cpp +++ b/src/test/transaction_tests.cpp @@ -14,6 +14,7 @@ #include "main.h" #include "script/script.h" #include "script/script_error.h" +#include "primitives/transaction.h" #include #include @@ -345,11 +346,11 @@ BOOST_AUTO_TEST_CASE(test_basic_pour_verification) // create CPourTx CScript scriptPubKey; - boost::array inputs = { + boost::array inputs = { PourInput(coin, addr, convertVectorToInt(index), path), PourInput(TEST_TREE_DEPTH) // dummy input of zero value }; - boost::array outputs = { + boost::array outputs = { PourOutput(50), PourOutput(50) }; diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index dbb9ba301..f76a379a9 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -16,6 +16,7 @@ #include "utilmoneystr.h" #include "wallet.h" #include "walletdb.h" +#include "primitives/transaction.h" #include @@ -2514,7 +2515,7 @@ Value zc_raw_pour(const json_spirit::Array& params, bool fHelp) vpourin.push_back(PourInput(input_coin, zcaddress, path_index, path)); } - while (vpourin.size() < 2) { + while (vpourin.size() < NUM_POUR_INPUTS) { vpourin.push_back(PourInput(INCREMENTAL_MERKLE_TREE_DEPTH)); } @@ -2541,13 +2542,13 @@ Value zc_raw_pour(const json_spirit::Array& params, bool fHelp) vpourout.push_back(output); } - while (vpourout.size() < 2) { + while (vpourout.size() < NUM_POUR_OUTPUTS) { vpourout.push_back(PourOutput(0)); } // TODO - if (vpourout.size() > 2 || vpourin.size() > 2) { - throw runtime_error("unsupported"); + if (vpourout.size() != NUM_POUR_INPUTS || vpourin.size() != NUM_POUR_OUTPUTS) { + throw runtime_error("unsupported pour input/output counts"); } CScript scriptPubKey;