mirror of
https://github.com/ElementsProject/lightning.git
synced 2024-11-19 18:11:28 +01:00
pytest: don't wait for sendrawtx, wait for expected tx.
In particular, test_no_fee_estimate was flaky due to seeing the funding tx being sent. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
parent
7744c41521
commit
252bbe1d2d
@ -475,7 +475,7 @@ def test_onchain_unwatch(node_factory, bitcoind):
|
|||||||
|
|
||||||
l1.rpc.dev_fail(l2.info['id'])
|
l1.rpc.dev_fail(l2.info['id'])
|
||||||
l1.daemon.wait_for_log('Failing due to dev-fail command')
|
l1.daemon.wait_for_log('Failing due to dev-fail command')
|
||||||
l1.daemon.wait_for_log('sendrawtx exit 0')
|
l1.wait_for_channel_onchain(l2.info['id'])
|
||||||
|
|
||||||
l1.bitcoin.generate_block(1)
|
l1.bitcoin.generate_block(1)
|
||||||
l1.daemon.wait_for_log(' to ONCHAIN')
|
l1.daemon.wait_for_log(' to ONCHAIN')
|
||||||
@ -594,7 +594,7 @@ def test_onchain_dust_out(node_factory, bitcoind, executor):
|
|||||||
|
|
||||||
# l1 will drop to chain.
|
# l1 will drop to chain.
|
||||||
l1.daemon.wait_for_log('permfail')
|
l1.daemon.wait_for_log('permfail')
|
||||||
l1.daemon.wait_for_log('sendrawtx exit 0')
|
l1.wait_for_channel_onchain(l2.info['id'])
|
||||||
l1.bitcoin.generate_block(1)
|
l1.bitcoin.generate_block(1)
|
||||||
l1.daemon.wait_for_log(' to ONCHAIN')
|
l1.daemon.wait_for_log(' to ONCHAIN')
|
||||||
l2.daemon.wait_for_log(' to ONCHAIN')
|
l2.daemon.wait_for_log(' to ONCHAIN')
|
||||||
@ -662,7 +662,7 @@ def test_onchain_timeout(node_factory, bitcoind, executor):
|
|||||||
|
|
||||||
# l1 will drop to chain.
|
# l1 will drop to chain.
|
||||||
l1.daemon.wait_for_log('permfail')
|
l1.daemon.wait_for_log('permfail')
|
||||||
l1.daemon.wait_for_log('sendrawtx exit 0')
|
l1.wait_for_channel_onchain(l2.info['id'])
|
||||||
l1.bitcoin.generate_block(1)
|
l1.bitcoin.generate_block(1)
|
||||||
l1.daemon.wait_for_log(' to ONCHAIN')
|
l1.daemon.wait_for_log(' to ONCHAIN')
|
||||||
l2.daemon.wait_for_log(' to ONCHAIN')
|
l2.daemon.wait_for_log(' to ONCHAIN')
|
||||||
@ -814,7 +814,7 @@ def test_onchain_feechange(node_factory, bitcoind, executor):
|
|||||||
|
|
||||||
# l2 will drop to chain.
|
# l2 will drop to chain.
|
||||||
l2.daemon.wait_for_log('permfail')
|
l2.daemon.wait_for_log('permfail')
|
||||||
l2.daemon.wait_for_log('sendrawtx exit 0')
|
l2.wait_for_channel_onchain(l1.info['id'])
|
||||||
bitcoind.generate_block(1)
|
bitcoind.generate_block(1)
|
||||||
l1.daemon.wait_for_log(' to ONCHAIN')
|
l1.daemon.wait_for_log(' to ONCHAIN')
|
||||||
l2.daemon.wait_for_log(' to ONCHAIN')
|
l2.daemon.wait_for_log(' to ONCHAIN')
|
||||||
@ -890,7 +890,7 @@ def test_onchain_all_dust(node_factory, bitcoind, executor):
|
|||||||
|
|
||||||
# l2 will drop to chain.
|
# l2 will drop to chain.
|
||||||
l2.daemon.wait_for_log('permfail')
|
l2.daemon.wait_for_log('permfail')
|
||||||
l2.daemon.wait_for_log('sendrawtx exit 0')
|
l2.wait_for_channel_onchain(l1.info['id'])
|
||||||
|
|
||||||
# Make l1's fees really high (and wait for it to exceed 50000)
|
# Make l1's fees really high (and wait for it to exceed 50000)
|
||||||
l1.set_feerates((100000, 100000, 100000))
|
l1.set_feerates((100000, 100000, 100000))
|
||||||
@ -944,7 +944,7 @@ def test_onchain_different_fees(node_factory, bitcoind, executor):
|
|||||||
|
|
||||||
# Drop to chain
|
# Drop to chain
|
||||||
l1.rpc.dev_fail(l2.info['id'])
|
l1.rpc.dev_fail(l2.info['id'])
|
||||||
l1.daemon.wait_for_log('sendrawtx exit 0')
|
l1.wait_for_channel_onchain(l2.info['id'])
|
||||||
|
|
||||||
bitcoind.generate_block(1)
|
bitcoind.generate_block(1)
|
||||||
l1.daemon.wait_for_log(' to ONCHAIN')
|
l1.daemon.wait_for_log(' to ONCHAIN')
|
||||||
@ -999,7 +999,7 @@ def test_permfail_new_commit(node_factory, bitcoind, executor):
|
|||||||
t = executor.submit(l1.pay, l2, 200000000)
|
t = executor.submit(l1.pay, l2, 200000000)
|
||||||
|
|
||||||
l2.daemon.wait_for_log('dev_disconnect permfail')
|
l2.daemon.wait_for_log('dev_disconnect permfail')
|
||||||
l2.daemon.wait_for_log('sendrawtx exit 0')
|
l2.wait_for_channel_onchain(l1.info['id'])
|
||||||
bitcoind.generate_block(1)
|
bitcoind.generate_block(1)
|
||||||
l1.daemon.wait_for_log('Their unilateral tx, new commit point')
|
l1.daemon.wait_for_log('Their unilateral tx, new commit point')
|
||||||
l1.daemon.wait_for_log(' to ONCHAIN')
|
l1.daemon.wait_for_log(' to ONCHAIN')
|
||||||
@ -1037,7 +1037,7 @@ def test_permfail_htlc_in(node_factory, bitcoind, executor):
|
|||||||
t = executor.submit(l1.pay, l2, 200000000)
|
t = executor.submit(l1.pay, l2, 200000000)
|
||||||
|
|
||||||
l2.daemon.wait_for_log('dev_disconnect permfail')
|
l2.daemon.wait_for_log('dev_disconnect permfail')
|
||||||
l2.daemon.wait_for_log('sendrawtx exit 0')
|
l2.wait_for_channel_onchain(l1.info['id'])
|
||||||
bitcoind.generate_block(1)
|
bitcoind.generate_block(1)
|
||||||
l1.daemon.wait_for_log('Their unilateral tx, old commit point')
|
l1.daemon.wait_for_log('Their unilateral tx, old commit point')
|
||||||
l1.daemon.wait_for_log(' to ONCHAIN')
|
l1.daemon.wait_for_log(' to ONCHAIN')
|
||||||
@ -1082,7 +1082,7 @@ def test_permfail_htlc_out(node_factory, bitcoind, executor):
|
|||||||
t = executor.submit(l2.pay, l1, 200000000)
|
t = executor.submit(l2.pay, l1, 200000000)
|
||||||
|
|
||||||
l2.daemon.wait_for_log('dev_disconnect permfail')
|
l2.daemon.wait_for_log('dev_disconnect permfail')
|
||||||
l2.daemon.wait_for_log('sendrawtx exit 0')
|
l2.wait_for_channel_onchain(l1.info['id'])
|
||||||
bitcoind.generate_block(1)
|
bitcoind.generate_block(1)
|
||||||
l1.daemon.wait_for_log('Their unilateral tx, old commit point')
|
l1.daemon.wait_for_log('Their unilateral tx, old commit point')
|
||||||
l1.daemon.wait_for_log(' to ONCHAIN')
|
l1.daemon.wait_for_log(' to ONCHAIN')
|
||||||
@ -1144,7 +1144,7 @@ def test_permfail(node_factory, bitcoind):
|
|||||||
# We fail l2, so l1 will reconnect to it.
|
# We fail l2, so l1 will reconnect to it.
|
||||||
l2.rpc.dev_fail(l1.info['id'])
|
l2.rpc.dev_fail(l1.info['id'])
|
||||||
l2.daemon.wait_for_log('Failing due to dev-fail command')
|
l2.daemon.wait_for_log('Failing due to dev-fail command')
|
||||||
l2.daemon.wait_for_log('sendrawtx exit 0')
|
l2.wait_for_channel_onchain(l1.info['id'])
|
||||||
|
|
||||||
assert l1.bitcoin.rpc.getmempoolinfo()['size'] == 1
|
assert l1.bitcoin.rpc.getmempoolinfo()['size'] == 1
|
||||||
|
|
||||||
|
@ -783,7 +783,7 @@ def test_channel_persistence(node_factory, bitcoind, executor):
|
|||||||
# Now make sure l1 is watching for unilateral closes
|
# Now make sure l1 is watching for unilateral closes
|
||||||
l2.rpc.dev_fail(l1.info['id'])
|
l2.rpc.dev_fail(l1.info['id'])
|
||||||
l2.daemon.wait_for_log('Failing due to dev-fail command')
|
l2.daemon.wait_for_log('Failing due to dev-fail command')
|
||||||
l2.daemon.wait_for_log('sendrawtx exit 0')
|
l2.wait_for_channel_onchain(l1.info['id'])
|
||||||
bitcoind.generate_block(1)
|
bitcoind.generate_block(1)
|
||||||
|
|
||||||
# L1 must notice.
|
# L1 must notice.
|
||||||
@ -836,8 +836,8 @@ def test_update_fee(node_factory, bitcoind):
|
|||||||
l2.daemon.wait_for_log(' to CLOSINGD_COMPLETE')
|
l2.daemon.wait_for_log(' to CLOSINGD_COMPLETE')
|
||||||
|
|
||||||
# And should put closing into mempool.
|
# And should put closing into mempool.
|
||||||
l1.daemon.wait_for_log('sendrawtx exit 0')
|
l1.wait_for_channel_onchain(l2.info['id'])
|
||||||
l2.daemon.wait_for_log('sendrawtx exit 0')
|
l2.wait_for_channel_onchain(l1.info['id'])
|
||||||
|
|
||||||
bitcoind.generate_block(1)
|
bitcoind.generate_block(1)
|
||||||
l1.daemon.wait_for_log(' to ONCHAIN')
|
l1.daemon.wait_for_log(' to ONCHAIN')
|
||||||
@ -925,8 +925,8 @@ def test_update_fee_reconnect(node_factory, bitcoind):
|
|||||||
l1.rpc.close(chan)
|
l1.rpc.close(chan)
|
||||||
|
|
||||||
# And should put closing into mempool.
|
# And should put closing into mempool.
|
||||||
l1.daemon.wait_for_log('sendrawtx exit 0')
|
l1.wait_for_channel_onchain(l2.info['id'])
|
||||||
l2.daemon.wait_for_log('sendrawtx exit 0')
|
l2.wait_for_channel_onchain(l1.info['id'])
|
||||||
|
|
||||||
bitcoind.generate_block(1)
|
bitcoind.generate_block(1)
|
||||||
l1.daemon.wait_for_log(' to ONCHAIN')
|
l1.daemon.wait_for_log(' to ONCHAIN')
|
||||||
@ -1150,7 +1150,7 @@ def test_no_fee_estimate(node_factory, bitcoind, executor):
|
|||||||
l1.daemon.wait_for_log('sendrawtx exit 0')
|
l1.daemon.wait_for_log('sendrawtx exit 0')
|
||||||
l1.rpc.dev_fail(l2.info['id'])
|
l1.rpc.dev_fail(l2.info['id'])
|
||||||
l1.daemon.wait_for_log('Failing due to dev-fail command')
|
l1.daemon.wait_for_log('Failing due to dev-fail command')
|
||||||
l1.daemon.wait_for_log('sendrawtx exit 0')
|
l1.wait_for_channel_onchain(l2.info['id'])
|
||||||
bitcoind.generate_block(6)
|
bitcoind.generate_block(6)
|
||||||
wait_for(lambda: only_one(l1.rpc.getpeer(l2.info['id'])['channels'])['state'] == 'ONCHAIN')
|
wait_for(lambda: only_one(l1.rpc.getpeer(l2.info['id'])['channels'])['state'] == 'ONCHAIN')
|
||||||
wait_for(lambda: only_one(l2.rpc.getpeer(l1.info['id'])['channels'])['state'] == 'ONCHAIN')
|
wait_for(lambda: only_one(l2.rpc.getpeer(l1.info['id'])['channels'])['state'] == 'ONCHAIN')
|
||||||
@ -1172,9 +1172,9 @@ def test_no_fee_estimate(node_factory, bitcoind, executor):
|
|||||||
l2.pay(l1, 10**9 // 2)
|
l2.pay(l1, 10**9 // 2)
|
||||||
l1.rpc.dev_fail(l2.info['id'])
|
l1.rpc.dev_fail(l2.info['id'])
|
||||||
l1.daemon.wait_for_log('Failing due to dev-fail command')
|
l1.daemon.wait_for_log('Failing due to dev-fail command')
|
||||||
l1.daemon.wait_for_log('sendrawtx exit 0')
|
l1.wait_for_channel_onchain(l2.info['id'])
|
||||||
bitcoind.generate_block(5)
|
bitcoind.generate_block(5)
|
||||||
l1.daemon.wait_for_log('sendrawtx exit 0')
|
wait_for(lambda: len(bitcoind.rpc.getrawmempool()) > 0)
|
||||||
bitcoind.generate_block(100)
|
bitcoind.generate_block(100)
|
||||||
|
|
||||||
# Start estimatesmartfee.
|
# Start estimatesmartfee.
|
||||||
@ -1280,7 +1280,7 @@ def test_dataloss_protection(node_factory, bitcoind):
|
|||||||
l2.daemon.wait_for_log("Peer permanent failure in CHANNELD_NORMAL: Awaiting unilateral close")
|
l2.daemon.wait_for_log("Peer permanent failure in CHANNELD_NORMAL: Awaiting unilateral close")
|
||||||
|
|
||||||
# l1 should drop to chain.
|
# l1 should drop to chain.
|
||||||
l1.daemon.wait_for_log('sendrawtx exit 0')
|
l1.wait_for_channel_onchain(l2.info['id'])
|
||||||
|
|
||||||
# l2 must NOT drop to chain.
|
# l2 must NOT drop to chain.
|
||||||
l2.daemon.wait_for_log("Cannot broadcast our commitment tx: they have a future one")
|
l2.daemon.wait_for_log("Cannot broadcast our commitment tx: they have a future one")
|
||||||
|
@ -182,7 +182,7 @@ def test_htlc_sig_persistence(node_factory, executor):
|
|||||||
# This should reload the htlc_sig
|
# This should reload the htlc_sig
|
||||||
l2.rpc.dev_fail(l1.info['id'])
|
l2.rpc.dev_fail(l1.info['id'])
|
||||||
# Make sure it broadcasts to chain.
|
# Make sure it broadcasts to chain.
|
||||||
l2.daemon.wait_for_log('sendrawtx exit 0')
|
l2.wait_for_channel_onchain(l1.info['id'])
|
||||||
l2.stop()
|
l2.stop()
|
||||||
l1.bitcoin.rpc.generate(1)
|
l1.bitcoin.rpc.generate(1)
|
||||||
l1.start()
|
l1.start()
|
||||||
|
@ -560,6 +560,10 @@ class LightningNode(object):
|
|||||||
active = [(c['short_channel_id'], c['flags']) for c in channels if c['active']]
|
active = [(c['short_channel_id'], c['flags']) for c in channels if c['active']]
|
||||||
return (chanid, 0) in active and (chanid, 1) in active
|
return (chanid, 0) in active and (chanid, 1) in active
|
||||||
|
|
||||||
|
def wait_for_channel_onchain(self, peerid):
|
||||||
|
txid = only_one(only_one(self.rpc.listpeers(peerid)['peers'])['channels'])['scratch_txid']
|
||||||
|
wait_for(lambda: txid in self.bitcoin.rpc.getrawmempool())
|
||||||
|
|
||||||
def wait_channel_active(self, chanid):
|
def wait_channel_active(self, chanid):
|
||||||
wait_for(lambda: self.is_channel_active(chanid), interval=1)
|
wait_for(lambda: self.is_channel_active(chanid), interval=1)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user