test_lightningd.py: test reconnection on htlc_add.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
Rusty Russell 2017-06-20 15:51:03 +09:30
parent 9e941e26ed
commit 6dbaa3ace6
1 changed files with 27 additions and 1 deletions

View File

@ -567,7 +567,33 @@ class LightningDTests(BaseLightningDTests):
ret = l1.rpc.connect('localhost', l2.info['port'], l2.info['id'])
self.fund_channel(l1, l2, 10**6)
def test_reconnect_add_htlc(self):
# Fail after add is OK, will cause payment failure though.
disconnects = ['-WIRE_UPDATE_ADD_HTLC',
'@WIRE_UPDATE_ADD_HTLC',
'+WIRE_UPDATE_ADD_HTLC']
l1 = self.node_factory.get_node(legacy=False, disconnect=disconnects)
l2 = self.node_factory.get_node(legacy=False)
ret = l1.rpc.connect('localhost', l2.info['port'], l2.info['id'])
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, 'testpayment3')['rhash']
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.
l1.rpc.sendpay(to_json(route), rhash)
l1.daemon.wait_for_log('Already have funding locked in')
l1.daemon.wait_for_log('Already have funding locked in')
def test_json_addfunds(self):
""" Attempt to add funds
"""