diff options
Diffstat (limited to 'src/test')
-rw-r--r-- | src/test/base58_tests.cpp | 4 | ||||
-rw-r--r-- | src/test/rpc_tests.cpp | 17 | ||||
-rw-r--r-- | src/test/rpc_wallet_tests.cpp | 11 | ||||
-rw-r--r-- | src/test/script_tests.cpp | 14 | ||||
-rw-r--r-- | src/test/sighash_tests.cpp | 4 | ||||
-rw-r--r-- | src/test/transaction_tests.cpp | 23 |
6 files changed, 29 insertions, 44 deletions
diff --git a/src/test/base58_tests.cpp b/src/test/base58_tests.cpp index 114bd79ea9..9e74f5f427 100644 --- a/src/test/base58_tests.cpp +++ b/src/test/base58_tests.cpp @@ -17,9 +17,9 @@ #include <boost/foreach.hpp> #include <boost/test/unit_test.hpp> -#include "json_spirit_wrapper.h" -using namespace json_spirit; +#include "univalue/univalue.h" + extern UniValue read_json(const std::string& jsondata); BOOST_FIXTURE_TEST_SUITE(base58_tests, BasicTestingSetup) diff --git a/src/test/rpc_tests.cpp b/src/test/rpc_tests.cpp index a97c96be72..8dbe377626 100644 --- a/src/test/rpc_tests.cpp +++ b/src/test/rpc_tests.cpp @@ -13,10 +13,11 @@ #include <boost/algorithm/string.hpp> #include <boost/test/unit_test.hpp> +#include "univalue/univalue.h" + using namespace std; -using namespace json_spirit; -Array +UniValue createArgs(int nRequired, const char* address1=NULL, const char* address2=NULL) { UniValue result(UniValue::VARR); @@ -28,7 +29,7 @@ createArgs(int nRequired, const char* address1=NULL, const char* address2=NULL) return result; } -Value CallRPC(string args) +UniValue CallRPC(string args) { vector<string> vArgs; boost::split(vArgs, args, boost::is_any_of(" \t")); @@ -38,10 +39,10 @@ Value CallRPC(string args) rpcfn_type method = tableRPC[strMethod]->actor; try { - Value result = (*method)(params, false); + UniValue result = (*method)(params, false); return result; } - catch (const Object& objError) { + catch (const UniValue& objError) { throw runtime_error(find_value(objError, "message").get_str()); } } @@ -52,7 +53,7 @@ BOOST_FIXTURE_TEST_SUITE(rpc_tests, TestingSetup) BOOST_AUTO_TEST_CASE(rpc_rawparams) { // Test raw transaction API argument handling - Value r; + UniValue r; BOOST_CHECK_THROW(CallRPC("getrawtransaction"), runtime_error); BOOST_CHECK_THROW(CallRPC("getrawtransaction not_hex"), runtime_error); @@ -92,7 +93,7 @@ BOOST_AUTO_TEST_CASE(rpc_rawparams) BOOST_AUTO_TEST_CASE(rpc_rawsign) { - Value r; + UniValue r; // input is a 1-of-2 multisig (so is output): string prevout = "[{\"txid\":\"b4cc287e58f87cdae59417329f710f3ecd75a4ee1d2872b7248f50977c8493f3\"," @@ -121,7 +122,7 @@ BOOST_AUTO_TEST_CASE(rpc_format_monetary_values) BOOST_CHECK(ValueFromAmount(2099999999999999LL).write() == "20999999.99999999"); } -static Value ValueFromString(const std::string &str) +static UniValue ValueFromString(const std::string &str) { UniValue value; BOOST_CHECK(value.setNumStr(str)); diff --git a/src/test/rpc_wallet_tests.cpp b/src/test/rpc_wallet_tests.cpp index 1a897fcd54..a72b656100 100644 --- a/src/test/rpc_wallet_tests.cpp +++ b/src/test/rpc_wallet_tests.cpp @@ -14,11 +14,12 @@ #include <boost/algorithm/string.hpp> #include <boost/test/unit_test.hpp> +#include "univalue/univalue.h" + using namespace std; -using namespace json_spirit; extern UniValue createArgs(int nRequired, const char* address1 = NULL, const char* address2 = NULL); -extern Value CallRPC(string args); +extern UniValue CallRPC(string args); extern CWallet* pwalletMain; @@ -35,7 +36,7 @@ BOOST_AUTO_TEST_CASE(rpc_addmultisig) // new, compressed: const char address2Hex[] = "0388c2037017c62240b6b72ac1a2a5f94da790596ebd06177c8572752922165cb4"; - Value v; + UniValue v; CBitcoinAddress address; BOOST_CHECK_NO_THROW(v = addmultisig(createArgs(1, address1Hex), false)); address.SetString(v.get_str()); @@ -66,13 +67,13 @@ BOOST_AUTO_TEST_CASE(rpc_addmultisig) BOOST_AUTO_TEST_CASE(rpc_wallet) { // Test RPC calls for various wallet statistics - Value r; + UniValue r; LOCK2(cs_main, pwalletMain->cs_wallet); CPubKey demoPubkey = pwalletMain->GenerateNewKey(); CBitcoinAddress demoAddress = CBitcoinAddress(CTxDestination(demoPubkey.GetID())); - Value retValue; + UniValue retValue; string strAccount = "walletDemoAccount"; string strPurpose = "receive"; BOOST_CHECK_NO_THROW({ /*Initialize Wallet with an account */ diff --git a/src/test/script_tests.cpp b/src/test/script_tests.cpp index af11c0c9d9..3733425699 100644 --- a/src/test/script_tests.cpp +++ b/src/test/script_tests.cpp @@ -26,10 +26,10 @@ #include <boost/foreach.hpp> #include <boost/test/unit_test.hpp> -#include "json_spirit_wrapper.h" + +#include "univalue/univalue.h" using namespace std; -using namespace json_spirit; // Uncomment if you want to output updated JSON tests. // #define UPDATE_JSON_TESTS @@ -39,15 +39,15 @@ static const unsigned int flags = SCRIPT_VERIFY_P2SH | SCRIPT_VERIFY_STRICTENC; unsigned int ParseScriptFlags(string strFlags); string FormatScriptFlags(unsigned int flags); -Array +UniValue read_json(const std::string& jsondata) { - Value v; + UniValue v; if (!v.read(jsondata) || !v.isArray()) { BOOST_ERROR("Parse error."); - return Array(); + return UniValue(UniValue::VARR); } return v.get_array(); } @@ -584,11 +584,11 @@ BOOST_AUTO_TEST_CASE(script_build) UniValue json_bad = read_json(std::string(json_tests::script_invalid, json_tests::script_invalid + sizeof(json_tests::script_invalid))); for (unsigned int idx = 0; idx < json_good.size(); idx++) { - const Value& tv = json_good[idx]; + const UniValue& tv = json_good[idx]; tests_good.insert(tv.get_array().write()); } for (unsigned int idx = 0; idx < json_bad.size(); idx++) { - const Value& tv = json_bad[idx]; + const UniValue& tv = json_bad[idx]; tests_bad.insert(tv.get_array().write()); } } diff --git a/src/test/sighash_tests.cpp b/src/test/sighash_tests.cpp index efdb4e8043..a0797d5f3f 100644 --- a/src/test/sighash_tests.cpp +++ b/src/test/sighash_tests.cpp @@ -16,9 +16,9 @@ #include <iostream> #include <boost/test/unit_test.hpp> -#include "json_spirit_wrapper.h" -using namespace json_spirit; +#include "univalue/univalue.h" + extern UniValue read_json(const std::string& jsondata); // Old script.cpp SignatureHash function diff --git a/src/test/transaction_tests.cpp b/src/test/transaction_tests.cpp index afd2d74013..4cfdec1267 100644 --- a/src/test/transaction_tests.cpp +++ b/src/test/transaction_tests.cpp @@ -24,10 +24,9 @@ #include <boost/test/unit_test.hpp> #include <boost/assign/list_of.hpp> -#include "json_spirit_wrapper.h" +#include "univalue/univalue.h" using namespace std; -using namespace json_spirit; // In script_tests.cpp extern UniValue read_json(const std::string& jsondata); @@ -92,19 +91,11 @@ BOOST_AUTO_TEST_CASE(tx_valid) // verifyFlags is a comma separated list of script verification flags to apply, or "NONE" UniValue tests = read_json(std::string(json_tests::tx_valid, json_tests::tx_valid + sizeof(json_tests::tx_valid))); -<<<<<<< HEAD ScriptError err; - BOOST_FOREACH(Value& tv, tests) - { - Array test = tv.get_array(); - string strTest = write_string(tv, false); - if (test[0].type() == array_type) -======= for (unsigned int idx = 0; idx < tests.size(); idx++) { UniValue test = tests[idx]; string strTest = test.write(); if (test[0].isArray()) ->>>>>>> Convert tree to using univalue. Eliminate all json_spirit uses. { if (test.size() != 3 || !test[1].isStr() || !test[2].isStr()) { @@ -116,7 +107,7 @@ BOOST_AUTO_TEST_CASE(tx_valid) UniValue inputs = test[0].get_array(); bool fValid = true; for (unsigned int inpIdx = 0; inpIdx < inputs.size(); inpIdx++) { - const Value& input = inputs[inpIdx]; + const UniValue& input = inputs[inpIdx]; if (!input.isArray()) { fValid = false; @@ -175,19 +166,11 @@ BOOST_AUTO_TEST_CASE(tx_invalid) // verifyFlags is a comma separated list of script verification flags to apply, or "NONE" UniValue tests = read_json(std::string(json_tests::tx_invalid, json_tests::tx_invalid + sizeof(json_tests::tx_invalid))); -<<<<<<< HEAD ScriptError err; - BOOST_FOREACH(Value& tv, tests) - { - Array test = tv.get_array(); - string strTest = write_string(tv, false); - if (test[0].type() == array_type) -======= for (unsigned int idx = 0; idx < tests.size(); idx++) { UniValue test = tests[idx]; string strTest = test.write(); if (test[0].isArray()) ->>>>>>> Convert tree to using univalue. Eliminate all json_spirit uses. { if (test.size() != 3 || !test[1].isStr() || !test[2].isStr()) { @@ -199,7 +182,7 @@ BOOST_AUTO_TEST_CASE(tx_invalid) UniValue inputs = test[0].get_array(); bool fValid = true; for (unsigned int inpIdx = 0; inpIdx < inputs.size(); inpIdx++) { - const Value& input = inputs[inpIdx]; + const UniValue& input = inputs[inpIdx]; if (!input.isArray()) { fValid = false; |