Changeset View
Changeset View
Standalone View
Standalone View
src/test/DoS_tests.cpp
Show First 20 Lines • Show All 163 Lines • ▼ Show 20 Lines | BOOST_AUTO_TEST_CASE(DoS_mapOrphans) { | ||||
// ... and 50 that depend on other orphans: | // ... and 50 that depend on other orphans: | ||||
for (int i = 0; i < 50; i++) { | for (int i = 0; i < 50; i++) { | ||||
CTransactionRef txPrev = RandomOrphan(); | CTransactionRef txPrev = RandomOrphan(); | ||||
CMutableTransaction tx; | CMutableTransaction tx; | ||||
tx.vin.resize(1); | tx.vin.resize(1); | ||||
tx.vin[0].prevout.n = 0; | tx.vin[0].prevout.n = 0; | ||||
tx.vin[0].prevout.hash = txPrev->GetId(); | tx.vin[0].prevout.hash = txPrev->GetHash(); | ||||
tx.vout.resize(1); | tx.vout.resize(1); | ||||
tx.vout[0].nValue = 1 * CENT.GetSatoshis(); | tx.vout[0].nValue = 1 * CENT.GetSatoshis(); | ||||
tx.vout[0].scriptPubKey = | tx.vout[0].scriptPubKey = | ||||
GetScriptForDestination(key.GetPubKey().GetID()); | GetScriptForDestination(key.GetPubKey().GetID()); | ||||
SignSignature(keystore, *txPrev, tx, 0, SIGHASH_ALL); | SignSignature(keystore, *txPrev, tx, 0, SIGHASH_ALL); | ||||
AddOrphanTx(MakeTransactionRef(tx), i); | AddOrphanTx(MakeTransactionRef(tx), i); | ||||
} | } | ||||
// This really-big orphan should be ignored: | // This really-big orphan should be ignored: | ||||
for (int i = 0; i < 10; i++) { | for (int i = 0; i < 10; i++) { | ||||
CTransactionRef txPrev = RandomOrphan(); | CTransactionRef txPrev = RandomOrphan(); | ||||
CMutableTransaction tx; | CMutableTransaction tx; | ||||
tx.vout.resize(1); | tx.vout.resize(1); | ||||
tx.vout[0].nValue = 1 * CENT.GetSatoshis(); | tx.vout[0].nValue = 1 * CENT.GetSatoshis(); | ||||
tx.vout[0].scriptPubKey = | tx.vout[0].scriptPubKey = | ||||
GetScriptForDestination(key.GetPubKey().GetID()); | GetScriptForDestination(key.GetPubKey().GetID()); | ||||
tx.vin.resize(2777); | tx.vin.resize(2777); | ||||
for (unsigned int j = 0; j < tx.vin.size(); j++) { | for (unsigned int j = 0; j < tx.vin.size(); j++) { | ||||
tx.vin[j].prevout.n = j; | tx.vin[j].prevout.n = j; | ||||
tx.vin[j].prevout.hash = txPrev->GetId(); | tx.vin[j].prevout.hash = txPrev->GetHash(); | ||||
} | } | ||||
SignSignature(keystore, *txPrev, tx, 0, SIGHASH_ALL); | SignSignature(keystore, *txPrev, tx, 0, SIGHASH_ALL); | ||||
// Re-use same signature for other inputs | // Re-use same signature for other inputs | ||||
// (they don't have to be valid for this test) | // (they don't have to be valid for this test) | ||||
for (unsigned int j = 1; j < tx.vin.size(); j++) | for (unsigned int j = 1; j < tx.vin.size(); j++) | ||||
tx.vin[j].scriptSig = tx.vin[0].scriptSig; | tx.vin[j].scriptSig = tx.vin[0].scriptSig; | ||||
BOOST_CHECK(!AddOrphanTx(MakeTransactionRef(tx), i)); | BOOST_CHECK(!AddOrphanTx(MakeTransactionRef(tx), i)); | ||||
Show All 19 Lines |