Skip to content

An example of automated testing TEAL (Algorand) smart contracts.

Notifications You must be signed in to change notification settings

hone-labs/teal-testing-example

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

36 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

teal-testing-example

An example of automated testing TEAL smart contracts (for the Algorand Blockchain).

Prerequisites

  1. Clone this repository so you have a local copy.
  2. Start an Algorand Sandbox.
  3. Edit scripts/environment.js with the connection details for your Algorand Sandbox.
  4. Node.js must be installed to run the deployment and testing scripts in this repo.

Setup

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

Deploy the smart contract

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.

Invoking smart contract methods

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>

Show globals

This is useful to test that the counterValue global is being incremented and decremented correctly:

npm run show-globals -- <app-id>

Delete the smart contract

If you want to remove the contract and clean up your Sandbox, invoke:

npm run delete -- <api-id>

Run "actual" automated tests

Run automated tests against your Sandbox:

npm run test-actual

Run "simulated" automated tests

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

About

An example of automated testing TEAL (Algorand) smart contracts.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published