MCPcopy Create free account
hub / github.com/ElementsProject/lightning / test_commando_stress

Function test_commando_stress

tests/test_plugin.py:3279–3312  ·  view source on GitHub ↗

Stress test to slam commando with many large queries

(node_factory, executor)

Source from the content-addressed store, hash-verified

3277
3278@pytest.mark.slow_test
3279def test_commando_stress(node_factory, executor):
3280 """Stress test to slam commando with many large queries"""
3281 nodes = node_factory.get_nodes(5, opts=[{'broken_log': 'Throttling incoming peer'}, {}, {}, {}, {}])
3282
3283 rune = nodes[0].rpc.createrune()['rune']
3284 for n in nodes[1:]:
3285 n.connect(nodes[0])
3286
3287 futs = []
3288 for i in range(1000):
3289 node = random.choice(nodes[1:])
3290 futs.append(executor.submit(node.rpc.call, method='commando',
3291 payload={'peer_id': nodes[0].info['id'],
3292 'rune': rune,
3293 'method': 'invoice',
3294 'params': {'amount_msat': 'any',
3295 'label': 'label{}'.format(i),
3296 'description': 'A' * 200000,
3297 'deschashonly': True}}))
3298 discards = 0
3299 for f in futs:
3300 try:
3301 f.result(TIMEOUT)
3302 except RpcError as e:
3303 assert(e.error['code'] == 0x4c50)
3304 assert(e.error['message'] == "Invalid JSON")
3305 discards += 1
3306
3307 # Should have at least one discard msg from each failure (we can have
3308 # more, if they kept replacing each other, as happens!)
3309 if discards > 0:
3310 nodes[0].daemon.wait_for_logs([r"New cmd from .*, replacing old"] * discards)
3311 else:
3312 assert not nodes[0].daemon.is_in_log(r"New cmd from .*, replacing old")
3313
3314
3315def test_autoclean(node_factory):

Callers

nothing calls this directly

Calls 4

get_nodesMethod · 0.80
wait_for_logsMethod · 0.80
is_in_logMethod · 0.80
connectMethod · 0.45

Tested by

no test coverage detected