move scriptTest to Util module
This commit is contained in:
parent
9dc89bcf55
commit
b58ccfd785
3 changed files with 30 additions and 12 deletions
|
|
@ -7,13 +7,11 @@ import Prelude
|
||||||
--------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------
|
||||||
|
|
||||||
import Test.Tasty (TestTree, testGroup)
|
import Test.Tasty (TestTree, testGroup)
|
||||||
import Test.Tasty.HUnit (assertFailure, testCase)
|
|
||||||
|
|
||||||
--------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------
|
||||||
|
|
||||||
import Plutarch (compile)
|
import Plutarch (compile)
|
||||||
import Plutarch.Evaluate (evalScript)
|
import Plutarch.Builtin (pforgetData)
|
||||||
import Plutus.V1.Ledger.Scripts (Script)
|
|
||||||
|
|
||||||
--------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
@ -21,10 +19,11 @@ import Agora.Stake (stakePolicy)
|
||||||
|
|
||||||
--------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------
|
||||||
|
|
||||||
import Plutarch.Builtin (pforgetData)
|
|
||||||
import Spec.Sample.Stake qualified as Stake
|
import Spec.Sample.Stake qualified as Stake
|
||||||
|
import Spec.Util (scriptTest)
|
||||||
|
|
||||||
--------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------
|
||||||
|
|
||||||
tests :: [TestTree]
|
tests :: [TestTree]
|
||||||
tests =
|
tests =
|
||||||
[ testGroup
|
[ testGroup
|
||||||
|
|
@ -32,11 +31,3 @@ tests =
|
||||||
[ scriptTest "minting" (compile $ stakePolicy Stake.stake # pforgetData (pconstantData ()) # pconstant Stake.stakeCreation)
|
[ 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.Sample.Stake
|
||||||
Spec.Stake
|
Spec.Stake
|
||||||
|
|
||||||
|
Spec.Util
|
||||||
|
|
||||||
build-depends:
|
build-depends:
|
||||||
, agora
|
, agora
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue