30 lines
792 B
Python
30 lines
792 B
Python
import os
|
|
from gravityweave.mfr_v2 import MutualFeasibilityReceiptV2
|
|
|
|
|
|
def test_mfr_v2_sign_and_size():
|
|
key = b"test-key-12345"
|
|
proposal_hash = "abcd1234"
|
|
invariants = [1, 2, 7]
|
|
m = MutualFeasibilityReceiptV2.create(
|
|
proposal_hash=proposal_hash,
|
|
invariant_id_set=invariants,
|
|
decision="ok",
|
|
uncertainty_pct=5,
|
|
round_nonce=42,
|
|
pass_ticket_hash="",
|
|
execution_hash_skim="deadbeef",
|
|
signer="node-A",
|
|
key=key,
|
|
)
|
|
|
|
assert m.verify(key)
|
|
s = m.serialize()
|
|
# ensure size is small (<= 512 bytes as requested by spec)
|
|
assert len(s) <= 512
|
|
|
|
# roundtrip
|
|
m2 = MutualFeasibilityReceiptV2.deserialize(s)
|
|
assert m2.proposal_hash == proposal_hash
|
|
assert m2.invariant_id_set == invariants
|