@ -201,10 +201,10 @@ class ReplaceByFeeTest(BitcoinTestFramework):
def test_doublespend_tree ( self ) :
def test_doublespend_tree ( self ) :
""" Doublespend of a big tree of transactions """
""" Doublespend of a big tree of transactions """
initial_nValue = 5 0 * COIN
initial_nValue = 5 * COIN
tx0_outpoint = self . make_utxo ( self . nodes [ 0 ] , initial_nValue )
tx0_outpoint = self . make_utxo ( self . nodes [ 0 ] , initial_nValue )
def branch ( prevout , initial_value , max_txs , tree_width = 5 , fee = 0.000 1 * COIN , _total_txs = None ) :
def branch ( prevout , initial_value , max_txs , tree_width = 5 , fee = 0.000 0 1 * COIN , _total_txs = None ) :
if _total_txs is None :
if _total_txs is None :
_total_txs = [ 0 ]
_total_txs = [ 0 ]
if _total_txs [ 0 ] > = max_txs :
if _total_txs [ 0 ] > = max_txs :
@ -235,7 +235,7 @@ class ReplaceByFeeTest(BitcoinTestFramework):
_total_txs = _total_txs ) :
_total_txs = _total_txs ) :
yield x
yield x
fee = int ( 0.000 1 * COIN )
fee = int ( 0.000 0 1 * COIN )
n = MAX_REPLACEMENT_LIMIT
n = MAX_REPLACEMENT_LIMIT
tree_txs = list ( branch ( tx0_outpoint , initial_nValue , n , fee = fee ) )
tree_txs = list ( branch ( tx0_outpoint , initial_nValue , n , fee = fee ) )
assert_equal ( len ( tree_txs ) , n )
assert_equal ( len ( tree_txs ) , n )
@ -248,10 +248,10 @@ class ReplaceByFeeTest(BitcoinTestFramework):
# This will raise an exception due to insufficient fee
# This will raise an exception due to insufficient fee
assert_raises_rpc_error ( - 26 , " insufficient fee " , self . nodes [ 0 ] . sendrawtransaction , dbl_tx_hex , 0 )
assert_raises_rpc_error ( - 26 , " insufficient fee " , self . nodes [ 0 ] . sendrawtransaction , dbl_tx_hex , 0 )
# 1 BTC fee is enough
# 0. 1 BTC fee is enough
dbl_tx = CTransaction ( )
dbl_tx = CTransaction ( )
dbl_tx . vin = [ CTxIn ( tx0_outpoint , nSequence = 0 ) ]
dbl_tx . vin = [ CTxIn ( tx0_outpoint , nSequence = 0 ) ]
dbl_tx . vout = [ CTxOut ( initial_nValue - fee * n - 1 * COIN , DUMMY_P2WPKH_SCRIPT ) ]
dbl_tx . vout = [ CTxOut ( initial_nValue - fee * n - int ( 0.1 * COIN ) , DUMMY_P2WPKH_SCRIPT ) ]
dbl_tx_hex = dbl_tx . serialize ( ) . hex ( )
dbl_tx_hex = dbl_tx . serialize ( ) . hex ( )
self . nodes [ 0 ] . sendrawtransaction ( dbl_tx_hex , 0 )
self . nodes [ 0 ] . sendrawtransaction ( dbl_tx_hex , 0 )
@ -264,7 +264,7 @@ class ReplaceByFeeTest(BitcoinTestFramework):
# Try again, but with more total transactions than the "max txs
# Try again, but with more total transactions than the "max txs
# double-spent at once" anti-DoS limit.
# double-spent at once" anti-DoS limit.
for n in ( MAX_REPLACEMENT_LIMIT + 1 , MAX_REPLACEMENT_LIMIT * 2 ) :
for n in ( MAX_REPLACEMENT_LIMIT + 1 , MAX_REPLACEMENT_LIMIT * 2 ) :
fee = int ( 0.000 1 * COIN )
fee = int ( 0.000 0 1 * COIN )
tx0_outpoint = self . make_utxo ( self . nodes [ 0 ] , initial_nValue )
tx0_outpoint = self . make_utxo ( self . nodes [ 0 ] , initial_nValue )
tree_txs = list ( branch ( tx0_outpoint , initial_nValue , n , fee = fee ) )
tree_txs = list ( branch ( tx0_outpoint , initial_nValue , n , fee = fee ) )
assert_equal ( len ( tree_txs ) , n )
assert_equal ( len ( tree_txs ) , n )