Skip to content

Commit

Permalink
Update with new plutarch logging
Browse files Browse the repository at this point in the history
  • Loading branch information
albertodvp committed May 31, 2024
1 parent a1acad8 commit 43b344c
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 11 deletions.
4 changes: 2 additions & 2 deletions src/plutarch/lib/Convex/Plutarch.hs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import Plutarch.LedgerApi (PScriptContext)
import Plutarch.Internal (punsafeCoerce)
import Plutarch.Prelude (PBool, PData, PIsData, POpaque,
PUnit (..), Term, pfromData, pif, plam,
ptraceError, type (:-->))
ptraceInfoError, type (:-->))
import Plutarch.Script (Script (..))
import PlutusLedgerApi.Common (serialiseUPLC)

Expand All @@ -31,7 +31,7 @@ wrapValidator validator = plam $ \datum redeemer ctx ->
let dt = pfromData $ punsafeCoerce datum
rdmr = pfromData $ punsafeCoerce redeemer
result = validator # dt # rdmr # ctx
in popaque $ pif result (pcon PUnit) (ptraceError "Validator reduced to False")
in popaque $ pif result (pcon PUnit) (ptraceInfoError "Validator reduced to False")

plutarchScriptToCapiScript :: Script -> C.PlutusScript C.PlutusScriptV2
plutarchScriptToCapiScript (Script k) = C.PlutusScriptSerialised $ serialiseUPLC k
7 changes: 2 additions & 5 deletions src/plutarch/lib/Convex/TestUtils.hs
Original file line number Diff line number Diff line change
Expand Up @@ -74,18 +74,15 @@ module Convex.TestUtils (
) where

import Control.Arrow (Kleisli (Kleisli), runKleisli, (>>>))
import Control.Monad ((>=>))
import Control.Monad.Reader (Reader)
import Data.Foldable (fold, foldl')
import Data.List (intercalate)
import Data.Monoid (Endo, First (First), appEndo, getFirst)
import Data.Monoid (First (First), getFirst)
import Data.Text (Text)
import Plutarch (Script)
import Plutarch.Evaluate (EvalError, evalScriptHuge)
import Plutarch.Extra.Script (applyArguments)
import PlutusCore.Data qualified as PLC
import PlutusLedgerApi.V2 (Datum, ExBudget, Redeemer, ScriptContext, toData)
import Prettyprinter (Pretty, pretty)
import Test.Tasty (TestTree)
import Test.Tasty.HUnit (assertFailure, testCase)
import Text.RE.TDFA.Text (RE, countMatches, reSource, (*=~))
Expand Down Expand Up @@ -382,7 +379,7 @@ attackCaseRegexPostCondition ::
attackCaseRegexPostCondition toErr expectedFailureRE =
mkPostCondition $ \(TxFCEKOutput eitherErrorOrScript _ logs) ->
case eitherErrorOrScript of
Left evalError ->
Left _evalError ->
let
numMatches = countMatches (fold logs *=~ expectedFailureRE)
in
Expand Down
8 changes: 4 additions & 4 deletions src/plutarch/test/Spec.hs
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ import Convex.Plutarch (plutarchScriptToCapiScript)
import Convex.Utils (failOnError)
import qualified Convex.Wallet.MockWallet as Wallet
import qualified Data.Text as Text
import Plutarch (Config (..),
TracingMode (NoTracing),
compile)
import Plutarch (compile,
Config(NoTracing),
)
import Plutarch.Prelude (PData, PUnit (..), Term,
pconstant, plam, type (:-->))
import Test.Tasty (TestTree, defaultMain,
Expand All @@ -37,7 +37,7 @@ tests = testGroup "plutarch"

alwaysSucceeds :: (MonadFail m, MonadMockchain m) => m ()
alwaysSucceeds = failOnError $ do
k <- either (fail . Text.unpack) (pure . plutarchScriptToCapiScript) (compile (Config NoTracing) alwaysSucceedsP)
k <- either (fail . Text.unpack) (pure . plutarchScriptToCapiScript) (compile NoTracing alwaysSucceedsP)
ref <- fmap (C.getTxId . C.getTxBody) $ tryBalanceAndSubmit mempty Wallet.w1 $ execBuildTx' $ do
payToPlutusV2 Defaults.networkId k () C.NoStakeAddress (C.lovelaceToValue 10_000_000)
void $ tryBalanceAndSubmit mempty Wallet.w1 $ execBuildTx' (spendPlutusV2 (C.TxIn ref (C.TxIx 0)) k () ())

0 comments on commit 43b344c

Please sign in to comment.