|
3 | 3 | from pyln.testing.utils import env, TEST_NETWORK |
4 | 4 | from pyln.client import Millisatoshi |
5 | 5 | import unittest |
| 6 | +import os |
6 | 7 | import requests |
7 | 8 | from pathlib import Path |
8 | 9 | from requests.adapters import HTTPAdapter |
@@ -433,3 +434,35 @@ def test_clnrest_http_headers(node_factory): |
433 | 434 | headers={'Origin': 'http://192.168.1.10:1010'}, |
434 | 435 | verify=ca_cert) |
435 | 436 | assert response.headers['Access-Control-Allow-Origin'] == 'http://192.168.1.10:1010' |
| 437 | + |
| 438 | + |
| 439 | +def test_clnrest_old_params(node_factory): |
| 440 | + """Test that we handle the v23.08-style parameters""" |
| 441 | + rest_port = str(reserve()) |
| 442 | + rest_host = '127.0.0.1' |
| 443 | + base_url = f'https://{rest_host}:{rest_port}' |
| 444 | + l1 = node_factory.get_node(options={'rest-port': rest_port, |
| 445 | + 'rest-host': rest_host, |
| 446 | + 'allow-deprecated-apis': True}) |
| 447 | + # This might happen really early! |
| 448 | + l1.daemon.logsearch_start = 0 |
| 449 | + l1.daemon.wait_for_logs([r'UNUSUAL lightningd: Option rest-port=.* deprecated in v23\.11, renaming to clnrest-port', |
| 450 | + r'UNUSUAL lightningd: Option rest-host=.* deprecated in v23\.11, renaming to clnrest-host']) |
| 451 | + l1.daemon.wait_for_log(r'plugin-clnrest.py: REST server running at ' + base_url) |
| 452 | + |
| 453 | + # Now try one where a plugin (e.g. clightning-rest) registers the option. |
| 454 | + plugin = os.path.join(os.path.dirname(__file__), 'plugins/clnrest-use-options.py') |
| 455 | + l2 = node_factory.get_node(options={'rest-port': rest_port, |
| 456 | + 'rest-host': rest_host, |
| 457 | + 'plugin': plugin, |
| 458 | + 'allow-deprecated-apis': True}) |
| 459 | + |
| 460 | + l2.daemon.logsearch_start = 0 |
| 461 | + # We still rename this one, since it's for clnrest. |
| 462 | + assert l2.daemon.is_in_log(r'UNUSUAL lightningd: Option rest-host=.* deprecated in v23\.11, renaming to clnrest-host') |
| 463 | + |
| 464 | + # This one does not get renamed! |
| 465 | + assert not l2.daemon.is_in_log(r'UNUSUAL lightningd: Option rest-port=.* deprecated in v23\.11, renaming to clnrest-host') |
| 466 | + assert [p for p in l2.rpc.plugin('list')['plugins'] if 'clnrest.py' in p['name']] == [] |
| 467 | + assert l2.daemon.is_in_log(r'plugin-clnrest.py: Killing plugin: disabled itself at init: `clnrest-port` option is not configured') |
| 468 | + assert l2.daemon.is_in_log(rf'clnrest-use-options.py: rest-port is {rest_port}') |
0 commit comments