Skip to content

listconfigs shows only 80 chars of "lightning-dir" path #5576

Closed
@SimonVrouwe

Description

@SimonVrouwe

On latest master (c4203e7), test_relative_config_dir fails when lightning-dir directory path is longer then 80 characters.

Accidentally ran into this when using the $TEST_DIR variable for the pytests, below example results in --lightning-dir path to be 81 chars.

TEST_DIR=/tmp/aaaaaaaaaaaaaaaaaa VALGRIND=0 pytest tests/ -k 'test_relative_config_dir'
============================================================================================================================= test session starts =============================================================================================================================
platform linux -- Python 3.9.2, pytest-7.1.2, pluggy-1.0.0
rootdir: /home/simon/git/SimonVrouwe/lightning, configfile: pytest.ini
plugins: custom-exit-code-0.3.0, test-groups-1.0.3, xdist-2.5.0, forked-1.4.0, timeout-2.1.0
collected 528 items / 527 deselected / 1 selected                                                                                                                                                                                                                             

tests/test_misc.py F                                                                                                                                                                                                                                                    [100%]

================================================================================================================================== FAILURES ===================================================================================================================================
__________________________________________________________________________________________________________________________ test_relative_config_dir ___________________________________________________________________________________________________________________________

node_factory = <pyln.testing.utils.NodeFactory object at 0x7fdd97606d60>

    def test_relative_config_dir(node_factory):
        l1 = node_factory.get_node(start=False)
        initial_dir = os.getcwd()
        lndir = l1.daemon.opts.get("lightning-dir")[:-1]
        *root_dir, l1.daemon.opts["lightning-dir"] = lndir.split('/')
        os.chdir('/'.join(root_dir))
        l1.daemon.executable = os.path.join(initial_dir, l1.daemon.executable)
        l1.start()
>       assert os.path.isabs(l1.rpc.listconfigs()["lightning-dir"])
E       AssertionError: assert False
E        +  where False = <function isabs at 0x7fdd9d7cf820>('tmp/aaaaaaaaaaaaaaaaaa/ltests-nhzau93b/test_relative_config_dir_1/lightning-1...')
E        +    where <function isabs at 0x7fdd9d7cf820> = <module 'posixpath' from '/usr/lib/python3.9/posixpath.py'>.isabs
E        +      where <module 'posixpath' from '/usr/lib/python3.9/posixpath.py'> = os.path

/home/simon/git/SimonVrouwe/lightning/tests/test_misc.py:1851: AssertionError

Seems caused by the way listconfigs calls opt->show(), which in this case is opt_show_charp() which only copies 80 chars.

lightning/lightningd/options.c

Lines 1568 to 1569 in c4203e7

opt->show(buf, opt->u.carg);
strcpy(buf + OPT_SHOW_LEN - 1, "...");

BTW listconfigs and getinfo returns different lightning-dir <== not documented very well

Metadata

Metadata

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions