An example of automated testing TEAL smart contracts (for the Algorand Blockchain).
- Clone this repository so you have a local copy.
- Start an Algorand Sandbox.
- Edit
scripts/environment.js
with the connection details for your Algorand Sandbox. - Node.js must be installed to run the deployment and testing scripts in this repo.
To deploy the contract or run "actual" tests you need to know the mnemonic for the account in the Sandbox that will deploy the smart contract. You must set CREATOR_MNEMONIC
environment vairable to the mnemonic like this:
export CREATOR_MNEMONIC=<mnemonic_for_the_creator_account>
Or on Windows:
set CREATOR_MNEMONIC=<mnemonic_for_the_creator_account>
Install dependencies:
npm install
The smart contract in this repo can be deployed to your Sandbox by invoking:
npm run deploy
Note the app id for the deployed smart contract. You will need this later to interact with the contract and in the next section if you want to delete it.
Invokes the increment "method" of the teal-counter:
npm run increment -- <app-id>
Invokes the decrement "method" of the teal-counter:
npm run decrement -- <app-id>
This is useful to test that the counterValue
global is being incremented and decremented correctly:
npm run show-globals -- <app-id>
If you want to remove the contract and clean up your Sandbox, invoke:
npm run delete -- <api-id>
Run automated tests against your Sandbox:
npm run test-actual
Simulated tests don't require any Algorand virtual machine (AVM) to run. You don't need any Algorand Sandbox to to run these tests, they are simulated via a teal-interpreter.
Run them like this:
npm run test-simulated
Or more simply:
npm test