Convert tree to using univalue. Eliminate all json_spirit uses.

This commit is contained in:
Jeff Garzik
2014-08-20 15:15:16 -04:00
committed by Jack Grigg
parent 03912600e8
commit ed21d5bd4b
23 changed files with 320 additions and 204 deletions

View File

@@ -25,7 +25,8 @@
#include <boost/algorithm/string/split.hpp>
#include <boost/test/unit_test.hpp>
#include <boost/assign/list_of.hpp>
#include "json/json_spirit_writer_template.h"
#include "json_spirit_wrapper.h"
#include "zcash/Note.hpp"
#include "zcash/Address.hpp"
@@ -99,14 +100,21 @@ BOOST_AUTO_TEST_CASE(tx_valid)
Array tests = read_json(std::string(json_tests::tx_valid, json_tests::tx_valid + sizeof(json_tests::tx_valid)));
auto verifier = libzcash::ProofVerifier::Strict();
<<<<<<< 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;
@@ -115,9 +123,9 @@ BOOST_AUTO_TEST_CASE(tx_valid)
map<COutPoint, CScript> 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;
@@ -176,14 +184,21 @@ BOOST_AUTO_TEST_CASE(tx_invalid)
Array tests = read_json(std::string(json_tests::tx_invalid, json_tests::tx_invalid + sizeof(json_tests::tx_invalid)));
auto verifier = libzcash::ProofVerifier::Strict();
<<<<<<< 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;
@@ -192,9 +207,9 @@ BOOST_AUTO_TEST_CASE(tx_invalid)
map<COutPoint, CScript> 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;