Skip to content

input-output-hk/quickcheck-dynamic

Repository files navigation

quickcheck-dynamic

 

A library for testing stateful programs using QuickCheck and dynamic logic.

This repository hosts:

  • The core quickcheck-dynamic library providing tools for quickchecking stateful models,
  • Example of integrating io-sim's Haskell runtime simulator and quickcheck-dynamic to model and test complex multi-threaded application.

Documentation

The following talks provide concrete examples on how this approach is used to test smart contracts in Plutus:

The following blog posts and talks provide some more in-depth educational material on quickcheck-dynamic:

  • Edsko de Vries wrote a nice post to compare quickcheck-dynamic with quickcheck-state-machine, another library to write model-based tests on top of QuickCheck. This blog post introduces quickcheck-lockstep which provides lockstep-style testing on top of quickcheck-dynamic,
  • IOG published an introductory post on quickcheck-dynamic, detailing some rationale and background for this work, and suggesting a step-by-step approach to use it based on some real world experience.
  • A presentation from BOBKonf 2024 which provides a good overview of why one would want to use such a library, how it's been applied in some concrete projects, and some basic understanding of the mechanics.

Building

Without nix

This package uses Cabal-based build. To build from source:

  • Ensure both ghc and cabal executables are in your PATH.
    • ghcup is a great way to manage Haskell toolchain.
    • quickcheck-dynamic currently requires a GHC version > 8.10
  • Run
    cabal update && cabal build all
    
  • To run tests:
    cabal test all
    

With nix

This repository uses nix to provide a development and build environment.

For instructions on how to install and configure nix (including how to enable access to our binary caches), refer to this document.

If you already have nix installed and configured, you may enter the development shell by running nix develop.

  • To enter a shell providing a complete haskell toolchain:
    nix develop
    
    This can automated using direnv:
    direnv allow
    
  • Then go back to Without nix instructions