Prerequisites
Install PCL and Foundry. This walkthrough was tested with PCL1.6.0. It uses local contracts and needs no wallet or RPC connection.
1. Check out the reviewed library
pcl test.
2. Add a target and three tests
Save this file asexamples/assertions-book/test/OwnerPolicy.t.sol:
0, matching the example. It is a test fixture, not a contract to deploy.
cl.assertion arms the selected assertion function for the next monitored call. This test selects the owner check. The source also has an admin check, which needs its own fixture and tests.
3. Run the tests
Adapt the example
Replace the teaching target with your deployed contract’s layout and call paths. Keep the accepted, rejected, and restored-state cases. If temporary authority changes are prohibited, an endpoint equality check is insufficient; the policy must observe the relevant writes or operations. For a constructor with configuration arguments, appendabi.encode(...) to its creation code when calling cl.assertion. Do not fetch protocol state in that constructor: the assertion deployment runtime is isolated from the test’s contract state. Pass addresses explicitly and read protocol state during assertion execution.
Continue with the ERC-4626 policy. Test each selected assertion function through a matching trigger. Before deployment, run historical backtests and scenarios on a replica of your protocol in alerting.
