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

Function test_upgrade_statickey_fail

tests/test_connection.py:3781–3842  ·  view source on GitHub ↗

We reconnect at all points during retransmit, and we won't upgrade.

(node_factory, executor, bitcoind)

Source from the content-addressed store, hash-verified

3779@unittest.skipIf(not EXPERIMENTAL_FEATURES, "upgrade protocol not available")
3780@pytest.mark.developer("dev-force-features, dev-disconnect required")
3781def test_upgrade_statickey_fail(node_factory, executor, bitcoind):
3782 """We reconnect at all points during retransmit, and we won't upgrade."""
3783 l1_disconnects = ['-WIRE_COMMITMENT_SIGNED',
3784 '-WIRE_REVOKE_AND_ACK']
3785 l2_disconnects = ['-WIRE_REVOKE_AND_ACK',
3786 '-WIRE_COMMITMENT_SIGNED']
3787
3788 l1, l2 = node_factory.line_graph(2, opts=[{'may_reconnect': True,
3789 'dev-no-reconnect': None,
3790 'disconnect': l1_disconnects,
3791 'dev-force-features': ["-13", "-21"],
3792 # Don't have feerate changes!
3793 'feerates': (7500, 7500, 7500, 7500)},
3794 {'may_reconnect': True,
3795 'dev-no-reconnect': None,
3796 'disconnect': l2_disconnects,
3797 'plugin': os.path.join(os.getcwd(), 'tests/plugins/hold_htlcs.py'),
3798 'hold-time': 10000,
3799 'hold-result': 'fail'}])
3800
3801 # This HTLC will fail
3802 l1.rpc.sendpay([{'amount_msat': 1000, 'id': l2.info['id'], 'delay': 5, 'channel': first_scid(l1, l2)}], '00' * 32, payment_secret='00' * 32)
3803
3804 # Each one should cause one disconnection, no upgrade.
3805 for d in l1_disconnects + l2_disconnects:
3806 l1.daemon.wait_for_log('Peer connection lost')
3807 l2.daemon.wait_for_log('Peer connection lost')
3808 assert not l1.daemon.is_in_log('option_static_remotekey enabled')
3809 assert not l2.daemon.is_in_log('option_static_remotekey enabled')
3810 l1.rpc.connect(l2.info['id'], 'localhost', l2.port)
3811 line1 = l1.daemon.wait_for_log('No upgrade')
3812 line2 = l2.daemon.wait_for_log('No upgrade')
3813
3814 # On the last reconnect, it retransmitted revoke_and_ack.
3815 assert re.search('No upgrade: we retransmitted', line1)
3816 assert re.search('No upgrade: pending changes', line2)
3817
3818 # Make sure we already skip the first of these.
3819 l1.daemon.wait_for_log('billboard perm: Reconnected, and reestablished.')
3820 assert 'option_static_remotekey' not in only_one(only_one(l1.rpc.listpeers()['peers'])['channels'])['features']
3821 assert 'option_static_remotekey' not in only_one(only_one(l2.rpc.listpeers()['peers'])['channels'])['features']
3822
3823 sleeptime = 1
3824 while True:
3825 # Now when we reconnect, despite having an HTLC, we're quiescent.
3826 l1.rpc.disconnect(l2.info['id'], force=True)
3827 l1.rpc.connect(l2.info['id'], 'localhost', l2.port)
3828
3829 oldstart = l1.daemon.logsearch_start
3830 l1.daemon.wait_for_log('billboard perm: Reconnected, and reestablished.')
3831 if not l1.daemon.is_in_log('No upgrade:', start=oldstart):
3832 break
3833
3834 # Give it some processing time before reconnect...
3835 time.sleep(sleeptime)
3836 sleeptime += 1
3837
3838 l1.daemon.logsearch_start = oldstart

Callers

nothing calls this directly

Calls 10

first_scidFunction · 0.90
only_oneFunction · 0.90
line_graphMethod · 0.80
joinMethod · 0.80
sendpayMethod · 0.80
wait_for_logMethod · 0.80
is_in_logMethod · 0.80
connectMethod · 0.45
listpeersMethod · 0.45
disconnectMethod · 0.45

Tested by

no test coverage detected