Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 1 addition & 1 deletion lightningd/plugin.c
Original file line number Diff line number Diff line change
Expand Up @@ -1821,7 +1821,7 @@ static const char *plugin_parse_getmanifest_response(const char *buffer,
}

/* Store fset to allow to remove feature bits when init returns disabled */
plugin->fset = tal_dup_or_null(plugin, struct feature_set, fset);
plugin->fset = feature_set_dup(plugin, fset);
} else {
plugin->fset = NULL;
}
Expand Down
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):
if options.get('disable-on-init'):
return {'disable': 'init saying disable'}
return {}


plugin.add_option('disable-on-init', False, 'disable plugin on init', opt_type='bool')
plugin.run()
21 changes: 21 additions & 0 deletions tests/test_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -1748,6 +1748,27 @@ def test_plugin_feature_announce(node_factory):
assert node['features'] == expected_node_features(extra=[203])


def test_plugin_feature_remove(node_factory):
"""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
"""

plugin = os.path.join(os.path.dirname(__file__), 'plugins/feature-test.py')
l1 = node_factory.get_node(options={'plugin': plugin, 'disable-on-init': True})

# 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