Checking conditions β
Asserts β
Check that the boolean expression condition
evaluates to True
and raises an error if it doesnβt. This is useful to prevent an entry point from proceeding if certain conditions are not met (e.g. in a contract that manages accounts a client cannot withdraw more money than they deposited).
An optional parameter message
is raised if condition is not met. When message is not present, an exception of the form WrongCondition: ...
is raised depending on the Exception Optimization Level.
sp.verify(cond,Β message=None)
Check that a condition is True
and otherwise raises an exception with message
.
sp.verify(condition, message = "Condition `<condition>` is false")
Equality Checking β
sp.verify_equal(v1, v2,Β message=None)
Checks that v1
and v2
are equal and of the same types. This works on both comparable and non-comparable types as long as the types are packable.
sp.verify_equal(v1, v2, message = "Condition `<condition>` is false")