WIP simple sample test for Stake policy

This commit is contained in:
Emily Martins 2022-03-09 22:00:02 +01:00
parent 9aa5f5b1a3
commit a2ea0a46f5
9 changed files with 256 additions and 137 deletions

39
agora-test/Spec/Stake.hs Normal file
View file

@ -0,0 +1,39 @@
module Spec.Stake (tests) where
--------------------------------------------------------------------------------
import Prelude
--------------------------------------------------------------------------------
import Test.Tasty (TestTree, testGroup)
import Test.Tasty.HUnit (assertFailure, testCase)
--------------------------------------------------------------------------------
import Plutarch (compile)
import Plutarch.Evaluate (evaluateScript)
import Plutus.V1.Ledger.Scripts (Script)
--------------------------------------------------------------------------------
import Agora.Stake (stakePolicy)
--------------------------------------------------------------------------------
import Plutarch.Builtin (pforgetData)
import Spec.Sample.Stake qualified as Stake
--------------------------------------------------------------------------------
tests :: [TestTree]
tests =
[ testGroup "policy" $
[ scriptTest "minting" (compile $ stakePolicy Stake.stake # pforgetData (pconstantData ()) # pconstant Stake.stakeCreation)
]
]
scriptTest :: String -> Script -> TestTree
scriptTest name script = testCase name $ do
case evaluateScript script of
Left e -> assertFailure (show e)
Right _v -> pure ()