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.
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-venvAlgorand 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
└── sandboxIf 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.
At first create the root directory:
cd ~
mkdir algorand
cd algorandThen clone both repositories:
git clone https://github.com/ipaleka/algorand-contracts-testing.git
git clone https://github.com/algorand/sandbox.gitAs always for the Python-based projects, you should create a Python environment and activate it:
python3 -m venv contractsvenv
source contractsvenv/bin/activateNow change the directory to the project root directory and install the project dependencies with:
(contractsvenv) $ cd algorand-contracts-testing
(contractsvenv) $ pip install -r requirements.txtPlease 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 -vFor speeding up the tests run, issue the following to use three of your processor's cores in parallel:
(contractsvenv) $ pytest -v -n 3If you want a fresh start, reset the Sandbox with:
../sandbox/sandbox clean
../sandbox/sandbox up