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

Function test_payment_success_persistence

tests/test_pay.py:343–383  ·  view source on GitHub ↗
(node_factory, bitcoind, executor)

Source from the content-addressed store, hash-verified

341@pytest.mark.openchannel('v1')
342@pytest.mark.openchannel('v2')
343def test_payment_success_persistence(node_factory, bitcoind, executor):
344 # Start two nodes and open a channel.. die during payment.
345 # Feerates identical so we don't get gratuitous commit to update them
346 disconnect = ['+WIRE_COMMITMENT_SIGNED']
347 if EXPERIMENTAL_DUAL_FUND:
348 # We have to add an extra 'wire-commitment-signed' because
349 # dual funding uses this for channel establishment also
350 disconnect = ['=WIRE_COMMITMENT_SIGNED'] + disconnect
351
352 l1 = node_factory.get_node(disconnect=disconnect,
353 options={'dev-no-reconnect': None},
354 may_reconnect=True,
355 feerates=(7500, 7500, 7500, 7500))
356 l2 = node_factory.get_node(may_reconnect=True)
357 l1.rpc.connect(l2.info['id'], 'localhost', l2.port)
358
359 chanid, _ = l1.fundchannel(l2, 100000)
360
361 inv1 = l2.rpc.invoice(1000, 'inv1', 'inv1')
362
363 # Fire off a pay request, it'll get interrupted by a restart
364 executor.submit(l1.dev_pay, inv1['bolt11'], dev_use_shadow=False)
365
366 l1.daemon.wait_for_log(r'dev_disconnect: \+WIRE_COMMITMENT_SIGNED')
367
368 print("Killing l1 in mid HTLC")
369 l1.daemon.kill()
370
371 # Restart l1, without disconnect stuff.
372 del l1.daemon.opts['dev-no-reconnect']
373 l1.daemon.disconnect = None
374
375 # Should reconnect, and sort the payment out.
376 l1.start()
377
378 wait_for(lambda: l1.rpc.listsendpays()['payments'][0]['status'] != 'pending')
379
380 payments = l1.rpc.listsendpays()['payments']
381 invoices = l2.rpc.listinvoices('inv1')['invoices']
382 assert len(payments) == 1 and payments[0]['status'] == 'complete'
383 assert len(invoices) == 1 and invoices[0]['status'] == 'paid'
384
385
386@pytest.mark.openchannel('v1')

Callers

nothing calls this directly

Calls 10

wait_forFunction · 0.90
wait_for_logMethod · 0.80
killMethod · 0.80
listsendpaysMethod · 0.80
get_nodeMethod · 0.45
connectMethod · 0.45
fundchannelMethod · 0.45
invoiceMethod · 0.45
startMethod · 0.45
listinvoicesMethod · 0.45

Tested by

no test coverage detected