Skip to content

Commit

Permalink
pyln-client: pass through level parameter on command notifications.
Browse files Browse the repository at this point in the history
Without this, everything came out as level INFO.

Changelog-Fixed: pyln-client: Fix Plugin.notify_message() not to ignore `level` parameter.
Signed-off-by: Rusty Russell <[email protected]>
  • Loading branch information
rustyrussell committed May 4, 2024
1 parent f1dc64b commit 168ecb8
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 10 deletions.
2 changes: 1 addition & 1 deletion contrib/pyln-client/pyln/client/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -707,7 +707,7 @@ def log(self, message: str, level: str = 'info') -> None:
def notify_message(self, request: Request, message: str,
level: str = 'info') -> None:
"""Send a notification message to sender of this request"""
request.notify(message=message)
request.notify(message=message, level=level)

def notify_progress(self, request: Request,
progress: int, progress_total: int,
Expand Down
17 changes: 8 additions & 9 deletions tests/test_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -2268,7 +2268,6 @@ def test_htlc_accepted_hook_crash(node_factory, executor):
f.result(10)


@pytest.mark.skip("With newer GCC versions reports a '*** buffer overflow detected ***: terminated'")
def test_notify(node_factory):
"""Test that notifications from plugins get ignored"""
plugins = [os.path.join(os.getcwd(), 'tests/plugins/notify.py'),
Expand All @@ -2292,17 +2291,17 @@ def test_notify(node_factory):
else:
assert out[2 + i].endswith("|\r")

assert out[102] == '# Beginning stage 2\n'
assert out[103] == '\r'

# These messages are DEBUG level, and default is INFO, so there is no
# "'# Beginning stage 2\n'
assert out[102] == '\r'
for i in range(10):
assert out[104 + i].startswith("# Stage 2/2 {:>2}/10 |".format(1 + i))
assert out[103 + i].startswith("# Stage 2/2 {:>2}/10 |".format(1 + i))
if i == 9:
assert out[104 + i].endswith("|\n")
assert out[103 + i].endswith("|\n")
else:
assert out[104 + i].endswith("|\r")
assert out[114] == '"This worked"\n'
assert len(out) == 115
assert out[103 + i].endswith("|\r")
assert out[113] == '"This worked"\n'
assert len(out) == 114

# At debug level, we get the second prompt.
out = subprocess.check_output(['cli/lightning-cli',
Expand Down

0 comments on commit 168ecb8

Please sign in to comment.