From f05a883472e9c3784783c7c0ae1a8127f7af47d5 Mon Sep 17 00:00:00 2001 From: Mikhail <16622558+mmv08@users.noreply.github.com> Date: Fri, 24 Nov 2023 15:54:14 +0100 Subject: [PATCH] Add ganache to docker-compose file, use it in the run-tests.sh script (#697) --- docker-compose.yml | 5 +++++ run_tests.sh | 29 +++-------------------------- 2 files changed, 8 insertions(+), 26 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index 09fb3b88a..ba0867d58 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -7,3 +7,8 @@ services: - "5432:5432" environment: POSTGRES_PASSWORD: postgres + ganache: + image: trufflesuite/ganache:latest + ports: + - "8545:8545" + command: --defaultBalanceEther 10000 --gasLimit 10000000 -a 30 --chain.chainId 1337 --chain.networkId 1337 -d diff --git a/run_tests.sh b/run_tests.sh index ea5d15807..af996472f 100755 --- a/run_tests.sh +++ b/run_tests.sh @@ -1,32 +1,9 @@ #!/bin/sh # Postgresql and ganache-cli must be running for the tests -ps aux | grep ganache-cli | grep -v grep > /dev/null -if [ $? -eq 1 ]; then - echo 'Running Ganache-Cli' - ganache-cli --defaultBalanceEther 10000 --gasLimit 10000000 -a 30 --chain.chainId 1337 --chain.networkId 1337 -d > /dev/null & - GANACHE_PID=$! - sleep 3 -fi - -docker ps | grep '\->5432' > /dev/null -if [ $? -eq 1 ]; then - docker-compose up -d db - sleep 3 - DATABASE_UP=1 -else - DATABASE_UP=0 -fi - +docker-compose up -d db ganache +sleep 3 # python manage.py test --settings=config.settings.test DJANGO_SETTINGS_MODULE=config.settings.test pytest - -if [ ${GANACHE_PID:-0} -gt 1 ]; then - echo 'Killing opened Ganache-Cli' - kill $GANACHE_PID -fi - -if [ $DATABASE_UP -eq 1 ]; then - docker-compose down -fi +docker-compose down