Skip to content

Create smart contracts in Algorand and test them using pytest.

License

Notifications You must be signed in to change notification settings

ipaleka/algorand-contracts-testing

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

37 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

py-algorand-sdk-pyteal-pytest

Create two Algorand smart contracts using Python Algorand SDK, respectively PyTeal package, and test them using pytest.


Security warning

This project has not been audited and should not be used in a production environment.


Requirements

You should have Python 3 installed on your system. Also, this tutorial uses python3-venv for creating virtual environments - install it in a Debian/Ubuntu based systems by issuing the following command:

$ sudo apt-get install python3-venv

Algorand Sandbox must be installed on your computer. It is implied that the Sandbox executable is in the sandbox directory next to this project directory:

$ tree -L 1
.
├── algorand-contracts-testing
└── sandbox

If that's not the case, then you should set SANDBOX_DIR environment variable holding sandbox directory before running the tests, like the following:

export SANDBOX_DIR="/home/ipaleka/dev/algorand/sandbox"

If you want to clone the repositories, not just download them, then you should have Git installed on your computer.

Setup

At first create the root directory:

cd ~
mkdir algorand
cd algorand

Then clone both repositories:

git clone https://github.com/ipaleka/algorand-contracts-testing.git
git clone https://github.com/algorand/sandbox.git

As always for the Python-based projects, you should create a Python environment and activate it:

python3 -m venv contractsvenv
source contractsvenv/bin/activate

Now change the directory to the project root directory and install the project dependencies with:

(contractsvenv) $ cd algorand-contracts-testing
(contractsvenv) $ pip install -r requirements.txt

Please bear in mind that starting the Sandbox for the first time takes time. If that's the case then your first tests run will take longer than usual.

Run the tests with:

(contractsvenv) $ pytest -v

For speeding up the tests run, issue the following to use three of your processor's cores in parallel:

(contractsvenv) $ pytest -v -n 3

Troubleshooting

If you want a fresh start, reset the Sandbox with:

../sandbox/sandbox clean
../sandbox/sandbox up

TL; DR

Algorand-smart-contracts-testing-in-pytest.mp4

About

Create smart contracts in Algorand and test them using pytest.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages