diff options
author | Sebastian Falbesoner <sebastian.falbesoner@gmail.com> | 2024-09-03 21:59:12 +0200 |
---|---|---|
committer | Sebastian Falbesoner <sebastian.falbesoner@gmail.com> | 2024-09-03 22:23:48 +0200 |
commit | 66d13c870284327abc89d36c0b5cc5f58e96f570 (patch) | |
tree | 23bc82cd7177b95952c398b478132a7b020f87a0 /src/test | |
parent | ed7d2246661ec1789b7db0f21668270f0681ea4a (diff) |
test: add check that large txs aren't put into orphanage
Diffstat (limited to 'src/test')
-rw-r--r-- | src/test/orphanage_tests.cpp | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/src/test/orphanage_tests.cpp b/src/test/orphanage_tests.cpp index d4c52d7fe1..799f2c0fec 100644 --- a/src/test/orphanage_tests.cpp +++ b/src/test/orphanage_tests.cpp @@ -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> @@ -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() |