27 lines
755 B
Python
27 lines
755 B
Python
from idea194_attractorforge_verified_attractor.models import BasinSketch
|
|
|
|
|
|
def test_basin_sketch_compact_payload_is_bounded_and_deterministic() -> None:
|
|
sketch = BasinSketch(
|
|
attractor_id="demo-1",
|
|
kind="motion_manifold",
|
|
estimated_basin_radius=1.23456789,
|
|
convergence_rate_bound=0.3456789,
|
|
controller_hash="deadbeef" * 8,
|
|
attractor_fingerprint="f" * 64,
|
|
dt=0.1,
|
|
)
|
|
|
|
p1 = sketch.compact_payload()
|
|
p2 = sketch.compact_payload()
|
|
|
|
# deterministic
|
|
assert p1 == p2
|
|
|
|
# size bound: either the inline JSON (<=128) or the 64-char hex digest
|
|
assert len(p1) <= 128
|
|
|
|
# if JSON fits, it must start with a brace
|
|
if p1.startswith(b"{"):
|
|
assert b'"id":"demo-1"' in p1
|