Browse Source

pytest: Make test_sendpay less flaky

While 1 second is very generous, it resolving the HTLCs may take longer, so we
just loop over this instead of making it one-shot

Signed-off-by: Christian Decker <decker.christian@gmail.com>
ppa-0.6.1
Christian Decker 7 years ago
committed by Rusty Russell
parent
commit
eb869cf144
  1. 17
      tests/test_lightningd.py

17
tests/test_lightningd.py

@ -1064,13 +1064,16 @@ class LightningDTests(BaseLightningDTests):
assert l2.rpc.listinvoices('testpayment2')['invoices'][0]['msatoshi_received'] == rs['msatoshi']
# Balances should reflect it.
time.sleep(1)
p1 = l1.rpc.getpeer(l2.info['id'], 'info')
p2 = l2.rpc.getpeer(l1.info['id'], 'info')
assert p1['channels'][0]['msatoshi_to_us'] == 10**6 * 1000 - amt
assert p1['channels'][0]['msatoshi_total'] == 10**6 * 1000
assert p2['channels'][0]['msatoshi_to_us'] == amt
assert p2['channels'][0]['msatoshi_total'] == 10**6 * 1000
def check_balances():
p1 = l1.rpc.getpeer(l2.info['id'], 'info')
p2 = l2.rpc.getpeer(l1.info['id'], 'info')
return (
p1['channels'][0]['msatoshi_to_us'] == 10**6 * 1000 - amt and
p1['channels'][0]['msatoshi_total'] == 10**6 * 1000 and
p2['channels'][0]['msatoshi_to_us'] == amt and
p2['channels'][0]['msatoshi_total'] == 10**6 * 1000
)
wait_for(check_balances)
# Repeat will "succeed", but won't actually send anything (duplicate)
assert not l1.daemon.is_in_log('... succeeded')

Loading…
Cancel
Save