aboutsummaryrefslogtreecommitdiff
path: root/src/test/denialofservice_tests.cpp
diff options
context:
space:
mode:
authorAnthony Towns <aj@erisian.com.au>2021-02-01 02:00:14 +1000
committerAnthony Towns <aj@erisian.com.au>2021-02-26 23:55:10 +1000
commit26d1a6ccd5fcc7abec737c0d8c67238561627d59 (patch)
tree73ac75c7b741aa5c083819011990bbb46adeab90 /src/test/denialofservice_tests.cpp
parent1041616d7eb66281bb4de51ffbc83df0923b2f7e (diff)
downloadbitcoin-26d1a6ccd5fcc7abec737c0d8c67238561627d59.tar.xz
denialofservices_tests: check txorphanage's AddTx
Rather than checking net_processing's internal implementation of AddOrphanTx, test txorphanage's exported AddTx interface. Note that this means AddToCompactExtraTransactions is no longer tested here.
Diffstat (limited to 'src/test/denialofservice_tests.cpp')
-rw-r--r--src/test/denialofservice_tests.cpp12
1 files changed, 5 insertions, 7 deletions
diff --git a/src/test/denialofservice_tests.cpp b/src/test/denialofservice_tests.cpp
index e2e38b3f03..83b2016cd4 100644
--- a/src/test/denialofservice_tests.cpp
+++ b/src/test/denialofservice_tests.cpp
@@ -44,9 +44,6 @@ struct CConnmanTest : public CConnman {
}
};
-// Tests these internal-to-net_processing.cpp methods:
-extern bool AddOrphanTx(const CTransactionRef& tx, NodeId peer);
-
static CService ip(uint32_t i)
{
struct in_addr s;
@@ -320,6 +317,8 @@ BOOST_AUTO_TEST_CASE(DoS_mapOrphans)
FillableSigningProvider keystore;
BOOST_CHECK(keystore.AddKey(key));
+ LOCK(g_cs_orphans);
+
// 50 orphan transactions:
for (int i = 0; i < 50; i++)
{
@@ -332,7 +331,7 @@ BOOST_AUTO_TEST_CASE(DoS_mapOrphans)
tx.vout[0].nValue = 1*CENT;
tx.vout[0].scriptPubKey = GetScriptForDestination(PKHash(key.GetPubKey()));
- AddOrphanTx(MakeTransactionRef(tx), i);
+ OrphanageAddTx(MakeTransactionRef(tx), i);
}
// ... and 50 that depend on other orphans:
@@ -349,7 +348,7 @@ BOOST_AUTO_TEST_CASE(DoS_mapOrphans)
tx.vout[0].scriptPubKey = GetScriptForDestination(PKHash(key.GetPubKey()));
BOOST_CHECK(SignSignature(keystore, *txPrev, tx, 0, SIGHASH_ALL));
- AddOrphanTx(MakeTransactionRef(tx), i);
+ OrphanageAddTx(MakeTransactionRef(tx), i);
}
// This really-big orphan should be ignored:
@@ -373,10 +372,9 @@ BOOST_AUTO_TEST_CASE(DoS_mapOrphans)
for (unsigned int j = 1; j < tx.vin.size(); j++)
tx.vin[j].scriptSig = tx.vin[0].scriptSig;
- BOOST_CHECK(!AddOrphanTx(MakeTransactionRef(tx), i));
+ BOOST_CHECK(!OrphanageAddTx(MakeTransactionRef(tx), i));
}
- LOCK2(cs_main, g_cs_orphans);
// Test EraseOrphansFor:
for (NodeId i = 0; i < 3; i++)
{