Test penalty transaction with an incoming HTLC
(node_factory, bitcoind, executor, chainparams, anchors)
| 509 | |
| 510 | @pytest.mark.parametrize("anchors", [False, True]) |
| 511 | def test_penalty_inhtlc(node_factory, bitcoind, executor, chainparams, anchors): |
| 512 | """Test penalty transaction with an incoming HTLC""" |
| 513 | |
| 514 | if chainparams['elements'] and anchors: |
| 515 | pytest.skip('elementsd anchors unsupported') |
| 516 | |
| 517 | # We track channel balances, to verify that accounting is ok. |
| 518 | coin_mvt_plugin = os.path.join(os.getcwd(), 'tests/plugins/coin_movements.py') |
| 519 | # We suppress each one after first commit; HTLC gets added not fulfilled. |
| 520 | # Feerates identical so we don't get gratuitous commit to update them |
| 521 | opts = {'dev-disable-commit-after': 1, |
| 522 | 'plugin': coin_mvt_plugin} |
| 523 | if anchors is False: |
| 524 | opts['dev-force-features'] = "-23" |
| 525 | |
| 526 | # FIXME: | for dicts was added in Python 3.9 apparently. |
| 527 | l1, l2 = node_factory.line_graph(2, opts=[{**opts, **{'may_fail': True, |
| 528 | 'feerates': (7500, 7500, 7500, 7500), |
| 529 | # We try to cheat! |
| 530 | 'broken_log': r"onchaind-chan#[0-9]*: Could not find resolution for output .*: did \*we\* cheat\?"}}, |
| 531 | opts]) |
| 532 | |
| 533 | channel_id = first_channel_id(l1, l2) |
| 534 | scid = first_scid(l1, l2) |
| 535 | |
| 536 | # Now, this will get stuck due to l1 commit being disabled.. |
| 537 | t = executor.submit(l1.pay, l2, 100000000) |
| 538 | |
| 539 | assert l1.is_local_channel_active(scid) |
| 540 | assert l2.is_local_channel_active(scid) |
| 541 | |
| 542 | # They should both have commitments blocked now. |
| 543 | l1.daemon.wait_for_log('dev-disable-commit-after: disabling') |
| 544 | l2.daemon.wait_for_log('dev-disable-commit-after: disabling') |
| 545 | |
| 546 | # Make sure l1 got l2's commitment to the HTLC, and sent to master. |
| 547 | l1.daemon.wait_for_log('got commitsig') |
| 548 | |
| 549 | # Take our snapshot. |
| 550 | tx = l1.rpc.dev_sign_last_tx(l2.info['id'])['tx'] |
| 551 | |
| 552 | # Let them continue |
| 553 | l1.rpc.dev_reenable_commit(l2.info['id']) |
| 554 | l2.rpc.dev_reenable_commit(l1.info['id']) |
| 555 | |
| 556 | # Should fulfill. |
| 557 | l1.daemon.wait_for_log('peer_in WIRE_UPDATE_FULFILL_HTLC') |
| 558 | l1.daemon.wait_for_log('peer_out WIRE_REVOKE_AND_ACK') |
| 559 | |
| 560 | l2.daemon.wait_for_log('peer_out WIRE_UPDATE_FULFILL_HTLC') |
| 561 | l1.daemon.wait_for_log('peer_in WIRE_REVOKE_AND_ACK') |
| 562 | |
| 563 | # Payment should now complete. |
| 564 | t.result(timeout=10) |
| 565 | |
| 566 | # Make sure both sides completely settled. |
| 567 | wait_for(lambda: all([only_one(n.rpc.listpeerchannels()['channels'])['htlcs'] == [] for n in (l1, l2)])) |
| 568 |
nothing calls this directly
no test coverage detected