What changed, and why it matters
This commit adds a new internal benchmark/test plugin command called 'spamlistcommand'. It is only used in automated performance tests to repeatedly call the 'listinvoices' RPC and measure speed. It does not change normal wallet behavior, add user-facing features, or fix any bug. There is no security relevance.
No security action needed. This is a benign test-only change.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The patch extends tests/plugins/test_libplugin.c with json_spamlistcommand, which accepts an ‘iterations’ parameter, creates a request batch, and sends that many ‘listinvoices’ outreqs. A corresponding pytest benchmark test_spam_listcommands is added to tests/benchmark.py. The code is test-only instrumentation and is not reachable in production unless the test plugin is explicitly loaded.
Changed components
tests/plugins/test_libplugin.ctests/benchmark.pyInspect captured patch +33 / −0
diff --git a/tests/benchmark.py b/tests/benchmark.py
index 81ab387d..ec0062e8 100644
--- a/tests/benchmark.py
+++ b/tests/benchmark.py
@@ -218,4 +218,13 @@ def test_spam_commands(node_factory, bitcoind, benchmark):
plugin = os.path.join(os.getcwd(), "tests/plugins/test_libplugin")
l1 = get_bench_node(node_factory, extra_options={"plugin": plugin})
+ # This calls "batch" 1M times (which doesn't need a transaction)
benchmark(l1.rpc.spamcommand, 1_000_000)
+
+
+def test_spam_listcommands(node_factory, bitcoind, benchmark):
+ plugin = os.path.join(os.getcwd(), "tests/plugins/test_libplugin")
+ l1 = get_bench_node(node_factory, extra_options={"plugin": plugin})
+
+ # This calls "listinvoice" 100,000 times (which doesn't need a transaction commit)
+ benchmark(l1.rpc.spamlistcommand, 100_000)
diff --git a/tests/plugins/test_libplugin.c b/tests/plugins/test_libplugin.c
index 2abf1f7f..c51ab55b 100644
--- a/tests/plugins/test_libplugin.c
+++ b/tests/plugins/test_libplugin.c
@@ -234,6 +234,26 @@ static struct command_result *json_spamcommand(struct command *cmd,
return batch_done(cmd, batch);
}
+static struct command_result *json_spamlistcommand(struct command *cmd,
+ const char *buf,
+ const jsmntok_t *params)
+{
+ u64 *iterations;
+ struct request_batch *batch;
+
+ if (!param(cmd, buf, params,
+ p_req("iterations", param_u64, &iterations),
+ NULL))
+ return command_param_failed();
+
+ batch = request_batch_new(cmd, NULL, spam_errcb, spam_done, NULL);
+ for (size_t i = 0; i < *iterations; i++) {
+ struct out_req *req = add_to_batch(cmd, batch, "listinvoices");
+ send_outreq(req);
+ }
+ return batch_done(cmd, batch);
+}
+
static char *set_dynamic(struct plugin *plugin,
const char *arg,
@@ -312,6 +332,10 @@ static const struct plugin_command commands[] = { {
"spamcommand",
json_spamcommand,
},
+ {
+ "spamlistcommand",
+ json_spamlistcommand,
+ },
};
static const char *before[] = { "dummy", NULL };
Why this scored 15/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.