Permalink
Browse files

Merge pull request #388 from input-output-hk/playground-test

add new playground test
  • Loading branch information...
j-mueller committed Dec 6, 2018
2 parents 02a3121 + f5f12f4 commit 9fd833d94489afc36498d32ee09d1f748b111fa3
Showing with 45 additions and 3 deletions.
  1. +45 −3 plutus-playground/plutus-playground-server/test/Playground/UsecasesSpec.hs
@@ -46,7 +46,8 @@ vestingSpec =
[ Action
(Fn "vestFunds")
(Wallet 1)
[JSON.String "{\"vestingTranche1\":{\"vestingTrancheDate\":{\"getHeight\":1},\"vestingTrancheAmount\":{\"getValue\":1}},\"vestingTranche2\":{\"vestingTrancheDate\":{\"getHeight\":1},\"vestingTrancheAmount\":{\"getValue\":1}},\"vestingOwner\":{\"getPubKey\":1}}"
[ JSON.String
"{\"vestingTranche1\":{\"vestingTrancheDate\":{\"getHeight\":1},\"vestingTrancheAmount\":{\"getValue\":1}},\"vestingTranche2\":{\"vestingTrancheDate\":{\"getHeight\":1},\"vestingTrancheAmount\":{\"getValue\":1}},\"vestingOwner\":{\"getPubKey\":1}}"
, JSON.String "{\"getValue\": 1}"
]
]
@@ -55,8 +56,49 @@ vestingSpec =
gameSpec :: Spec
gameSpec =
describe "game" $
it "should compile" $ compile game >>= (`shouldSatisfy` isRight)
describe "game" $ do
it "should compile" $ compile game >>= (`shouldSatisfy` isRight)
it
"Sequential fund transfer fails - 'Game' script - 'payToPublicKey' action" $
evaluate payAll >>=
(`shouldSatisfy` hasFundsDistribution
[ (Wallet 1, 10)
, (Wallet 2, 10)
, (Wallet 3, 10)
])
where
payAll =
Evaluation
[(Wallet 1, 10), (Wallet 2, 10), (Wallet 3, 10)]
[ Action
(Fn "payToPublicKey")
(Wallet 1)
[ JSON.String "{\"getValue\":9}"
, JSON.String "{\"getPubKey\":2}"
]
, Action
(Fn "payToPublicKey")
(Wallet 2)
[ JSON.String "{\"getValue\":9}"
, JSON.String "{\"getPubKey\":3}"
]
, Action
(Fn "payToPublicKey")
(Wallet 3)
[ JSON.String "{\"getValue\":9}"
, JSON.String "{\"getPubKey\":1}"
]
]
(sourceCode game)
[]
hasFundsDistribution ::
[(Wallet, Value)]
-> Either PlaygroundError (Blockchain, [EmulatorEvent], [(Wallet, Value)])
-> Bool
hasFundsDistribution _ (Left _) = False
hasFundsDistribution requiredDistribution (Right (_, _, actualDistribution)) =
requiredDistribution == actualDistribution
messagesSpec :: Spec
messagesSpec =

0 comments on commit 9fd833d

Please sign in to comment.