Skip to content

Add off-chain voting anchor tests#3498

Open
ArturWieczorek wants to merge 1 commit into
masterfrom
artur/offchain-voting-anchor-tests
Open

Add off-chain voting anchor tests#3498
ArturWieczorek wants to merge 1 commit into
masterfrom
artur/offchain-voting-anchor-tests

Conversation

@ArturWieczorek

@ArturWieczorek ArturWieczorek commented Jun 8, 2026

Copy link
Copy Markdown
Collaborator

Summary

Conway tests verifying cardano-db-sync's off-chain voting anchor handling (db-sync PR #2005, issue #1995). When an anchor's hash matches, db-sync stores it regardless of whether it parses, recording the outcome in off_chain_vote_data.is_valid:

  • TRUE - valid JSON db-sync can decode (CIP-100 / CIP-108 / CIP-119)
  • FALSE - valid JSON it cannot decode against any CIP schema (warning records why)
  • NULL - not valid JSON (error object in json, raw bytes preserved)

Covered for both gov-action (info action) and DRep anchors.

Helper changes

  • get_action_data / check_action_data: optional voting_anchor_id to select the correct row when several anchors share the same content hash; check_action_data now asserts is_valid is TRUE.
  • GovActionProposalDBRow.param_proposal made nullable - it is NULL for info actions and only set for parameter-change actions. test_pparam_update still passes.

Anchor data files and URLs

Each vector lives in a committed file under cardano_node_tests/tests/data/, fetched by db-sync over HTTP from its public raw.githubusercontent.com URL. The URLs are kept as PUBLIC_ACTION_ANCHOR_* constants in common.py, following #3531 (no tinyurl). File names are short so the raw URL stays under the 128-byte on-chain anchor limit:

  • ga_anchor.json - conformant (already on master)
  • ga_anchor_nonconf.json - valid JSON, not CIP-decodable
  • ga_anchor_invalid.json - not valid JSON

The last two were added with long names in #3497 and are renamed here.

Verification

Verified end-to-end on a local dev cluster - 5 passed on db-sync 13.7.2.1 (rev db8cdf6, which includes PR #2005):

5 passed in 1573.88s (0:26:13)

Note on CI / merge order

The ga_anchor_nonconf.json / ga_anchor_invalid.json URLs point at master, so the four non-conformant / invalid tests only go green once those renamed files are on master (the same bootstrap this PR originally had with #3497). The conformant test passes already. Local verification used a byte-identical shortlink for the two pending files - hashes are computed from the committed files, so db-sync behaves identically once the URLs resolve.

@ArturWieczorek ArturWieczorek changed the title test(db-sync): add off-chain voting anchor tests Add off-chain voting anchor tests Jul 16, 2026
Verify db-sync off-chain voting anchor handling (PR #2005, issue
#1995): an anchor whose hash matches is stored regardless of whether
it parses, with off_chain_vote_data.is_valid set to TRUE (CIP
decodable), FALSE (valid JSON, not decodable) or NULL (not valid
JSON), for both gov-action and DRep anchors.

The test vector files use short names so their public raw-content
URLs stay under the 128-byte on-chain anchor limit; the URLs are
kept as PUBLIC_ACTION_ANCHOR_* constants in common.

Supporting helper changes:

- get_action_data / check_action_data: optional voting_anchor_id to
  pick the right row when several anchors share a content hash, and
  assert is_valid.
- GovActionProposalDBRow.param_proposal made nullable; it is NULL for
  info actions and only set for parameter-change actions.
@ArturWieczorek ArturWieczorek force-pushed the artur/offchain-voting-anchor-tests branch from 56ebbcb to 7f2eee1 Compare July 16, 2026 13:18
@ArturWieczorek

ArturWieczorek commented Jul 16, 2026

Copy link
Copy Markdown
Collaborator Author

Local cluster tests: 💚

============================= test session starts ==============================
platform linux -- Python 3.13.9, pytest-9.0.3, pluggy-1.5.0
metadata: cardano-node: 11.0.1, cardano-cli: 11.0.0.0, TESTNET_VARIANT: local_fast,
  CLUSTERS_COUNT: 1, HAS_CC: True, HAS_DBSYNC: True, db-sync: 13.7.2.1
  (rev db8cdf668cda632e9a09c30e1159fcb9fb34e952), HAS_SMASH: True, network magic: 42
rootdir: /home/artur/Projects/cardano-node-tests
configfile: pyproject.toml
collected 5 items

test_offchain_voting_anchor.py::TestGovActionAnchor::test_valid_voting_anchor_json@long PASSED [ 20%]
test_offchain_voting_anchor.py::TestGovActionAnchor::test_valid_voting_anchor_json_not_conforming_to_cip_100@long PASSED [ 40%]
test_offchain_voting_anchor.py::TestGovActionAnchor::test_invalid_voting_anchor_json@long PASSED [ 60%]
test_offchain_voting_anchor.py::TestDrepAnchor::test_drep_anchor_json_not_conforming@long PASSED [ 80%]
test_offchain_voting_anchor.py::TestDrepAnchor::test_drep_invalid_anchor_json@long PASSED [100%]

======================== 5 passed in 1573.88s (0:26:13) ========================

Full log:
cardano-node-tests-pr-3498-logs.txt

@ArturWieczorek ArturWieczorek marked this pull request as ready for review July 16, 2026 13:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant