@@ -330,10 +330,12 @@ def run_test (self):
330330 # disabled until issue is fixed: https://github.com/bitcoin/bitcoin/issues/7463
331331 # '-salvagewallet',
332332 ]
333+ chainlimit = 6
333334 for m in maintenance :
334335 print ("check " + m )
335336 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 )
337339 while m == '-reindex' and [block_count ] * 3 != [self .nodes [i ].getblockcount () for i in range (3 )]:
338340 # reindex will leave rpc warm up "early"; Wait for it to finish
339341 time .sleep (0.1 )
@@ -346,5 +348,26 @@ def run_test (self):
346348 assert_equal (coinbase_tx_1 ["transactions" ][0 ]["blockhash" ], blocks [1 ])
347349 assert_equal (len (self .nodes [0 ].listsinceblock (blocks [1 ])["transactions" ]), 0 )
348350
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+
349372if __name__ == '__main__' :
350373 WalletTest ().main ()
0 commit comments