v30.3-roots.1 · Commit 7: [PATCH 07/68] build: adapt Roots maintenance and assurance to Core 30.3
src/test/mempool_tests.cpp
Before: src/test/mempool_tests.cpp · After: src/test/mempool_tests.cpp
File metadata
index 2d8d0baa9677ed32f3dbdf617842f7533e584e67..099cc8ea6a9560cab430fac079384aff96ee47ea 100644
Download original patch · Release notes
Diff rows 1–36 of 36. Line numbers refer to the original before/after files.
+ Added− RemovedUnmarked lines are context.
Scroll the code area horizontally to read long lines. Before is on the left; after is on the right. Unified view fits narrow screens more easily.
src/test/mempool_tests.cpp
CHANGED
|
@@ -11,12 +11,36 @@
|
|
| 11 |
#include <test/util/setup_common.h>
|
| 12 |
|
| 13 |
#include <boost/test/unit_test.hpp>
|
|
|
|
|
|
|
| 14 |
#include <vector>
|
| 15 |
|
| 16 |
BOOST_FIXTURE_TEST_SUITE(mempool_tests, TestingSetup)
|
| 17 |
|
| 18 |
static constexpr auto REMOVAL_REASON_DUMMY = MemPoolRemovalReason::REPLACED;
|
| 19 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 20 |
class MemPoolTest final : public CTxMemPool
|
| 21 |
{
|
| 22 |
public:
|
|
|
|
| 11 |
#include <test/util/setup_common.h>
|
| 12 |
|
| 13 |
#include <boost/test/unit_test.hpp>
|
| 14 |
+
#include <array>
|
| 15 |
+
#include <limits>
|
| 16 |
#include <vector>
|
| 17 |
|
| 18 |
BOOST_FIXTURE_TEST_SUITE(mempool_tests, TestingSetup)
|
| 19 |
|
| 20 |
static constexpr auto REMOVAL_REASON_DUMMY = MemPoolRemovalReason::REPLACED;
|
| 21 |
|
| 22 |
+
BOOST_AUTO_TEST_CASE(MempoolExtraWeightBoundary)
|
| 23 |
+
{
|
| 24 |
+
CMutableTransaction tx;
|
| 25 |
+
tx.vin.resize(1);
|
| 26 |
+
tx.vout.emplace_back(0, CScript{} << OP_RETURN << std::vector<unsigned char>(100, 0));
|
| 27 |
+
const CTransactionRef txref{MakeTransactionRef(tx)};
|
| 28 |
+
CCoinsView view;
|
| 29 |
+
CCoinsViewCache cache{&view};
|
| 30 |
+
const int32_t max_extra_weight{CalculateExtraTxWeight(*txref, cache, std::numeric_limits<unsigned int>::max())};
|
| 31 |
+
BOOST_REQUIRE_EQUAL(max_extra_weight, std::numeric_limits<int32_t>::max());
|
| 32 |
+
const int32_t tx_weight{GetTransactionWeight(*txref)};
|
| 33 |
+
for (const int32_t extra_weight : std::array<int32_t, 4>{0, 4, max_extra_weight - tx_weight, max_extra_weight}) {
|
| 34 |
+
const CTxMemPoolEntry entry{txref, 0, 0, 1, 0, COIN_AGE_CACHE_ZERO, false, extra_weight, 0, {}};
|
| 35 |
+
// Configured carrier cost can reach the clamp; its virtual size must
|
| 36 |
+
// remain positive and charge every weight unit across INT32_MAX.
|
| 37 |
+
BOOST_CHECK_EQUAL(entry.GetTxSize(), (int64_t{tx_weight} + extra_weight + 3) / 4);
|
| 38 |
+
BOOST_CHECK_GT(entry.GetTxSize(), 0);
|
| 39 |
+
BOOST_CHECK_EQUAL(entry.GetSizeWithAncestors(), entry.GetTxSize());
|
| 40 |
+
BOOST_CHECK_EQUAL(entry.GetSizeWithDescendants(), entry.GetTxSize());
|
| 41 |
+
}
|
| 42 |
+
}
|
| 43 |
+
|
| 44 |
class MemPoolTest final : public CTxMemPool
|
| 45 |
{
|
| 46 |
public:
|