mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-02-22 14:42:40 +01:00
tests/test_lightningd.py: make test less flaky.
When we drop an HTLC_ADD packet, sometimes the commit timer fires before we try to read from the fd. In this case, the payment is considered committed and we don't fail. We need manual commit to work around this, and also we'd need to do the pay command asynchronously from python because it will block. That's a bit out of scope for now, so just handle either way. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
parent
ac703ff9dc
commit
5edc14ee1a
1 changed files with 17 additions and 5 deletions
|
@ -611,19 +611,31 @@ class LightningDTests(BaseLightningDTests):
|
|||
self.fund_channel(l1, l2, 10**6)
|
||||
|
||||
amt = 200000000
|
||||
rhash = l2.rpc.invoice(amt, 'testpayment2')['rhash']
|
||||
assert l2.rpc.listinvoice('testpayment2')[0]['complete'] == False
|
||||
rhash = l2.rpc.invoice(amt, 'testpayment')['rhash']
|
||||
assert l2.rpc.listinvoice('testpayment')[0]['complete'] == False
|
||||
|
||||
route = [ { 'msatoshi' : amt, 'id' : l2.info['id'], 'delay' : 5, 'channel': '1:1:1'} ]
|
||||
# First time, it will fail because it doesn't send commit.
|
||||
self.assertRaises(ValueError, l1.rpc.sendpay, to_json(route), rhash)
|
||||
# Wait for reconnection.
|
||||
l1.daemon.wait_for_log('Already have funding locked in')
|
||||
# This will send commit, so will reconnect.
|
||||
|
||||
# These are *racy* whether they succeeds or not: does the commit timer
|
||||
# fire before it tries reading and notices fd is closed?
|
||||
for i in range(1,3):
|
||||
try:
|
||||
l1.rpc.sendpay(to_json(route), rhash)
|
||||
assert l2.rpc.listinvoice('testpayment')[0]['complete'] == True
|
||||
rhash = l2.rpc.invoice(amt, 'testpayment' + str(i))['rhash']
|
||||
except:
|
||||
pass
|
||||
# Wait for reconnection.
|
||||
l1.daemon.wait_for_log('Already have funding locked in')
|
||||
|
||||
# This will send commit, so will reconnect as required.
|
||||
l1.rpc.sendpay(to_json(route), rhash)
|
||||
assert l2.rpc.listinvoice('testpayment2')[0]['complete'] == True
|
||||
# Should have printed this for every reconnect.
|
||||
for i in range(1,len(disconnects)):
|
||||
for i in range(3,len(disconnects)):
|
||||
l1.daemon.wait_for_log('Already have funding locked in')
|
||||
|
||||
def test_reconnect_receiver_add(self):
|
||||
|
|
Loading…
Add table
Reference in a new issue