Skip to main content
Run an example policy that rejects ownership changes. Inspect its passing and failing cases in local tests.

Prerequisites

  • PCL 1.9.0 installed
  • Git; the pinned project selects Solidity 0.8.29, which PCL downloads on first use
No wallet or live transaction is required.

1. Clone the Starter

Clone the example project with its dependencies:
The project contains example protocol contracts in src, assertions in assertions/src, and tests in assertions/test.

2. Run the Tests

From the repository root, run:
The command compiles the project and runs the two ownership tests. Both passed with PCL 1.9.0 on Linux ARM64. The full starter suite at this revision has an unrelated failing PhyLock test; it is not the expected result of this lesson. The output includes these two Ownable cases; gas values and timing vary:
A passing ownership-change test means the test correctly observed the expected assertion rejection. It does not mean the rule permits ownership changes.

3. Inspect the Rule and Its Tests

Open assertions/src/OwnableAssertion.a.sol and assertions/test/OwnableAssertion.t.sol. The rule compares the owner before and after the candidate operation. In the test, cl.assertion() registers the assertion for the next external call. One case attempts a change and expects the assertion to revert; the other leaves the owner unchanged and passes. This rule rejects legitimate ownership transfers too. For a real protocol, define which changes should be allowed before adapting the example.

4. Understand What You Have Verified

The tests check ownership changes in the local harness. The starter contract has no Ethereum guard, so these tests do not establish production protection. Use the current Ethereum integration guide instead of the starter’s earlier deployment instructions.

Continue Exploring

Next, test the allowed and rejected cases and examine how the same rule treats a legitimate ownership transfer. For a separate exercise that exposes temporary ownership changes, follow Test the Limits of an Ownership Policy. That lesson uses a different checkout and adds three tests. To adapt the policy, see Writing Your Own Policies.