Browse Source

lightningd/plugin: extend plugins->startup window to include plugins_config

Fixes incorrect configuration[`startup`] in plugin `init`, modified tests
to test this.
pull/2938/head
Simon Vrouwe 6 years ago
committed by Rusty Russell
parent
commit
5b5d70d640
  1. 4
      lightningd/plugin.c
  2. 2
      tests/plugins/dblog.py
  3. 2
      tests/plugins/slow_init.py
  4. 4
      tests/test_plugin.py

4
lightningd/plugin.c

@ -1019,8 +1019,6 @@ void plugins_init(struct plugins *plugins, const char *dev_plugin_debug)
if (plugins->pending_manifests > 0)
io_loop_with_timers(plugins->ld);
// There won't be io_loop anymore to wait for plugins
plugins->startup = false;
}
static void plugin_config_cb(const char *buffer,
@ -1074,6 +1072,8 @@ void plugins_config(struct plugins *plugins)
plugin_config(p);
}
}
plugins->startup = false;
}
void json_add_opt_plugins(struct json_stream *response,

2
tests/plugins/dblog.py

@ -20,7 +20,7 @@ def init(configuration, options, plugin):
plugin.conn.execute(c)
plugin.log("{}".format(c))
plugin.initted = True
plugin.log("initialized")
plugin.log("initialized {}".format(configuration))
@plugin.hook('db_write')

2
tests/plugins/slow_init.py

@ -7,7 +7,7 @@ plugin = Plugin()
@plugin.init()
def init(options, configuration, plugin):
plugin.log("slow_init.py initializing")
plugin.log("slow_init.py initializing {}".format(configuration))
time.sleep(1)

4
tests/test_plugin.py

@ -98,7 +98,7 @@ def test_plugin_slowinit(node_factory):
n = node_factory.get_node()
n.rpc.plugin_start(os.path.join(os.getcwd(), "tests/plugins/slow_init.py"))
n.daemon.wait_for_log("slow_init.py initializing")
n.daemon.wait_for_log("slow_init.py initializing.* 'startup': False")
# It's not actually configured yet, see what happens;
# make sure 'rescan' and 'list' controls dont crash
@ -304,7 +304,7 @@ def test_db_hook(node_factory, executor):
l1.daemon.wait_for_log('plugin-dblog.py replaying pre-init data:')
l1.daemon.wait_for_log('plugin-dblog.py PRAGMA foreign_keys = ON;')
l1.daemon.wait_for_log('plugin-dblog.py CREATE TABLE version \\(version INTEGER\\)')
l1.daemon.wait_for_log('plugin-dblog.py initialized')
l1.daemon.wait_for_log("plugin-dblog.py initialized.* 'startup': True")
l1.stop()

Loading…
Cancel
Save