Skip to content

Conversation

@newhoggy
Copy link
Collaborator

@newhoggy newhoggy commented Dec 5, 2025

Changelog

- description: |
    Add comprehensive golden tests for TxOut, TxOutValue, AddressInEra, and ReferenceScript JSON serialization to ensure backwards compatibility during constraint migration from IsShelleyBasedEra/IsCardanoEra to Exp.IsEra constraints.
# uncomment types applicable to the change:
  type:
  - test           # fixes/modifies tests
# uncomment at least one main project this PR is associated with
  projects:
  - cardano-api

Context

This PR adds a comprehensive golden test suite for TxOut and related types to ensure JSON format stability after migrating from IsShelleyBasedEra/IsCardanoEra constraints to Exp.IsEra constraints. These tests are critical for maintaining backwards compatibility of the JSON API that downstream consumers depend on.

The test suite covers all variations of transaction outputs that are commonly used in the Cardano ecosystem, ensuring that the JSON serialization format remains stable across the constraint system migration.

How to trust this PR

The PR adds extensive golden tests that verify JSON serialization for:

  • TxOut variations: Simple outputs, outputs with datum hashes, inline datums, reference scripts, and fully-featured outputs
  • TxOutValue types: Lovelace-only values and multi-asset values
  • AddressInEra: Payment address serialization
  • ReferenceScript: Simple script reference handling
  • UTxO maps: Complete UTxO serialization with multiple outputs

To verify the tests:

# Run the new golden tests
cabal test cardano-api-golden --test-options='-p "TxOut"'

# Regenerate golden files if needed
cabal test cardano-api-golden --test-options='--accept'

The golden files provide a clear reference for the expected JSON format and can be inspected at:

  • cardano-api/test/cardano-api-golden/files/TxOut/conway/*.json

Checklist

  • Commit sequence broadly makes sense and commits have useful messages
  • New tests are added if needed and existing tests are updated. See Running tests for more details
  • Self-reviewed the diff

…tion

Implements a complete golden test suite for TxOut, TxOutValue, AddressInEra,
and ReferenceScript types to ensure JSON format stability after migrating
from IsShelleyBasedEra/IsCardanoEra constraints to Exp.IsEra constraints.

Test Coverage:
- TxOut variations: simple, with datum hash, inline datum, reference script, and full
- TxOutValue: lovelace-only and multi-asset configurations
- AddressInEra: payment address serialization
- ReferenceScript: simple script reference handling
- UTxO: complete UTxO map serialization with multiple outputs

Golden Test Infrastructure:
- Helper functions for constructing test addresses, values, and scripts
- Pretty JSON encoding for readable golden files
- Comprehensive test data builders with realistic hash values
- Support for ConwayEra and future eras (Dijkstra)

This test suite ensures backwards compatibility of the JSON format is
maintained during the constraint migration, preventing breaking changes
in API consumers that depend on JSON serialization.
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.

2 participants