mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-03-03 18:57:06 +01:00
commando: add stress test, fix memleak report.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
parent
05a666e424
commit
c10e385612
2 changed files with 38 additions and 1 deletions
|
@ -452,8 +452,11 @@ static void handle_incmd(struct node_id *peer,
|
||||||
|
|
||||||
incmd = find_commando(incoming_commands, peer, NULL);
|
incmd = find_commando(incoming_commands, peer, NULL);
|
||||||
/* Don't let them buffer multiple commands: discard old. */
|
/* Don't let them buffer multiple commands: discard old. */
|
||||||
if (incmd && incmd->id != idnum)
|
if (incmd && incmd->id != idnum) {
|
||||||
|
plugin_log(plugin, LOG_DBG, "New cmd from %s, replacing old",
|
||||||
|
node_id_to_hexstr(tmpctx, peer));
|
||||||
incmd = tal_free(incmd);
|
incmd = tal_free(incmd);
|
||||||
|
}
|
||||||
|
|
||||||
if (!incmd) {
|
if (!incmd) {
|
||||||
incmd = tal(plugin, struct commando);
|
incmd = tal(plugin, struct commando);
|
||||||
|
@ -705,6 +708,7 @@ static struct command_result *json_commando(struct command *cmd,
|
||||||
tal_free(peer);
|
tal_free(peer);
|
||||||
tal_free(method);
|
tal_free(method);
|
||||||
tal_free(cparams);
|
tal_free(cparams);
|
||||||
|
tal_free(rune);
|
||||||
|
|
||||||
return send_more_cmd(cmd, NULL, NULL, outgoing);
|
return send_more_cmd(cmd, NULL, NULL, outgoing);
|
||||||
}
|
}
|
||||||
|
|
|
@ -2804,3 +2804,36 @@ def test_commando_rune(node_factory):
|
||||||
'rune': rune['rune'],
|
'rune': rune['rune'],
|
||||||
'method': cmd,
|
'method': cmd,
|
||||||
'params': params})
|
'params': params})
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.slow_test
|
||||||
|
def test_commando_stress(node_factory, executor):
|
||||||
|
"""Stress test to slam commando with many large queries"""
|
||||||
|
nodes = node_factory.get_nodes(5)
|
||||||
|
|
||||||
|
rune = nodes[0].rpc.commando_rune()['rune']
|
||||||
|
for n in nodes[1:]:
|
||||||
|
n.connect(nodes[0])
|
||||||
|
|
||||||
|
futs = []
|
||||||
|
for i in range(1000):
|
||||||
|
node = random.choice(nodes[1:])
|
||||||
|
futs.append(executor.submit(node.rpc.call, method='commando',
|
||||||
|
payload={'peer_id': nodes[0].info['id'],
|
||||||
|
'rune': rune,
|
||||||
|
'method': 'invoice',
|
||||||
|
'params': {'amount_msat': 'any',
|
||||||
|
'label': 'label{}'.format(i),
|
||||||
|
'description': 'A' * 200000,
|
||||||
|
'deschashonly': True}}))
|
||||||
|
discards = 0
|
||||||
|
for f in futs:
|
||||||
|
try:
|
||||||
|
f.result(TIMEOUT)
|
||||||
|
except RpcError as e:
|
||||||
|
assert(e.error['code'] == 0x4c50)
|
||||||
|
assert(e.error['message'] == "Invalid JSON")
|
||||||
|
discards += 1
|
||||||
|
|
||||||
|
# Should have exactly one discard msg from each discard
|
||||||
|
nodes[0].daemon.wait_for_logs([r"New cmd from .*, replacing old"] * discards)
|
||||||
|
|
Loading…
Add table
Reference in a new issue