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

Function test_large_request_body

tests/test_clnrest.py:889–905  ·  view source on GitHub ↗

Test large request bodies getting rejected without a crash. Run over plain HTTP: with TLS, a client that sends the whole body before reading the response can only see a connection reset instead of the 413, depending on the OpenSSL version.

(node_factory)

Source from the content-addressed store, hash-verified

887
888
889def test_large_request_body(node_factory):
890 """Test large request bodies getting rejected without a crash.
891
892 Run over plain HTTP: with TLS, a client that sends the whole body before
893 reading the response can only see a connection reset instead of the 413,
894 depending on the OpenSSL version.
895 """
896 l1, base_url, _ = start_node_with_clnrest(node_factory, protocol='http')
897 http_session = http_session_with_retry()
898
899 body = b'{"pad":"' + b"B" * (32 * 1024 * 1024) + b'"}'
900 response = http_session.post(base_url + "/v1/getinfo", data=body)
901 assert response.status_code == 413
902 assert response.json()["code"] == -32600
903 assert "Request body exceeds the maximum allowed size" in response.json()["message"]
904
905 l1.rpc.getinfo()

Callers

nothing calls this directly

Calls 4

start_node_with_clnrestFunction · 0.85
http_session_with_retryFunction · 0.85
jsonMethod · 0.80
getinfoMethod · 0.45

Tested by

no test coverage detected