Testing Guide
The Algorand TypeScript Testing framework provides powerful tools for testing Algorand TypeScript smart contracts within a Node.js environment. This guide covers the main features and concepts of the framework, helping you write effective tests for your Algorand applications.
For all code examples in the _Testing Guide_ section, assume `context` is an instance of `TestExecutionContext` obtained using the initialising an instance of `TestExecutionContext` class. All subsequent code is executed within this context.
The Algorand TypeScript Testing framework streamlines unit testing of your Algorand TypeScript smart contracts by offering functionality to:
- Simulate the Algorand Virtual Machine (AVM) environment
- Create and manipulate test accounts, assets, applications, transactions, and ARC4 types
- Test smart contract classes, including their states, variables, and methods
- Verify logic signatures and subroutines
- Manage global state, local state, scratch slots, and boxes in test contexts
- Simulate transactions and transaction groups, including inner transactions
- Verify opcode behavior
By using this framework, you can ensure your Algorand TypeScript smart contracts function correctly before deploying them to a live network.
Key features of the framework include:
TestExecutionContext
: The main entry point for testing, providing access to various testing utilities and simulated blockchain state- AVM Type Simulation: Accurate representations of AVM types like
uint64
andbytes
- ARC4 Support: Tools for testing ARC4 contracts and methods, including struct definitions and ABI encoding/decoding
- Transaction Simulation: Ability to create and execute various transaction types
- State Management: Tools for managing and verifying global and local state changes
- Opcode Simulation: Implementations of AVM opcodes for accurate smart contract behavior testing
The framework is designed to work seamlessly with Algorand TypeScript smart contracts, allowing developers to write comprehensive unit tests that closely mimic the behavior of contracts on the Algorand blockchain.