Skip to content

Add goldenBundle and goldenBundle' test functions #7057

New issue

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

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

Already on GitHub? # to your account

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

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.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants