Test the configuration parsing with extra whitespace in the configuration file.
(node_factory)
| 4485 | |
| 4486 | |
| 4487 | def test_config_whitespace(node_factory): |
| 4488 | """ Test the configuration parsing with extra |
| 4489 | whitespace in the configuration file. """ |
| 4490 | l1 = node_factory.get_node() |
| 4491 | |
| 4492 | configfile = os.path.join(l1.daemon.opts.get("lightning-dir"), TEST_NETWORK, 'config') |
| 4493 | |
| 4494 | # Stop the node to modify the configuration file safely |
| 4495 | l1.stop() |
| 4496 | |
| 4497 | # Ensure the log-prefix option is not set in the command line arguments |
| 4498 | if 'log-prefix' in l1.daemon.opts: |
| 4499 | del l1.daemon.opts['log-prefix'] |
| 4500 | |
| 4501 | # Write configuration parameters with extra whitespace |
| 4502 | with open(configfile, "a") as f: |
| 4503 | f.write("\n\n# Test whitespace\n") |
| 4504 | f.write("funder-policy-mod=100 \n") |
| 4505 | f.write("funder-min-their-funding=10000\n") |
| 4506 | f.write("allow-deprecated-apis=false \n") |
| 4507 | f.write("alias=MyLightningNode \n") |
| 4508 | f.write("log-prefix=MyNode \n") |
| 4509 | |
| 4510 | l1.start() |
| 4511 | |
| 4512 | configs = l1.rpc.listconfigs() |
| 4513 | |
| 4514 | # Verify that the trimmed configuration values are correctly set |
| 4515 | assert configs['configs']['funder-policy-mod']['value_str'] == '100', "funder-policy-mod should be '100'" |
| 4516 | assert configs['configs']['funder-min-their-funding']['value_str'] == '10000', "funder-min-their-funding should be '10000'" |
| 4517 | assert configs['configs']['allow-deprecated-apis']['value_bool'] is False, "allow-deprecated-apis should be False" |
| 4518 | |
| 4519 | # We want to keep the whitespaces at the parameter 'alias' & 'log-prefix' |
| 4520 | assert configs['configs']['alias']['value_str'] == 'MyLightningNode ', "alias should be 'MyLightningNode '" |
| 4521 | assert configs['configs']['log-prefix']['value_str'] == 'MyNode ', "log-prefix should be 'MyNode '" |
| 4522 | |
| 4523 | |
| 4524 | def test_setconfig(node_factory, bitcoind): |