pytest: Stabilize test_closing_negotiation_reconnect

The test was not considering that concurrent sendrawtx of the same tx
is not stable, and either endpoint will submit it first. Now just
checking state transitions and the mempool.
This commit is contained in:
Christian Decker
2021-01-21 12:17:39 +01:00
committed by Rusty Russell
parent 52e82b76b6
commit bbdf35c6fe

View File

@@ -304,18 +304,15 @@ def test_closing_negotiation_reconnect(node_factory, bitcoind):
assert bitcoind.rpc.getmempoolinfo()['size'] == 0 assert bitcoind.rpc.getmempoolinfo()['size'] == 0
l1.rpc.close(l2.info['id']) l1.rpc.close(l2.info['id'])
l1.daemon.wait_for_log(r'State changed from CHANNELD_NORMAL to CHANNELD_SHUTTING_DOWN')
l2.daemon.wait_for_log(r'State changed from CHANNELD_NORMAL to CHANNELD_SHUTTING_DOWN')
l1.daemon.wait_for_log(' to CHANNELD_SHUTTING_DOWN') # Now verify that the closing tx is in the mempool.
l2.daemon.wait_for_log(' to CHANNELD_SHUTTING_DOWN') bitcoind.generate_block(6, wait_for_mempool=1)
sync_blockheight(bitcoind, [l1, l2])
l1.daemon.wait_for_log(' to CLOSINGD_SIGEXCHANGE') for n in [l1, l2]:
l2.daemon.wait_for_log(' to CLOSINGD_SIGEXCHANGE') # Ensure we actually got a mutual close.
n.daemon.wait_for_log(r'Resolved FUNDING_TRANSACTION/FUNDING_OUTPUT by MUTUAL_CLOSE')
# And should put closing into mempool (happens async, so
# CLOSINGD_COMPLETE may come first).
l1.daemon.wait_for_logs(['sendrawtx exit 0', ' to CLOSINGD_COMPLETE'])
l2.daemon.wait_for_logs(['sendrawtx exit 0', ' to CLOSINGD_COMPLETE'])
assert bitcoind.rpc.getmempoolinfo()['size'] == 1
@unittest.skipIf(not DEVELOPER, "needs DEVELOPER=1") @unittest.skipIf(not DEVELOPER, "needs DEVELOPER=1")