Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Proposal: "single monad" interface for test cases #132

Open
mikekeke opened this issue Sep 8, 2022 · 0 comments
Open

Proposal: "single monad" interface for test cases #132

mikekeke opened this issue Sep 8, 2022 · 0 comments

Comments

@mikekeke
Copy link
Collaborator

mikekeke commented Sep 8, 2022

Now Plutip lets user build test case like this

        assertExecution                                  -- start of test case
          "Some description"                -- description
          (initAda [100])                                -- wallets initialization
          (withContract $ \walletsKeys -> someContract)  -- contract execution
          [ shouldSucceed                                -- asserions
          , yieldSatisfies "Returns single UTxO" ((== 1) . Map.size)
          ]

During mob design session there was discussion about providing alternative (less restricted?) syntax with ability to add wallets, run contracts and run assertions directly, something like:

       contractTestCase  -- start of test case
         "Some description"  -- description
         $ do
            wallet1 <- addWallet [adaAmount1, adaAmount2]  -- initialize wallet
            result1 <- runContract (someContract $ getWalletPkh wallet1)  -- run contract and get result
            
            result1 @?= someExpectedResult  -- HUnit assertion
            assertSomethingOnResult result1  -- user defined assertion of type `Assertion`
            
            wallet2 <- addWallet [adaAmount3]   -- initialize another wallet
            result2 <- runContract (anotherContract $ getWalletPkh wallet2)  -- run contract and get result
           
           assertWalletValueEq (wallet2, someValue)  -- library provided assertion of type `Assertion`
         ]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant