(node_factory, bitcoind, executor)
| 392 | @pytest.mark.openchannel('v1') |
| 393 | @pytest.mark.openchannel('v2') |
| 394 | def test_payment_success_persistence(node_factory, bitcoind, executor): |
| 395 | # Start two nodes and open a channel.. die during payment. |
| 396 | # Feerates identical so we don't get gratuitous commit to update them |
| 397 | disconnect = ['+WIRE_COMMITMENT_SIGNED'] |
| 398 | if EXPERIMENTAL_DUAL_FUND: |
| 399 | # We have to add an extra 'wire-commitment-signed' because |
| 400 | # dual funding uses this for channel establishment also |
| 401 | disconnect = ['=WIRE_COMMITMENT_SIGNED'] + disconnect |
| 402 | |
| 403 | l1 = node_factory.get_node(disconnect=disconnect, |
| 404 | options={'dev-no-reconnect': None}, |
| 405 | may_reconnect=True, |
| 406 | feerates=(7500, 7500, 7500, 7500)) |
| 407 | l2 = node_factory.get_node(may_reconnect=True) |
| 408 | l1.rpc.connect(l2.info['id'], 'localhost', l2.port) |
| 409 | |
| 410 | chanid, _ = l1.fundchannel(l2, 100000) |
| 411 | |
| 412 | inv1 = l2.rpc.invoice(1000, 'inv1', 'inv1') |
| 413 | |
| 414 | # Fire off a pay request, it'll get interrupted by a restart |
| 415 | executor.submit(l1.dev_pay, inv1['bolt11'], use_shadow=False) |
| 416 | |
| 417 | l1.daemon.wait_for_log(r'dev_disconnect: \+WIRE_COMMITMENT_SIGNED') |
| 418 | |
| 419 | print("Killing l1 in mid HTLC") |
| 420 | l1.daemon.kill() |
| 421 | |
| 422 | # Restart l1, without disconnect stuff. |
| 423 | del l1.daemon.opts['dev-no-reconnect'] |
| 424 | del l1.daemon.opts['dev-disconnect'] |
| 425 | |
| 426 | # Should reconnect, and sort the payment out. |
| 427 | l1.start() |
| 428 | |
| 429 | wait_for(lambda: l1.rpc.listsendpays()['payments'][0]['status'] != 'pending') |
| 430 | |
| 431 | payments = l1.rpc.listsendpays()['payments'] |
| 432 | invoices = l2.rpc.listinvoices('inv1')['invoices'] |
| 433 | assert len(payments) == 1 and payments[0]['status'] == 'complete' |
| 434 | assert len(invoices) == 1 and invoices[0]['status'] == 'paid' |
| 435 | |
| 436 | l1.wait_channel_active(chanid) |
| 437 | |
| 438 | # A duplicate should succeed immediately (nop) and return correct preimage. |
| 439 | preimage = l1.dev_pay( |
| 440 | inv1['bolt11'], |
| 441 | use_shadow=False |
| 442 | )['payment_preimage'] |
| 443 | assert l1.rpc.dev_rhash(preimage)['rhash'] == inv1['payment_hash'] |
| 444 | |
| 445 | |
| 446 | @pytest.mark.developer("needs DEVELOPER=1") |
nothing calls this directly
no test coverage detected