Skip to content

Testing

Writing tests for Contracts

Writing tests for contracts is not as straightforward as for normal Rust programs, because we are in a no_std environment and are using smart contracts that are meant to run in the VM.

There are currently two feasible ways to test your contracts:

  • Integration tests can be used to test the interface of the created WASM module with an ephemeral_vm from rusk-abi. Integration tests can only call the functions which are publicly available (Every function that got wrapped with rusk-abi through wrap_call).
  • Deployment & testing on the testnet Nocturne. This can also be automated through a testing project that makes use of the wallet-sdk from Integrations.

An example for integration testing can be seen in the tests folder of our genesis contracts, for example the staking contract or the transfer contract.

Testing on Nocturne

Testing on Nocturne requires you to deploy the smart contract to the Nocturne chain and call the functions there via transactions. To get nDusk for the testnet you can use the Faucet.

Additional Resources

  • More information on Rusts integration testing capabilities can also be found in the Rust book section about integration tests.