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

Function test_large_response

tests/test_clnrest.py:240–259  ·  view source on GitHub ↗

Test a large reply still works (and msat fields are integers!)

(node_factory)

Source from the content-addressed store, hash-verified

238
239
240def test_large_response(node_factory):
241 """Test a large reply still works (and msat fields are integers!)"""
242 # start a node with clnrest
243 l1, base_url, ca_cert = start_node_with_clnrest(node_factory)
244 http_session = http_session_with_retry()
245
246 # Add 500 invoices, test list
247 NUM_INVOICES = 500
248 for i in range(NUM_INVOICES):
249 l1.rpc.invoice(amount_msat=100, label=str(i), description="inv")
250
251 rune = l1.rpc.createrune()['rune']
252 response = http_session.post(base_url + '/v1/listinvoices', headers={'Rune': rune},
253 verify=ca_cert)
254 # No, this doesn't return JSON, it *parses* it into a Python object!
255 resp = response.json()
256
257 # Make sure it hasn't turned msat fields into strings!
258 assert not isinstance(resp['invoices'][0]['amount_msat'], Millisatoshi)
259 assert len(resp['invoices']) == NUM_INVOICES
260
261
262# Tests for websocket are written separately to avoid flake8

Callers

nothing calls this directly

Calls 4

start_node_with_clnrestFunction · 0.85
http_session_with_retryFunction · 0.85
jsonMethod · 0.80
invoiceMethod · 0.45

Tested by

no test coverage detected