File tree Expand file tree Collapse file tree 2 files changed +31
-0
lines changed
Expand file tree Collapse file tree 2 files changed +31
-0
lines changed Original file line number Diff line number Diff line change 11#!/usr/bin/env python3
22
33from pyln .client import Plugin
4+ import os
45
56# Register a different set feature of feature bits for each location so we can
67# later check that they are being passed correctly.
1213)
1314
1415
16+ @plugin .init ()
17+ def init (configuration , options , plugin ):
18+ disable = os .getenv ("PLUGIN_DISABLE" )
19+ if disable :
20+ return {'disable' : 'init saying disable' }
21+ return {}
22+
23+
1524plugin .run ()
Original file line number Diff line number Diff line change @@ -1748,6 +1748,28 @@ def test_plugin_feature_announce(node_factory):
17481748 assert node ['features' ] == expected_node_features (extra = [203 ])
17491749
17501750
1751+ def test_plugin_feature_remove (node_factory , monkeypatch ):
1752+ """Check that features registered by plugins get removed if a plugin
1753+ disables itself.
1754+
1755+ We set the following feature bits we don't want to include if the plugin is
1756+ disabled during init.
1757+ - 1 << 201 for `init` messages
1758+ - 1 << 203 for `node_announcement`
1759+ - 1 << 205 for bolt11 invoices
1760+ """
1761+
1762+ monkeypatch .setenv ("PLUGIN_DISABLE" , "1" )
1763+ plugin = os .path .join (os .path .dirname (__file__ ), 'plugins/feature-test.py' )
1764+ l1 = node_factory .get_node (options = {'plugin' : plugin })
1765+
1766+ # Check that we don't include the features set in getmanifest.
1767+ our_feats = l1 .rpc .getinfo ()["our_features" ]
1768+ assert ((int (our_feats ["init" ], 16 ) & (1 << 201 )) == 0 )
1769+ assert ((int (our_feats ["node" ], 16 ) & (1 << 203 )) == 0 )
1770+ assert ((int (our_feats ["invoice" ], 16 ) & (1 << 205 )) == 0 )
1771+
1772+
17511773def test_hook_chaining (node_factory ):
17521774 """Check that hooks are called in order and the chain exits correctly
17531775
You can’t perform that action at this time.
0 commit comments