@@ -330,10 +330,12 @@ def run_test (self):
330
330
# disabled until issue is fixed: https://github.com/bitcoin/bitcoin/issues/7463
331
331
# '-salvagewallet',
332
332
]
333
+ chainlimit = 6
333
334
for m in maintenance :
334
335
print ("check " + m )
335
336
stop_nodes (self .nodes )
336
- self .nodes = start_nodes (3 , self .options .tmpdir , [[m ]] * 3 )
337
+ # set lower ancestor limit for later
338
+ self .nodes = start_nodes (3 , self .options .tmpdir , [[m , "-limitancestorcount=" + str (chainlimit )]] * 3 )
337
339
while m == '-reindex' and [block_count ] * 3 != [self .nodes [i ].getblockcount () for i in range (3 )]:
338
340
# reindex will leave rpc warm up "early"; Wait for it to finish
339
341
time .sleep (0.1 )
@@ -346,5 +348,26 @@ def run_test (self):
346
348
assert_equal (coinbase_tx_1 ["transactions" ][0 ]["blockhash" ], blocks [1 ])
347
349
assert_equal (len (self .nodes [0 ].listsinceblock (blocks [1 ])["transactions" ]), 0 )
348
350
351
+ # ==Check that wallet prefers to use coins that don't exceed mempool limits =====
352
+
353
+ # Get all non-zero utxos together
354
+ chain_addrs = [self .nodes [0 ].getnewaddress (), self .nodes [0 ].getnewaddress ()]
355
+ singletxid = self .nodes [0 ].sendtoaddress (chain_addrs [0 ], self .nodes [0 ].getbalance (), "" , "" , True )
356
+ self .nodes [0 ].generate (1 )
357
+ node0_balance = self .nodes [0 ].getbalance ()
358
+ # Split into two chains
359
+ rawtx = self .nodes [0 ].createrawtransaction ([{"txid" :singletxid , "vout" :0 }], {chain_addrs [0 ]:node0_balance / 2 - Decimal ('0.01' ), chain_addrs [1 ]:node0_balance / 2 - Decimal ('0.01' )})
360
+ signedtx = self .nodes [0 ].signrawtransaction (rawtx )
361
+ singletxid = self .nodes [0 ].sendrawtransaction (signedtx ["hex" ])
362
+ txids = [singletxid , singletxid ]
363
+ self .nodes [0 ].generate (1 )
364
+
365
+ # Make a long chain of unconfirmed payments without hitting mempool limit
366
+ txid_list = []
367
+ for i in range (chainlimit * 2 ):
368
+ txid_list .append (self .nodes [0 ].sendtoaddress (chain_addrs [0 ], Decimal ('0.0001' )))
369
+ assert_equal (self .nodes [0 ].getmempoolinfo ()['size' ], chainlimit * 2 )
370
+ assert_equal (len (txid_list ), chainlimit * 2 )
371
+
349
372
if __name__ == '__main__' :
350
373
WalletTest ().main ()
0 commit comments