- Rename `par` to `pred` (predecessor) in types, serialization, tests - Remove `pol`, `pol_decision` from core payload; move to `ect_ext` - Remove `sub` from payload (not part of ECT spec) - Update `typ` from `wimse-exec+jwt` to `exec+jwt` (accept both) - Rename MaxParLength to MaxPredLength everywhere - Update testdata, demos, READMEs with migration table - All Go tests pass, all 56 Python tests pass (90% coverage)
39 lines
1013 B
Python
39 lines
1013 B
Python
"""Additional tests for ledger module."""
|
|
|
|
import time
|
|
|
|
import pytest
|
|
|
|
from ect import Payload, MemoryLedger, ErrTaskIDExists
|
|
|
|
|
|
def test_ledger_append_and_get():
|
|
m = MemoryLedger()
|
|
p = Payload(iss="i", aud=["a"], iat=1, exp=2, jti="j1", exec_act="act", pred=[])
|
|
seq = m.append("jws1", p)
|
|
assert seq == 1
|
|
assert m.get_by_tid("j1").jti == "j1"
|
|
|
|
|
|
def test_ledger_err_task_id_exists():
|
|
m = MemoryLedger()
|
|
p = Payload(iss="i", aud=["a"], iat=1, exp=2, jti="j-dup", exec_act="e", pred=[])
|
|
m.append("jws1", p)
|
|
with pytest.raises(ErrTaskIDExists):
|
|
m.append("jws2", p)
|
|
|
|
|
|
def test_ledger_contains_wid():
|
|
m = MemoryLedger()
|
|
p = Payload(iss="i", aud=["a"], iat=1, exp=2, jti="j1", exec_act="e", pred=[], wid="wf1")
|
|
m.append("jws", p)
|
|
assert m.contains("j1", "") is True
|
|
assert m.contains("j1", "wf1") is True
|
|
assert m.contains("j1", "wf2") is False
|
|
|
|
|
|
def test_ledger_append_none():
|
|
m = MemoryLedger()
|
|
seq = m.append("jws", None)
|
|
assert seq == 0
|