Skip to content

Commit

Permalink
test: add check that large txs aren't put into orphanage
Browse files Browse the repository at this point in the history
  • Loading branch information
theStack committed Sep 3, 2024
1 parent ed7d224 commit 66d13c8
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions src/test/orphanage_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,15 @@
// file COPYING or http://www.opensource.org/licenses/mit-license.php.

#include <arith_uint256.h>
#include <consensus/validation.h>
#include <policy/policy.h>
#include <primitives/transaction.h>
#include <pubkey.h>
#include <script/sign.h>
#include <script/signingprovider.h>
#include <test/util/random.h>
#include <test/util/setup_common.h>
#include <test/util/transaction_utils.h>
#include <txorphanage.h>

#include <array>
Expand Down Expand Up @@ -370,4 +373,21 @@ BOOST_AUTO_TEST_CASE(get_children)
}
}

BOOST_AUTO_TEST_CASE(too_large_orphan_tx)
{
TxOrphanage orphanage;
CMutableTransaction tx;
tx.vin.resize(1);

// check that txs larger than MAX_STANDARD_TX_WEIGHT are not added to the orphanage
BulkTransaction(tx, MAX_STANDARD_TX_WEIGHT + 4);
BOOST_CHECK_EQUAL(GetTransactionWeight(CTransaction(tx)), MAX_STANDARD_TX_WEIGHT + 4);
BOOST_CHECK(!orphanage.AddTx(MakeTransactionRef(tx), 0));

tx.vout.clear();
BulkTransaction(tx, MAX_STANDARD_TX_WEIGHT);
BOOST_CHECK_EQUAL(GetTransactionWeight(CTransaction(tx)), MAX_STANDARD_TX_WEIGHT);
BOOST_CHECK(orphanage.AddTx(MakeTransactionRef(tx), 0));
}

BOOST_AUTO_TEST_SUITE_END()

0 comments on commit 66d13c8

Please sign in to comment.