Skip to content

Add goldenBundle and goldenBundle' test functions #7057

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

Merged
merged 6 commits into from
May 8, 2025

Conversation

zeme-wana
Copy link
Contributor

@zeme-wana zeme-wana commented Apr 24, 2025

For many budget tests we want a golden PIR test, a golden UPLC test, a golden budget test and a golden evaluation test, so we write these four lines:

, goldenPirReadable "filter" filter
, goldenUPlcReadable "filter" filter
, goldenEvalCekCatch "filter" [filter `unsafeApplyCode` l]
, goldenBudget "filter" (filter `unsafeApplyCode` l)

This is quite repetitive. This PR introduces two new functions goldenBundle and goldenBundle' that do these four things.

@@ -26,7 +26,7 @@ import PlutusTx.TH (compile)

tests :: TestTree
tests =
runTestNested ["test-plugin", "Spec", "Data", "SriptContext"] . pure . testNestedGhc $
runTestNested ["test-plugin", "Spec", "Data", "ScriptContext"] . pure . testNestedGhc $
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This causes the following file renames:

plutus-ledger-api/test-plugin/Spec/Data/ScriptContext/9.6/alwaysSucceeds.pir.golden
plutus-ledger-api/test-plugin/Spec/Data/ScriptContext/9.6/alwaysSucceeds.uplc.golden
plutus-ledger-api/test-plugin/Spec/Data/ScriptContext/9.6/succeedsIfHasDatum.pir.golden
plutus-ledger-api/test-plugin/Spec/Data/ScriptContext/9.6/succeedsIfHasDatum.uplc.golden

But the contents stayed the same


, goldenBudget "sumAtIndices" (compiledSumAtIndices `unsafeApplyCode` sumAtIndicesInput)
, goldenUPlcReadable "sumAtIndices" compiledSumAtIndices
, goldenPirReadableU "sumAtIndices" compiledSumAtIndices
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I assume this is a typo: goldenPirReadableU was meant to be goldenPirReadable.
The new goldenBundle' function uses goldenPirReadable and this is why we get a different .pir.golden


, goldenBudget "show" compiledShow
, goldenUPlcReadable "show" compiledShow
, goldenPirReadable "show" compiledShow
Copy link
Contributor Author

Choose a reason for hiding this comment

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

goldenEvalCekCatch missing for "show". I assumed this is an oversight, and replaced these tests with goldenBundle

@@ -0,0 +1 @@
(con integer -2469135780)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@@ -0,0 +1,27 @@
(program
Copy link
Contributor Author

@zeme-wana zeme-wana Apr 24, 2025

Choose a reason for hiding this comment

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

@@ -0,0 +1,54 @@
(let
Copy link
Contributor Author

@zeme-wana zeme-wana Apr 24, 2025

Choose a reason for hiding this comment

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

, goldenUPlcReadable "inlineLocalOnce" compiledInlineLocalOnce
, goldenEvalCekCatch
"inlineLocalOnce"
[compiledInlineLocalOnce `unsafeApplyCode` liftCodeDef 2]
Copy link
Contributor Author

Choose a reason for hiding this comment

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

goldenBudget missing for inlineLocalOnce. I assumed this is an oversight, and replaced these tests with goldenBundle

@@ -0,0 +1,3 @@
cpu: 597469
Copy link
Contributor Author

Choose a reason for hiding this comment

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

, goldenEvalCekCatch "ifThenElse2" [compiledIfThenElse2]

, goldenBudget "matchAsDataE" matchAsData
, goldenEvalCekCatch "matchAsDataE" [matchAsData]
Copy link
Contributor Author

Choose a reason for hiding this comment

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

goldenPirReadable and goldenUPlcReadable missing for "matchAsDataE". I assumed this is an oversight, and replaced these tests with goldenBundle

@@ -1,10 +1,9 @@
\(d-1579 : data) ->
\(d : data) ->
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@zeme-wana zeme-wana marked this pull request as ready for review April 24, 2025 11:45
Copy link
Contributor

@effectfully effectfully left a comment

Choose a reason for hiding this comment

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

Good idea.

@zeme-wana zeme-wana force-pushed the better-golden-merged branch from 9d28d91 to 4f18c97 Compare May 7, 2025 10:30
@zeme-wana zeme-wana added the No Changelog Required Add this to skip the Changelog Check label May 7, 2025
@zeme-wana zeme-wana force-pushed the better-golden-merged branch from d94ada7 to 31c0144 Compare May 7, 2025 13:53
@zeme-wana zeme-wana force-pushed the better-golden-merged branch from 31c0144 to 351a4e8 Compare May 8, 2025 09:15
@zeme-wana zeme-wana merged commit b2bde08 into master May 8, 2025
55 checks passed
@zeme-wana zeme-wana deleted the better-golden-merged branch May 8, 2025 11:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
No Changelog Required Add this to skip the Changelog Check
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants