mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-06-04 12:12:58 +02:00
-BEGIN VERIFY SCRIPT- # Move files for f in $(git ls-files src/test/lib/); do git mv $f src/test/util/; done git mv src/test/setup_common.cpp src/test/util/ git mv src/test/setup_common.h src/test/util/ # Replace Windows paths sed -i -e 's|\\setup_common|\\util\\setup_common|g' $(git grep -l '\\setup_common') sed -i -e 's|src\\test\\lib\\|src\\test\\util\\|g' build_msvc/test_bitcoin/test_bitcoin.vcxproj # Everything else sed -i -e 's|/setup_common|/util/setup_common|g' $(git grep -l 'setup_common') sed -i -e 's|test/lib/|test/util/|g' $(git grep -l 'test/lib/') # Fix include guard sed -i -e 's|BITCOIN_TEST_SETUP_COMMON_H|BITCOIN_TEST_UTIL_SETUP_COMMON_H|g' ./src/test/util/setup_common.h sed -i -e 's|BITCOIN_TEST_LIB_|BITCOIN_TEST_UTIL_|g' $(git grep -l 'BITCOIN_TEST_LIB_') -END VERIFY SCRIPT-
56 lines
1.7 KiB
C++
56 lines
1.7 KiB
C++
// Copyright (c) 2017-2019 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 <validation.h>
|
|
#include <consensus/validation.h>
|
|
#include <primitives/transaction.h>
|
|
#include <script/script.h>
|
|
#include <test/util/setup_common.h>
|
|
|
|
#include <boost/test/unit_test.hpp>
|
|
|
|
|
|
BOOST_AUTO_TEST_SUITE(txvalidation_tests)
|
|
|
|
/**
|
|
* Ensure that the mempool won't accept coinbase transactions.
|
|
*/
|
|
BOOST_FIXTURE_TEST_CASE(tx_mempool_reject_coinbase, TestChain100Setup)
|
|
{
|
|
CScript scriptPubKey = CScript() << ToByteVector(coinbaseKey.GetPubKey()) << OP_CHECKSIG;
|
|
CMutableTransaction coinbaseTx;
|
|
|
|
coinbaseTx.nVersion = 1;
|
|
coinbaseTx.vin.resize(1);
|
|
coinbaseTx.vout.resize(1);
|
|
coinbaseTx.vin[0].scriptSig = CScript() << OP_11 << OP_EQUAL;
|
|
coinbaseTx.vout[0].nValue = 1 * CENT;
|
|
coinbaseTx.vout[0].scriptPubKey = scriptPubKey;
|
|
|
|
BOOST_CHECK(CTransaction(coinbaseTx).IsCoinBase());
|
|
|
|
TxValidationState state;
|
|
|
|
LOCK(cs_main);
|
|
|
|
unsigned int initialPoolSize = mempool.size();
|
|
|
|
BOOST_CHECK_EQUAL(
|
|
false,
|
|
AcceptToMemoryPool(mempool, state, MakeTransactionRef(coinbaseTx),
|
|
nullptr /* plTxnReplaced */,
|
|
true /* bypass_limits */,
|
|
0 /* nAbsurdFee */));
|
|
|
|
// Check that the transaction hasn't been added to mempool.
|
|
BOOST_CHECK_EQUAL(mempool.size(), initialPoolSize);
|
|
|
|
// Check that the validation state reflects the unsuccessful attempt.
|
|
BOOST_CHECK(state.IsInvalid());
|
|
BOOST_CHECK_EQUAL(state.GetRejectReason(), "coinbase");
|
|
BOOST_CHECK(state.GetResult() == TxValidationResult::TX_CONSENSUS);
|
|
}
|
|
|
|
BOOST_AUTO_TEST_SUITE_END()
|