Something good is always possible: testing smart contracts with QuickCheck
summary
A QuickCheck-based framework for Cardano Plutus contracts generates random sequences of wallet actions, models contract state, and shrinks failing runs; it finds real crashes (one failure required 10 tests and 6 shrinks) and exposes missing preconditions (start-once, token ownership). The example builds a passworded guessing game that forges a game token, shows off-chain/on-chain testing with Plutus and QuickCheck, adds a small strategy language to prove a liveness goal, and runs 100 (typically 10,000) tests to validate that recovery always works.
AI-written summary · about
chapters (13)
- 0:00Smart contract testing intro
- 1:56Cardano and Haskell matter
- 4:02Cardano smart contracts
- 7:08On-chain vs off-chain testing
- 9:37QuickCheck for smart contracts
- 13:24Guessing game contract model
- 15:08First test failure and shrinking
- 17:38Adding preconditions
- 20:08Beyond safety: liveness tests
- 22:35Goal-reaching strategies
- 26:28Recovery strategy refinement
- 28:57New PBT opportunities
- 29:20Closing remarks and Q&A
related talks
51mA Deal with the Devil: Breaking Smart Contracts
19mTop 5 Tricks for Smart Contract Productivity
54mMy Little Token (Part 1)
45mPresent & Future of Blockchain Ⅱ
23mGradual Verification for Smart Contracts
25mCommSec D2 - Smart Contract (In)Security
16mTips and Tricks to Deploy L1 Smart Contracts on Optimism
20mLearning How to Build Secure Smart Contracts
