Skip to content

Examples

Below is a showcase of various examples of unit testing real and sample Algorand Python smart contracts using algorand-python-testing.

Detailed per-example pages are generated from the repository examples/ folders and available in this section’s sidebar.

Contract NameTest FileKey Features DemonstratedTest versions of Algopy Abstractions used
Auctiontest_contract.py- Use of algopy_testing_context
- Mocking of global state and transaction fields
- Testing of ARC4 contract methods
- Emulation of asset creation and transfers
- Verification of inner transactions
- ARC4Contract
- Global
- Txn
- Asset
- Account
- LocalState
Proof of Attendancetest_contract.py- Creation and management of dummy assets
- Testing of box storage operations
- Verification of inner transactions for asset transfers
- Use of any.* methods for generating test data
- ARC4Contract
- Box
- BoxMap
- Asset
- Account
- op
Simple Votingtest_contract.py- Testing of global and local state operations
- Verification of transaction group operations
- Mocking of payment transactions
- Contract
- GlobalState
- LocalState
- Txn
- op.GTxn
ZK Whitelisttest_contract.py- Testing of zero-knowledge proof verification
- Mocking of external application calls
- Use of ARC4 types and methods
- ARC4Contract
- ARC4 types
- LocalState
- Global
- Txn
HTLC LogicSigtest_signature.py- Testing of LogicSig contracts
- Verification of time-based conditions
- Mocking of transaction parameters
- logicsig
- Account
- Txn
- Global
- op
Marketplacetest_contract.py- Testing of complex marketplace operations
- Use of BoxMap for listings
- Testing of asset transfers and payments
- ARC4Contract
- BoxMap
- Asset
- ARC4 types
- Global
- Txn
Scratch Storagetest_contract.py- Testing of scratch space usage
- Verification of scratch slot values
- ARC4Contract
- Contract
- op