From 15982a8b69ec6ab3c3a6bf71fc6a9b681d3ff541 Mon Sep 17 00:00:00 2001 From: Jeff Garzik Date: Wed, 20 Aug 2014 15:15:16 -0400 Subject: Convert tree to using univalue. Eliminate all json_spirit uses. --- src/test/transaction_tests.cpp | 33 ++++++++++++++++++++++++--------- 1 file changed, 24 insertions(+), 9 deletions(-) (limited to 'src/test/transaction_tests.cpp') diff --git a/src/test/transaction_tests.cpp b/src/test/transaction_tests.cpp index d12535e43..cdd88f348 100644 --- a/src/test/transaction_tests.cpp +++ b/src/test/transaction_tests.cpp @@ -22,7 +22,8 @@ #include #include #include -#include "json/json_spirit_writer_template.h" + +#include "json_spirit_wrapper.h" using namespace std; using namespace json_spirit; @@ -90,14 +91,21 @@ BOOST_AUTO_TEST_CASE(tx_valid) // verifyFlags is a comma separated list of script verification flags to apply, or "NONE" Array 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++) { + Array 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].type() != str_type || test[2].type() != str_type) + if (test.size() != 3 || !test[1].isStr() || !test[2].isStr()) { BOOST_ERROR("Bad test: " << strTest); continue; @@ -106,9 +114,9 @@ BOOST_AUTO_TEST_CASE(tx_valid) map mapprevOutScriptPubKeys; Array inputs = test[0].get_array(); bool fValid = true; - BOOST_FOREACH(Value& input, inputs) - { - if (input.type() != array_type) + for (unsigned int inpIdx = 0; inpIdx < inputs.size(); inpIdx++) { + const Value& input = inputs[inpIdx]; + if (!input.isArray()) { fValid = false; break; @@ -166,14 +174,21 @@ BOOST_AUTO_TEST_CASE(tx_invalid) // verifyFlags is a comma separated list of script verification flags to apply, or "NONE" Array 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++) { + Array 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].type() != str_type || test[2].type() != str_type) + if (test.size() != 3 || !test[1].isStr() || !test[2].isStr()) { BOOST_ERROR("Bad test: " << strTest); continue; @@ -182,9 +197,9 @@ BOOST_AUTO_TEST_CASE(tx_invalid) map mapprevOutScriptPubKeys; Array inputs = test[0].get_array(); bool fValid = true; - BOOST_FOREACH(Value& input, inputs) - { - if (input.type() != array_type) + for (unsigned int inpIdx = 0; inpIdx < inputs.size(); inpIdx++) { + const Value& input = inputs[inpIdx]; + if (!input.isArray()) { fValid = false; break; -- cgit v1.2.3 From 53b4671a9de75f7c8e2903d510cf88867c3f6b97 Mon Sep 17 00:00:00 2001 From: Jonas Schnelli Date: Sun, 10 May 2015 13:35:44 +0200 Subject: extend conversion to UniValue --- src/test/transaction_tests.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'src/test/transaction_tests.cpp') diff --git a/src/test/transaction_tests.cpp b/src/test/transaction_tests.cpp index cdd88f348..0ddc48271 100644 --- a/src/test/transaction_tests.cpp +++ b/src/test/transaction_tests.cpp @@ -20,6 +20,7 @@ #include #include +#include #include #include -- cgit v1.2.3 From 3df0411ad9fd75fb27af53e44835d41f5480fe3f Mon Sep 17 00:00:00 2001 From: Jonas Schnelli Date: Wed, 13 May 2015 21:29:19 +0200 Subject: remove JSON Spirit UniValue wrapper --- src/test/transaction_tests.cpp | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'src/test/transaction_tests.cpp') diff --git a/src/test/transaction_tests.cpp b/src/test/transaction_tests.cpp index 0ddc48271..afd2d7401 100644 --- a/src/test/transaction_tests.cpp +++ b/src/test/transaction_tests.cpp @@ -30,7 +30,7 @@ using namespace std; using namespace json_spirit; // In script_tests.cpp -extern Array read_json(const std::string& jsondata); +extern UniValue read_json(const std::string& jsondata); static std::map mapFlagNames = boost::assign::map_list_of (string("NONE"), (unsigned int)SCRIPT_VERIFY_NONE) @@ -90,7 +90,7 @@ BOOST_AUTO_TEST_CASE(tx_valid) // ... where all scripts are stringified scripts. // // verifyFlags is a comma separated list of script verification flags to apply, or "NONE" - Array tests = read_json(std::string(json_tests::tx_valid, json_tests::tx_valid + sizeof(json_tests::tx_valid))); + UniValue tests = read_json(std::string(json_tests::tx_valid, json_tests::tx_valid + sizeof(json_tests::tx_valid))); <<<<<<< HEAD ScriptError err; @@ -101,7 +101,7 @@ BOOST_AUTO_TEST_CASE(tx_valid) if (test[0].type() == array_type) ======= for (unsigned int idx = 0; idx < tests.size(); idx++) { - Array test = tests[idx]; + UniValue test = tests[idx]; string strTest = test.write(); if (test[0].isArray()) >>>>>>> Convert tree to using univalue. Eliminate all json_spirit uses. @@ -113,7 +113,7 @@ BOOST_AUTO_TEST_CASE(tx_valid) } map mapprevOutScriptPubKeys; - Array inputs = test[0].get_array(); + UniValue inputs = test[0].get_array(); bool fValid = true; for (unsigned int inpIdx = 0; inpIdx < inputs.size(); inpIdx++) { const Value& input = inputs[inpIdx]; @@ -122,7 +122,7 @@ BOOST_AUTO_TEST_CASE(tx_valid) fValid = false; break; } - Array vinput = input.get_array(); + UniValue vinput = input.get_array(); if (vinput.size() != 3) { fValid = false; @@ -173,7 +173,7 @@ BOOST_AUTO_TEST_CASE(tx_invalid) // ... where all scripts are stringified scripts. // // verifyFlags is a comma separated list of script verification flags to apply, or "NONE" - Array tests = read_json(std::string(json_tests::tx_invalid, json_tests::tx_invalid + sizeof(json_tests::tx_invalid))); + UniValue tests = read_json(std::string(json_tests::tx_invalid, json_tests::tx_invalid + sizeof(json_tests::tx_invalid))); <<<<<<< HEAD ScriptError err; @@ -184,7 +184,7 @@ BOOST_AUTO_TEST_CASE(tx_invalid) if (test[0].type() == array_type) ======= for (unsigned int idx = 0; idx < tests.size(); idx++) { - Array test = tests[idx]; + UniValue test = tests[idx]; string strTest = test.write(); if (test[0].isArray()) >>>>>>> Convert tree to using univalue. Eliminate all json_spirit uses. @@ -196,7 +196,7 @@ BOOST_AUTO_TEST_CASE(tx_invalid) } map mapprevOutScriptPubKeys; - Array inputs = test[0].get_array(); + UniValue inputs = test[0].get_array(); bool fValid = true; for (unsigned int inpIdx = 0; inpIdx < inputs.size(); inpIdx++) { const Value& input = inputs[inpIdx]; @@ -205,7 +205,7 @@ BOOST_AUTO_TEST_CASE(tx_invalid) fValid = false; break; } - Array vinput = input.get_array(); + UniValue vinput = input.get_array(); if (vinput.size() != 3) { fValid = false; -- cgit v1.2.3 From 9a8897f4ac992741e153d88b54bd2cde877c713d Mon Sep 17 00:00:00 2001 From: Jonas Schnelli Date: Mon, 18 May 2015 14:02:18 +0200 Subject: Remove JSON Spirit wrapper, remove JSON Spirit leftovers - implement find_value() function for UniValue - replace all Array/Value/Object types with UniValues, remove JSON Spirit to UniValue wrapper - remove JSON Spirit sources --- src/test/transaction_tests.cpp | 23 +++-------------------- 1 file changed, 3 insertions(+), 20 deletions(-) (limited to 'src/test/transaction_tests.cpp') diff --git a/src/test/transaction_tests.cpp b/src/test/transaction_tests.cpp index afd2d7401..4cfdec126 100644 --- a/src/test/transaction_tests.cpp +++ b/src/test/transaction_tests.cpp @@ -24,10 +24,9 @@ #include #include -#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; -- cgit v1.2.3