A Test Context is a context manager that provides a simulated Algorand environment for testing TypeScript smart contracts. It allows developers to create and manipulate a virtual Algorand ecosystem for testing purposes. For more details, see the Test Context section in our documentation.
The Algorand Virtual Machine (AVM) is the runtime environment for Algorand smart contracts. It executes the compiled code of smart contracts on the Algorand blockchain. To learn more about the AVM, visit the official Algorand documentation.
Operational Codes, or opcodes, are AVM instructions that are executed directly by the AVM. In the context of Algorand TypeScript testing, these opcodes are provided by algorand-typescript-testing
stubs and are either emulated, implemented, or mocked by algorand-typescript-testing
. For a comprehensive list of opcodes, refer to the Algorand Developer Documentation.
Value Generators are helper methods that generate randomized values for testing when the specific value of the tested type is not important. In the context of Algorand TypeScript testing, these are represented by property on the context manager, accessed via any.*
(any.txn.*
, or any.arc4.*
. in the case of ARC 4 types). To understand how to use Value Generators effectively, check out our Value Generators section in the documentation.
The Algorand TypeScript Testing framework emulates the Algorand Virtual Machine (AVM) for unit testing Algorand TypeScript smart contracts without interacting with the real Algorand Network. However, it has some limitations due to its scope and purpose:
- Simplified balance tracking and transaction validation
- No consensus mechanism or AVM network operations simulation
- Absence of a strict opcode budget system
- Certain cryptographic operations are mocked or simplified
- No state proof generation or verification
For scenarios where these limitations are crucial, it's recommended to pair this framework with integration testing. If you have a solid reason to justify introducing new emulated behaviour, please open an issue or contribute to the project on Github.
The framework uses simplified balance tracking and transaction validation. For scenarios where precise balance or fee verification is important, it's recommended to complement unit tests with integration testing.
No, the framework does not simulate the entire AVM network or consensus mechanism. It focuses on emulating the parts of the AVM relevant to unit testing smart contracts.
The framework does not implement a strict opcode budget system. For scenarios where validating opcode budget is crucial, it's recommended to use integration testing alongside this framework.
Some cryptographic operations are mocked or simplified in the framework. For a detailed list of which operations are mocked, refer to the mockable types under the coverage section.
While this framework is useful for unit testing and local development, it should not be the only tool used for security-critical validations or performance benchmarking. It's designed to approximate AVM behavior for common scenarios. Always complement your testing with additional integration testing options available in algokit
, where you can test against real localnet or testnet environments.
Yes, the algokit-typescript-template
, accessible via algokit init
, provides a working example of how to structure algorand-typecript-testing
along with regular integration tests against localnet.
An `algokit-typescript-template` accessible via `algokit init -t typescript`, provides a comprehensive and customizable working example of how to structure `algorand-typescript-testing` along with regular integration tests against localnet.
Yes, it is compatible with vitest
and any other TypeScript testing framework as its agnostic of the testing framework as long as it's TypeScript. If you spot incompatibility with a certain tool, please open an issue or contribute to the project on Github.