mirror of
https://github.com/PR0M3TH3AN/SeedPass.git
synced 2025-09-10 00:09:04 +00:00
Revert "Merge pull request #66 from PR0M3TH3AN/codex/replace-monstr-with-pynostr-in-client"
This reverts commitc79dd805e3
, reversing changes made toc05f19d3a4
.
This commit is contained in:
@@ -3,8 +3,6 @@ from pathlib import Path
|
||||
from tempfile import TemporaryDirectory
|
||||
from unittest.mock import patch
|
||||
from cryptography.fernet import Fernet
|
||||
from types import SimpleNamespace
|
||||
import time
|
||||
|
||||
sys.path.append(str(Path(__file__).resolve().parents[1]))
|
||||
|
||||
@@ -18,32 +16,11 @@ def test_nostr_client_uses_custom_relays():
|
||||
enc_mgr = EncryptionManager(key, Path(tmpdir))
|
||||
custom_relays = ["wss://relay1", "wss://relay2"]
|
||||
|
||||
with patch("nostr.client.RelayManager") as MockManager, patch(
|
||||
with patch("nostr.client.ClientPool") as MockPool, patch(
|
||||
"nostr.client.KeyManager"
|
||||
), patch.object(NostrClient, "initialize_client_pool"):
|
||||
with patch.object(enc_mgr, "decrypt_parent_seed", return_value="seed"):
|
||||
client = NostrClient(enc_mgr, "fp", relays=custom_relays)
|
||||
|
||||
MockPool.assert_called_with(custom_relays)
|
||||
assert client.relays == custom_relays
|
||||
added = [c.args[0] for c in MockManager.return_value.add_relay.call_args_list]
|
||||
assert added == custom_relays
|
||||
|
||||
|
||||
def test_wait_for_connection_timeout():
|
||||
with TemporaryDirectory() as tmpdir:
|
||||
key = Fernet.generate_key()
|
||||
enc_mgr = EncryptionManager(key, Path(tmpdir))
|
||||
|
||||
with patch.object(NostrClient, "initialize_client_pool"), patch(
|
||||
"nostr.client.RelayManager"
|
||||
), patch("nostr.client.KeyManager"), patch.object(
|
||||
enc_mgr, "decrypt_parent_seed", return_value="seed"
|
||||
):
|
||||
client = NostrClient(enc_mgr, "fp")
|
||||
|
||||
client.client_pool = SimpleNamespace(connection_statuses={"wss://r": False})
|
||||
|
||||
start = time.monotonic()
|
||||
client.wait_for_connection(timeout=0.2)
|
||||
duration = time.monotonic() - start
|
||||
assert duration >= 0.2
|
||||
|
Reference in New Issue
Block a user