dropp baes64 use binary
This commit is contained in:
@@ -372,12 +372,53 @@ def test_relay_rpc_round_trips_http_request_to_peer():
|
||||
assert json.loads(response["body"]) == {"ok": True, "path": "/v1/chat/completions"}
|
||||
|
||||
|
||||
def test_binary_relay_frame_codecs_interoperate():
|
||||
"""Node and relay ship the same binary frame format as separate copies."""
|
||||
import os
|
||||
|
||||
from meshnet_node import relay_bridge
|
||||
from meshnet_relay import server as relay_server
|
||||
|
||||
header = {"request_id": "r-1", "status": 200, "headers": {"X": "y"}}
|
||||
body = os.urandom(4096)
|
||||
for encoder, decoder in (
|
||||
(relay_bridge.encode_binary_frame, relay_server.decode_binary_frame),
|
||||
(relay_server.encode_binary_frame, relay_bridge.decode_binary_frame),
|
||||
):
|
||||
assert decoder(encoder(header, body)) == (header, body)
|
||||
|
||||
try:
|
||||
relay_server.decode_binary_frame(b"not a frame")
|
||||
except ValueError:
|
||||
pass
|
||||
else:
|
||||
raise AssertionError("garbage bytes must not decode as a binary frame")
|
||||
|
||||
|
||||
def test_activation_compression_round_trips_and_skips_small_bodies():
|
||||
"""Pipeline hops zstd-compress large activations; tiny decode bodies pass raw."""
|
||||
import os
|
||||
|
||||
from meshnet_node.server import _decompress_body
|
||||
from meshnet_node.torch_server import _maybe_compress_activation
|
||||
|
||||
small = os.urandom(1024)
|
||||
assert _maybe_compress_activation(small) == (small, None)
|
||||
|
||||
large = os.urandom(96 * 1024) * 2 # repetition so zstd actually shrinks it
|
||||
wire, encoding = _maybe_compress_activation(large)
|
||||
assert encoding == "zstd"
|
||||
assert len(wire) < len(large)
|
||||
assert _decompress_body(wire, encoding) == large
|
||||
|
||||
|
||||
def test_relay_rpc_carries_activation_sized_frames():
|
||||
"""A >1 MiB activation body must survive the full relay round trip.
|
||||
|
||||
Regression: the websockets library caps frames at 1 MiB by default, so
|
||||
prefill activations forwarded via /rpc/<peer> died with close code 1009
|
||||
at every hop (requester → relay, relay → bridge, bridge → relay → requester).
|
||||
The body now travels as binary frames — raw bytes, no base64.
|
||||
"""
|
||||
import http.server
|
||||
import os
|
||||
|
||||
Reference in New Issue
Block a user