diff options
| author | Christophe Besson <cbesson@gmail.com> | 2026-09-23 22:25:28 +0200 |
|---|---|---|
| committer | Christophe Besson <cbesson@gmail.com> | 2026-09-24 16:45:37 +0200 |
| commit | 328b01a2dd545d70a078db8df1e91b02d65bfc9c (patch) | |
| tree | 9af69d617d9482ba4256f3d7334c9dd6cde0d5e2 /packages/meshbay-node/tests/test_transport_wire_parity.py | |
| parent | 92ea222b7aca6a3eb5f04330f0af6755e6e434e3 (diff) | |
| download | meshbay-328b01a2dd545d70a078db8df1e91b02d65bfc9c.tar.gz | |
test: read the WebRTC transport's source as a set of files
Source-reading tests take their text from node_source (node) and node_tree
(hub): webrtc_server.py plus anything under transport/webrtc/, so a check
for something's absence keeps reading the code it guards if that code moves.
test_node_source_scope holds the boundary.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Diffstat (limited to 'packages/meshbay-node/tests/test_transport_wire_parity.py')
| -rw-r--r-- | packages/meshbay-node/tests/test_transport_wire_parity.py | 30 |
1 files changed, 17 insertions, 13 deletions
diff --git a/packages/meshbay-node/tests/test_transport_wire_parity.py b/packages/meshbay-node/tests/test_transport_wire_parity.py index 6e74b28..cd31fb4 100644 --- a/packages/meshbay-node/tests/test_transport_wire_parity.py +++ b/packages/meshbay-node/tests/test_transport_wire_parity.py @@ -23,6 +23,7 @@ from meshbay_common.protocol import MNP, file_chunk_plaintext, file_chunk_wire from meshbay_node.indexer import DirectoryIndexer from meshbay_node.transport import quic_server, webrtc_server from meshbay_node.transport.wire import index_sync_message +from node_source import webrtc_source from conftest import one_root @@ -41,23 +42,27 @@ def shared_dir(tmp_path): return d +def _transports(): + """Each transport's whole source: WebRTC is several modules, QUIC is one.""" + return [("the WebRTC transport", webrtc_source()), + (quic_server.__name__, inspect.getsource(quic_server))] + + def test_both_transports_use_the_one_chunk_encoder(): """Neither server may encrypt a chunk itself.""" - for module in (webrtc_server, quic_server): - source = inspect.getsource(module) - assert "file_chunk_wire" in source, f"{module.__name__} bypasses the shared encoder" + for name, source in _transports(): + assert "file_chunk_wire" in source, f"{name} bypasses the shared encoder" assert "encrypt_chunk_aes(" not in source, ( - f"{module.__name__} encrypts a chunk on its own — that is how the two " + f"{name} encrypts a chunk on its own — that is how the two " f"copies diverged the first time") assert "chunk_key_aes(" not in source, ( - f"{module.__name__} derives a chunk key on its own") + f"{name} derives a chunk key on its own") def test_both_transports_use_the_one_index_builder(): - for module in (webrtc_server, quic_server): - source = inspect.getsource(module) + for name, source in _transports(): assert "index_sync_message" in source, ( - f"{module.__name__} builds index_sync itself") + f"{name} builds index_sync itself") assert "index_b64" not in inspect.getsource(quic_server), ( "QUIC is serializing the index again — that was the fork") @@ -68,13 +73,12 @@ def test_neither_transport_seals_by_hand(): A server reaching for AESGCM or HKDF directly is a second envelope waiting to disagree with the first about a nonce length, an info string or an AAD. """ - for module in (webrtc_server, quic_server): - source = inspect.getsource(module) - assert "seal(" in source, f"{module.__name__} sends an unsealed ack" + for name, source in _transports(): + assert "seal(" in source, f"{name} sends an unsealed ack" assert "AESGCM(" not in source, ( - f"{module.__name__} builds its own AEAD instead of using groupbox") + f"{name} builds its own AEAD instead of using groupbox") assert "HKDF(" not in source, ( - f"{module.__name__} derives its own subkey instead of using groupbox") + f"{name} derives its own subkey instead of using groupbox") def test_the_daemon_does_not_build_an_index_message_itself(): |