test(beacon_anchor): add 53 unit tests for Beacon v2 envelope system [T3]#6366
test(beacon_anchor): add 53 unit tests for Beacon v2 envelope system [T3]#6366waefrebeorn wants to merge 1 commit into
Conversation
…[T3] Covers 14 functions across: - Agent ID derivation from Ed25519 pubkeys (bcn_ prefix) - Canonical signed field extraction and JSON serialization - Blake2b payload hashing (deterministic, compact separators) - Ed25519 signature verification (valid, missing fields, bad hex, agent_id mismatch, NACL unavailable, BadSignatureError) - Envelope storage with full validation pipeline - Digest computation over un-anchored envelopes - mark_anchored lifecycle management - Pagination clamping (int, string, overflow, negative) - get_recent_envelopes (newest-first, limit, offset) - init_beacon_table (idempotent, indexes, migration column) - _ensure_payload_hash_version_column migration 53 tests, all pass. Coverage: 0% to covered. RTC: rtc17c0d21f04f6f65c1a85c0aeb5d4a305d57531096
shadow88sky
left a comment
There was a problem hiding this comment.
Reviewed PR #6366, focused on node/tests/test_beacon_anchor.py for the Beacon v2 envelope system.
The new suite covers canonical signing/hash helpers, agent id derivation, real Ed25519 verification, signature failure cases, store-time validation, duplicate nonce handling, digest computation, anchoring, pagination normalization, recent-envelope ordering, migration/idempotent table setup, and constants. I specifically checked that the signature path is not only mocked: the valid-signature and store-envelope helpers generate real nacl.signing.SigningKey keys and sign the canonical payload.
The digest/storage tests also exercise fresh payload hash version 2 writes and the mixed-version reporting surface. One limitation is that the mixed-version test only asserts the all-new-write case is not mixed; it does not seed a legacy-v1 row plus a v2 row to assert the positive mixed case. That would be a useful follow-up, but I do not see it as a blocker for this test-only PR.
Validation performed:
- GitHub PR checks are passing
git diff --check $(git merge-base HEAD origin/main)..HEADpassed.venv/bin/python -m py_compile node/beacon_anchor.py node/tests/test_beacon_anchor.pypassedPYTHONPATH=. PYTEST_DISABLE_PLUGIN_AUTOLOAD=1 .venv/bin/python -m pytest node/tests/test_beacon_anchor.py -q-> 53 passed
I received RTC compensation for this review.
jaxint
left a comment
There was a problem hiding this comment.
Great work! Thanks for contributing to RustChain! 🦀
jaxint
left a comment
There was a problem hiding this comment.
Great work! Thanks for contributing to RustChain! 🦀
jaxint
left a comment
There was a problem hiding this comment.
Great work! Thanks for contributing to RustChain! 🦀
jaxint
left a comment
There was a problem hiding this comment.
Great work! Thanks for contributing to RustChain! 🦀
jaxint
left a comment
There was a problem hiding this comment.
Thanks for this contribution! 🎉
jaxint
left a comment
There was a problem hiding this comment.
Thanks for this contribution! 🎉
jaxint
left a comment
There was a problem hiding this comment.
Thanks for this contribution! 🎉
jaxint
left a comment
There was a problem hiding this comment.
Thanks for this contribution! The code looks well-structured and follows good practices. Appreciate the effort put into this PR.
jaxint
left a comment
There was a problem hiding this comment.
Thanks for this contribution! The code looks well-structured.
Clean replacement for #6320. Single commit, no unrelated files, no p2p.py regression.
RTC Wallet:
RTC17c0d21f04f6f65c1a85c0aeb5d4a305d57531096