diff --git a/foundry.toml b/foundry.toml index d4e6301d..e0a6f2d5 100644 --- a/foundry.toml +++ b/foundry.toml @@ -2,7 +2,7 @@ src = 'contracts' out = 'out' libs = ['node_modules'] -test = 'test' +match-path = 'test/foundry' optimizer = true optimizer_runs = 200 via_ir = true diff --git a/package.json b/package.json index 53aaaafa..7419fc8f 100644 --- a/package.json +++ b/package.json @@ -12,6 +12,8 @@ "build": "forge build", "test:hardhat": "npx hardhat test", "test:foundry": "forge test", + "test:ci": "scripts/run-test.sh", + "test:anvil": "anvil --hardfork istanbul --mnemonic 'clock radar mass judge dismiss just intact mind resemble fringe diary casino' -p 9545 --gas-limit 10000000 --gas-price 0 --code-size-limit 999999 --accounts 200", "template:process": "node scripts/process-templates.cjs", "coverage": "SOLIDITY_COVERAGE=true npx hardhat coverage --solcoverjs .solcover.cjs", "bor:simulate": "cd test-bor-docker && bash run-docker.sh", diff --git a/scripts/run-test.sh b/scripts/run-test.sh new file mode 100644 index 00000000..8bf3dff6 --- /dev/null +++ b/scripts/run-test.sh @@ -0,0 +1,46 @@ +#!/usr/bin/env bash + +# Exit script as soon as a command fails. +set -o errexit + +# Executes cleanup function at script exit. +trap cleanup EXIT + +# get current directory +PWD=$(pwd) + +cleanup() { + echo "Cleaning up" + pkill -f ganache-cli + cd $PWD/test-bor-docker + bash stop-docker.sh + bash clean.sh + cd .. + echo "Done" +} + +start_testrpc() { + npm run test:anvil > /dev/null & +} + +start_blockchain() { + cd $PWD/test-bor-docker + bash run-docker.sh + cd .. +} + + +echo "Starting our own testrpc instance" +start_testrpc + +echo "Starting our own geth instance" +start_blockchain + +if [ "$SOLIDITY_COVERAGE" = true ]; then + npm run coverage "$@" +else + npm run test:hardhat "$@" + npm run test:foundry "$@" +fi + +