We test penalty before/after, and unilateral before/after
(node_factory, executor, bitcoind)
| 3653 | @unittest.skipIf(not EXPERIMENTAL_FEATURES, "upgrade protocol not available") |
| 3654 | @pytest.mark.developer("dev-force-features required") |
| 3655 | def test_upgrade_statickey_onchaind(node_factory, executor, bitcoind): |
| 3656 | """We test penalty before/after, and unilateral before/after""" |
| 3657 | l1, l2 = node_factory.line_graph(2, opts=[{'may_reconnect': True, |
| 3658 | 'dev-no-reconnect': None, |
| 3659 | 'dev-force-features': ["-13", "-21"], |
| 3660 | # We try to cheat! |
| 3661 | 'allow_broken_log': True}, |
| 3662 | {'may_reconnect': True, |
| 3663 | 'dev-no-reconnect': None}]) |
| 3664 | |
| 3665 | # TEST 1: Cheat from pre-upgrade. |
| 3666 | tx = l1.rpc.dev_sign_last_tx(l2.info['id'])['tx'] |
| 3667 | |
| 3668 | l1.rpc.disconnect(l2.info['id'], force=True) |
| 3669 | l1.rpc.connect(l2.info['id'], 'localhost', l2.port) |
| 3670 | l1.daemon.wait_for_log('option_static_remotekey enabled at 1/1') |
| 3671 | |
| 3672 | # Make sure another commitment happens, sending failed payment. |
| 3673 | routestep = { |
| 3674 | 'amount_msat': 1, |
| 3675 | 'id': l2.info['id'], |
| 3676 | 'delay': 5, |
| 3677 | 'channel': first_scid(l1, l2) |
| 3678 | } |
| 3679 | l1.rpc.sendpay([routestep], '00' * 32, payment_secret='00' * 32) |
| 3680 | with pytest.raises(RpcError, match=r'WIRE_INCORRECT_OR_UNKNOWN_PAYMENT_DETAILS'): |
| 3681 | l1.rpc.waitsendpay('00' * 32) |
| 3682 | |
| 3683 | # Make sure l2 gets REVOKE_AND_ACK from previous. |
| 3684 | l2.daemon.wait_for_log('peer_in WIRE_UPDATE_ADD_HTLC') |
| 3685 | l2.daemon.wait_for_log('peer_out WIRE_REVOKE_AND_ACK') |
| 3686 | l2.daemon.wait_for_log('peer_in WIRE_REVOKE_AND_ACK') |
| 3687 | |
| 3688 | # Pre-statickey penalty works. |
| 3689 | bitcoind.rpc.sendrawtransaction(tx) |
| 3690 | bitcoind.generate_block(1) |
| 3691 | |
| 3692 | l2.wait_for_onchaind_broadcast('OUR_PENALTY_TX', |
| 3693 | 'THEIR_REVOKED_UNILATERAL/DELAYED_CHEAT_OUTPUT_TO_THEM') |
| 3694 | bitcoind.generate_block(100) |
| 3695 | # This works even if they disconnect and listpeers() is empty: |
| 3696 | wait_for(lambda: all([p['channels'] == [] for p in l2.rpc.listpeers()['peers']])) |
| 3697 | |
| 3698 | # TEST 2: Cheat from post-upgrade. |
| 3699 | node_factory.join_nodes([l1, l2]) |
| 3700 | l1.rpc.disconnect(l2.info['id'], force=True) |
| 3701 | l1.rpc.connect(l2.info['id'], 'localhost', l2.port) |
| 3702 | |
| 3703 | l1.daemon.wait_for_log('option_static_remotekey enabled at 1/1') |
| 3704 | l2.daemon.wait_for_log('option_static_remotekey enabled at 1/1') |
| 3705 | |
| 3706 | l1.pay(l2, 1000000) |
| 3707 | |
| 3708 | # We will try to cheat later. |
| 3709 | tx = l1.rpc.dev_sign_last_tx(l2.info['id'])['tx'] |
| 3710 | |
| 3711 | l1.pay(l2, 1000000) |
| 3712 |
nothing calls this directly
no test coverage detected