diff --git a/tests/test_lightningd.py b/tests/test_lightningd.py index 9ba52ef74..24713f82b 100644 --- a/tests/test_lightningd.py +++ b/tests/test_lightningd.py @@ -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 """