mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-11-12 23:18:14 +01:00
CValidationState framework
This commit is contained in:
committed by
Pieter Wuille
parent
2835080e16
commit
ef3988ca36
@@ -66,7 +66,9 @@ BOOST_AUTO_TEST_CASE(tx_valid)
|
||||
CTransaction tx;
|
||||
stream >> tx;
|
||||
|
||||
BOOST_CHECK_MESSAGE(tx.CheckTransaction(), strTest);
|
||||
CValidationState state;
|
||||
BOOST_CHECK_MESSAGE(tx.CheckTransaction(state), strTest);
|
||||
BOOST_CHECK(state.IsValid());
|
||||
|
||||
for (unsigned int i = 0; i < tx.vin.size(); i++)
|
||||
{
|
||||
@@ -133,7 +135,8 @@ BOOST_AUTO_TEST_CASE(tx_invalid)
|
||||
CTransaction tx;
|
||||
stream >> tx;
|
||||
|
||||
fValid = tx.CheckTransaction();
|
||||
CValidationState state;
|
||||
fValid = tx.CheckTransaction(state) && state.IsValid();
|
||||
|
||||
for (unsigned int i = 0; i < tx.vin.size() && fValid; i++)
|
||||
{
|
||||
@@ -159,11 +162,12 @@ BOOST_AUTO_TEST_CASE(basic_transaction_tests)
|
||||
CDataStream stream(vch, SER_DISK, CLIENT_VERSION);
|
||||
CTransaction tx;
|
||||
stream >> tx;
|
||||
BOOST_CHECK_MESSAGE(tx.CheckTransaction(), "Simple deserialized transaction should be valid.");
|
||||
CValidationState state;
|
||||
BOOST_CHECK_MESSAGE(tx.CheckTransaction(state) && state.IsValid(), "Simple deserialized transaction should be valid.");
|
||||
|
||||
// Check that duplicate txins fail
|
||||
tx.vin.push_back(tx.vin[0]);
|
||||
BOOST_CHECK_MESSAGE(!tx.CheckTransaction(), "Transaction with duplicate txins should be invalid.");
|
||||
BOOST_CHECK_MESSAGE(!tx.CheckTransaction(state) || !state.IsValid(), "Transaction with duplicate txins should be invalid.");
|
||||
}
|
||||
|
||||
//
|
||||
|
||||
Reference in New Issue
Block a user