Fix Event default timestamp (#24)

Co-authored-by: calle <93376500+callebtc@users.noreply.github.com>
This commit is contained in:
Ryan Armstrong
2023-01-19 11:29:25 -08:00
committed by GitHub
parent 3a903b77ab
commit 87f4207b88
2 changed files with 11 additions and 2 deletions

View File

@@ -19,7 +19,7 @@ class Event():
self,
public_key: str,
content: str,
created_at: int=int(time.time()),
created_at: int = None,
kind: int=EventKind.TEXT_NOTE,
tags: "list[list[str]]"=[],
id: str=None,
@@ -30,7 +30,7 @@ class Event():
self.id = id if not id is None else Event.compute_id(public_key, created_at, kind, tags, content)
self.public_key = public_key
self.content = content
self.created_at = created_at
self.created_at = created_at or int(time.time())
self.kind = kind
self.tags = tags
self.signature = signature

9
test/test_event.py Normal file
View File

@@ -0,0 +1,9 @@
from nostr.event import Event
from nostr.key import PrivateKey
import time
def test_event_default_time():
time.sleep(1.5)
public_key = PrivateKey().public_key.hex()
event = Event(public_key=public_key, content='test event')
assert (event.created_at - time.time()) < 1