Skip to content

Commit b545a6e

Browse files
author
MarcoFalke
committed
Merge #14964: test: Fix race in mempool_accept
faee591 test: Fix race in mempool_accept (MarcoFalke) Pull request description: If we happen to pick the same random coin to spend, there would be mempool conflicts in some runs of the test. Fix that by popping from a static list of coins to spend from. Tree-SHA512: f6fd37e43d919371aa8bc3a2c93b569f9169961fe702f3641bb63180c3a88f12ca1857e9ed4d3723d5f04ca8ab5ef009a90e679580f36246a10b987620a55bee
2 parents bfd7e54 + faee591 commit b545a6e

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

test/functional/mempool_accept.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,14 +58,15 @@ def run_test(self):
5858
self.mempool_size = 0
5959
wait_until(lambda: node.getblockcount() == 200)
6060
assert_equal(node.getmempoolinfo()['size'], self.mempool_size)
61+
coins = node.listunspent()
6162

6263
self.log.info('Should not accept garbage to testmempoolaccept')
6364
assert_raises_rpc_error(-3, 'Expected type array, got string', lambda: node.testmempoolaccept(rawtxs='ff00baar'))
6465
assert_raises_rpc_error(-8, 'Array must contain exactly one raw transaction for now', lambda: node.testmempoolaccept(rawtxs=['ff00baar', 'ff22']))
6566
assert_raises_rpc_error(-22, 'TX decode failed', lambda: node.testmempoolaccept(rawtxs=['ff00baar']))
6667

6768
self.log.info('A transaction already in the blockchain')
68-
coin = node.listunspent()[0] # Pick a random coin(base) to spend
69+
coin = coins.pop() # Pick a random coin(base) to spend
6970
raw_tx_in_block = node.signrawtransactionwithwallet(node.createrawtransaction(
7071
inputs=[{'txid': coin['txid'], 'vout': coin['vout']}],
7172
outputs=[{node.getnewaddress(): 0.3}, {node.getnewaddress(): 49}],
@@ -93,7 +94,7 @@ def run_test(self):
9394
)
9495

9596
self.log.info('A final transaction not in the mempool')
96-
coin = node.listunspent()[0] # Pick a random coin(base) to spend
97+
coin = coins.pop() # Pick a random coin(base) to spend
9798
raw_tx_final = node.signrawtransactionwithwallet(node.createrawtransaction(
9899
inputs=[{'txid': coin['txid'], 'vout': coin['vout'], "sequence": 0xffffffff}], # SEQUENCE_FINAL
99100
outputs=[{node.getnewaddress(): 0.025}],

0 commit comments

Comments
 (0)