mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-11-11 22:50:59 +01:00
Removed implicit CTransaction constructor from tests
This commit is contained in:
@@ -273,11 +273,11 @@ BOOST_AUTO_TEST_CASE(basic_transaction_tests)
|
||||
CMutableTransaction tx;
|
||||
stream >> tx;
|
||||
CValidationState state;
|
||||
BOOST_CHECK_MESSAGE(CheckTransaction(tx, state) && state.IsValid(), "Simple deserialized transaction should be valid.");
|
||||
BOOST_CHECK_MESSAGE(CheckTransaction(CTransaction(tx), state) && state.IsValid(), "Simple deserialized transaction should be valid.");
|
||||
|
||||
// Check that duplicate txins fail
|
||||
tx.vin.push_back(tx.vin[0]);
|
||||
BOOST_CHECK_MESSAGE(!CheckTransaction(tx, state) || !state.IsValid(), "Transaction with duplicate txins should be invalid.");
|
||||
BOOST_CHECK_MESSAGE(!CheckTransaction(CTransaction(tx), state) || !state.IsValid(), "Transaction with duplicate txins should be invalid.");
|
||||
}
|
||||
|
||||
//
|
||||
@@ -306,14 +306,14 @@ SetupDummyInputs(CBasicKeyStore& keystoreRet, CCoinsViewCache& coinsRet)
|
||||
dummyTransactions[0].vout[0].scriptPubKey << ToByteVector(key[0].GetPubKey()) << OP_CHECKSIG;
|
||||
dummyTransactions[0].vout[1].nValue = 50*CENT;
|
||||
dummyTransactions[0].vout[1].scriptPubKey << ToByteVector(key[1].GetPubKey()) << OP_CHECKSIG;
|
||||
AddCoins(coinsRet, dummyTransactions[0], 0);
|
||||
AddCoins(coinsRet, CTransaction(dummyTransactions[0]), 0);
|
||||
|
||||
dummyTransactions[1].vout.resize(2);
|
||||
dummyTransactions[1].vout[0].nValue = 21*CENT;
|
||||
dummyTransactions[1].vout[0].scriptPubKey = GetScriptForDestination(key[2].GetPubKey().GetID());
|
||||
dummyTransactions[1].vout[1].nValue = 22*CENT;
|
||||
dummyTransactions[1].vout[1].scriptPubKey = GetScriptForDestination(key[3].GetPubKey().GetID());
|
||||
AddCoins(coinsRet, dummyTransactions[1], 0);
|
||||
AddCoins(coinsRet, CTransaction(dummyTransactions[1]), 0);
|
||||
|
||||
return dummyTransactions;
|
||||
}
|
||||
@@ -340,8 +340,8 @@ BOOST_AUTO_TEST_CASE(test_Get)
|
||||
t1.vout[0].nValue = 90*CENT;
|
||||
t1.vout[0].scriptPubKey << OP_1;
|
||||
|
||||
BOOST_CHECK(AreInputsStandard(t1, coins));
|
||||
BOOST_CHECK_EQUAL(coins.GetValueIn(t1), (50+21+22)*CENT);
|
||||
BOOST_CHECK(AreInputsStandard(CTransaction(t1), coins));
|
||||
BOOST_CHECK_EQUAL(coins.GetValueIn(CTransaction(t1)), (50+21+22)*CENT);
|
||||
}
|
||||
|
||||
static void CreateCreditAndSpend(const CKeyStore& keystore, const CScript& outscript, CTransactionRef& output, CMutableTransaction& input, bool success = true)
|
||||
@@ -697,75 +697,75 @@ BOOST_AUTO_TEST_CASE(test_IsStandard)
|
||||
t.vout[0].scriptPubKey = GetScriptForDestination(key.GetPubKey().GetID());
|
||||
|
||||
std::string reason;
|
||||
BOOST_CHECK(IsStandardTx(t, reason));
|
||||
BOOST_CHECK(IsStandardTx(CTransaction(t), reason));
|
||||
|
||||
// Check dust with default relay fee:
|
||||
CAmount nDustThreshold = 182 * dustRelayFee.GetFeePerK()/1000;
|
||||
BOOST_CHECK_EQUAL(nDustThreshold, 546);
|
||||
// dust:
|
||||
t.vout[0].nValue = nDustThreshold - 1;
|
||||
BOOST_CHECK(!IsStandardTx(t, reason));
|
||||
BOOST_CHECK(!IsStandardTx(CTransaction(t), reason));
|
||||
// not dust:
|
||||
t.vout[0].nValue = nDustThreshold;
|
||||
BOOST_CHECK(IsStandardTx(t, reason));
|
||||
BOOST_CHECK(IsStandardTx(CTransaction(t), reason));
|
||||
|
||||
// Check dust with odd relay fee to verify rounding:
|
||||
// nDustThreshold = 182 * 3702 / 1000
|
||||
dustRelayFee = CFeeRate(3702);
|
||||
// dust:
|
||||
t.vout[0].nValue = 673 - 1;
|
||||
BOOST_CHECK(!IsStandardTx(t, reason));
|
||||
BOOST_CHECK(!IsStandardTx(CTransaction(t), reason));
|
||||
// not dust:
|
||||
t.vout[0].nValue = 673;
|
||||
BOOST_CHECK(IsStandardTx(t, reason));
|
||||
BOOST_CHECK(IsStandardTx(CTransaction(t), reason));
|
||||
dustRelayFee = CFeeRate(DUST_RELAY_TX_FEE);
|
||||
|
||||
t.vout[0].scriptPubKey = CScript() << OP_1;
|
||||
BOOST_CHECK(!IsStandardTx(t, reason));
|
||||
BOOST_CHECK(!IsStandardTx(CTransaction(t), reason));
|
||||
|
||||
// MAX_OP_RETURN_RELAY-byte TX_NULL_DATA (standard)
|
||||
t.vout[0].scriptPubKey = CScript() << OP_RETURN << ParseHex("04678afdb0fe5548271967f1a67130b7105cd6a828e03909a67962e0ea1f61deb649f6bc3f4cef3804678afdb0fe5548271967f1a67130b7105cd6a828e03909a67962e0ea1f61deb649f6bc3f4cef38");
|
||||
BOOST_CHECK_EQUAL(MAX_OP_RETURN_RELAY, t.vout[0].scriptPubKey.size());
|
||||
BOOST_CHECK(IsStandardTx(t, reason));
|
||||
BOOST_CHECK(IsStandardTx(CTransaction(t), reason));
|
||||
|
||||
// MAX_OP_RETURN_RELAY+1-byte TX_NULL_DATA (non-standard)
|
||||
t.vout[0].scriptPubKey = CScript() << OP_RETURN << ParseHex("04678afdb0fe5548271967f1a67130b7105cd6a828e03909a67962e0ea1f61deb649f6bc3f4cef3804678afdb0fe5548271967f1a67130b7105cd6a828e03909a67962e0ea1f61deb649f6bc3f4cef3800");
|
||||
BOOST_CHECK_EQUAL(MAX_OP_RETURN_RELAY + 1, t.vout[0].scriptPubKey.size());
|
||||
BOOST_CHECK(!IsStandardTx(t, reason));
|
||||
BOOST_CHECK(!IsStandardTx(CTransaction(t), reason));
|
||||
|
||||
// Data payload can be encoded in any way...
|
||||
t.vout[0].scriptPubKey = CScript() << OP_RETURN << ParseHex("");
|
||||
BOOST_CHECK(IsStandardTx(t, reason));
|
||||
BOOST_CHECK(IsStandardTx(CTransaction(t), reason));
|
||||
t.vout[0].scriptPubKey = CScript() << OP_RETURN << ParseHex("00") << ParseHex("01");
|
||||
BOOST_CHECK(IsStandardTx(t, reason));
|
||||
BOOST_CHECK(IsStandardTx(CTransaction(t), reason));
|
||||
// OP_RESERVED *is* considered to be a PUSHDATA type opcode by IsPushOnly()!
|
||||
t.vout[0].scriptPubKey = CScript() << OP_RETURN << OP_RESERVED << -1 << 0 << ParseHex("01") << 2 << 3 << 4 << 5 << 6 << 7 << 8 << 9 << 10 << 11 << 12 << 13 << 14 << 15 << 16;
|
||||
BOOST_CHECK(IsStandardTx(t, reason));
|
||||
BOOST_CHECK(IsStandardTx(CTransaction(t), reason));
|
||||
t.vout[0].scriptPubKey = CScript() << OP_RETURN << 0 << ParseHex("01") << 2 << ParseHex("ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");
|
||||
BOOST_CHECK(IsStandardTx(t, reason));
|
||||
BOOST_CHECK(IsStandardTx(CTransaction(t), reason));
|
||||
|
||||
// ...so long as it only contains PUSHDATA's
|
||||
t.vout[0].scriptPubKey = CScript() << OP_RETURN << OP_RETURN;
|
||||
BOOST_CHECK(!IsStandardTx(t, reason));
|
||||
BOOST_CHECK(!IsStandardTx(CTransaction(t), reason));
|
||||
|
||||
// TX_NULL_DATA w/o PUSHDATA
|
||||
t.vout.resize(1);
|
||||
t.vout[0].scriptPubKey = CScript() << OP_RETURN;
|
||||
BOOST_CHECK(IsStandardTx(t, reason));
|
||||
BOOST_CHECK(IsStandardTx(CTransaction(t), reason));
|
||||
|
||||
// Only one TX_NULL_DATA permitted in all cases
|
||||
t.vout.resize(2);
|
||||
t.vout[0].scriptPubKey = CScript() << OP_RETURN << ParseHex("04678afdb0fe5548271967f1a67130b7105cd6a828e03909a67962e0ea1f61deb649f6bc3f4cef38");
|
||||
t.vout[1].scriptPubKey = CScript() << OP_RETURN << ParseHex("04678afdb0fe5548271967f1a67130b7105cd6a828e03909a67962e0ea1f61deb649f6bc3f4cef38");
|
||||
BOOST_CHECK(!IsStandardTx(t, reason));
|
||||
BOOST_CHECK(!IsStandardTx(CTransaction(t), reason));
|
||||
|
||||
t.vout[0].scriptPubKey = CScript() << OP_RETURN << ParseHex("04678afdb0fe5548271967f1a67130b7105cd6a828e03909a67962e0ea1f61deb649f6bc3f4cef38");
|
||||
t.vout[1].scriptPubKey = CScript() << OP_RETURN;
|
||||
BOOST_CHECK(!IsStandardTx(t, reason));
|
||||
BOOST_CHECK(!IsStandardTx(CTransaction(t), reason));
|
||||
|
||||
t.vout[0].scriptPubKey = CScript() << OP_RETURN;
|
||||
t.vout[1].scriptPubKey = CScript() << OP_RETURN;
|
||||
BOOST_CHECK(!IsStandardTx(t, reason));
|
||||
BOOST_CHECK(!IsStandardTx(CTransaction(t), reason));
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_SUITE_END()
|
||||
|
||||
Reference in New Issue
Block a user