Skip to content

Commit 26d1a6c

Browse files
committed
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.
1 parent 1041616 commit 26d1a6c

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

src/test/denialofservice_tests.cpp

+5-7
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,6 @@ struct CConnmanTest : public CConnman {
4444
}
4545
};
4646

47-
// Tests these internal-to-net_processing.cpp methods:
48-
extern bool AddOrphanTx(const CTransactionRef& tx, NodeId peer);
49-
5047
static CService ip(uint32_t i)
5148
{
5249
struct in_addr s;
@@ -320,6 +317,8 @@ BOOST_AUTO_TEST_CASE(DoS_mapOrphans)
320317
FillableSigningProvider keystore;
321318
BOOST_CHECK(keystore.AddKey(key));
322319

320+
LOCK(g_cs_orphans);
321+
323322
// 50 orphan transactions:
324323
for (int i = 0; i < 50; i++)
325324
{
@@ -332,7 +331,7 @@ BOOST_AUTO_TEST_CASE(DoS_mapOrphans)
332331
tx.vout[0].nValue = 1*CENT;
333332
tx.vout[0].scriptPubKey = GetScriptForDestination(PKHash(key.GetPubKey()));
334333

335-
AddOrphanTx(MakeTransactionRef(tx), i);
334+
OrphanageAddTx(MakeTransactionRef(tx), i);
336335
}
337336

338337
// ... and 50 that depend on other orphans:
@@ -349,7 +348,7 @@ BOOST_AUTO_TEST_CASE(DoS_mapOrphans)
349348
tx.vout[0].scriptPubKey = GetScriptForDestination(PKHash(key.GetPubKey()));
350349
BOOST_CHECK(SignSignature(keystore, *txPrev, tx, 0, SIGHASH_ALL));
351350

352-
AddOrphanTx(MakeTransactionRef(tx), i);
351+
OrphanageAddTx(MakeTransactionRef(tx), i);
353352
}
354353

355354
// This really-big orphan should be ignored:
@@ -373,10 +372,9 @@ BOOST_AUTO_TEST_CASE(DoS_mapOrphans)
373372
for (unsigned int j = 1; j < tx.vin.size(); j++)
374373
tx.vin[j].scriptSig = tx.vin[0].scriptSig;
375374

376-
BOOST_CHECK(!AddOrphanTx(MakeTransactionRef(tx), i));
375+
BOOST_CHECK(!OrphanageAddTx(MakeTransactionRef(tx), i));
377376
}
378377

379-
LOCK2(cs_main, g_cs_orphans);
380378
// Test EraseOrphansFor:
381379
for (NodeId i = 0; i < 3; i++)
382380
{

0 commit comments

Comments
 (0)