ExamplesΒΆ

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

Contract Name

Test File

Key Features Demonstrated

Test versions of Algopy Abstractions used

Auction

test_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 Attendance

test_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 Voting

test_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 Whitelist

test_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 LogicSig

test_signature.py

- Testing of LogicSig contracts
- Verification of time-based conditions
- Mocking of transaction parameters

- logicsig
- Account
- Txn
- Global
- op

Marketplace

test_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 Storage

test_contract.py

- Testing of scratch space usage
- Verification of scratch slot values

- ARC4Contract
- Contract
- op