Test that we drop onchain if the peer doesn't accept fulfilled HTLC
(node_factory, bitcoind, executor)
| 504 | |
| 505 | |
| 506 | def test_htlc_in_timeout(node_factory, bitcoind, executor): |
| 507 | """Test that we drop onchain if the peer doesn't accept fulfilled HTLC""" |
| 508 | |
| 509 | # HTLC 1->2, 1 fails after 2 has sent committed the fulfill |
| 510 | disconnects = ['-WIRE_REVOKE_AND_ACK*2'] |
| 511 | # Feerates identical so we don't get gratuitous commit to update them |
| 512 | l1 = node_factory.get_node(disconnect=disconnects, |
| 513 | options={'dev-no-reconnect': None}, |
| 514 | feerates=(7500, 7500, 7500, 7500)) |
| 515 | l2 = node_factory.get_node() |
| 516 | # Give it some sats for anchor spend! |
| 517 | l2.fundwallet(25000, mine_block=False) |
| 518 | |
| 519 | l1.rpc.connect(l2.info['id'], 'localhost', l2.port) |
| 520 | chanid, _ = l1.fundchannel(l2, 10**6) |
| 521 | |
| 522 | sync_blockheight(bitcoind, [l1, l2]) |
| 523 | |
| 524 | amt = 200000000 |
| 525 | inv = l2.rpc.invoice(amt, 'test_htlc_in_timeout', 'desc')['bolt11'] |
| 526 | assert only_one(l2.rpc.listinvoices('test_htlc_in_timeout')['invoices'])['status'] == 'unpaid' |
| 527 | |
| 528 | executor.submit(l1.rpc.xpay, inv) |
| 529 | |
| 530 | # l1 will disconnect and not reconnect. |
| 531 | l1.daemon.wait_for_log('dev_disconnect: -WIRE_REVOKE_AND_ACK') |
| 532 | |
| 533 | bitcoind.generate_block(2) |
| 534 | assert not l2.daemon.is_in_log('hit deadline') |
| 535 | bitcoind.generate_block(1) |
| 536 | |
| 537 | l2.daemon.wait_for_log('Fulfilled HTLC 0 SENT_REMOVE_COMMIT cltv .* hit deadline') |
| 538 | l2.daemon.wait_for_log('sendrawtx exit 0') |
| 539 | l2.bitcoin.generate_block(1) |
| 540 | l2.daemon.wait_for_log(' to ONCHAIN') |
| 541 | l1.daemon.wait_for_log(' to ONCHAIN') |
| 542 | |
| 543 | # L2 will collect HTLC |
| 544 | _, txid, blocks = l2.wait_for_onchaind_tx('OUR_HTLC_SUCCESS_TX', |
| 545 | 'OUR_UNILATERAL/THEIR_HTLC') |
| 546 | assert blocks == 0 |
| 547 | |
| 548 | # If we try to reuse the same output as we used for the anchor spend, then |
| 549 | # bitcoind can reject it. In that case we'll try again after we get change |
| 550 | # from anchor spend. |
| 551 | if txid not in bitcoind.rpc.getrawmempool(): |
| 552 | bitcoind.generate_block(1) |
| 553 | bitcoind.generate_block(1, wait_for_mempool=1) |
| 554 | else: |
| 555 | bitcoind.generate_block(1) |
| 556 | |
| 557 | rawtx, txid, blocks = l2.wait_for_onchaind_tx('OUR_DELAYED_RETURN_TO_WALLET', |
| 558 | 'OUR_HTLC_SUCCESS_TX/DELAYED_OUTPUT_TO_US') |
| 559 | assert blocks == 4 |
| 560 | bitcoind.generate_block(4) |
| 561 | l2.daemon.wait_for_log('sendrawtx exit 0.*{}'.format(rawtx)) |
| 562 | |
| 563 | # Now, 100 blocks it should be both done. |
nothing calls this directly
no test coverage detected