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

Function test_large_response

tests/test_clnrest.py:242–261  ·  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

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