✍️Writing Properties

Everything you need to know about writing properties

With fuzzing you can automatically test properties (also called property-based testing). So, you'll first need to write some properties.

Diligence Fuzzing supports multiple property formats, but our preferred option is Scribble.

Scribble

Scribble is a specification language for smart contracts where you write properties as annotations in your code. These annotations can be translated into runtime checks that trigger whenever a specified property is violated. This way Diligence Fuzzing can tell you exactly which property was violated.

Example Scribble property:

// #if_succeeds balance(_to) == old(balance(_to)) + amount;
function transfer(address _to, uint amount) public { ... }

Learn more about Scribble over at docs.scribble.codes.

Other formats

Assertions

We don't just find property violations of Scribble properties, but we also detect regular assertion failures.

Property-Based Testing

We realise that you might already have test-cases for property-based testing tools. For this reason we've implemented a utility which converts such tests to Scribble-annotations!

Last updated