X-Git-Url: https://git.novaco.in/?a=blobdiff_plain;f=src%2Ftest%2FDoS_tests.cpp;h=cea4577a3b9ab4b40df3570a45549ea2abc3967b;hb=469f6da8bcaf0179f1afbb5d927aae0d9b1ce610;hp=e5a8b4f68b489e184f59a55cb265030c96a2f813;hpb=87593b98379544f3dadc2529ea0817d9ebefc4ce;p=novacoin.git diff --git a/src/test/DoS_tests.cpp b/src/test/DoS_tests.cpp index e5a8b4f..cea4577 100644 --- a/src/test/DoS_tests.cpp +++ b/src/test/DoS_tests.cpp @@ -13,10 +13,10 @@ #include // Tests this internal-to-main.cpp method: -extern void AddOrphanTx(const CDataStream& vMsg); +extern bool AddOrphanTx(const CDataStream& vMsg); extern unsigned int LimitOrphanTxSize(unsigned int nMaxOrphans); extern std::map mapOrphanTransactions; -extern std::multimap mapOrphanTransactionsByPrev; +extern std::map > mapOrphanTransactionsByPrev; CService ip(uint32_t i) { @@ -192,6 +192,32 @@ BOOST_AUTO_TEST_CASE(DoS_mapOrphans) AddOrphanTx(ds); } + // This really-big orphan should be ignored: + for (int i = 0; i < 10; i++) + { + CTransaction txPrev = RandomOrphan(); + + CTransaction tx; + tx.vout.resize(1); + tx.vout[0].nValue = 1*CENT; + tx.vout[0].scriptPubKey.SetBitcoinAddress(key.GetPubKey()); + tx.vin.resize(500); + for (int j = 0; j < tx.vin.size(); j++) + { + tx.vin[j].prevout.n = j; + tx.vin[j].prevout.hash = txPrev.GetHash(); + } + SignSignature(keystore, txPrev, tx, 0); + // Re-use same signature for other inputs + // (they don't have to be valid for this test) + for (int j = 1; j < tx.vin.size(); j++) + tx.vin[j].scriptSig = tx.vin[0].scriptSig; + + CDataStream ds(SER_DISK, CLIENT_VERSION); + ds << tx; + BOOST_CHECK(!AddOrphanTx(ds)); + } + // Test LimitOrphanTxSize() function: LimitOrphanTxSize(40); BOOST_CHECK(mapOrphanTransactions.size() <= 40);