6#include <chainparams.h>
16#include <boost/test/unit_test.hpp>
25 tx.
vin[0].scriptSig.resize(10);
27 tx.
vout[0].nValue = 42;
39 block.
nBits = 0x207fffff;
42 tx.
vin[0].prevout.n = 0;
46 for (
size_t i = 0; i < tx.
vin.size(); i++) {
48 tx.
vin[i].prevout.n = 0;
92 size_t poolSize = pool.
size();
216 txhash = block.
vtx[2]->GetHash();
269 txhash = block.
vtx[1]->GetHash();
288 block.
nBits = 0x207fffff;
310 std::vector<CTransactionRef> vtx_missing;
325 mtx.
vin[0].prevout.n = 0;
336 std::vector<std::pair<Wtxid, CTransactionRef>> extra_txn;
337 extra_txn.resize(10);
343 for (
const auto &block_tx : block.
vtx) {
344 BOOST_CHECK_NE(block_tx->GetHash(), non_block_tx->GetHash());
360 extra_txn[0] = {non_block_tx->GetWitnessHash(), non_block_tx};
362 extra_txn[1] = {block.
vtx[1]->GetWitnessHash(), block.
vtx[1]};
371 extra_txn[2] = {block.
vtx[2]->GetWitnessHash(), non_block_tx};
374 BOOST_CHECK(partial_block_with_extra_collision.IsTxAvailable(1));
375 BOOST_CHECK(!partial_block_with_extra_collision.IsTxAvailable(2));
380 extra_txn[3] = {block.
vtx[1]->GetWitnessHash(), non_block_tx};
383 BOOST_CHECK(!partial_block_with_extra_source_collision.IsTxAvailable(1));
384 BOOST_CHECK(!partial_block_with_extra_source_collision.IsTxAvailable(2));
385 BOOST_CHECK_EQUAL(partial_block_with_extra_source_collision.GetMempoolCount(), 0U);
386 BOOST_CHECK_EQUAL(partial_block_with_extra_source_collision.GetExtraCount(), 0U);
389 extra_txn[4] = {block.
vtx[2]->GetWitnessHash(), block.
vtx[2]};
390 extra_txn[5] = {block.
vtx[1]->GetWitnessHash(), block.
vtx[1]};
393 BOOST_CHECK(!partial_block_no_refill.IsTxAvailable(1));
394 BOOST_CHECK(!partial_block_no_refill.IsTxAvailable(2));
447 req0.
indexes[1] = 0x10000 - 0x7000 - 2;
463 }
catch(std::ios_base::failure &) {
TryAddToMempool(pool, CTxMemPoolEntry(tx, fee, 0, 1, 0, false, 4, lp))
static CBlock BuildBlockTestCase(FastRandomContext &ctx)
BOOST_AUTO_TEST_CASE(SimpleRoundTripTest)
const std::vector< std::pair< Wtxid, CTransactionRef > > empty_extra_txn
constexpr long SHARED_TX_OFFSET
static CMutableTransaction BuildTransactionTestCase()
const CChainParams & Params()
Return the currently selected parameters.
#define Assert(val)
Identity function.
std::vector< uint16_t > indexes
uint64_t GetShortID(const Wtxid &wtxid) const
std::vector< CTransactionRef > vtx
CTxMemPool stores valid-according-to-the-current-best-chain transactions that may be included in the ...
void check(const CCoinsViewCache &active_coins_tip, int64_t spendheight) const EXCLUSIVE_LOCKS_REQUIRED(void removeRecursive(const CTransaction &tx, MemPoolRemovalReason reason) EXCLUSIVE_LOCKS_REQUIRED(cs)
If sanity-checking is turned on, check makes sure the pool is consistent (does not contain two transa...
CTransactionRef get(const Txid &hash) const
Return a mempool transaction with a given hash.
unsigned long size() const
Double ended buffer combining vector and stream-like interfaces.
PartiallyDownloadedBlock(CTxMemPool *poolIn)
ReadStatus FillBlock(CBlock &block, const std::vector< CTransactionRef > &vtx_missing, bool segwit_active)
bool IsTxAvailable(size_t index) const
ReadStatus InitData(const CBlockHeaderAndShortTxIDs &cmpctblock, const std::vector< std::pair< Wtxid, CTransactionRef > > &extra_txn)
uint256 rand256() noexcept
generate a random uint256.
TestHeaderAndShortIDs(const CBlockHeaderAndShortTxIDs &orig)
std::vector< uint64_t > shorttxids
std::vector< PrefilledTransaction > prefilledtxn
TestHeaderAndShortIDs(const CBlock &block, FastRandomContext &ctx)
uint64_t GetShortID(const Wtxid &txhash) const
SERIALIZE_METHODS(TestHeaderAndShortIDs, obj)
std::string ToString() const
transaction_identifier represents the two canonical transaction identifier types (txid,...
static transaction_identifier FromUint256(const uint256 &id)
uint256 BlockMerkleRoot(const CBlock &block, bool *mutated)
RecursiveMutex cs_main
Mutex to guard access to validation specific variables, such as reading or changing the chainstate.
BOOST_FIXTURE_TEST_SUITE(cuckoocache_tests, BasicTestingSetup)
Test Suite for CuckooCache.
BOOST_AUTO_TEST_SUITE_END()
BOOST_CHECK_EQUAL(headers.FindFirst("key"), "value")
@ REPLACED
Removed for replacement.
std::string ToString(const T &t)
Locale-independent version of std::to_string.
#define BOOST_CHECK(expr)
bool CheckProofOfWork(uint256 hash, unsigned int nBits, const Consensus::Params ¶ms)
Check whether a block hash satisfies the proof-of-work requirement specified by nBits.
static CTransactionRef MakeTransactionRef(Tx &&txIn)
std::shared_ptr< const CTransaction > CTransactionRef
void WriteCompactSize(SizeComputer &os, uint64_t nSize)
static Wrapper< Formatter, T & > Using(T &&t)
Cause serialization/deserialization of an object to be done using a specified formatter class.
A mutable version of CTransaction.
std::vector< CTxOut > vout
Identical to TestingSetup, but chain set to regtest.
CTxMemPoolEntry FromTx(const CMutableTransaction &tx) const
size_t GetExtraCount() const
size_t GetMempoolCount() const
std::unique_ptr< CTxMemPool > mempool