Skip to content
This repository has been archived by the owner on Nov 15, 2022. It is now read-only.

mlabs-haskell/apropos-tx

Repository files navigation

This repo has been superseded by apropos and hedgehog-plutus-simple

Some functionality of apropos-tx may not be available in hedgehog-plutus-simple. For example:

  • Ability to test memory usage limits

  • Ability to simultaneously check script success and resource usage.

If you need these features, please open an issue at hedgehog-plutus-simple.

apropos-tx

Plutus and Plutarch extensions for apropos.

Modelling Script behaviour with ScriptModel

A logical model that can describe when a script should validate/error can be used to test a Script. This example uses Plutarch to create the script inline but the ScriptModel class is language agnostic and will work with any means of creating a Plutus Script. The script function requires only that you can convert the type (in this case Int) to a Script.

instance ScriptModel IntProp Int where
  expect _ = Var IsSmall :&&: Var IsNegative
  script _ i =
    let ii = fromIntegral i :: Integer
     in compile (pif ((fromInteger ii #< (0 :: Term s PInteger)) #&& ((fromInteger (-10) :: Term s PInteger) #<= fromInteger ii)) (pcon PUnit) perror)

tests :: TestTree
tests =
  testGroup "intPermutationGenPlutarchTests" $
    fromGroup
      <$> [ runScriptTestsWhere (Apropos :: Int :+ IntProp) "AcceptsSmallNegativeInts" Yes
          ]

What is this?

For more information please see the examples directory.

The code is licensed under Apache 2.0; check the LICENSE.md file for details.