@ -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 )
static CService ip ( uint32_t i )
{
{
struct in_addr s ;
struct in_addr s ;
@ -320,6 +317,8 @@ BOOST_AUTO_TEST_CASE(DoS_mapOrphans)
FillableSigningProvider keystore ;
FillableSigningProvider keystore ;
BOOST_CHECK ( keystore . AddKey ( key ) ) ;
BOOST_CHECK ( keystore . AddKey ( key ) ) ;
LOCK ( g_cs_orphans ) ;
// 50 orphan transactions:
// 50 orphan transactions:
for ( int i = 0 ; i < 50 ; i + + )
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 ] . nValue = 1 * CENT ;
tx . vout [ 0 ] . scriptPubKey = GetScriptForDestination ( PKHash ( key . GetPubKey ( ) ) ) ;
tx . vout [ 0 ] . scriptPubKey = GetScriptForDestination ( PKHash ( key . GetPubKey ( ) ) ) ;
Add OrphanTx( MakeTransactionRef ( tx ) , i ) ;
OrphanageAdd Tx( MakeTransactionRef ( tx ) , i ) ;
}
}
// ... and 50 that depend on other orphans:
// ... 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 ( ) ) ) ;
tx . vout [ 0 ] . scriptPubKey = GetScriptForDestination ( PKHash ( key . GetPubKey ( ) ) ) ;
BOOST_CHECK ( SignSignature ( keystore , * txPrev , tx , 0 , SIGHASH_ALL ) ) ;
BOOST_CHECK ( SignSignature ( keystore , * txPrev , tx , 0 , SIGHASH_ALL ) ) ;
Add OrphanTx( MakeTransactionRef ( tx ) , i ) ;
OrphanageAdd Tx( MakeTransactionRef ( tx ) , i ) ;
}
}
// This really-big orphan should be ignored:
// 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 + + )
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 ( ! Add OrphanTx( MakeTransactionRef ( tx ) , i ) ) ;
BOOST_CHECK ( ! OrphanageAdd Tx( MakeTransactionRef ( tx ) , i ) ) ;
}
}
LOCK2 ( cs_main , g_cs_orphans ) ;
// Test EraseOrphansFor:
// Test EraseOrphansFor:
for ( NodeId i = 0 ; i < 3 ; i + + )
for ( NodeId i = 0 ; i < 3 ; i + + )
{
{