29 lines
745 B
Python
29 lines
745 B
Python
from gravityweave.ticket import PassWindowTicket
|
|
|
|
|
|
def test_ticket_mint_and_verify():
|
|
key = b"ticket-key-xyz"
|
|
start = 1700000000
|
|
end = start + 60
|
|
t = PassWindowTicket.mint(
|
|
window_start=start,
|
|
window_end=end,
|
|
comm_budget_bytes=2048,
|
|
resource_budget_digest="rbdig-0123",
|
|
trigger_policy_id="policy-1",
|
|
signer="authority-1",
|
|
key=key,
|
|
)
|
|
|
|
assert t.verify(key)
|
|
serialized = t.serialize()
|
|
assert len(serialized) < 1024
|
|
# ticket hash is stable and hex
|
|
th = t.ticket_hash()
|
|
assert isinstance(th, str) and len(th) == 64
|
|
|
|
# roundtrip
|
|
t2 = PassWindowTicket.deserialize(serialized)
|
|
assert t2.window_start == start
|
|
assert t2.window_end == end
|