@@ -56,6 +56,7 @@ import Hydra.Cardano.Api (
56
56
UTxO ,
57
57
evaluateTransactionExecutionUnits ,
58
58
getTxBody ,
59
+ prettyError ,
59
60
toLedgerExUnits ,
60
61
)
61
62
import Hydra.Cardano.Api.Pretty (renderTxWithUTxO )
@@ -73,6 +74,8 @@ import Ouroboros.Consensus.HardFork.History (
73
74
initBound ,
74
75
mkInterpreter ,
75
76
)
77
+ import Prettyprinter (defaultLayoutOptions , layoutPretty )
78
+ import Prettyprinter.Render.Text (renderStrict )
76
79
import Test.QuickCheck (Property , choose , counterexample , property )
77
80
import Test.QuickCheck.Gen (chooseWord64 )
78
81
@@ -158,6 +161,19 @@ data EvaluationError
158
161
type EvaluationReport =
159
162
(Map ScriptWitnessIndex (Either ScriptExecutionError ExecutionUnits ))
160
163
164
+ -- | Render the 'EvaluationReport' as a pretty multi-line text.
165
+ renderEvaluationReport :: EvaluationReport -> Text
166
+ renderEvaluationReport =
167
+ unlines . map render . Map. toList
168
+ where
169
+ render (ix, Right exunits) =
170
+ " - " <> show ix <> " OK and used " <> show exunits
171
+ render (ix, Left err) =
172
+ unlines
173
+ [ " - " <> show ix <> " FAIL with error: "
174
+ , renderStrict $ layoutPretty defaultLayoutOptions $ prettyError err
175
+ ]
176
+
161
177
-- | Get the total used 'ExecutionUnits' from an 'EvaluationReport'. Useful to
162
178
-- further process the result of 'evaluateTx'.
163
179
usedExecutionUnits :: EvaluationReport -> ExecutionUnits
@@ -333,7 +349,7 @@ propTransactionEvaluates (tx, lookupUTxO) =
333
349
Right redeemerReport ->
334
350
all isRight (Map. elems redeemerReport)
335
351
& counterexample (" Transaction: " <> renderTxWithUTxO lookupUTxO tx)
336
- & counterexample (" Redeemer report: " <> show redeemerReport)
352
+ & counterexample (" Redeemer report:\n " <> toString (renderEvaluationReport redeemerReport) )
337
353
& counterexample " Phase-2 validation failed"
338
354
339
355
-- | Expect a given 'Tx' and 'UTxO' to fail phase 1 or phase 2 evaluation.
0 commit comments