Skip to content
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

checking exported ledger types to have Arbitrary instances #6428

Closed
wants to merge 0 commits into from

Conversation

aleeusgr
Copy link
Contributor

@aleeusgr aleeusgr commented Aug 21, 2024

The issue I am working on asks to implement Arbitrary instances for the types plutus-ledger-api exports so I wrote tests to check if a type has an Arbitrary instance and to check module against a list of exports verified by the user:

Pre-submit checklist:

  • Branch
    • Tests are provided (if possible)
    • Commit sequence broadly makes sense
    • Key commits have useful messages
    • Changelog fragments have been written (if appropriate)
    • Relevant tickets are mentioned in commit messages
    • Formatting, PNG optimization, etc. are updated
  • PR
    • (For external contributions) Corresponding issue exists and is linked in the description QuickCheck Arbitrary instances for Ledger types #6210
    • Targeting master unless this is a cherry-pick backport
    • Self-reviewed the diff
    • Useful pull request description
    • Reviewer requested

@aleeusgr aleeusgr changed the title checking exported ledger types to checking exported ledger types to have Arbitrary instances Aug 21, 2024
@aleeusgr

This comment was marked as outdated.

@aleeusgr
Copy link
Contributor Author

aleeusgr commented Sep 9, 2024

  • assert existence of an instance for a type
  • add parser to list exported types

The code I wrote uses ghc --show-iface command which if I run in shell tells me that Magic Number is mismatched.

Copy link
Contributor Author

@aleeusgr aleeusgr Sep 9, 2024

Choose a reason for hiding this comment

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

-- This test suite checks the correctness of the PlutusLedgerApi module.
-- It uses QuickCheck to verify that certain types have Arbitrary instances,
TODO:

  • list all types that need to be checked.

testsArb :: IO TestTree
testsArb = do
files <- listDirectory "./src/PlutusLedgerApi"
let hsFiles = filter (\file -> file `elem` ["V1.hs", "V2.hs"]) files
Copy link
Contributor Author

Choose a reason for hiding this comment

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

which files do we check?


parseExports :: FilePath -> IO [String]
parseExports filePath = do
output <- readProcess "ghc" ["--show-iface", "./src/PlutusLedgerApi/" ++ filePath] ""
Copy link
Contributor Author

Choose a reason for hiding this comment

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

error here

@aleeusgr
Copy link
Contributor Author

aleeusgr commented Sep 9, 2024

@aleeusgr aleeusgr closed this Oct 3, 2024
@aleeusgr aleeusgr force-pushed the ledger-types-testing branch from ed07a32 to f912edc Compare October 3, 2024 07:53
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