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

Function test_config_in_subdir

tests/test_misc.py:2650–2702  ·  view source on GitHub ↗
(node_factory, chainparams)

Source from the content-addressed store, hash-verified

2648
2649
2650def test_config_in_subdir(node_factory, chainparams):
2651 l1 = node_factory.get_node(start=False)
2652 network = chainparams['name']
2653
2654 subdir = os.path.join(l1.daemon.opts.get("lightning-dir"), network)
2655 with open(os.path.join(subdir, "config"), 'w') as f:
2656 f.write('alias=test_config_in_subdir')
2657 l1.start()
2658
2659 assert l1.rpc.listconfigs('alias')['configs']['alias'] == {'source': os.path.join(subdir, "config") + ":1", 'value_str': 'test_config_in_subdir'}
2660
2661 l1.stop()
2662
2663 # conf is not allowed in any config file.
2664 with open(os.path.join(l1.daemon.opts.get("lightning-dir"), "config"), 'w') as f:
2665 f.write('conf={}/conf'.format(network))
2666
2667 out = subprocess.run(['lightningd/lightningd',
2668 '--lightning-dir={}'.format(l1.daemon.opts.get("lightning-dir"))],
2669 stdout=subprocess.PIPE, stderr=subprocess.PIPE, timeout=TIMEOUT)
2670 assert out.returncode == 1
2671 assert "conf: not permitted in configuration files" in out.stderr.decode('utf-8')
2672
2673 # network is allowed in root config file.
2674 with open(os.path.join(l1.daemon.opts.get("lightning-dir"), "config"), 'w') as f:
2675 f.write('network={}'.format(network))
2676
2677 l1.start()
2678 l1.stop()
2679
2680 # but not in network config file.
2681 with open(os.path.join(subdir, "config"), 'w') as f:
2682 f.write('network={}'.format(network))
2683
2684 out = subprocess.run(['lightningd/lightningd',
2685 '--lightning-dir={}'.format(l1.daemon.opts.get("lightning-dir"))],
2686 stdout=subprocess.PIPE, stderr=subprocess.PIPE)
2687 assert out.returncode == 1
2688 assert "network={}: not permitted in network-specific configuration files".format(network) in out.stderr.decode('utf-8')
2689
2690 # lightning-dir only allowed if we explicitly use --conf
2691 os.unlink(os.path.join(subdir, "config"))
2692 with open(os.path.join(l1.daemon.opts.get("lightning-dir"), "config"), 'w') as f:
2693 f.write('lightning-dir={}/test'.format(l1.daemon.opts.get("lightning-dir")))
2694
2695 out = subprocess.run(['lightningd/lightningd',
2696 '--lightning-dir={}'.format(l1.daemon.opts.get("lightning-dir"))],
2697 stdout=subprocess.PIPE, stderr=subprocess.PIPE)
2698 assert out.returncode == 1
2699 assert "lightning-dir={}/test: not permitted in implicit configuration files".format(l1.daemon.opts.get("lightning-dir")) in out.stderr.decode('utf-8')
2700
2701 l1.daemon.opts['conf'] = os.path.join(l1.daemon.opts.get("lightning-dir"), "config")
2702 l1.start()
2703
2704
2705def restore_valgrind(node, subdir):

Callers

nothing calls this directly

Calls 9

joinMethod · 0.80
listconfigsMethod · 0.80
get_nodeMethod · 0.45
getMethod · 0.45
writeMethod · 0.45
startMethod · 0.45
stopMethod · 0.45
runMethod · 0.45
decodeMethod · 0.45

Tested by

no test coverage detected