Testing
Smart contract testing is vital to ensure safe, resilient, and accurate computation.
Guides in this category:
📄️ Implement basic tests for a contract
A contract's test functions can be used as a simple way to ensure a contract's functions behave as expected. The increment example contract has a function that increments a counter by one on every invocation. The corresponding test invokes that function several time, ensuring with assert_eq!(...) the count increases as expected.
📄️ Test authorized contract invocations
A contract's test functions can be used as a way to ensure the authorization is indeed carried out the way a developer intends. A simple example can be found in the auth example contract. (In the following code block, some code has been omitted for brevity.)