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

Function test_configfile_before_chdir

tests/test_misc.py:2060–2080  ·  view source on GitHub ↗

Must read config file before chdir into lightning dir

(node_factory)

Source from the content-addressed store, hash-verified

2058
2059
2060def test_configfile_before_chdir(node_factory):
2061 """Must read config file before chdir into lightning dir"""
2062 l1 = node_factory.get_node()
2063 l1.stop()
2064
2065 olddir = os.getcwd()
2066 # as lightning_dir ends in /, basename and dirname don't work as expected.
2067 os.chdir(os.path.dirname(l1.daemon.lightning_dir[:-1]))
2068 config = os.path.join(os.path.basename(l1.daemon.lightning_dir[:-1]), TEST_NETWORK, "test_configfile")
2069 # Test both an early arg and a normal arg.
2070 with open(config, 'wb') as f:
2071 f.write(b'always-use-proxy=true\n')
2072 f.write(b'proxy=127.0.0.1:100\n')
2073 l1.daemon.opts['conf'] = config
2074
2075 # Update executable to point to right place
2076 l1.daemon.executable = os.path.join(olddir, l1.daemon.executable)
2077 l1.start()
2078 assert l1.rpc.listconfigs()['configs']['always-use-proxy'] == {'source': os.path.abspath(config) + ":1", 'value_bool': True}
2079 assert l1.rpc.listconfigs()['configs']['proxy'] == {'source': os.path.abspath(config) + ":2", 'value_str': '127.0.0.1:100'}
2080 os.chdir(olddir)
2081
2082
2083def test_json_error(node_factory):

Callers

nothing calls this directly

Calls 6

joinMethod · 0.80
listconfigsMethod · 0.80
get_nodeMethod · 0.45
stopMethod · 0.45
writeMethod · 0.45
startMethod · 0.45

Tested by

no test coverage detected