Skip to content

Commit

Permalink
[fix bitcoin#1] Understand transaction_tests
Browse files Browse the repository at this point in the history
  • Loading branch information
stplaydog committed Jun 25, 2019
1 parent 84d0fdc commit e48b456
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/primitives/transaction.h
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ class CTxIn
}

std::string ToString() const;
std::string toString() const;
};

/** An output of a transaction. It contains the public key that the next input
Expand Down Expand Up @@ -356,6 +357,18 @@ class CTransaction
}
return false;
}

std::string toString() {
std::string ret;
for(uint64_t i=0; i<vin.size(); i++) {
ret += vin[i].ToString();
}
for(uint64_t i=0; i<vout.size(); i++) {
ret += vout[i].ToString();
}
ret += "\n---------\n";
return ret;
}
};

/** A mutable version of CTransaction. */
Expand Down
4 changes: 4 additions & 0 deletions src/test/transaction_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,8 @@ BOOST_AUTO_TEST_CASE(tx_valid)
continue;
}

//std::cout<<test[1].write()<<std::endl;

std::map<COutPoint, CScript> mapprevOutScriptPubKeys;
std::map<COutPoint, int64_t> mapprevOutValues;
UniValue inputs = test[0].get_array();
Expand Down Expand Up @@ -149,6 +151,8 @@ BOOST_AUTO_TEST_CASE(tx_valid)
std::string transaction = test[1].get_str();
CDataStream stream(ParseHex(transaction), SER_NETWORK, PROTOCOL_VERSION);
CTransaction tx(deserialize, stream);

std::cout<<tx.toString()<<std::endl;

CValidationState state;
BOOST_CHECK_MESSAGE(CheckTransaction(tx, state), strTest);
Expand Down

0 comments on commit e48b456

Please sign in to comment.