mirror of
https://github.com/BigBodyCobain/Shadowbroker.git
synced 2026-08-27 04:42:40 +02:00
Harden mesh bootstrap defaults
This commit is contained in:
@@ -1,6 +1,9 @@
|
||||
from services.mesh.mesh_fleet_defaults import (
|
||||
FLEET_SEED_ONION_URL,
|
||||
FLEET_PEER_PUSH_SECRET,
|
||||
configured_bootstrap_seed_peers_with_fleet_default,
|
||||
effective_bootstrap_signer_public_key_b64,
|
||||
effective_fleet_seed_peers,
|
||||
effective_peer_push_secret,
|
||||
infonet_fleet_join_enabled,
|
||||
)
|
||||
@@ -9,8 +12,8 @@ from services.mesh.mesh_fleet_defaults import (
|
||||
def test_fleet_defaults_apply_when_join_enabled(monkeypatch):
|
||||
from services.config import get_settings
|
||||
|
||||
monkeypatch.delenv("MESH_BOOTSTRAP_SIGNER_PUBLIC_KEY", raising=False)
|
||||
monkeypatch.delenv("MESH_PEER_PUSH_SECRET", raising=False)
|
||||
monkeypatch.setenv("MESH_BOOTSTRAP_SIGNER_PUBLIC_KEY", "")
|
||||
monkeypatch.setenv("MESH_PEER_PUSH_SECRET", "")
|
||||
monkeypatch.setenv("MESH_INFONET_FLEET_JOIN", "true")
|
||||
get_settings.cache_clear()
|
||||
try:
|
||||
@@ -21,6 +24,52 @@ def test_fleet_defaults_apply_when_join_enabled(monkeypatch):
|
||||
get_settings.cache_clear()
|
||||
|
||||
|
||||
def test_empty_bootstrap_peers_use_fleet_seed_defaults(monkeypatch):
|
||||
from services.config import get_settings
|
||||
|
||||
monkeypatch.delenv("MESH_FLEET_SEED_PEERS", raising=False)
|
||||
monkeypatch.setenv("MESH_INFONET_FLEET_JOIN", "true")
|
||||
get_settings.cache_clear()
|
||||
try:
|
||||
assert configured_bootstrap_seed_peers_with_fleet_default([]) == [FLEET_SEED_ONION_URL]
|
||||
finally:
|
||||
get_settings.cache_clear()
|
||||
|
||||
|
||||
def test_configured_bootstrap_peers_override_fleet_defaults(monkeypatch):
|
||||
from services.config import get_settings
|
||||
|
||||
monkeypatch.setenv("MESH_INFONET_FLEET_JOIN", "true")
|
||||
get_settings.cache_clear()
|
||||
try:
|
||||
assert configured_bootstrap_seed_peers_with_fleet_default(
|
||||
["http://alphaexample.onion:8000", "http://alphaexample.onion:8000"]
|
||||
) == ["http://alphaexample.onion:8000"]
|
||||
finally:
|
||||
get_settings.cache_clear()
|
||||
|
||||
|
||||
def test_fleet_seed_override_can_ship_multiple_seeds(monkeypatch):
|
||||
from services.config import get_settings
|
||||
|
||||
monkeypatch.setenv(
|
||||
"MESH_FLEET_SEED_PEERS",
|
||||
"http://alphaexample.onion:8000,http://betaexample.onion:8000,http://alphaexample.onion:8000",
|
||||
)
|
||||
get_settings.cache_clear()
|
||||
try:
|
||||
assert effective_fleet_seed_peers() == [
|
||||
"http://alphaexample.onion:8000",
|
||||
"http://betaexample.onion:8000",
|
||||
]
|
||||
assert configured_bootstrap_seed_peers_with_fleet_default([]) == [
|
||||
"http://alphaexample.onion:8000",
|
||||
"http://betaexample.onion:8000",
|
||||
]
|
||||
finally:
|
||||
get_settings.cache_clear()
|
||||
|
||||
|
||||
def test_fleet_defaults_disabled(monkeypatch):
|
||||
from services.config import get_settings
|
||||
|
||||
|
||||
@@ -479,4 +479,4 @@ def test_meshnode_scripts_enable_private_hashchain_runtime():
|
||||
assert "MESH_INFONET_ALLOW_CLEARNET_SYNC=false" in script
|
||||
assert "MESH_ARTI_ENABLED=true" in script
|
||||
assert "MESH_DM_HASHCHAIN_SPOOL_LIMIT=2" in script
|
||||
assert "gqpbunqbgtkcqilvclm3xrkt3zowjyl3s62kkktvojgvxzizamvbrqid.onion:8000" in script
|
||||
assert "sb-testnet fleet defaults" in script
|
||||
|
||||
@@ -16,6 +16,7 @@ from services.mesh.mesh_swarm_runtime import (
|
||||
merge_manifest_into_peer_store,
|
||||
peer_registry_enabled,
|
||||
publish_registry_manifest,
|
||||
refresh_swarm_manifest_from_seeds,
|
||||
record_peer_announcement,
|
||||
)
|
||||
|
||||
@@ -180,6 +181,30 @@ def test_parse_bootstrap_manifest_dict_rejects_expired():
|
||||
)
|
||||
|
||||
|
||||
def test_refresh_swarm_manifest_reports_retrying_when_all_seeds_unreachable(monkeypatch):
|
||||
from services.config import get_settings
|
||||
|
||||
monkeypatch.setenv("MESH_BOOTSTRAP_SIGNER_PUBLIC_KEY", "ul1d0kj/ODPIp0OhHzX8eLAVXzJ3CVvzW1vn2IC6q3I=")
|
||||
monkeypatch.setenv(
|
||||
"MESH_BOOTSTRAP_SEED_PEERS",
|
||||
"http://seed-a.onion:8000,http://seed-b.onion:8000",
|
||||
)
|
||||
monkeypatch.setattr(
|
||||
"services.mesh.mesh_swarm_runtime.fetch_remote_bootstrap_manifest",
|
||||
lambda *_args, **_kwargs: None,
|
||||
)
|
||||
get_settings.cache_clear()
|
||||
try:
|
||||
result = refresh_swarm_manifest_from_seeds(force=True, now=1_750_000_000)
|
||||
finally:
|
||||
get_settings.cache_clear()
|
||||
|
||||
assert result["ok"] is False
|
||||
assert result["retrying"] is True
|
||||
assert result["tried_seed_count"] == 2
|
||||
assert result["detail"] == "bootstrap seeds unreachable; local node will retry"
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_bootstrap_manifest_endpoint_serves_live_registry(tmp_path, monkeypatch):
|
||||
import main
|
||||
|
||||
Reference in New Issue
Block a user