Test scenario is the current industry standard to ensure a contract has the expected behavior. Basically a test is a program that originates the contract(s), calls them and checks the storage value(s) and account(s) balances.
This article presents how to write and execute tests with Completium.
The goal is to check whether the contract is in the right state after a series of calls to
inc_value twice and
complete entrypoints, and to check whether the caller's balance is unchanged while transferring 5tz to
init (within cost of transactions).
The cost of transactions is accumulated in the local
cost variable. It is used to test that the caller has got back the 5 tezies send to
The script is using the current account and endpoint, shown with the Completium CLI commands:
This means the script is using the
edo network with the account
admin. It is possible to programmatically switch account and endpoint from within the test scenario.
Edit the package file to set the test command:
Launch the test with:
$completium-cli provides the possibility to run the scenario on a local sandbox network.
In order to launch the test in a sandbox, run the following script: