This repository was archived by the owner on Dec 2, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +15
-0
lines changed
plutus-contract/src/Plutus/Contract/Test
plutus-use-cases/test/Spec Expand file tree Collapse file tree 2 files changed +15
-0
lines changed Original file line number Diff line number Diff line change @@ -96,6 +96,8 @@ module Plutus.Contract.Test.ContractModel
9696 , SchemaConstraints
9797 , ContractInstanceSpec (.. )
9898 , HandleFun
99+ -- ** Model properties
100+ , propSanityCheckModel
99101 -- ** Emulator properties
100102 , propRunActions_
101103 , propRunActions
@@ -1111,6 +1113,12 @@ checkNoCrashes = foldr (\ (ContractInstanceSpec k w c) -> (assertOutcome c (inst
11111113 notError Done {} = True
11121114 notError NotDone {} = True
11131115
1116+ -- | Sanity check a `ContractModel`. Ensures that wallet balances are not always unchanged.
1117+ propSanityCheckModel :: forall state . ContractModel state => Property
1118+ propSanityCheckModel = QC. expectFailure $ noBalanceChanges . stateAfter @ state
1119+ where
1120+ noBalanceChanges s = all isZero (s ^. balanceChanges)
1121+
11141122-- $noLockedFunds
11151123-- Showing that funds can not be locked in the contract forever.
11161124
Original file line number Diff line number Diff line change @@ -19,6 +19,7 @@ module Spec.GameStateMachine
1919 , prop_Game , propGame' , prop_GameWhitelist
2020 , prop_NoLockedFunds
2121 , prop_CheckNoLockedFundsProof
22+ , prop_SanityCheckModel
2223 ) where
2324
2425import Control.Lens
@@ -171,6 +172,9 @@ prop_Game = propRunActions_ handleSpec
171172prop_GameWhitelist :: Actions GameModel -> Property
172173prop_GameWhitelist = checkErrorWhitelist handleSpec defaultWhitelist
173174
175+ prop_SanityCheckModel :: Property
176+ prop_SanityCheckModel = propSanityCheckModel @ GameModel
177+
174178propGame' :: LogLevel -> Actions GameModel -> Property
175179propGame' l = propRunActionsWithOptions
176180 (set minLogLevel l defaultCheckOptions)
@@ -293,6 +297,9 @@ tests =
293297
294298 , testProperty " can always get the funds out" $
295299 withMaxSuccess 10 prop_NoLockedFunds
300+
301+ , testProperty " sanity check the contract model" $
302+ prop_SanityCheckModel
296303 ]
297304
298305initialVal :: Value
You can’t perform that action at this time.
0 commit comments