24 lines
888 B
Python
24 lines
888 B
Python
from missionledger.governance import GovernanceLedger
|
|
|
|
|
|
def test_poetic_cert_and_replay_bundle_creation():
|
|
gl = GovernanceLedger(device_id="test-device-2")
|
|
|
|
invariants = {"collision_envelope": 1.2, "energy_budget": 42}
|
|
cert = gl.emit_poetic_cert(invariants=invariants, summary="Safe envelope OK", issuer="planner-v1")
|
|
|
|
assert cert.issued_by == "planner-v1"
|
|
assert "collision_envelope" in cert.invariants
|
|
|
|
entries = [
|
|
{"event": "plan_step", "step": 1},
|
|
{"event": "plan_step", "step": 2},
|
|
]
|
|
bundle = gl.create_replay_bundle(entries=entries, signer="device-A", nonce="n-123")
|
|
|
|
assert bundle.signer == "device-A"
|
|
assert bundle.merkle_root != ""
|
|
assert len(bundle.entries) == 2
|
|
# ensure ledger recorded the bundle creation as an entry
|
|
assert any(e.get("entry", {}).get("type") == "replay_bundle_created" for e in gl.entries)
|