Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions tests/plugins/feature-test.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#!/usr/bin/env python3

from pyln.client import Plugin
import os

# Register a different set feature of feature bits for each location so we can
# later check that they are being passed correctly.
Expand All @@ -12,4 +13,12 @@
)


@plugin.init()
def init(configuration, options, plugin):
disable = os.getenv("PLUGIN_DISABLE")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This works, but a normal parameter would be more usual?

Copy link
Collaborator Author

@nepet nepet Oct 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

f9e938c refactors the test-plugin to use an option instead of an env var.

if disable:
return {'disable': 'init saying disable'}
return {}


plugin.run()
22 changes: 22 additions & 0 deletions tests/test_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -1748,6 +1748,28 @@ def test_plugin_feature_announce(node_factory):
assert node['features'] == expected_node_features(extra=[203])


def test_plugin_feature_remove(node_factory, monkeypatch):
"""Check that features registered by plugins get removed if a plugin
disables itself.

We set the following feature bits we don't want to include if the plugin is
disabled during init.
- 1 << 201 for `init` messages
- 1 << 203 for `node_announcement`
- 1 << 205 for bolt11 invoices
"""

monkeypatch.setenv("PLUGIN_DISABLE", "1")
plugin = os.path.join(os.path.dirname(__file__), 'plugins/feature-test.py')
l1 = node_factory.get_node(options={'plugin': plugin})

# Check that we don't include the features set in getmanifest.
our_feats = l1.rpc.getinfo()["our_features"]
assert((int(our_feats["init"], 16) & (1 << 201)) == 0)
assert((int(our_feats["node"], 16) & (1 << 203)) == 0)
assert((int(our_feats["invoice"], 16) & (1 << 205)) == 0)


def test_hook_chaining(node_factory):
"""Check that hooks are called in order and the chain exits correctly

Expand Down
Loading