You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Aug 11, 2022. It is now read-only.
In production Plutus code one creates a transaction by constructing its constraints and lookups. The constraints may specify multiple input UTxOs to consume, and if they are locked by validators every validator script will be run in turn.
The same transaction constraints and lookups are provided by a ContextBuilder. However tasty-plutus insists that the user also specify a particular UTxO that's going to be tested. This is not only confusingly diverging from the Plutus model, but also gets rather annoying if there is more than one input UTxO locked by the same validator. The inFromValidator function already specifies which inputs are testable, but the user has to specify them again with a SpendingTest.
There could easily be a function
shouldValidateAllInputs :: ContextBuilder 'ForSpending n -> WithScript 'ForSpending ()
which would iterate over all ValidatorUTXOs in the given context and run the validator script for each of them in turn. They're even named, so individual tests can be described using those names.
Taking this a bit further and closer to the production code, we could have a variant of inFromValidator that takes a TestScript as an argument; then shouldValidateAllInputs could test multiple different scripts and return a TestTree directly.
The text was updated successfully, but these errors were encountered:
The tests in question are for a set of transactions that always have two input UTxOs locked by the same validator script. Among other issues this is causing:
Every unit test specifies either stateTestData or registrationTestData (sometimes modified) as its second argument. The choice depends on whether the validator implementation happens to perform the test against one input UTxO or the other. This makes specification-driven black-box testing impossible.
Because the input specified by this argument gets inserted into the script context, every test takes care to remove its duplicate from completeContext which already contains it. There may be a way to refactor this in a saner form but it's not obvious.
I'd love to be able to use makeIncompleteContexts, but some of the incomplete contexts would need to be tested with one input and some with the other.
If nobody else is working on this issue I can take it up.
In production Plutus code one creates a transaction by constructing its constraints and lookups. The constraints may specify multiple input UTxOs to consume, and if they are locked by validators every validator script will be run in turn.
The same transaction constraints and lookups are provided by a
ContextBuilder
. Howevertasty-plutus
insists that the user also specify a particular UTxO that's going to be tested. This is not only confusingly diverging from the Plutus model, but also gets rather annoying if there is more than one input UTxO locked by the same validator. TheinFromValidator
function already specifies which inputs are testable, but the user has to specify them again with aSpendingTest
.There could easily be a function
which would iterate over all
ValidatorUTXO
s in the given context and run the validator script for each of them in turn. They're even named, so individual tests can be described using those names.Taking this a bit further and closer to the production code, we could have a variant of
inFromValidator
that takes aTestScript
as an argument; thenshouldValidateAllInputs
could test multiple different scripts and return aTestTree
directly.The text was updated successfully, but these errors were encountered: