Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix default args, fix flake #5460

Merged
merged 5 commits into from
Jul 26, 2022

Commits on Jul 26, 2022

  1. pytest: set dblog-file when adding the dblog plugin (TEST_CHECK_DBSTM…

    …TS=1)
    
    As we'll see in the next patch, this wasn't *supposed* to work wihtout dblog-file,
    but it did, creating a dblog called "null".
    
    Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
    rustyrussell committed Jul 26, 2022
    Configuration menu
    Copy the full SHA
    d1b4576 View commit details
    Browse the repository at this point in the history
  2. lightningd: ignore default if it's a literal 'null' JSON token.

    I wondered how `tests/plugins/dblog.py` worked, since it is supposed to fail
    unless the `dblog-file` arg is set:
    
    ```
    @plugin.init()
    def init(configuration, options, plugin):
        if not plugin.get_option('dblog-file'):
            raise RpcError("No dblog-file specified")
    ```
    
    But it was set to "null".  That's because 'None' in python is turned into a literal
    JSON "null", and we take that as the default value.
    
    We also cleanup the popt->description double-assignment (a leftover
    from when this was optional).
    
    Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
    Changelog-Fixed: plugins: setting the default value of a parameter to `null` is the same as not setting it (pyln plugins did this!).
    rustyrussell committed Jul 26, 2022
    Configuration menu
    Copy the full SHA
    299afa0 View commit details
    Browse the repository at this point in the history
  3. pytest: fix flake in test_channel_persistence w/ TEST_CHECK_DBSTMTS

    This was weird.  Here is the message (with \n turned into real new lines):
    
    ```
    2022-07-24T07:20:08.9144998Z Plugin '/home/runner/work/lightning/lightning/tests/plugins/dblog.py' returned an invalid response to the db_write hook: {"jsonrpc": "2.0", "id": 40, "error": {"code": -32600, "message": "Error while processing db_write: UNIQUE constraint failed: shachain_known.shachain_id, shachain_known.pos", "traceback": "Traceback (most recent call last):
      File \"/home/runner/work/lightning/lightning/contrib/pyln-client/pyln/client/plugin.py\", line 631, in _dispatch_request
        result = self._exec_func(method.func, request)
      File \"/home/runner/work/lightning/lightning/contrib/pyln-client/pyln/client/plugin.py\", line 616, in _exec_func
        return func(*ba.args, **ba.kwargs)
      File \"/home/runner/work/lightning/lightning/tests/plugins/dblog.py\", line 45, in db_write
        plugin.conn.execute(c)
    sqlite3.IntegrityError: UNIQUE constraint failed: shachain_known.shachain_id, shachain_known.pos
    "}}
    ```
    
    Finally, I realized that we *kill* l2: this means it has updated the
    plugin db but not the real db.  This is expected: a real backup plugin
    would handle this case.
    
    Simply disable the test for this case.
    
    Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
    rustyrussell committed Jul 26, 2022
    Configuration menu
    Copy the full SHA
    3a3c7b5 View commit details
    Browse the repository at this point in the history
  4. commando: free incmd as soon as we use it.

    Otherwise we left it in the cache, causing "New cmd replacing old"
    messages.
    rustyrussell committed Jul 26, 2022
    Configuration menu
    Copy the full SHA
    1eedde0 View commit details
    Browse the repository at this point in the history
  5. pytest: fix test_commando_stress

    On fast machines, we don't get failures sometimes on commando commands.
    
    (*But* we still got "New cmd replacing old" messages, which is how I
    realized we weren't freeing them promptly, hence the previous fix).
    
    ```
            # Should have exactly one discard msg from each discard
    >       nodes[0].daemon.wait_for_logs([r"New cmd from .*, replacing old"] * discards)
    
    tests/test_plugin.py:2839: 
    ...
    >                   raise TimeoutError('Unable to find "{}" in logs.'.format(exs))
    E                   TimeoutError: Unable to find "[]" in logs.
    
    ```
    
    Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
    rustyrussell committed Jul 26, 2022
    Configuration menu
    Copy the full SHA
    95baee5 View commit details
    Browse the repository at this point in the history