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

Function test_penalty_outhtlc

tests/test_closing.py:606–729  ·  view source on GitHub ↗

Test penalty transaction with an outgoing HTLC

(node_factory, bitcoind, executor, chainparams)

Source from the content-addressed store, hash-verified

604
605@pytest.mark.developer("needs dev-disable-commit-after")
606def test_penalty_outhtlc(node_factory, bitcoind, executor, chainparams):
607 """Test penalty transaction with an outgoing HTLC"""
608
609 # We track channel balances, to verify that accounting is ok.
610 coin_mvt_plugin = os.path.join(os.getcwd(), 'tests/plugins/coin_movements.py')
611 # First we need to get funds to l2, so suppress after second.
612 # Feerates identical so we don't get gratuitous commit to update them
613 l1, l2 = node_factory.line_graph(2,
614 opts=[{'dev-disable-commit-after': 3,
615 'may_fail': True,
616 'feerates': (7500, 7500, 7500, 7500),
617 'allow_broken_log': True,
618 'plugin': coin_mvt_plugin},
619 {'dev-disable-commit-after': 3,
620 'plugin': coin_mvt_plugin}])
621 channel_id = first_channel_id(l1, l2)
622
623 # Move some across to l2.
624 l1.pay(l2, 200000000)
625
626 assert not l1.daemon.is_in_log('dev-disable-commit-after: disabling')
627 assert not l2.daemon.is_in_log('dev-disable-commit-after: disabling')
628
629 # Now, this will get stuck due to l1 commit being disabled..
630 t = executor.submit(l2.pay, l1, 100000000)
631
632 # Make sure we get signature from them.
633 l1.daemon.wait_for_log('peer_in WIRE_UPDATE_ADD_HTLC')
634 l1.daemon.wait_for_log('peer_in WIRE_COMMITMENT_SIGNED')
635
636 # They should both have commitments blocked now.
637 l1.daemon.wait_for_log('dev-disable-commit-after: disabling')
638 l2.daemon.wait_for_log('dev-disable-commit-after: disabling')
639
640 # Make sure both sides got revoke_and_ack for that commitment.
641 l1.daemon.wait_for_log('peer_in WIRE_REVOKE_AND_ACK')
642 l2.daemon.wait_for_log('peer_in WIRE_REVOKE_AND_ACK')
643
644 # Take our snapshot.
645 tx = l1.rpc.dev_sign_last_tx(l2.info['id'])['tx']
646
647 # Let them continue
648 l1.rpc.dev_reenable_commit(l2.info['id'])
649 l2.rpc.dev_reenable_commit(l1.info['id'])
650
651 # Thread should complete.
652 t.result(timeout=10)
653
654 # Make sure both sides got revoke_and_ack for final.
655 l1.daemon.wait_for_log('peer_in WIRE_REVOKE_AND_ACK')
656 l2.daemon.wait_for_log('peer_in WIRE_REVOKE_AND_ACK')
657
658 # Now we really mess things up!
659 bitcoind.rpc.sendrawtransaction(tx)
660 bitcoind.generate_block(1)
661
662 l2.daemon.wait_for_log(' to ONCHAIN')
663 # FIXME: l1 should try to stumble along!

Callers

nothing calls this directly

Calls 15

first_channel_idFunction · 0.90
sync_blockheightFunction · 0.90
wait_forFunction · 0.90
only_oneFunction · 0.90
account_balanceFunction · 0.90
anchor_expectedFunction · 0.90
check_utxos_channelFunction · 0.90
joinMethod · 0.80
line_graphMethod · 0.80
is_in_logMethod · 0.80
wait_for_logMethod · 0.80
dev_sign_last_txMethod · 0.80

Tested by

no test coverage detected