MCPcopy Create free account
hub / github.com/ElementsProject/lightning / test_pay_disconnect

Function test_pay_disconnect

tests/test_pay.py:232–282  ·  view source on GitHub ↗

If the remote node has disconnected, we fail payment, but can try again when it reconnects

(node_factory, bitcoind)

Source from the content-addressed store, hash-verified

230
231
232def test_pay_disconnect(node_factory, bitcoind):
233 """If the remote node has disconnected, we fail payment, but can try again when it reconnects"""
234 l1, l2 = node_factory.line_graph(2, opts={'dev-max-fee-multiplier': 5,
235 'may_reconnect': True,
236 'allow_warning': True})
237
238 # Dummy payment to kick off update_fee messages
239 l1.pay(l2, 1000)
240
241 inv = l2.rpc.invoice(123000, 'test_pay_disconnect', 'description')
242 rhash = inv['payment_hash']
243
244 # Can't use `pay` since that'd notice that we can't route, due to disabling channel_update
245 route = l1.single_route(l2.info['id'], 123000)
246
247 l2.stop()
248 # Make sure channeld has exited!
249 wait_for(lambda: 'owner' not in only_one(l1.rpc.listpeerchannels(l2.info['id'])['channels']))
250
251 # Can't pay while its offline.
252 with pytest.raises(RpcError, match=r'failed: WIRE_TEMPORARY_CHANNEL_FAILURE \(First peer not ready\)'):
253 l1.rpc.sendpay(route, rhash, payment_secret=inv['payment_secret'])
254
255 l2.start()
256 l1.daemon.wait_for_log('peer_out WIRE_CHANNEL_REESTABLISH')
257
258 # Make l2 upset by asking for crazy fee.
259 l1.set_feerates((10**6, 10**6, 10**6, 10**6), False)
260
261 # Wait for l1 notice
262 if 'anchors/even' in only_one(l1.rpc.listpeerchannels()['channels'])['channel_type']['names']:
263 l1.daemon.wait_for_log(r'WARNING .*: update_fee \d+ outside range 253-75000')
264 else:
265 l1.daemon.wait_for_log(r'WARNING .*: update_fee \d+ outside range 1875-75000')
266 # They hang up on us
267 l1.daemon.wait_for_log(r'Peer transient failure in CHANNELD_NORMAL')
268
269 # Make l2 fail hard.
270 l2.rpc.close(l1.info['id'], unilateraltimeout=1)
271 l2.daemon.wait_for_log('sendrawtx exit')
272 bitcoind.generate_block(1, wait_for_mempool=1)
273 sync_blockheight(bitcoind, [l1, l2])
274
275 # Should fail due to permenant channel fail
276 with pytest.raises(RpcError, match=r'WIRE_UNKNOWN_NEXT_PEER'):
277 l1.rpc.sendpay(route, rhash, payment_secret=inv['payment_secret'])
278
279 assert not l1.daemon.is_in_log('Payment is still in progress')
280
281 # After it sees block, someone should close channel.
282 l1.daemon.wait_for_log('ONCHAIN')
283
284
285def test_pay_error_update_fees(node_factory):

Callers

nothing calls this directly

Calls 15

wait_forFunction · 0.90
only_oneFunction · 0.90
sync_blockheightFunction · 0.90
line_graphMethod · 0.80
single_routeMethod · 0.80
listpeerchannelsMethod · 0.80
sendpayMethod · 0.80
wait_for_logMethod · 0.80
set_feeratesMethod · 0.80
generate_blockMethod · 0.80
is_in_logMethod · 0.80
payMethod · 0.45

Tested by

no test coverage detected