From 5b5d70d640d270c7dfb637e6d173e80ca0dd1a6c Mon Sep 17 00:00:00 2001 From: Simon Vrouwe Date: Sat, 24 Aug 2019 11:51:58 +0300 Subject: [PATCH] lightningd/plugin: extend plugins->startup window to include plugins_config Fixes incorrect configuration[`startup`] in plugin `init`, modified tests to test this. --- lightningd/plugin.c | 4 ++-- tests/plugins/dblog.py | 2 +- tests/plugins/slow_init.py | 2 +- tests/test_plugin.py | 4 ++-- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/lightningd/plugin.c b/lightningd/plugin.c index d1a3df9f9..69d4e824d 100644 --- a/lightningd/plugin.c +++ b/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, diff --git a/tests/plugins/dblog.py b/tests/plugins/dblog.py index 2b985958a..97d1b8ed0 100755 --- a/tests/plugins/dblog.py +++ b/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') diff --git a/tests/plugins/slow_init.py b/tests/plugins/slow_init.py index 4c5316b16..4be95ced8 100755 --- a/tests/plugins/slow_init.py +++ b/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) diff --git a/tests/test_plugin.py b/tests/test_plugin.py index c655d8027..e1ece1a52 100644 --- a/tests/test_plugin.py +++ b/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()