Skip to content

Refactor and modernise DRep golden tests for thread-safety #1209

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

newhoggy
Copy link
Contributor

@newhoggy newhoggy commented Jun 1, 2025

Changelog

- description: |
    Refactor and modernise `DRep` golden tests for thread-safety
# uncomment types applicable to the change:
  type:
  # - feature        # introduces a new feature
  # - breaking       # the API has changed in a breaking way
  - compatible     # the API has changed but is non-breaking
  # - optimisation   # measurable performance improvements
  # - refactoring    # QoL changes
  - bugfix         # fixes a defect
  # - test           # fixes/modifies tests
  # - maintenance    # not directly related to the code
  # - release        # related to a new release preparation
  # - documentation  # change in code docs, haddocks...

Context

This PR improves the structure and exception safety of golden tests related to DRep governance features by:

  • Replacing Property-based Hedgehog tests with a new UnitIO style enabled by Hedgehog.Extras.Test.New.Monad from hedgehog-extras, which simplifies composition and improves readability.
  • Extracting serveFilesWhile to two new modules:
    • Test.Cardano.CLI.Network (used in traditional test code)
    • Test.Cardano.CLI.New.Network (uses MonadMask, preferred in the new-style tests)

Dependency Update

Updates the hedgehog-extras dependency, for the new support for the UnitIO abstraction and new test monads.

Benefits

  • Clearer test structure and improved type safety via UnitIO.
  • Better exception handling guarantees using MonadMask.
  • Isolated network test utilities support both legacy and modern test styles.

How to trust this PR

Highlight important bits of the PR that will make the review faster. If there are commands the reviewer can run to observe the new behavior, describe them.

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

@@ -121,26 +123,25 @@ hprop_golden_governance_drep_id_hex =

-- | Execute me with:
-- @cabal test cardano-cli-golden --test-options '-p "/golden governance drep id hash/"'@
hprop_golden_governance_drep_id_hash :: Property
hprop_golden_governance_drep_id_hash =
watchdogProp . propertyOnce $ do
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should keep watchdogs everywhere.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We will need to write a new watchdog for the new test api. I wanted to see it hang in one of these property test first before adding it.

@newhoggy newhoggy force-pushed the newhoggy/thread-safe-golden-tests-with-hedgehog-extras branch from 8baf41b to 8d3138d Compare June 2, 2025 14:34
@Jimbo4350 Jimbo4350 self-requested a review June 2, 2025 18:36
Copy link
Contributor

@Jimbo4350 Jimbo4350 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not convinced this refactor is necessary. Let's explore other options.

Copy link

This PR is stale because it has been open 45 days with no activity.

@github-actions github-actions bot added the Stale label Jul 18, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants