mirror of
https://github.com/PR0M3TH3AN/SeedPass.git
synced 2025-09-08 23:38:49 +00:00
Fix Nostr publish logging for new SDK
This commit is contained in:
@@ -100,8 +100,13 @@ class NostrClient:
|
|||||||
)
|
)
|
||||||
|
|
||||||
# Send the event using the client
|
# Send the event using the client
|
||||||
event_id = self.publish_event(event)
|
event_output = self.publish_event(event)
|
||||||
logger.info(f"Successfully published event with ID: {event_id.to_hex()}")
|
event_id_hex = (
|
||||||
|
event_output.id.to_hex()
|
||||||
|
if hasattr(event_output, "id")
|
||||||
|
else str(event_output)
|
||||||
|
)
|
||||||
|
logger.info(f"Successfully published event with ID: {event_id_hex}")
|
||||||
return True
|
return True
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
@@ -44,12 +44,24 @@ class FakeBuilder:
|
|||||||
return FakeUnsignedEvent()
|
return FakeUnsignedEvent()
|
||||||
|
|
||||||
|
|
||||||
|
class FakeEventId:
|
||||||
|
def to_hex(self):
|
||||||
|
return "abcd"
|
||||||
|
|
||||||
|
|
||||||
|
class FakeSendEventOutput:
|
||||||
|
def __init__(self):
|
||||||
|
self.id = FakeEventId()
|
||||||
|
|
||||||
|
|
||||||
def test_publish_json_success():
|
def test_publish_json_success():
|
||||||
with TemporaryDirectory() as tmpdir, patch(
|
with TemporaryDirectory() as tmpdir, patch(
|
||||||
"nostr.client.EventBuilder.text_note", return_value=FakeBuilder()
|
"nostr.client.EventBuilder.text_note", return_value=FakeBuilder()
|
||||||
):
|
):
|
||||||
client = setup_client(Path(tmpdir))
|
client = setup_client(Path(tmpdir))
|
||||||
with patch.object(client, "publish_event") as mock_pub:
|
with patch.object(
|
||||||
|
client, "publish_event", return_value=FakeSendEventOutput()
|
||||||
|
) as mock_pub:
|
||||||
assert client.publish_json_to_nostr(b"data") is True
|
assert client.publish_json_to_nostr(b"data") is True
|
||||||
mock_pub.assert_called()
|
mock_pub.assert_called()
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user