move scriptTest to Util module
This commit is contained in:
parent
f9244aca38
commit
611e6fa2a6
3 changed files with 30 additions and 12 deletions
|
|
@ -7,13 +7,11 @@ import Prelude
|
|||
--------------------------------------------------------------------------------
|
||||
|
||||
import Test.Tasty (TestTree, testGroup)
|
||||
import Test.Tasty.HUnit (assertFailure, testCase)
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
import Plutarch (compile)
|
||||
import Plutarch.Evaluate (evalScript)
|
||||
import Plutus.V1.Ledger.Scripts (Script)
|
||||
import Plutarch.Builtin (pforgetData)
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
|
|
@ -21,10 +19,11 @@ import Agora.Stake (stakePolicy)
|
|||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
import Plutarch.Builtin (pforgetData)
|
||||
import Spec.Sample.Stake qualified as Stake
|
||||
import Spec.Util (scriptTest)
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
tests :: [TestTree]
|
||||
tests =
|
||||
[ testGroup
|
||||
|
|
@ -32,11 +31,3 @@ tests =
|
|||
[ scriptTest "minting" (compile $ stakePolicy Stake.stake # pforgetData (pconstantData ()) # pconstant Stake.stakeCreation)
|
||||
]
|
||||
]
|
||||
|
||||
scriptTest :: String -> Script -> TestTree
|
||||
scriptTest name script = testCase name $ do
|
||||
let (res, _budget, traces) = evalScript script
|
||||
case res of
|
||||
Left e -> do
|
||||
assertFailure (show e <> " Traces: " <> show traces)
|
||||
Right _v -> pure ()
|
||||
|
|
|
|||
25
agora-test/Spec/Util.hs
Normal file
25
agora-test/Spec/Util.hs
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
module Spec.Util (scriptTest) where
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
import Prelude
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
import Test.Tasty (TestTree)
|
||||
import Test.Tasty.HUnit (assertFailure, testCase)
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
import Plutarch.Evaluate (evalScript)
|
||||
import Plutus.V1.Ledger.Scripts (Script)
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
scriptTest :: String -> Script -> TestTree
|
||||
scriptTest name script = testCase name $ do
|
||||
let (res, _budget, traces) = evalScript script
|
||||
case res of
|
||||
Left e -> do
|
||||
assertFailure (show e <> " Traces: " <> show traces)
|
||||
Right _v -> pure ()
|
||||
|
|
@ -152,6 +152,8 @@ test-suite agora-test
|
|||
Spec.Sample.Stake
|
||||
Spec.Stake
|
||||
|
||||
Spec.Util
|
||||
|
||||
build-depends:
|
||||
, agora
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue