mirror of
https://github.com/aljazceru/python-nostr.git
synced 2025-12-18 23:04:20 +01:00
Fix Event default timestamp (#24)
Co-authored-by: calle <93376500+callebtc@users.noreply.github.com>
This commit is contained in:
@@ -19,7 +19,7 @@ class Event():
|
|||||||
self,
|
self,
|
||||||
public_key: str,
|
public_key: str,
|
||||||
content: str,
|
content: str,
|
||||||
created_at: int=int(time.time()),
|
created_at: int = None,
|
||||||
kind: int=EventKind.TEXT_NOTE,
|
kind: int=EventKind.TEXT_NOTE,
|
||||||
tags: "list[list[str]]"=[],
|
tags: "list[list[str]]"=[],
|
||||||
id: str=None,
|
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.id = id if not id is None else Event.compute_id(public_key, created_at, kind, tags, content)
|
||||||
self.public_key = public_key
|
self.public_key = public_key
|
||||||
self.content = content
|
self.content = content
|
||||||
self.created_at = created_at
|
self.created_at = created_at or int(time.time())
|
||||||
self.kind = kind
|
self.kind = kind
|
||||||
self.tags = tags
|
self.tags = tags
|
||||||
self.signature = signature
|
self.signature = signature
|
||||||
|
|||||||
9
test/test_event.py
Normal file
9
test/test_event.py
Normal 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
|
||||||
Reference in New Issue
Block a user