(node_factory, executor)
| 32 | |
| 33 | |
| 34 | def 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) |
nothing calls this directly
no test coverage detected