Skip to content

Commit 66d13c8

Browse files
committed
test: add check that large txs aren't put into orphanage
1 parent ed7d224 commit 66d13c8

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

src/test/orphanage_tests.cpp

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,15 @@
33
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
44

55
#include <arith_uint256.h>
6+
#include <consensus/validation.h>
7+
#include <policy/policy.h>
68
#include <primitives/transaction.h>
79
#include <pubkey.h>
810
#include <script/sign.h>
911
#include <script/signingprovider.h>
1012
#include <test/util/random.h>
1113
#include <test/util/setup_common.h>
14+
#include <test/util/transaction_utils.h>
1215
#include <txorphanage.h>
1316

1417
#include <array>
@@ -370,4 +373,21 @@ BOOST_AUTO_TEST_CASE(get_children)
370373
}
371374
}
372375

376+
BOOST_AUTO_TEST_CASE(too_large_orphan_tx)
377+
{
378+
TxOrphanage orphanage;
379+
CMutableTransaction tx;
380+
tx.vin.resize(1);
381+
382+
// check that txs larger than MAX_STANDARD_TX_WEIGHT are not added to the orphanage
383+
BulkTransaction(tx, MAX_STANDARD_TX_WEIGHT + 4);
384+
BOOST_CHECK_EQUAL(GetTransactionWeight(CTransaction(tx)), MAX_STANDARD_TX_WEIGHT + 4);
385+
BOOST_CHECK(!orphanage.AddTx(MakeTransactionRef(tx), 0));
386+
387+
tx.vout.clear();
388+
BulkTransaction(tx, MAX_STANDARD_TX_WEIGHT);
389+
BOOST_CHECK_EQUAL(GetTransactionWeight(CTransaction(tx)), MAX_STANDARD_TX_WEIGHT);
390+
BOOST_CHECK(orphanage.AddTx(MakeTransactionRef(tx), 0));
391+
}
392+
373393
BOOST_AUTO_TEST_SUITE_END()

0 commit comments

Comments
 (0)