Skip to main content
In this tutorial, you will run an ownership assertion against a small contract. You will see a normal operation succeed, an ownership change revert, and a temporary change escape an endpoint-only check. This is a self-contained Book exercise in a credible-std checkout. If you want to run existing tests before adding your own, start with Run an Example Policy Locally; that starter lesson uses a different repository.

Prerequisites

Install PCL and Git. This walkthrough was re-tested with PCL 1.9.0 and Solidity 0.8.29 on Linux ARM64 on 2026-11-17. It uses local contracts and needs no wallet or RPC connection.

1. Check out the reviewed library

The command compiles and lists tests for the book profile. Compilation does not execute assertions. At this revision, the book profile has no supplied behavior tests; add the test below before running pcl test.

2. Add a target and three tests

Save this file as examples/assertions-book/test/OwnerPolicy.t.sol:
The target deliberately has an unrestricted ownership setter so the assertion has a violating transaction to reject. Its owner occupies slot 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

Expected result: 3 passed, 0 failed.

What You Learned

The owner check rejects a permanent change and rolls back that transaction. It permits a temporary change that restores the owner before the endpoint comparison, even though another call observed the temporary owner. Passing an endpoint check therefore does not prove that authority stayed unchanged throughout execution. You also tested only the owner assertion function. The source’s admin check needs a separate fixture; the three passing tests do not establish its behavior.

Next Steps