From 913cdb695c51318851499820faba1d5aa2b7ff3e Mon Sep 17 00:00:00 2001 From: barton26 Date: Fri, 15 Oct 2021 18:02:55 -0400 Subject: [PATCH] transaction tests - header, includes, namespace --- src/test/transaction_tests.cpp | 35 ++++++++++++++++++---------------- 1 file changed, 19 insertions(+), 16 deletions(-) diff --git a/src/test/transaction_tests.cpp b/src/test/transaction_tests.cpp index 96d1862be5..78185f666f 100755 --- a/src/test/transaction_tests.cpp +++ b/src/test/transaction_tests.cpp @@ -1,22 +1,25 @@ +// Copyright (c) 2011-2020 The Bitcoin Core developers +// Distributed under the MIT software license, see the accompanying +// file COPYING or http://www.opensource.org/licenses/mit-license.php. + #include #include +#include #include -#include "main.h" -#include "streams.h" -#include "wallet/wallet.h" +#include +#include +#include #include -#include "test/data/tx_valid.json.h" -#include "test/data/tx_invalid.json.h" +#include +#include #include -using namespace std; - // In script_tests.cpp extern UniValue read_json(const std::string& jsondata); -extern CScript ParseScript(string s); +extern CScript ParseScript(std::string s); // This is in anonymous namespace as the CMutableBitcoinTransaction is only used here in this testing suite. namespace { @@ -74,7 +77,7 @@ BOOST_AUTO_TEST_CASE(tx_valid) for (unsigned int idx = 0; idx < tests.size(); idx++) { UniValue test = tests[idx]; - string strTest = test.write(); + std::string strTest = test.write(); if (test[0].isArray()) { if (test.size() != 3 || !test[1].isStr() || !test[2].isBool()) @@ -83,7 +86,7 @@ BOOST_AUTO_TEST_CASE(tx_valid) continue; } - map mapprevOutScriptPubKeys; + std::map mapprevOutScriptPubKeys; UniValue inputs = test[0].get_array(); bool fValid = true; for (unsigned int inpIdx = 0; inpIdx < inputs.size(); inpIdx++) @@ -111,7 +114,7 @@ BOOST_AUTO_TEST_CASE(tx_valid) continue; } - string transaction = test[1].get_str(); + std::string transaction = test[1].get_str(); CDataStream stream(ParseHex(transaction), SER_NETWORK, PROTOCOL_VERSION); CMutableBitcoinTransaction btx; stream >> btx; @@ -155,7 +158,7 @@ BOOST_AUTO_TEST_CASE(tx_invalid) continue; } - map mapprevOutScriptPubKeys; + std::map mapprevOutScriptPubKeys; UniValue inputs = test[0].get_array(); bool fValid = true; for (unsigned int inpIdx = 0; inpIdx < inputs.size(); inpIdx++) @@ -179,7 +182,7 @@ BOOST_AUTO_TEST_CASE(tx_invalid) continue; } - string transaction = test[1].get_str(); + std::string transaction = test[1].get_str(); CDataStream stream(ParseHex(transaction), SER_NETWORK, PROTOCOL_VERSION); CMutableBitcoinTransaction btx; stream >> btx; @@ -228,7 +231,7 @@ BOOST_AUTO_TEST_CASE(basic_transaction_tests) 0x00, 0x19, 0x76, 0xa9, 0x14, 0xc1, 0x09, 0x32, 0x48, 0x3f, 0xec, 0x93, 0xed, 0x51, 0xf5, 0xfe, 0x95, 0xe7, 0x25, 0x59, 0xf2, 0xcc, 0x70, 0x43, 0xf9, 0x88, 0xac, 0x00, 0x00, 0x00, 0x00, 0x00}; - vector vch(ch, ch + sizeof(ch) -1); + std::vector vch(ch, ch + sizeof(ch) -1); CDataStream stream(vch, SER_DISK, CLIENT_VERSION); CMutableBitcoinTransaction btx; stream >> btx; @@ -266,14 +269,14 @@ SetupDummyInputs(CBasicKeyStore& keystoreRet, MapPrevTx& inputsRet) dummyTransactions[0].vout[0].scriptPubKey << key[0].GetPubKey() << OP_CHECKSIG; dummyTransactions[0].vout[1].nValue = 50*CENT; dummyTransactions[0].vout[1].scriptPubKey << key[1].GetPubKey() << OP_CHECKSIG; - inputsRet[dummyTransactions[0].GetHash()] = make_pair(CTxIndex(), dummyTransactions[0]); + inputsRet[dummyTransactions[0].GetHash()] = std::make_pair(CTxIndex(), dummyTransactions[0]); dummyTransactions[1].vout.resize(2); dummyTransactions[1].vout[0].nValue = 21*CENT; dummyTransactions[1].vout[0].scriptPubKey.SetDestination(key[2].GetPubKey().GetID()); dummyTransactions[1].vout[1].nValue = 22*CENT; dummyTransactions[1].vout[1].scriptPubKey.SetDestination(key[3].GetPubKey().GetID()); - inputsRet[dummyTransactions[1].GetHash()] = make_pair(CTxIndex(), dummyTransactions[1]); + inputsRet[dummyTransactions[1].GetHash()] = std::make_pair(CTxIndex(), dummyTransactions[1]); return dummyTransactions; }