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

Function test_downgrade

tests/test_downgrade.py:34–98  ·  view source on GitHub ↗
(node_factory, executor)

Source from the content-addressed store, hash-verified

32
33
34def test_downgrade(node_factory, executor):
35 # To downgrade before 25.12, we need old-style hsm_secret.
36 l1, l2 = node_factory.line_graph(2, opts={'may_reconnect': True, 'old_hsmsecret': True}, wait_for_announce=True)
37
38 bias_scidd = f"{first_scid(l1, l2)}/0"
39 # Create a bias for this channel.
40 l1.rpc.askrene_bias_channel('xpay', bias_scidd, 1)
41 bias = only_one(only_one(l1.rpc.askrene_listlayers('xpay')['layers'])['biases'])
42 assert bias['short_channel_id_dir'] == bias_scidd
43 assert bias['bias'] == 1
44
45 # Make a payment, which means we update layer information.
46 old_inv = l2.rpc.invoice(1000, 'test_downgrade1', 'test_downgrade')
47 l1.rpc.xpay(old_inv['bolt11'])
48
49 cmd_line = downgrade_cmdline(l1)
50
51 # No downgrade on live nodes!
52 retcode = subprocess.call(cmd_line, timeout=TIMEOUT)
53 assert retcode == ERROR_USAGE
54
55 l1.stop()
56 subprocess.check_call(cmd_line)
57
58 # Test with old lightningd if it's available.
59 old_cln = os.getenv('PREV_LIGHTNINGD')
60 if old_cln:
61 current_executable = l1.daemon.executable
62 l1.daemon.executable = old_cln
63
64 l1.start()
65
66 # Disable schema checking here: the node is OLD!
67 l1.rpc.jsonschemas = {}
68
69 # It should connect to l2 no problems, make payment.
70 l1.connect(l2)
71 inv = l2.rpc.invoice(1000, 'test_downgrade', 'test_downgrade')
72 l1.rpc.xpay(inv['bolt11'])
73
74 # It should see the bias!
75 bias = only_one(only_one(l1.rpc.askrene_listlayers('xpay')['layers'])['biases'])
76 assert bias['short_channel_id_dir'] == bias_scidd
77 assert bias['bias'] == 1
78
79 l1.stop()
80 l1.daemon.executable = current_executable
81
82 # Another downgrade is a noop.
83 assert "Already compatible with " in subprocess.check_output(cmd_line).decode("utf8")
84
85 # Should be able to upgrade without any trouble
86 l1.daemon.opts['database-upgrade'] = True
87 l1.start()
88 # Note: currently a noop, this will break on first database upgrade.
89 assert not l1.daemon.is_in_log("Updating database from version 281")
90
91 l1.connect(l2)

Callers

nothing calls this directly

Calls 12

first_scidFunction · 0.90
only_oneFunction · 0.90
downgrade_cmdlineFunction · 0.85
line_graphMethod · 0.80
is_in_logMethod · 0.80
invoiceMethod · 0.45
xpayMethod · 0.45
callMethod · 0.45
stopMethod · 0.45
startMethod · 0.45
connectMethod · 0.45
decodeMethod · 0.45

Tested by

no test coverage detected