diff options
| author | Christophe Besson <cbesson@gmail.com> | 2026-09-19 17:58:05 +0200 |
|---|---|---|
| committer | Christophe Besson <cbesson@gmail.com> | 2026-09-19 17:58:05 +0200 |
| commit | 1ec316035ce9aa656dd18a05889856bce9e3aba3 (patch) | |
| tree | b50e97f50d485ef2a88ce36fe4d7511d9fe3e288 /packages/meshbay-node/tests | |
| parent | 171a3e175889ce30f201fcdf5c4632f480344ae6 (diff) | |
| parent | 95dd3dc13aecec85c2fd72410cd4d1f4ed582dfa (diff) | |
| download | meshbay-1ec316035ce9aa656dd18a05889856bce9e3aba3.tar.gz | |
Merge origin/main: the tree-wide ruff pass beside the Music reconnect work
Diffstat (limited to 'packages/meshbay-node/tests')
77 files changed, 202 insertions, 231 deletions
diff --git a/packages/meshbay-node/tests/test_admin_ops_mnp.py b/packages/meshbay-node/tests/test_admin_ops_mnp.py index 92e50b5..7fd1c2b 100644 --- a/packages/meshbay-node/tests/test_admin_ops_mnp.py +++ b/packages/meshbay-node/tests/test_admin_ops_mnp.py @@ -15,13 +15,10 @@ thing that finishes a revocation: the ex-member still holds the current key. """ import base64 -import time from pathlib import Path import pytest from cryptography.hazmat.primitives.asymmetric.ed25519 import Ed25519PrivateKey - -from conftest import one_root from meshbay_common.adminop import ( OP_GEK_ROTATE, OP_MEMBER_UNPIN, @@ -34,6 +31,8 @@ from meshbay_node.indexer.group_index import GroupIndex from meshbay_node.roster import open_roster from meshbay_node.transport.webrtc_server import WebRTCPeerSession +from conftest import one_root + GROUP = "g" * 32 diff --git a/packages/meshbay-node/tests/test_app_directories.py b/packages/meshbay-node/tests/test_app_directories.py index 726f5bd..955a769 100644 --- a/packages/meshbay-node/tests/test_app_directories.py +++ b/packages/meshbay-node/tests/test_app_directories.py @@ -26,7 +26,6 @@ from types import SimpleNamespace import pytest from cryptography.hazmat.primitives.asymmetric.ed25519 import Ed25519PrivateKey - from meshbay_common.adminop import OP_APP_DIRECTORIES from meshbay_node import ops from meshbay_node.indexer.group_index import GroupIndex diff --git a/packages/meshbay-node/tests/test_app_directories_signed.py b/packages/meshbay-node/tests/test_app_directories_signed.py index eda09d8..af362a1 100644 --- a/packages/meshbay-node/tests/test_app_directories_signed.py +++ b/packages/meshbay-node/tests/test_app_directories_signed.py @@ -24,7 +24,6 @@ from pathlib import Path import pytest from cryptography.hazmat.primitives.asymmetric.ed25519 import Ed25519PrivateKey - from meshbay_common.adminop import OP_APP_DIRECTORIES, admin_transcript from meshbay_common.crypto import pk_to_b64 from meshbay_common.join import ROLE_OPERATOR diff --git a/packages/meshbay-node/tests/test_apps_enabled_policy.py b/packages/meshbay-node/tests/test_apps_enabled_policy.py index 40c7cc8..1fa3d5c 100644 --- a/packages/meshbay-node/tests/test_apps_enabled_policy.py +++ b/packages/meshbay-node/tests/test_apps_enabled_policy.py @@ -13,12 +13,11 @@ way an unsigned upload is refused, so the check has to happen up front. from pathlib import Path import pytest - +from cryptography.hazmat.primitives.asymmetric.ed25519 import Ed25519PrivateKey from meshbay_common.adminop import OP_APPS_ENABLED from meshbay_node.indexer.group_index import GroupIndex from meshbay_node.roster import Roster from meshbay_node.transport.webrtc_server import WebRTCPeerSession -from cryptography.hazmat.primitives.asymmetric.ed25519 import Ed25519PrivateKey from conftest import one_root diff --git a/packages/meshbay-node/tests/test_audio_root_gates_enrichment.py b/packages/meshbay-node/tests/test_audio_root_gates_enrichment.py index 251617c..b8c4dd6 100644 --- a/packages/meshbay-node/tests/test_audio_root_gates_enrichment.py +++ b/packages/meshbay-node/tests/test_audio_root_gates_enrichment.py @@ -17,10 +17,9 @@ import os import pytest from cryptography.hazmat.primitives.asymmetric.ed25519 import Ed25519PrivateKey - from meshbay_common.crypto import generate_gek from meshbay_node import ops -from meshbay_node.config import Config, HubConfig, NodeConfig, GroupConfig, KeystoreConfig +from meshbay_node.config import Config, GroupConfig, HubConfig, KeystoreConfig, NodeConfig from meshbay_node.daemon import NodeDaemon from meshbay_node.indexer import DirectoryIndexer from meshbay_node.indexer.enrich_audio import AudioEnricher diff --git a/packages/meshbay-node/tests/test_audio_transcode.py b/packages/meshbay-node/tests/test_audio_transcode.py index a6557f0..acb39b7 100644 --- a/packages/meshbay-node/tests/test_audio_transcode.py +++ b/packages/meshbay-node/tests/test_audio_transcode.py @@ -145,7 +145,8 @@ async def test_missing_file_id_is_an_error(tmp_path, media_cache): sk_node = Ed25519PrivateKey.generate() session = WebRTCPeerSession.__new__(WebRTCPeerSession) session._ctx = { - "roots": one_root(tmp_path), "index": GroupIndex(group_id="g" * 32, sk_node=sk_node, gek=gek), + "roots": one_root(tmp_path), + "index": GroupIndex(group_id="g" * 32, sk_node=sk_node, gek=gek), "gek": gek, "sk_node": sk_node, "media_cache": media_cache, } session._group_id = None @@ -170,7 +171,8 @@ async def test_multi_chunk_cached_blob_reassembles_correctly(tmp_path, media_cac sk_node = Ed25519PrivateKey.generate() session = WebRTCPeerSession.__new__(WebRTCPeerSession) session._ctx = { - "roots": one_root(tmp_path), "index": GroupIndex(group_id="g" * 32, sk_node=sk_node, gek=gek), + "roots": one_root(tmp_path), + "index": GroupIndex(group_id="g" * 32, sk_node=sk_node, gek=gek), "gek": gek, "sk_node": sk_node, "media_cache": media_cache, } session._group_id = None diff --git a/packages/meshbay-node/tests/test_chat_is_bounded.py b/packages/meshbay-node/tests/test_chat_is_bounded.py index 4e767bc..5dc1128 100644 --- a/packages/meshbay-node/tests/test_chat_is_bounded.py +++ b/packages/meshbay-node/tests/test_chat_is_bounded.py @@ -33,7 +33,6 @@ import os import pytest from cryptography.hazmat.primitives.asymmetric.ed25519 import Ed25519PrivateKey - from meshbay_common.chatbox import NONCE_LEN, SIG_LEN from meshbay_common.crypto import pk_to_b64 from meshbay_node.chat import FORMAT_SEALED_V1, ChatStore diff --git a/packages/meshbay-node/tests/test_chat_multidevice.py b/packages/meshbay-node/tests/test_chat_multidevice.py index bb61285..058544a 100644 --- a/packages/meshbay-node/tests/test_chat_multidevice.py +++ b/packages/meshbay-node/tests/test_chat_multidevice.py @@ -16,10 +16,9 @@ account where it should be keyed by connection" mistake as `pin_identity`'s old INSERT OR REPLACE. """ -from pathlib import Path - import base64 import hashlib +from pathlib import Path from aiortc import RTCPeerConnection from cryptography.hazmat.primitives.asymmetric.ed25519 import Ed25519PrivateKey diff --git a/packages/meshbay-node/tests/test_chat_pagination.py b/packages/meshbay-node/tests/test_chat_pagination.py index caf1f73..f3949a9 100644 --- a/packages/meshbay-node/tests/test_chat_pagination.py +++ b/packages/meshbay-node/tests/test_chat_pagination.py @@ -13,12 +13,10 @@ The cursor is the row id rather than the timestamp. `timestamp` is a float from timestamp cursor would then skip a message or return it twice. """ -import asyncio from pathlib import Path import pytest import pytest_asyncio - from meshbay_node.chat.store import ChatStore diff --git a/packages/meshbay-node/tests/test_chat_store.py b/packages/meshbay-node/tests/test_chat_store.py index d74310d..2533921 100644 --- a/packages/meshbay-node/tests/test_chat_store.py +++ b/packages/meshbay-node/tests/test_chat_store.py @@ -2,10 +2,9 @@ Tests for the SQLite-backed chat message store. """ + import pytest import pytest_asyncio -from pathlib import Path - from meshbay_node.chat.store import ChatStore diff --git a/packages/meshbay-node/tests/test_cli_dispatch.py b/packages/meshbay-node/tests/test_cli_dispatch.py index ad60b91..cf2fd6e 100644 --- a/packages/meshbay-node/tests/test_cli_dispatch.py +++ b/packages/meshbay-node/tests/test_cli_dispatch.py @@ -14,10 +14,8 @@ branch nobody ever ran. """ import sys -from pathlib import Path import pytest - from meshbay_node import daemon as daemon_mod # Each verb, with the arguments that reach its branch. `--yes` where the command @@ -155,7 +153,6 @@ def test_the_verb_list_here_matches_the_parser(): A verb added to the parser and not to this file would go untested, which is exactly how `reload` shipped broken. """ - import argparse import inspect source = inspect.getsource(daemon_mod.main) diff --git a/packages/meshbay-node/tests/test_daemon.py b/packages/meshbay-node/tests/test_daemon.py index 8bd169d..8c4da2d 100644 --- a/packages/meshbay-node/tests/test_daemon.py +++ b/packages/meshbay-node/tests/test_daemon.py @@ -9,20 +9,21 @@ Hub interaction is mocked. import asyncio import base64 import os +from unittest.mock import AsyncMock, MagicMock, patch import pytest from cryptography.hazmat.primitives import serialization from cryptography.hazmat.primitives.asymmetric.ed25519 import Ed25519PrivateKey from cryptography.hazmat.primitives.asymmetric.x25519 import X25519PrivateKey -from unittest.mock import AsyncMock, MagicMock, patch - from meshbay_common.crypto import generate_gek from meshbay_common.groupbox import PURPOSE_INDEX, unseal -from meshbay_node.config import Config, HubConfig, NodeConfig, GroupConfig, KeystoreConfig -from conftest import one_root +from meshbay_node.config import Config, GroupConfig, HubConfig, KeystoreConfig, NodeConfig from meshbay_node.daemon import NodeDaemon from meshbay_node.indexer import DirectoryIndexer +from conftest import one_root + + def _mock_keystore_keys(sk_ed): """Create a mock keystore with real Ed25519 + X25519 key material.""" sk_x = X25519PrivateKey.generate() @@ -125,7 +126,7 @@ async def test_daemon_creates_chat_store(tmp_path, node_config, gek, hub_pk_pem) patch("signal.SIGTERM", 15): try: await asyncio.wait_for(daemon.run(), timeout=5) - except (asyncio.TimeoutError, Exception): + except (TimeoutError, Exception): pass task = asyncio.create_task(run_daemon()) @@ -204,7 +205,7 @@ async def test_daemon_no_groups_stays_up(tmp_path, hub_pk_pem): patch("signal.SIGTERM", 15): try: await asyncio.wait_for(daemon.run(), timeout=5) - except (asyncio.TimeoutError, Exception): + except (TimeoutError, Exception): pass task = asyncio.create_task(run_daemon()) diff --git a/packages/meshbay-node/tests/test_device_linking.py b/packages/meshbay-node/tests/test_device_linking.py index 6d50580..53387ca 100644 --- a/packages/meshbay-node/tests/test_device_linking.py +++ b/packages/meshbay-node/tests/test_device_linking.py @@ -25,8 +25,6 @@ from pathlib import Path import pytest from cryptography.hazmat.primitives.asymmetric.ed25519 import Ed25519PrivateKey - -from conftest import one_root from meshbay_common.crypto import pk_to_b64 from meshbay_common.device import ( device_add_transcript, @@ -39,6 +37,8 @@ from meshbay_node.indexer.group_index import GroupIndex from meshbay_node.roster import generate_code, normalize_code, open_roster from meshbay_node.transport.webrtc_server import WebRTCPeerSession +from conftest import one_root + GROUP = "g" * 32 NONCE = b"\x11" * 32 diff --git a/packages/meshbay-node/tests/test_enrich.py b/packages/meshbay-node/tests/test_enrich.py index e059bbe..ca03392 100644 --- a/packages/meshbay-node/tests/test_enrich.py +++ b/packages/meshbay-node/tests/test_enrich.py @@ -3,15 +3,15 @@ import asyncio import shutil import subprocess -from pathlib import Path - import sys +from pathlib import Path import pytest - from meshbay_common.protocol import IndexEntry from meshbay_node.indexer.enrich import ( - Enricher, _season_and_show_from_ancestors, _synthetic_episode_number, + Enricher, + _season_and_show_from_ancestors, + _synthetic_episode_number, _title_from_siblings, ) from meshbay_node.media_cache import MediaCache diff --git a/packages/meshbay-node/tests/test_enrich_photo.py b/packages/meshbay-node/tests/test_enrich_photo.py index 81367eb..d1bbd28 100644 --- a/packages/meshbay-node/tests/test_enrich_photo.py +++ b/packages/meshbay-node/tests/test_enrich_photo.py @@ -6,11 +6,10 @@ from pathlib import Path import piexif import pytest -from PIL import Image - from meshbay_common.protocol import IndexEntry from meshbay_node.indexer.enrich_photo import PhotoEnricher from meshbay_node.media_cache import MediaCache +from PIL import Image @pytest.fixture @@ -167,7 +166,8 @@ async def test_enricher_corrects_orientation(tmp_path, media_cache): "width/height must reflect the EXIF-corrected orientation, not the raw stored frame") thumb_bytes = await media_cache.get_thumb(fields["thumb_hash"]) thumb = Image.open(io.BytesIO(thumb_bytes)) - assert thumb.size[0] < thumb.size[1], "the stored thumbnail itself must be portrait, not sideways" + assert thumb.size[0] < thumb.size[1], ( + "the stored thumbnail itself must be portrait, not sideways") def test_gps_is_never_read_by_this_module(): diff --git a/packages/meshbay-node/tests/test_group_roster.py b/packages/meshbay-node/tests/test_group_roster.py index a41cce2..74908e7 100644 --- a/packages/meshbay-node/tests/test_group_roster.py +++ b/packages/meshbay-node/tests/test_group_roster.py @@ -23,8 +23,6 @@ import time import pytest from cryptography.hazmat.primitives.asymmetric.ed25519 import Ed25519PrivateKey - -from conftest import one_root from meshbay_common.crypto import generate_gek, pk_to_b64 from meshbay_common.device import device_add_transcript from meshbay_common.groupbox import PURPOSE_ROSTER, unseal @@ -34,6 +32,8 @@ from meshbay_node.indexer.group_index import GroupIndex from meshbay_node.roster import open_roster from meshbay_node.transport.webrtc_server import WebRTCPeerSession +from conftest import one_root + GROUP = "g" * 32 NONCE = b"\x11" * 32 diff --git a/packages/meshbay-node/tests/test_hot_reload_survives_client_close.py b/packages/meshbay-node/tests/test_hot_reload_survives_client_close.py index fc6af70..fb9eade 100644 --- a/packages/meshbay-node/tests/test_hot_reload_survives_client_close.py +++ b/packages/meshbay-node/tests/test_hot_reload_survives_client_close.py @@ -18,17 +18,15 @@ import asyncio import base64 import os from pathlib import Path +from unittest.mock import AsyncMock, MagicMock, patch +import meshbay_node.indexer.indexer as indexer_mod import pytest from cryptography.hazmat.primitives import serialization from cryptography.hazmat.primitives.asymmetric.ed25519 import Ed25519PrivateKey from cryptography.hazmat.primitives.asymmetric.x25519 import X25519PrivateKey -from unittest.mock import AsyncMock, MagicMock, patch - from meshbay_node import ops -from meshbay_node.config import Config, HubConfig, NodeConfig, GroupConfig, KeystoreConfig from meshbay_node.daemon import NodeDaemon -import meshbay_node.indexer.indexer as indexer_mod def _free_port() -> int: @@ -149,7 +147,7 @@ async def test_hot_loaded_group_finishes_scanning_without_anyone_awaiting_the_re with patch("signal.SIGINT", 2), patch("signal.SIGTERM", 15): try: await asyncio.wait_for(daemon.run(), timeout=15) - except (asyncio.TimeoutError, Exception): + except (TimeoutError, Exception): pass run_task = asyncio.create_task(run_daemon()) @@ -270,7 +268,7 @@ async def test_group_scoped_ops_404_until_listed_then_succeed(tmp_path): with patch("signal.SIGINT", 2), patch("signal.SIGTERM", 15): try: await asyncio.wait_for(daemon.run(), timeout=15) - except (asyncio.TimeoutError, Exception): + except (TimeoutError, Exception): pass run_task = asyncio.create_task(run_daemon()) diff --git a/packages/meshbay-node/tests/test_hub_client.py b/packages/meshbay-node/tests/test_hub_client.py index 2975ee8..e733610 100644 --- a/packages/meshbay-node/tests/test_hub_client.py +++ b/packages/meshbay-node/tests/test_hub_client.py @@ -2,24 +2,17 @@ Tests for meshbay_node.hub_client — uses httpx.MockTransport to avoid network. """ -import json -import os import time -import pytest -from pathlib import Path -from unittest.mock import AsyncMock, MagicMock, patch import httpx import jwt +import pytest +from cryptography.hazmat.primitives import serialization from cryptography.hazmat.primitives.asymmetric.ed25519 import Ed25519PrivateKey from cryptography.hazmat.primitives.asymmetric.x25519 import X25519PrivateKey -from cryptography.hazmat.primitives import serialization - - -from meshbay_node.hub_client import HubClient, HubConfig, HubSession +from meshbay_node.hub_client import HubClient, HubConfig from meshbay_node.keystore import NodeKeys - # ── Test fixtures ────────────────────────────────────────────────────────────── @pytest.fixture diff --git a/packages/meshbay-node/tests/test_hub_ws_group_claim.py b/packages/meshbay-node/tests/test_hub_ws_group_claim.py index 49ac776..98b944b 100644 --- a/packages/meshbay-node/tests/test_hub_ws_group_claim.py +++ b/packages/meshbay-node/tests/test_hub_ws_group_claim.py @@ -15,7 +15,6 @@ import asyncio import json import pytest - from meshbay_node.hub_client import HubClient, HubConfig, HubSession diff --git a/packages/meshbay-node/tests/test_ice_filter.py b/packages/meshbay-node/tests/test_ice_filter.py index a995c2b..0fec2d2 100644 --- a/packages/meshbay-node/tests/test_ice_filter.py +++ b/packages/meshbay-node/tests/test_ice_filter.py @@ -3,8 +3,8 @@ transport/ice_filter — the interface filter must name the same adapter on every platform, and must never leave the gather with no address at all. """ -import ifaddr import aioice.ice +import ifaddr import pytest from meshbay_node.transport import ice_filter diff --git a/packages/meshbay-node/tests/test_index_cache.py b/packages/meshbay-node/tests/test_index_cache.py index 036b4d7..8f0ff25 100644 --- a/packages/meshbay-node/tests/test_index_cache.py +++ b/packages/meshbay-node/tests/test_index_cache.py @@ -1,7 +1,6 @@ """Tests for the (path, size, mtime) -> hash cache (indexer/cache.py).""" import pytest - from meshbay_node.indexer.cache import IndexCache diff --git a/packages/meshbay-node/tests/test_index_delta_carries_roots.py b/packages/meshbay-node/tests/test_index_delta_carries_roots.py index 227f2d0..c939b4a 100644 --- a/packages/meshbay-node/tests/test_index_delta_carries_roots.py +++ b/packages/meshbay-node/tests/test_index_delta_carries_roots.py @@ -19,14 +19,12 @@ Additive on the wire (MNP 1.1): a 1.0 client sees a field it does not read. from pathlib import Path from cryptography.hazmat.primitives.asymmetric.ed25519 import Ed25519PrivateKey - from meshbay_common.crypto import generate_gek from meshbay_common.groupbox import PURPOSE_INDEX, unseal from meshbay_node.indexer.group_index import GroupIndex from meshbay_node.roots import RootSet from meshbay_node.transport.wire import index_delta_message, index_sync_message - GROUP = "g" * 32 diff --git a/packages/meshbay-node/tests/test_index_no_cleartext.py b/packages/meshbay-node/tests/test_index_no_cleartext.py index e5e4555..30d1226 100644 --- a/packages/meshbay-node/tests/test_index_no_cleartext.py +++ b/packages/meshbay-node/tests/test_index_no_cleartext.py @@ -14,7 +14,6 @@ framing or in a field name. import msgpack import pytest -from conftest import one_root from cryptography.hazmat.primitives.asymmetric.ed25519 import Ed25519PrivateKey from meshbay_common.crypto import generate_gek from meshbay_common.groupbox import PURPOSE_ACK, PURPOSE_INDEX, seal, unseal @@ -22,6 +21,8 @@ from meshbay_common.protocol import MNP from meshbay_node.indexer import DirectoryIndexer, GroupIndex from meshbay_node.transport.wire import index_delta_message, index_sync_message +from conftest import one_root + # A filename and a folder name that appear nowhere else in the tree. SECRET_FILE = "quixotry-ledger-2019.pdf" SECRET_DIR = "zarfwidget-archive" diff --git a/packages/meshbay-node/tests/test_index_progress.py b/packages/meshbay-node/tests/test_index_progress.py index df51e85..ecdc223 100644 --- a/packages/meshbay-node/tests/test_index_progress.py +++ b/packages/meshbay-node/tests/test_index_progress.py @@ -6,16 +6,15 @@ itself (see test_daemon.py for that) and never anything sent to the hub. """ import asyncio +from unittest.mock import MagicMock import pytest from cryptography.hazmat.primitives.asymmetric.ed25519 import Ed25519PrivateKey -from unittest.mock import MagicMock from fastapi.testclient import TestClient - -from meshbay_node.config import Config, HubConfig, NodeConfig, GroupConfig, KeystoreConfig +from meshbay_node.config import Config, HubConfig, KeystoreConfig, NodeConfig from meshbay_node.daemon import NodeDaemon -from meshbay_node.indexer.indexer import IndexProgress from meshbay_node.indexer.group_index import GroupIndex +from meshbay_node.indexer.indexer import IndexProgress from meshbay_node.transport.webrtc_server import WebRTCPeerSession from meshbay_node.ui.app import create_ui_app diff --git a/packages/meshbay-node/tests/test_indexer.py b/packages/meshbay-node/tests/test_indexer.py index 6aee1b5..e97e2ef 100644 --- a/packages/meshbay-node/tests/test_indexer.py +++ b/packages/meshbay-node/tests/test_indexer.py @@ -4,16 +4,15 @@ import asyncio import os import threading import time -import pytest from pathlib import Path -from cryptography.hazmat.primitives.asymmetric.ed25519 import Ed25519PrivateKey -from cryptography.hazmat.primitives.asymmetric.x25519 import X25519PrivateKey +import meshbay_node.indexer.indexer as indexer_mod +import pytest +from cryptography.hazmat.primitives.asymmetric.ed25519 import Ed25519PrivateKey from meshbay_common.crypto import generate_gek from meshbay_node.indexer import DirectoryIndexer, GroupIndex, IndexCache -import meshbay_node.indexer.indexer as indexer_mod + from conftest import one_root -from meshbay_node.keystore import NodeKeys @pytest.fixture @@ -397,7 +396,8 @@ async def test_scan_interrupted_partway_leaves_only_completed_files_cached( indexer_mod._scan_file = real_scan_file assert resumed.index.count == 5 - assert len(calls) == 2, f"expected only the 2 not-yet-cached files to be hashed, got {len(calls)}" + assert len(calls) == 2, ( + f"expected only the 2 not-yet-cached files to be hashed, got {len(calls)}") # ── Progress state ─────────────────────────────────────────────────────────── @@ -741,7 +741,7 @@ def test_small_file_gets_hash_version_1(tmp_path): def test_large_file_gets_hash_version_2(tmp_path): - from meshbay_node.indexer.indexer import _scan_file, _PARTIAL_THRESHOLD + from meshbay_node.indexer.indexer import _PARTIAL_THRESHOLD, _scan_file d = tmp_path / "root" d.mkdir() f = d / "big.mkv" @@ -755,7 +755,7 @@ def test_large_file_gets_hash_version_2(tmp_path): def test_file_at_threshold_gets_hash_version_1(tmp_path): - from meshbay_node.indexer.indexer import _scan_file, _PARTIAL_THRESHOLD + from meshbay_node.indexer.indexer import _PARTIAL_THRESHOLD, _scan_file d = tmp_path / "root" d.mkdir() f = d / "exact.mkv" @@ -770,7 +770,7 @@ def test_partial_hash_differs_from_full_hash(tmp_path): """For a file above the threshold, the partial hash must differ from what a full-file blake3 would produce (they read different bytes).""" import blake3 as b3 - from meshbay_node.indexer.indexer import _scan_file, _PARTIAL_THRESHOLD + from meshbay_node.indexer.indexer import _PARTIAL_THRESHOLD, _scan_file d = tmp_path / "root" d.mkdir() f = d / "big.mkv" @@ -785,7 +785,7 @@ def test_partial_hash_differs_from_full_hash(tmp_path): def test_partial_hash_is_deterministic(tmp_path): - from meshbay_node.indexer.indexer import _scan_file, _PARTIAL_THRESHOLD + from meshbay_node.indexer.indexer import _PARTIAL_THRESHOLD, _scan_file d = tmp_path / "root" d.mkdir() f = d / "big.mkv" diff --git a/packages/meshbay-node/tests/test_keystore.py b/packages/meshbay-node/tests/test_keystore.py index 7dfefce..b9dd3a4 100644 --- a/packages/meshbay-node/tests/test_keystore.py +++ b/packages/meshbay-node/tests/test_keystore.py @@ -3,15 +3,13 @@ import sys import pytest -from pathlib import Path +from meshbay_common.crypto import generate_gek from meshbay_node.keystore import ( - NodeKeys, create_keystore, load_keystore, - save_keystore, load_or_create_keystore, + save_keystore, ) -from meshbay_common.crypto import generate_gek def test_create_and_load(tmp_path): diff --git a/packages/meshbay-node/tests/test_leaseless_reads.py b/packages/meshbay-node/tests/test_leaseless_reads.py index 6bd7f1f..2c4c6cd 100644 --- a/packages/meshbay-node/tests/test_leaseless_reads.py +++ b/packages/meshbay-node/tests/test_leaseless_reads.py @@ -23,9 +23,10 @@ import re from pathlib import Path import pytest - from meshbay_node.transfers import ( - LEASELESS_IDLE_SECS, MAX_LEASELESS_IN_FLIGHT, LeaselessReads, + LEASELESS_IDLE_SECS, + MAX_LEASELESS_IN_FLIGHT, + LeaselessReads, ) SPA = (Path(__file__).resolve().parents[2] / "meshbay-hub" / "src" diff --git a/packages/meshbay-node/tests/test_media_cache.py b/packages/meshbay-node/tests/test_media_cache.py index dc78d8d..ec4e56e 100644 --- a/packages/meshbay-node/tests/test_media_cache.py +++ b/packages/meshbay-node/tests/test_media_cache.py @@ -3,8 +3,7 @@ import time import pytest - -from meshbay_node.media_cache import MediaCache, TMDB_META_TTL_SECS, MUSICBRAINZ_META_TTL_SECS +from meshbay_node.media_cache import MUSICBRAINZ_META_TTL_SECS, TMDB_META_TTL_SECS, MediaCache @pytest.fixture diff --git a/packages/meshbay-node/tests/test_media_cache_eviction.py b/packages/meshbay-node/tests/test_media_cache_eviction.py index 587063a..f0292b5 100644 --- a/packages/meshbay-node/tests/test_media_cache_eviction.py +++ b/packages/meshbay-node/tests/test_media_cache_eviction.py @@ -18,7 +18,6 @@ about `create_all()`. Every existing node has a `thumbs` table without it. import sqlite3 import pytest - from meshbay_node.media_cache import MediaCache diff --git a/packages/meshbay-node/tests/test_multi_group.py b/packages/meshbay-node/tests/test_multi_group.py index 3dc4778..b75bad0 100644 --- a/packages/meshbay-node/tests/test_multi_group.py +++ b/packages/meshbay-node/tests/test_multi_group.py @@ -7,19 +7,18 @@ Verifies that: - A user in both groups can access both """ -import os import time + import jwt import pytest -from pathlib import Path -from cryptography.hazmat.primitives.asymmetric.ed25519 import Ed25519PrivateKey from cryptography.hazmat.primitives import serialization - +from cryptography.hazmat.primitives.asymmetric.ed25519 import Ed25519PrivateKey from meshbay_common.crypto import generate_gek, pk_to_b64 from meshbay_node.indexer import DirectoryIndexer -from conftest import one_root -from meshbay_node.transport.quic_server import QuicChunkServer from meshbay_node.transport.quic_client import QuicChunkClient +from meshbay_node.transport.quic_server import QuicChunkServer + +from conftest import one_root @pytest.fixture @@ -73,10 +72,12 @@ async def multi_group_server(sk_node, sk_hub, gek_a, gek_b, dir_a, dir_b, tmp_pa hub_pk_pem = sk_hub.public_key().public_bytes( serialization.Encoding.PEM, serialization.PublicFormat.SubjectPublicKeyInfo) - indexer_a = DirectoryIndexer(roots=one_root(dir_a), group_id="group-a", sk_node=sk_node, gek=gek_a) + indexer_a = DirectoryIndexer(roots=one_root(dir_a), group_id="group-a", + sk_node=sk_node, gek=gek_a) await indexer_a.initial_scan() - indexer_b = DirectoryIndexer(roots=one_root(dir_b), group_id="group-b", sk_node=sk_node, gek=gek_b) + indexer_b = DirectoryIndexer(roots=one_root(dir_b), group_id="group-b", + sk_node=sk_node, gek=gek_b) await indexer_b.initial_scan() # RootSet, not a bare Path — what the daemon actually puts in a group context. diff --git a/packages/meshbay-node/tests/test_musicbrainz_enabled_policy.py b/packages/meshbay-node/tests/test_musicbrainz_enabled_policy.py index 76b687e..00c1b69 100644 --- a/packages/meshbay-node/tests/test_musicbrainz_enabled_policy.py +++ b/packages/meshbay-node/tests/test_musicbrainz_enabled_policy.py @@ -13,12 +13,11 @@ The contact string stays node-wide — see test_musicbrainz_config_policy.py. from pathlib import Path import pytest - +from cryptography.hazmat.primitives.asymmetric.ed25519 import Ed25519PrivateKey from meshbay_common.adminop import OP_MUSICBRAINZ_ENABLED from meshbay_node.indexer.group_index import GroupIndex from meshbay_node.roster import Roster from meshbay_node.transport.webrtc_server import WebRTCPeerSession -from cryptography.hazmat.primitives.asymmetric.ed25519 import Ed25519PrivateKey from conftest import one_root diff --git a/packages/meshbay-node/tests/test_node_status.py b/packages/meshbay-node/tests/test_node_status.py index 897be33..8bb2f39 100644 --- a/packages/meshbay-node/tests/test_node_status.py +++ b/packages/meshbay-node/tests/test_node_status.py @@ -12,22 +12,22 @@ from pathlib import Path import pytest from cryptography.hazmat.primitives.asymmetric.ed25519 import Ed25519PrivateKey - -from conftest import one_root from meshbay_common.adminop import ( - OP_ROOT_ADD, OP_ROOT_REMOVE, OP_GROUP_ATTACH, OP_MEMBER_UNPIN, + OP_MEMBER_UNPIN, admin_transcript, ) -from meshbay_node.transport.quic_server import Denylist from meshbay_common.crypto import pk_to_b64 from meshbay_common.join import ROLE_OPERATOR from meshbay_common.protocol import MNP from meshbay_node import ops from meshbay_node.indexer.group_index import GroupIndex -from meshbay_node.roster import open_roster from meshbay_node.roots import RootSet +from meshbay_node.roster import open_roster +from meshbay_node.transport.quic_server import Denylist from meshbay_node.transport.webrtc_server import WebRTCPeerSession +from conftest import one_root + GROUP = "g" * 32 @@ -207,7 +207,6 @@ async def test_node_status_catches_send_failure(tmp_path, roster): not silently vanish — it used to, because _send was outside the try block.""" session = await _session(tmp_path, roster, operator=True, node_user_id="grenet") - original_send = session._send sent = [] call_count = [0] @@ -260,7 +259,7 @@ async def test_add_root_creates_directory_and_returns_info(tmp_path): shared.mkdir() new_dir = tmp_path / "new_root" - from meshbay_node.config import NodeConfig, GroupConfig, RootSpec + from meshbay_node.config import GroupConfig, NodeConfig, RootSpec cfg = GroupConfig(id=GROUP, name="test", roots=[ RootSpec(path=str(shared), name="shared", kind="generic", writable=True), ]) @@ -300,7 +299,7 @@ async def test_remove_root_requires_at_least_one_remaining(tmp_path): shared = tmp_path / "shared" shared.mkdir() - from meshbay_node.config import GroupConfig, RootSpec, NodeConfig + from meshbay_node.config import GroupConfig, NodeConfig, RootSpec cfg = GroupConfig(id=GROUP, name="test", roots=[ RootSpec(path=str(shared), name="shared", kind="generic", writable=True), ]) @@ -333,7 +332,7 @@ async def test_removing_a_writable_root_is_allowed(tmp_path): d1.mkdir() d2.mkdir() - from meshbay_node.config import GroupConfig, RootSpec, NodeConfig + from meshbay_node.config import GroupConfig, NodeConfig, RootSpec cfg = GroupConfig(id=GROUP, name="test", roots=[ RootSpec(path=str(d1), name="incoming", kind="generic", writable=True), RootSpec(path=str(d2), name="shared", kind="generic", writable=False), @@ -369,7 +368,7 @@ async def test_update_root_rewrites_the_flags_in_node_toml(tmp_path): d1 = tmp_path / "media" d1.mkdir() - from meshbay_node.config import GroupConfig, RootSpec, NodeConfig + from meshbay_node.config import GroupConfig, NodeConfig, RootSpec cfg = GroupConfig(id=GROUP, name="test", roots=[ RootSpec(path=str(d1), name="media", kind="generic", writable=False), ]) @@ -420,7 +419,7 @@ async def test_update_root_replaces_a_legacy_upload_line(tmp_path): d1 = tmp_path / "media" d1.mkdir() - from meshbay_node.config import GroupConfig, RootSpec, NodeConfig + from meshbay_node.config import GroupConfig, NodeConfig, RootSpec cfg = GroupConfig(id=GROUP, name="test", roots=[ RootSpec(path=str(d1), name="media", kind="generic", writable=True), ]) @@ -452,7 +451,7 @@ async def test_remove_root_succeeds_with_two_roots(tmp_path): d1.mkdir() d2.mkdir() - from meshbay_node.config import GroupConfig, RootSpec, NodeConfig + from meshbay_node.config import GroupConfig, NodeConfig, RootSpec cfg = GroupConfig(id=GROUP, name="test", roots=[ RootSpec(path=str(d1), name="dir1", kind="generic", writable=True), RootSpec(path=str(d2), name="dir2", kind="generic", writable=False), diff --git a/packages/meshbay-node/tests/test_packaging_win.py b/packages/meshbay-node/tests/test_packaging_win.py index 7b44bbe..aa77c29 100644 --- a/packages/meshbay-node/tests/test_packaging_win.py +++ b/packages/meshbay-node/tests/test_packaging_win.py @@ -1230,13 +1230,14 @@ def test_service_mode_ps1_starts_the_task_after_installing_it(): already-running task pointlessly on every mode switch away from service. """ src = (WIN / "service-mode.ps1").read_text(encoding="utf-8") - install_branch, remove_branch = src.split('$Action -eq "install"', 1)[1], None + install_branch = src.split('$Action -eq "install"', 1)[1] assert '"run"' in install_branch or "'run'" in install_branch, ( "service-mode.ps1 registers the task but never starts it -- the " "daemon stays down until the next reboot") # The run step must be conditioned on install having actually succeeded, # not fired unconditionally regardless of $Action. - guard_line = src[src.index('$Action -eq "install"') - 40:src.index('$Action -eq "install"') + 40] + at = src.index('$Action -eq "install"') + guard_line = src[at - 40:at + 40] assert "-and" in guard_line or "-not $failed" in install_branch, ( "the follow-up `run` must be gated on Action=install and success, " "not run unconditionally on every invocation including remove") diff --git a/packages/meshbay-node/tests/test_partial_uploads.py b/packages/meshbay-node/tests/test_partial_uploads.py index 0270a69..80ab454 100644 --- a/packages/meshbay-node/tests/test_partial_uploads.py +++ b/packages/meshbay-node/tests/test_partial_uploads.py @@ -23,21 +23,23 @@ from pathlib import Path from cryptography.hazmat.primitives.asymmetric.ed25519 import Ed25519PrivateKey from meshbay_common.crypto import generate_gek +from meshbay_common.protocol import ( + UPLOAD_PROBE_INDEX, + file_upload_ack_payload, +) from meshbay_node.daemon import NodeDaemon from meshbay_node.indexer.group_index import GroupIndex from meshbay_node.roots import Root, RootSet from meshbay_node.transport.webrtc_server import WebRTCPeerSession - -from meshbay_common.protocol import ( - UPLOAD_PROBE_INDEX, file_upload_ack_payload, -) - -from conftest import one_root, sealed_upload - from meshbay_node.uploads import ( - ORPHAN_AFTER_SECS, PART_SUFFIX, PartialUploads, find_parts, orphaned_parts, + ORPHAN_AFTER_SECS, + PART_SUFFIX, + PartialUploads, + find_parts, + orphaned_parts, ) +from conftest import one_root, sealed_upload # ── the state ─────────────────────────────────────────────────────────────── @@ -466,7 +468,7 @@ async def test_an_upload_chunk_says_its_slot_is_in_use(tmp_path): The download twin of this was fixed a day earlier; the same omission was still here, invisible until uploads took a real lease. """ - from meshbay_node.transfers import TransferSlots, UPLOAD + from meshbay_node.transfers import UPLOAD, TransferSlots ctx = _group_ctx(tmp_path) peer = _peer(ctx) diff --git a/packages/meshbay-node/tests/test_peer_session_limits.py b/packages/meshbay-node/tests/test_peer_session_limits.py index 64961ad..d5c909b 100644 --- a/packages/meshbay-node/tests/test_peer_session_limits.py +++ b/packages/meshbay-node/tests/test_peer_session_limits.py @@ -15,10 +15,12 @@ import asyncio from unittest.mock import MagicMock import pytest - from meshbay_node.transport import webrtc_server as ws_mod from meshbay_node.transport.webrtc_server import ( - MAX_PEER_SESSIONS, UNAUTHENTICATED_SESSION_TIMEOUT, WebRTCTransport) + MAX_PEER_SESSIONS, + UNAUTHENTICATED_SESSION_TIMEOUT, + WebRTCTransport, +) def _transport() -> WebRTCTransport: diff --git a/packages/meshbay-node/tests/test_platform.py b/packages/meshbay-node/tests/test_platform.py index 3fb27f3..5c80c5b 100644 --- a/packages/meshbay-node/tests/test_platform.py +++ b/packages/meshbay-node/tests/test_platform.py @@ -5,8 +5,8 @@ here by monkeypatching that (and `os.environ`) rather than only on the OS the suite happens to run on. """ -import os import asyncio +import os import sys from pathlib import Path from unittest.mock import Mock diff --git a/packages/meshbay-node/tests/test_poster_cache.py b/packages/meshbay-node/tests/test_poster_cache.py index bbd824d..908fb69 100644 --- a/packages/meshbay-node/tests/test_poster_cache.py +++ b/packages/meshbay-node/tests/test_poster_cache.py @@ -15,7 +15,6 @@ already uses to resolve a thumbnail by id. """ import pytest - from meshbay_node.media_cache import MediaCache from meshbay_node.transport.webrtc_server import WebRTCPeerSession diff --git a/packages/meshbay-node/tests/test_quic_transport.py b/packages/meshbay-node/tests/test_quic_transport.py index fb28295..8eb0622 100644 --- a/packages/meshbay-node/tests/test_quic_transport.py +++ b/packages/meshbay-node/tests/test_quic_transport.py @@ -6,17 +6,17 @@ Same structure as test_transport.py but uses QUIC instead of TCP+TLS. import asyncio import os import time + import jwt import pytest -from pathlib import Path -from cryptography.hazmat.primitives.asymmetric.ed25519 import Ed25519PrivateKey from cryptography.hazmat.primitives import serialization - +from cryptography.hazmat.primitives.asymmetric.ed25519 import Ed25519PrivateKey from meshbay_common.crypto import generate_gek, pk_to_b64 from meshbay_node.indexer import DirectoryIndexer -from conftest import one_root -from meshbay_node.transport.quic_server import QuicChunkServer, Denylist from meshbay_node.transport.quic_client import QuicChunkClient +from meshbay_node.transport.quic_server import Denylist, QuicChunkServer + +from conftest import one_root @pytest.fixture diff --git a/packages/meshbay-node/tests/test_rename_reenrichment.py b/packages/meshbay-node/tests/test_rename_reenrichment.py index f6761d9..7ddca6f 100644 --- a/packages/meshbay-node/tests/test_rename_reenrichment.py +++ b/packages/meshbay-node/tests/test_rename_reenrichment.py @@ -17,9 +17,8 @@ import asyncio import pytest from cryptography.hazmat.primitives.asymmetric.ed25519 import Ed25519PrivateKey - from meshbay_common.crypto import generate_gek -from meshbay_node.config import Config, HubConfig, NodeConfig, GroupConfig, KeystoreConfig +from meshbay_node.config import Config, GroupConfig, HubConfig, KeystoreConfig, NodeConfig from meshbay_node.daemon import NodeDaemon from meshbay_node.indexer import DirectoryIndexer from meshbay_node.media_cache import MediaCache diff --git a/packages/meshbay-node/tests/test_replug_restores_enrichment.py b/packages/meshbay-node/tests/test_replug_restores_enrichment.py index 04a06ae..a2d2db4 100644 --- a/packages/meshbay-node/tests/test_replug_restores_enrichment.py +++ b/packages/meshbay-node/tests/test_replug_restores_enrichment.py @@ -46,10 +46,8 @@ import os import pytest from cryptography.hazmat.primitives.asymmetric.ed25519 import Ed25519PrivateKey - from meshbay_common.crypto import generate_gek -from meshbay_node.config import (Config, GroupConfig, HubConfig, KeystoreConfig, - NodeConfig) +from meshbay_node.config import Config, GroupConfig, HubConfig, KeystoreConfig, NodeConfig from meshbay_node.daemon import NodeDaemon from meshbay_node.indexer import DirectoryIndexer from meshbay_node.indexer.enrich_audio import AudioEnricher diff --git a/packages/meshbay-node/tests/test_root_availability.py b/packages/meshbay-node/tests/test_root_availability.py index 2d848c7..82bf6bd 100644 --- a/packages/meshbay-node/tests/test_root_availability.py +++ b/packages/meshbay-node/tests/test_root_availability.py @@ -13,13 +13,11 @@ an indexer that treats a vanished root as a set of deletions, which is what the straightforward implementation does. """ -import asyncio import os from pathlib import Path import pytest from cryptography.hazmat.primitives.asymmetric.ed25519 import Ed25519PrivateKey - from meshbay_node.indexer.indexer import DirectoryIndexer from meshbay_node.roots import RootSet diff --git a/packages/meshbay-node/tests/test_root_eject.py b/packages/meshbay-node/tests/test_root_eject.py index f57fb92..d73e71c 100644 --- a/packages/meshbay-node/tests/test_root_eject.py +++ b/packages/meshbay-node/tests/test_root_eject.py @@ -21,7 +21,6 @@ from pathlib import Path import pytest from cryptography.hazmat.primitives.asymmetric.ed25519 import Ed25519PrivateKey - from meshbay_node.indexer.indexer import DirectoryIndexer from meshbay_node.roots import RootSet from meshbay_node.roster import Roster diff --git a/packages/meshbay-node/tests/test_root_ops_reach_the_live_set.py b/packages/meshbay-node/tests/test_root_ops_reach_the_live_set.py index 976af82..6a52c06 100644 --- a/packages/meshbay-node/tests/test_root_ops_reach_the_live_set.py +++ b/packages/meshbay-node/tests/test_root_ops_reach_the_live_set.py @@ -28,7 +28,6 @@ from types import SimpleNamespace import pytest from cryptography.hazmat.primitives.asymmetric.ed25519 import Ed25519PrivateKey - from meshbay_node import ops from meshbay_node.config import GroupConfig, NodeConfig, RootSpec from meshbay_node.indexer.group_index import GroupIndex diff --git a/packages/meshbay-node/tests/test_root_paths_are_operator_only.py b/packages/meshbay-node/tests/test_root_paths_are_operator_only.py index 080d4be..0e89afa 100644 --- a/packages/meshbay-node/tests/test_root_paths_are_operator_only.py +++ b/packages/meshbay-node/tests/test_root_paths_are_operator_only.py @@ -21,7 +21,6 @@ import inspect import re from pathlib import Path - from meshbay_node import daemon as daemon_mod from meshbay_node import ops from meshbay_node.roots import RootSet diff --git a/packages/meshbay-node/tests/test_root_writable_policy.py b/packages/meshbay-node/tests/test_root_writable_policy.py index 3c8a837..0cd9af8 100644 --- a/packages/meshbay-node/tests/test_root_writable_policy.py +++ b/packages/meshbay-node/tests/test_root_writable_policy.py @@ -26,15 +26,15 @@ from pathlib import Path import pytest from cryptography.hazmat.primitives.asymmetric.ed25519 import Ed25519PrivateKey - -from conftest import sealed_upload -from meshbay_common.adminop import OP_ROOT_UPDATE, OP_ROOT_EJECT, OP_ROOT_PLUG +from meshbay_common.adminop import OP_ROOT_EJECT, OP_ROOT_PLUG, OP_ROOT_UPDATE from meshbay_common.crypto import generate_gek from meshbay_common.protocol import MNP from meshbay_node.indexer.group_index import GroupIndex from meshbay_node.roots import RootSet from meshbay_node.transport.webrtc_server import WebRTCPeerSession +from conftest import sealed_upload + pytestmark = pytest.mark.asyncio diff --git a/packages/meshbay-node/tests/test_roots.py b/packages/meshbay-node/tests/test_roots.py index 9233180..004f004 100644 --- a/packages/meshbay-node/tests/test_roots.py +++ b/packages/meshbay-node/tests/test_roots.py @@ -7,15 +7,17 @@ file went to the wrong disk" or "the same film is listed twice and deleting one copy breaks the other". """ -from pathlib import Path import pytest - +from meshbay_common.protocol import IndexEntry from meshbay_node.roots import ( - Root, RootError, RootSet, entry_abs_path, - SAFE_UPLOAD_NAME, safe_subdir, _free_name, + SAFE_UPLOAD_NAME, + RootError, + RootSet, + _free_name, + entry_abs_path, + safe_subdir, ) -from meshbay_common.protocol import IndexEntry def _spec(path, **kw): diff --git a/packages/meshbay-node/tests/test_roster_pairing.py b/packages/meshbay-node/tests/test_roster_pairing.py index 2e8c183..82336e2 100644 --- a/packages/meshbay-node/tests/test_roster_pairing.py +++ b/packages/meshbay-node/tests/test_roster_pairing.py @@ -18,14 +18,13 @@ import pytest from cryptography.hazmat.primitives import serialization from cryptography.hazmat.primitives.asymmetric.ed25519 import Ed25519PrivateKey from cryptography.hazmat.primitives.asymmetric.x25519 import X25519PrivateKey - from meshbay_common.crypto import generate_gek, pk_to_b64, unwrap_gek_aes from meshbay_common.join import ROLE_MEMBER, ROLE_OPERATOR, join_transcript from meshbay_node.indexer.group_index import GroupIndex -from conftest import one_root from meshbay_node.roster import Roster, hash_code, normalize_code from meshbay_node.transport.webrtc_server import WebRTCPeerSession +from conftest import one_root # ── Fixtures ────────────────────────────────────────────────────────────────── @@ -570,7 +569,8 @@ def test_challenge_carries_node_pk_in_source(): builds, whatever the surrounding handshake does. """ source = (Path(__file__).parent.parent - / "src" / "meshbay_node" / "transport" / "webrtc_server.py").read_text(encoding="utf-8") + / "src" / "meshbay_node" / "transport" + / "webrtc_server.py").read_text(encoding="utf-8") challenge = source[source.find("MNP.HANDSHAKE_CHALLENGE,"):] challenge = challenge[:challenge.find("})")] assert "node_pk" in challenge, ( @@ -694,7 +694,6 @@ async def test_unpinned_operator_loses_authority_immediately(tmp_path, roster): def _ui_client(tmp_path, roster, **extra): from fastapi.testclient import TestClient - from meshbay_node.config import Config from meshbay_node.ui.app import create_ui_app diff --git a/packages/meshbay-node/tests/test_scan_settings_policy.py b/packages/meshbay-node/tests/test_scan_settings_policy.py index 94f4421..926c94f 100644 --- a/packages/meshbay-node/tests/test_scan_settings_policy.py +++ b/packages/meshbay-node/tests/test_scan_settings_policy.py @@ -13,7 +13,6 @@ from pathlib import Path import pytest from cryptography.hazmat.primitives.asymmetric.ed25519 import Ed25519PrivateKey - from meshbay_common.adminop import OP_SET_SCAN_SETTINGS from meshbay_common.crypto import generate_gek from meshbay_node import ops diff --git a/packages/meshbay-node/tests/test_season_and_search_requests.py b/packages/meshbay-node/tests/test_season_and_search_requests.py index 4141d13..7e81e63 100644 --- a/packages/meshbay-node/tests/test_season_and_search_requests.py +++ b/packages/meshbay-node/tests/test_season_and_search_requests.py @@ -10,7 +10,6 @@ test_tmdb_override_policy.py. """ import pytest - from meshbay_common.protocol import MNP from meshbay_node.media_cache import MediaCache from meshbay_node.transport.webrtc_server import WebRTCPeerSession diff --git a/packages/meshbay-node/tests/test_security_regressions.py b/packages/meshbay-node/tests/test_security_regressions.py index d6ecb71..7010523 100644 --- a/packages/meshbay-node/tests/test_security_regressions.py +++ b/packages/meshbay-node/tests/test_security_regressions.py @@ -9,20 +9,18 @@ only ever exercised happy paths, never an authorization boundary. If one of these starts failing, a fix has been reverted. Do not "fix" the test. """ -import base64 import struct from pathlib import Path import pytest from cryptography.hazmat.primitives.asymmetric.ed25519 import Ed25519PrivateKey - from meshbay_common.crypto import generate_gek -from meshbay_common.protocol import IndexEntry from meshbay_node.indexer.group_index import GroupIndex from meshbay_node.roots import RootSet -from conftest import one_root, opened_ack, sealed_upload from meshbay_node.transport.webrtc_server import WebRTCPeerSession +from conftest import one_root, opened_ack, sealed_upload + def _safe_name_re(): """ @@ -64,7 +62,7 @@ def test_daemon_exposes_no_plaintext_listener(): C1: the daemon must not bind anything that serves content without a handshake. NodeConfig no longer carries an HTTP port at all. """ - from meshbay_node.config import NodeConfig, GroupConfig + from meshbay_node.config import GroupConfig, NodeConfig assert "http_port" not in NodeConfig.__dataclass_fields__ assert "http_port" not in GroupConfig.__dataclass_fields__ @@ -464,7 +462,8 @@ def test_no_member_can_hand_the_node_key_material(tmp_path): ) source = (Path(__file__).parent.parent - / "src" / "meshbay_node" / "transport" / "webrtc_server.py").read_text(encoding="utf-8") + / "src" / "meshbay_node" / "transport" + / "webrtc_server.py").read_text(encoding="utf-8") assert "_do_gek_bundle_store" not in source assert "_admin_exec_bundle_store" not in source @@ -568,6 +567,7 @@ def test_admin_signature_does_not_transfer_between_operations(tmp_path): def test_admin_challenge_expires(tmp_path): """H5: a stale challenge must not be usable.""" import time as _time + from meshbay_common.adminop import ADMIN_CHALLENGE_TTL, OP_FILE_DELETE session = _session(tmp_path, "operator") @@ -633,6 +633,7 @@ def test_keystore_records_argon2_params_for_migration(tmp_path): envelope records the parameters it was written with. """ import json + from meshbay_node.keystore import create_keystore, load_keystore path = tmp_path / "keystore.enc" @@ -648,11 +649,17 @@ def test_legacy_keystore_still_opens(tmp_path): """M2: a keystore written under the 64 MB profile must still unlock.""" import base64 as _b64 import json + import msgpack from cryptography.hazmat.primitives.asymmetric.x25519 import X25519PrivateKey from meshbay_common.crypto import ( - LEGACY_ARGON2_ITERATIONS, LEGACY_ARGON2_LANES, LEGACY_ARGON2_MEMORY_COST, - derive_keystore_key, encrypt_keystore, pk_to_b64, sk_to_b64, + LEGACY_ARGON2_ITERATIONS, + LEGACY_ARGON2_LANES, + LEGACY_ARGON2_MEMORY_COST, + derive_keystore_key, + encrypt_keystore, + pk_to_b64, + sk_to_b64, ) from meshbay_node.keystore import load_keystore @@ -717,7 +724,9 @@ def test_pre_handshake_message_budget_is_small(): unauthenticated peer could announce a huge frame and dribble bytes into it. """ from meshbay_node.transport.webrtc_server import ( - MAX_MSG, PRE_HANDSHAKE_MAX_MSG, _DataChannelBuffer, + MAX_MSG, + PRE_HANDSHAKE_MAX_MSG, + _DataChannelBuffer, ) assert PRE_HANDSHAKE_MAX_MSG <= 1024 * 1024 assert PRE_HANDSHAKE_MAX_MSG < MAX_MSG @@ -918,8 +927,8 @@ async def test_an_identified_device_that_is_not_an_operator_is_refused(tmp_path) and `operator_pks()` is rebuilt from the roster on every call so a revoked one stops working at once. """ - from meshbay_node.roster import Roster from meshbay_common.crypto import pk_to_b64 + from meshbay_node.roster import Roster roster = Roster(db_path=tmp_path / "roster.db") await roster.open() @@ -940,9 +949,9 @@ async def test_an_identified_device_that_is_not_an_operator_is_refused(tmp_path) async def test_a_paired_operator_device_is_what_opens_it(tmp_path): """The positive case, so the test above is about authority and not about everything being refused.""" - from meshbay_node.roster import Roster - from meshbay_common.join import ROLE_OPERATOR from meshbay_common.crypto import pk_to_b64 + from meshbay_common.join import ROLE_OPERATOR + from meshbay_node.roster import Roster roster = Roster(db_path=tmp_path / "roster.db") await roster.open() diff --git a/packages/meshbay-node/tests/test_startup_scan_enrichment.py b/packages/meshbay-node/tests/test_startup_scan_enrichment.py index f43c6e9..f3ad2ca 100644 --- a/packages/meshbay-node/tests/test_startup_scan_enrichment.py +++ b/packages/meshbay-node/tests/test_startup_scan_enrichment.py @@ -21,12 +21,9 @@ is exercised the same way a real operator's group would be. import asyncio import pytest -from cryptography.hazmat.primitives import serialization from cryptography.hazmat.primitives.asymmetric.ed25519 import Ed25519PrivateKey -from unittest.mock import MagicMock - from meshbay_common.crypto import generate_gek -from meshbay_node.config import Config, HubConfig, NodeConfig, GroupConfig, KeystoreConfig +from meshbay_node.config import Config, GroupConfig, HubConfig, KeystoreConfig, NodeConfig from meshbay_node.daemon import NodeDaemon from meshbay_node.indexer import DirectoryIndexer from meshbay_node.indexer.enrich import Enricher diff --git a/packages/meshbay-node/tests/test_stream_audio_track_selection.py b/packages/meshbay-node/tests/test_stream_audio_track_selection.py index 53781f9..b9e2105 100644 --- a/packages/meshbay-node/tests/test_stream_audio_track_selection.py +++ b/packages/meshbay-node/tests/test_stream_audio_track_selection.py @@ -23,7 +23,6 @@ from pathlib import Path import pytest from cryptography.hazmat.primitives.asymmetric.ed25519 import Ed25519PrivateKey - from meshbay_common.crypto import generate_gek from meshbay_common.webcrypto import chunk_key_aes, decrypt_chunk_aes from meshbay_node.indexer.group_index import GroupIndex diff --git a/packages/meshbay-node/tests/test_stream_audio_transcode.py b/packages/meshbay-node/tests/test_stream_audio_transcode.py index 92518ba..6c9bde7 100644 --- a/packages/meshbay-node/tests/test_stream_audio_transcode.py +++ b/packages/meshbay-node/tests/test_stream_audio_transcode.py @@ -22,7 +22,6 @@ from pathlib import Path import pytest from cryptography.hazmat.primitives.asymmetric.ed25519 import Ed25519PrivateKey - from meshbay_common.crypto import generate_gek from meshbay_common.webcrypto import chunk_key_aes, decrypt_chunk_aes from meshbay_node.indexer.group_index import GroupIndex @@ -44,7 +43,7 @@ def _make_clip(path: Path, *, acodec: str, channels: int = 2) -> None: subprocess.run( ["ffmpeg", "-hide_banner", "-loglevel", "error", "-y", "-f", "lavfi", "-i", "testsrc=size=320x240:rate=25:duration=1", - "-f", "lavfi", "-i", f"sine=frequency=440:duration=1:sample_rate=48000", + "-f", "lavfi", "-i", "sine=frequency=440:duration=1:sample_rate=48000", "-ac", str(channels), "-c:v", "libx264", "-preset", "ultrafast", "-c:a", acodec, str(path)], diff --git a/packages/meshbay-node/tests/test_stream_capacity.py b/packages/meshbay-node/tests/test_stream_capacity.py index a35ece8..7ce6bf6 100644 --- a/packages/meshbay-node/tests/test_stream_capacity.py +++ b/packages/meshbay-node/tests/test_stream_capacity.py @@ -17,9 +17,10 @@ find. import asyncio import pytest - from meshbay_node.transport.webrtc_server import ( - MAX_CONCURRENT_TRANSCODES, WebRTCPeerSession, WebRTCTransport, + MAX_CONCURRENT_TRANSCODES, + WebRTCPeerSession, + WebRTCTransport, ) @@ -35,11 +36,11 @@ def transport(tmp_path): """A real WebRTCTransport. Its keys and index are genuine but incidental — nothing below the capacity code reads them.""" from cryptography.hazmat.primitives.asymmetric.ed25519 import Ed25519PrivateKey - - from conftest import one_root from meshbay_common.crypto import generate_gek from meshbay_node.indexer.group_index import GroupIndex + from conftest import one_root + sk_node = Ed25519PrivateKey.generate() gek = generate_gek() shared = tmp_path / "shared" diff --git a/packages/meshbay-node/tests/test_stream_capacity_config.py b/packages/meshbay-node/tests/test_stream_capacity_config.py index 442d3ef..c788ba6 100644 --- a/packages/meshbay-node/tests/test_stream_capacity_config.py +++ b/packages/meshbay-node/tests/test_stream_capacity_config.py @@ -23,7 +23,6 @@ import textwrap from pathlib import Path import pytest - from meshbay_node.config import load_config from meshbay_node.roots import RootSet from meshbay_node.transport.webrtc_server import ( diff --git a/packages/meshbay-node/tests/test_stream_seek_audio_alignment.py b/packages/meshbay-node/tests/test_stream_seek_audio_alignment.py index c1d0c66..5d78c00 100644 --- a/packages/meshbay-node/tests/test_stream_seek_audio_alignment.py +++ b/packages/meshbay-node/tests/test_stream_seek_audio_alignment.py @@ -29,7 +29,6 @@ from pathlib import Path import pytest from cryptography.hazmat.primitives.asymmetric.ed25519 import Ed25519PrivateKey - from meshbay_common.crypto import generate_gek from meshbay_common.webcrypto import chunk_key_aes, decrypt_chunk_aes from meshbay_node.indexer.group_index import GroupIndex diff --git a/packages/meshbay-node/tests/test_stream_seek_reports_the_keyframe.py b/packages/meshbay-node/tests/test_stream_seek_reports_the_keyframe.py index 9aea2b4..c575572 100644 --- a/packages/meshbay-node/tests/test_stream_seek_reports_the_keyframe.py +++ b/packages/meshbay-node/tests/test_stream_seek_reports_the_keyframe.py @@ -35,7 +35,6 @@ from pathlib import Path import pytest from cryptography.hazmat.primitives.asymmetric.ed25519 import Ed25519PrivateKey - from meshbay_common.crypto import generate_gek from meshbay_common.webcrypto import chunk_key_aes, decrypt_chunk_aes from meshbay_node.indexer.group_index import GroupIndex diff --git a/packages/meshbay-node/tests/test_stream_subtitle_tracks.py b/packages/meshbay-node/tests/test_stream_subtitle_tracks.py index d3bcc8b..7a27a37 100644 --- a/packages/meshbay-node/tests/test_stream_subtitle_tracks.py +++ b/packages/meshbay-node/tests/test_stream_subtitle_tracks.py @@ -33,7 +33,6 @@ from pathlib import Path import pytest from cryptography.hazmat.primitives.asymmetric.ed25519 import Ed25519PrivateKey - from meshbay_common.crypto import generate_gek from meshbay_common.webcrypto import chunk_key_aes, decrypt_chunk_aes from meshbay_node.indexer.group_index import GroupIndex diff --git a/packages/meshbay-node/tests/test_stream_video_transcode.py b/packages/meshbay-node/tests/test_stream_video_transcode.py index 316fdce..b60d546 100644 --- a/packages/meshbay-node/tests/test_stream_video_transcode.py +++ b/packages/meshbay-node/tests/test_stream_video_transcode.py @@ -32,7 +32,6 @@ from pathlib import Path import pytest from cryptography.hazmat.primitives.asymmetric.ed25519 import Ed25519PrivateKey - from meshbay_common.crypto import generate_gek from meshbay_common.webcrypto import chunk_key_aes, decrypt_chunk_aes from meshbay_node import hwaccel diff --git a/packages/meshbay-node/tests/test_title_parse.py b/packages/meshbay-node/tests/test_title_parse.py index 2c4573a..95c798b 100644 --- a/packages/meshbay-node/tests/test_title_parse.py +++ b/packages/meshbay-node/tests/test_title_parse.py @@ -17,7 +17,6 @@ from meshbay_node.indexer.title_parse import ( year_in, ) - # ── §3.3 row: plain, well-formed movie filename ────────────────────────────── def test_plain_movie_filename_parses_confidently(): diff --git a/packages/meshbay-node/tests/test_tmdb.py b/packages/meshbay-node/tests/test_tmdb.py index 299ff2a..981357a 100644 --- a/packages/meshbay-node/tests/test_tmdb.py +++ b/packages/meshbay-node/tests/test_tmdb.py @@ -2,7 +2,6 @@ import httpx import pytest - from meshbay_node.tmdb import TmdbClient diff --git a/packages/meshbay-node/tests/test_tmdb_config_policy.py b/packages/meshbay-node/tests/test_tmdb_config_policy.py index cef4fda..6a51eb0 100644 --- a/packages/meshbay-node/tests/test_tmdb_config_policy.py +++ b/packages/meshbay-node/tests/test_tmdb_config_policy.py @@ -21,12 +21,11 @@ wire (see _issue_admin_challenge's docstring). from pathlib import Path import pytest - +from cryptography.hazmat.primitives.asymmetric.ed25519 import Ed25519PrivateKey from meshbay_common.adminop import OP_TMDB_CONFIG from meshbay_node.indexer.group_index import GroupIndex from meshbay_node.roster import Roster from meshbay_node.transport.webrtc_server import WebRTCPeerSession -from cryptography.hazmat.primitives.asymmetric.ed25519 import Ed25519PrivateKey from conftest import one_root diff --git a/packages/meshbay-node/tests/test_tmdb_enabled_policy.py b/packages/meshbay-node/tests/test_tmdb_enabled_policy.py index 0a748cd..10d1e2b 100644 --- a/packages/meshbay-node/tests/test_tmdb_enabled_policy.py +++ b/packages/meshbay-node/tests/test_tmdb_enabled_policy.py @@ -14,12 +14,11 @@ test_tmdb_config_policy.py for those. from pathlib import Path import pytest - +from cryptography.hazmat.primitives.asymmetric.ed25519 import Ed25519PrivateKey from meshbay_common.adminop import OP_TMDB_ENABLED from meshbay_node.indexer.group_index import GroupIndex from meshbay_node.roster import Roster from meshbay_node.transport.webrtc_server import WebRTCPeerSession -from cryptography.hazmat.primitives.asymmetric.ed25519 import Ed25519PrivateKey from conftest import one_root diff --git a/packages/meshbay-node/tests/test_tmdb_language_fallback.py b/packages/meshbay-node/tests/test_tmdb_language_fallback.py index 52fe4c4..62171c3 100644 --- a/packages/meshbay-node/tests/test_tmdb_language_fallback.py +++ b/packages/meshbay-node/tests/test_tmdb_language_fallback.py @@ -9,7 +9,6 @@ field, or silently showing a blank overview/poster. """ import pytest - from meshbay_node.transport.webrtc_server import WebRTCPeerSession pytestmark = pytest.mark.asyncio diff --git a/packages/meshbay-node/tests/test_tmdb_override_policy.py b/packages/meshbay-node/tests/test_tmdb_override_policy.py index d434e1a..aed3ea2 100644 --- a/packages/meshbay-node/tests/test_tmdb_override_policy.py +++ b/packages/meshbay-node/tests/test_tmdb_override_policy.py @@ -14,9 +14,8 @@ from pathlib import Path import pytest from cryptography.hazmat.primitives.asymmetric.ed25519 import Ed25519PrivateKey - from meshbay_common.adminop import OP_TMDB_OVERRIDE -from meshbay_common.protocol import IndexEntry, MNP +from meshbay_common.protocol import MNP, IndexEntry from meshbay_node.indexer.group_index import GroupIndex from meshbay_node.media_cache import MediaCache from meshbay_node.transport.webrtc_server import WebRTCPeerSession diff --git a/packages/meshbay-node/tests/test_tmdb_rematch_policy.py b/packages/meshbay-node/tests/test_tmdb_rematch_policy.py index 198d75b..4d43552 100644 --- a/packages/meshbay-node/tests/test_tmdb_rematch_policy.py +++ b/packages/meshbay-node/tests/test_tmdb_rematch_policy.py @@ -9,7 +9,6 @@ asking for a fresh resolution. import hashlib import pytest -from conftest import one_root from cryptography.hazmat.primitives.asymmetric.ed25519 import Ed25519PrivateKey from meshbay_common.adminop import OP_TMDB_REMATCH from meshbay_common.protocol import MNP, IndexEntry @@ -17,6 +16,8 @@ from meshbay_node.indexer.group_index import GroupIndex from meshbay_node.media_cache import MediaCache from meshbay_node.transport.webrtc_server import WebRTCPeerSession +from conftest import one_root + pytestmark = pytest.mark.asyncio diff --git a/packages/meshbay-node/tests/test_tmdb_show_director.py b/packages/meshbay-node/tests/test_tmdb_show_director.py index cb31c2c..fd324b1 100644 --- a/packages/meshbay-node/tests/test_tmdb_show_director.py +++ b/packages/meshbay-node/tests/test_tmdb_show_director.py @@ -12,7 +12,6 @@ the show details. Several creators is ordinary, so they join into one line. """ import pytest - from meshbay_node.transport.webrtc_server import WebRTCPeerSession pytestmark = pytest.mark.asyncio diff --git a/packages/meshbay-node/tests/test_transfer_settings.py b/packages/meshbay-node/tests/test_transfer_settings.py index bcfa6a8..a2c7fd9 100644 --- a/packages/meshbay-node/tests/test_transfer_settings.py +++ b/packages/meshbay-node/tests/test_transfer_settings.py @@ -19,10 +19,12 @@ shape of the bug this whole branch started from (`webrtc._stream_sem`). """ import pytest - from meshbay_node.roster import Roster from meshbay_node.transfers import ( - DEFAULT_MAX_PER_MEMBER, DOWNLOAD, UPLOAD, TransferSlots, + DEFAULT_MAX_PER_MEMBER, + DOWNLOAD, + UPLOAD, + TransferSlots, ) diff --git a/packages/meshbay-node/tests/test_transfer_slots.py b/packages/meshbay-node/tests/test_transfer_slots.py index 7056e93..08e7e70 100644 --- a/packages/meshbay-node/tests/test_transfer_slots.py +++ b/packages/meshbay-node/tests/test_transfer_slots.py @@ -21,12 +21,18 @@ by reasoning about it. import random import pytest - from meshbay_node.transfers import ( - DOWNLOAD, GRANT_DEADLINE_SECS, IDLE_TIMEOUT_SECS, KINDS, - MAX_MISSED_GRANTS, MAX_QUEUED_PER_MEMBER, REASON_ABANDONED, REASON_IDLE, - REASON_NOT_TAKEN_UP, TransferSlots, + DOWNLOAD, + GRANT_DEADLINE_SECS, + IDLE_TIMEOUT_SECS, + KINDS, + MAX_MISSED_GRANTS, + MAX_QUEUED_PER_MEMBER, + REASON_ABANDONED, + REASON_IDLE, + REASON_NOT_TAKEN_UP, UPLOAD, + TransferSlots, ) diff --git a/packages/meshbay-node/tests/test_transfer_slots_wire.py b/packages/meshbay-node/tests/test_transfer_slots_wire.py index c9fc85a..d96456c 100644 --- a/packages/meshbay-node/tests/test_transfer_slots_wire.py +++ b/packages/meshbay-node/tests/test_transfer_slots_wire.py @@ -19,6 +19,9 @@ Three things can only be checked here: """ import pytest +from meshbay_common.protocol import MNP +from meshbay_node.transfers import DOWNLOAD, UPLOAD +from meshbay_node.transport.webrtc_server import WebRTCPeerSession # Every test drives a message handler, and in the node a message handler always # runs inside the event loop: `_do_transfer_open` starts the sweeper task there. @@ -26,10 +29,6 @@ import pytest # on "no current event loop" the moment the sweeper stopped being faked. pytestmark = pytest.mark.asyncio -from meshbay_common.protocol import MNP -from meshbay_node.transfers import DOWNLOAD, UPLOAD -from meshbay_node.transport.webrtc_server import WebRTCPeerSession - class _Session(WebRTCPeerSession): """A session with the DataChannel replaced by a list, and nothing else.""" diff --git a/packages/meshbay-node/tests/test_transport_wire_parity.py b/packages/meshbay-node/tests/test_transport_wire_parity.py index bc6b134..6e74b28 100644 --- a/packages/meshbay-node/tests/test_transport_wire_parity.py +++ b/packages/meshbay-node/tests/test_transport_wire_parity.py @@ -16,7 +16,6 @@ again. import inspect import pytest -from conftest import one_root from cryptography.hazmat.primitives.asymmetric.ed25519 import Ed25519PrivateKey from meshbay_common.crypto import generate_gek from meshbay_common.groupbox import PURPOSE_INDEX, unseal @@ -25,6 +24,8 @@ 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 conftest import one_root + @pytest.fixture def gek(): diff --git a/packages/meshbay-node/tests/test_upload_size_cap.py b/packages/meshbay-node/tests/test_upload_size_cap.py index dca6e15..cc04eba 100644 --- a/packages/meshbay-node/tests/test_upload_size_cap.py +++ b/packages/meshbay-node/tests/test_upload_size_cap.py @@ -17,7 +17,6 @@ import textwrap from pathlib import Path import pytest - from meshbay_node.config import load_config from meshbay_node.roots import RootSet from meshbay_node.transport.webrtc_server import ( diff --git a/packages/meshbay-node/tests/test_video_root_gates_enrichment.py b/packages/meshbay-node/tests/test_video_root_gates_enrichment.py index d06b3f4..c39876a 100644 --- a/packages/meshbay-node/tests/test_video_root_gates_enrichment.py +++ b/packages/meshbay-node/tests/test_video_root_gates_enrichment.py @@ -17,10 +17,9 @@ import asyncio import pytest from cryptography.hazmat.primitives.asymmetric.ed25519 import Ed25519PrivateKey - from meshbay_common.crypto import generate_gek from meshbay_node import ops -from meshbay_node.config import Config, HubConfig, NodeConfig, GroupConfig, KeystoreConfig +from meshbay_node.config import Config, GroupConfig, HubConfig, KeystoreConfig, NodeConfig from meshbay_node.daemon import NodeDaemon from meshbay_node.indexer import DirectoryIndexer from meshbay_node.indexer.enrich import Enricher diff --git a/packages/meshbay-node/tests/test_webrtc_transport.py b/packages/meshbay-node/tests/test_webrtc_transport.py index 0839d42..91a6e1c 100644 --- a/packages/meshbay-node/tests/test_webrtc_transport.py +++ b/packages/meshbay-node/tests/test_webrtc_transport.py @@ -9,52 +9,58 @@ Uses local loopback (no STUN/ICE needed for localhost). import asyncio import base64 -from contextlib import asynccontextmanager import hashlib import hmac import os import struct import time +from contextlib import asynccontextmanager import jwt import msgpack import pytest +from aiortc import RTCPeerConnection, RTCSessionDescription from cryptography.hazmat.primitives import serialization from cryptography.hazmat.primitives.asymmetric.ed25519 import ( - Ed25519PrivateKey, Ed25519PublicKey, + Ed25519PrivateKey, + Ed25519PublicKey, ) -from aiortc import RTCPeerConnection, RTCSessionDescription - from meshbay_common import MNP_VERSION +from meshbay_common.adminop import ( + OP_FILE_DELETE, + OP_INVITE_CREATE, + admin_transcript, +) from meshbay_common.crypto import ( generate_gek, pk_to_b64, - wrap_gek, - wrap_gek_aes, unwrap_gek, unwrap_gek_aes, + wrap_gek, + wrap_gek_aes, ) from meshbay_common.groupbox import PURPOSE_ACK, PURPOSE_INDEX, unseal -from meshbay_common.webcrypto import chunk_key_aes, decrypt_chunk_aes -from meshbay_common.protocol import MNP -TEST_GROUP = "g" - from meshbay_common.handshake import ( - NONCE_LEN, ROLE_CLIENT, ROLE_NODE, handshake_transcript, - make_proof, verify_proof, webrtc_binding, -) -from meshbay_common.adminop import ( - OP_FILE_DELETE, - OP_INVITE_CREATE, - admin_transcript, + NONCE_LEN, + ROLE_CLIENT, + ROLE_NODE, + handshake_transcript, + make_proof, + verify_proof, + webrtc_binding, ) from meshbay_common.join import ROLE_MEMBER, ROLE_OPERATOR, join_transcript +from meshbay_common.protocol import MNP +from meshbay_common.webcrypto import chunk_key_aes, decrypt_chunk_aes from meshbay_node.bundle_store import BundleStore -from conftest import one_root -from meshbay_node.roster import Roster from meshbay_node.indexer import DirectoryIndexer +from meshbay_node.roster import Roster from meshbay_node.transport.webrtc_server import WebRTCTransport +from conftest import one_root + +TEST_GROUP = "g" + @pytest.fixture def sk_node(): diff --git a/packages/meshbay-node/tests/test_windows_root_shapes.py b/packages/meshbay-node/tests/test_windows_root_shapes.py index 5c5da25..56279b1 100644 --- a/packages/meshbay-node/tests/test_windows_root_shapes.py +++ b/packages/meshbay-node/tests/test_windows_root_shapes.py @@ -27,7 +27,6 @@ import tomllib from pathlib import Path, PureWindowsPath import pytest - from meshbay_node.roots import RootError, RootSet, derive_name BS = chr(92) diff --git a/packages/meshbay-node/tests/test_wizard_apps_endpoint.py b/packages/meshbay-node/tests/test_wizard_apps_endpoint.py index 10ab489..77fa9a6 100644 --- a/packages/meshbay-node/tests/test_wizard_apps_endpoint.py +++ b/packages/meshbay-node/tests/test_wizard_apps_endpoint.py @@ -13,12 +13,12 @@ from pathlib import Path import pytest from cryptography.hazmat.primitives.asymmetric.ed25519 import Ed25519PrivateKey from fastapi.testclient import TestClient - -from conftest import one_root from meshbay_node.indexer.group_index import GroupIndex from meshbay_node.roster import Roster from meshbay_node.ui.app import create_ui_app +from conftest import one_root + pytestmark = pytest.mark.asyncio diff --git a/packages/meshbay-node/tests/transfer_probe.py b/packages/meshbay-node/tests/transfer_probe.py index 38e6cb6..7aa4902 100755 --- a/packages/meshbay-node/tests/transfer_probe.py +++ b/packages/meshbay-node/tests/transfer_probe.py @@ -69,9 +69,8 @@ if not (_QE / "e2e.py").exists(): f"run this from a machine that has one.") sys.path.insert(0, str(_QE)) -import httpx # noqa: E402 - -from e2e import Client, env # noqa: E402 +import httpx # noqa: E402 +from e2e import Client, env # noqa: E402 def _line(ok: bool, text: str) -> None: @@ -272,7 +271,6 @@ async def operator_checks(client, ack, group, node_id) -> int: and the operator's view because it reported the module defaults. """ import asyncio as _a - import json as _json import re as _re failures = 0 @@ -322,7 +320,7 @@ async def operator_checks(client, ack, group, node_id) -> int: try: started = await _a.wait_for( _wait_for_grant(client, tr_waiting), timeout=20) - except _a.TimeoutError: + except TimeoutError: started = False _line(started, "raising the cap started the waiting transfer, with no " "restart and no reconnection") @@ -371,7 +369,7 @@ async def operator_checks(client, ack, group, node_id) -> int: _cli("transfers", "per-member", "4", "4", "--group", group["id"]) try: moved = await _a.wait_for(_wait_for_grant(client, tr_c), timeout=20) - except _a.TimeoutError: + except TimeoutError: moved = False _line(moved, "raising the per-member cap started what was waiting on it") failures += not moved @@ -526,7 +524,7 @@ async def probe(args) -> int: try: seen.append(await alice.recv_type("transfer_state", timeout=15)) - except asyncio.TimeoutError: + except TimeoutError: break promoted = [m for m in seen if m.get("state") == "granted"] ok = bool(promoted) |