(Fix) Replace testrpc with ganache-cli

This commit is contained in:
Vadim Arasev 2018-05-22 15:44:04 +03:00
parent e402159041
commit d9db06704b
6 changed files with 247 additions and 2212 deletions

1
.gitignore vendored
View File

@ -3,5 +3,6 @@ build
flat
mochawesome-report
coverageEnv
scTopics
.DS_Store
contracts.json

View File

@ -4,7 +4,7 @@ merge:
node_modules/.bin/sol-merger "src/*.sol" build
testrpc:
node_modules/.bin/testrpc -p 8544 \
node_modules/.bin/ganache-cli -p 8544 \
--account="0x7e9a1de56cce758c544ba5dea3a6347a4a01c453d81edc32c2385e9767f29505, 1000000000000000000000000000" \
--account="0xf2029a2f20a9f57cd1a9a2a44c63d0c875f906c646f333b028cb6f1c38ef7db5, 1000000000000000000000000000" \
--account="0x84f24b0dddc8262675927168bbbf8688f846bcaedc2618ae576d34c043401719, 1000000000000000000000000000" \
@ -13,12 +13,14 @@ testrpc:
--account="0x1fdc76364db4a4bcfad8f2c010995a96fcb98a165e34858665a234ba54715123, 1000000000000000000000000000" \
--account="0x1fdc76364db4a4bcfad8f2c010995a96fcb98a165e34858665a234ba54715104, 1000000000000000000000000000" \
--account="0x1fdc76364db4a4bcfad8f2c010995a96fcb98a165e34858665a234ba54715105, 1000000000000000000000000000" \
--account="0x1fdc76364db4a4bcfad8f2c010995a96fcb98a165e34858665a234ba54715106, 1000000000000000000000000000" \
--account="0x1fdc76364db4a4bcfad8f2c010995a96fcb98a165e34858665a234ba54715107, 1000000000000000000000000000" \
test:
node_modules/.bin/truffle test --network test
solhint:
solhint contracts/*.sol contracts/util/*.sol
solhint "contracts/**/*.sol"
travis_test:
nohup make testrpc &

2411
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -5,7 +5,7 @@
"main": "",
"scripts": {
"test": "bash scripts/test.sh",
"coverage": "scripts/coverage.sh"
"coverage": "SOLIDITY_COVERAGE=true bash scripts/test.sh"
},
"author": "Roman Storm & Viktor Baranov",
"license": "MIT",
@ -13,11 +13,11 @@
"chai": "^4.1.2",
"chai-as-promised": "^7.1.1",
"chai-bignumber": "^2.0.2",
"ethereumjs-testrpc": "^6.0.3",
"mochawesome": "^3.0.0",
"ganache-cli": "^6.1.0",
"mochawesome": "^3.0.2",
"moment": "^2.19.3",
"solhint": "^1.2.1",
"solidity-coverage": "^0.4.15",
"solidity-coverage": "^0.5.2",
"truffle": "^4.1.8"
},
"dependencies": {}

View File

@ -1,3 +0,0 @@
#!/usr/bin/env bash
SOLIDITY_COVERAGE=true scripts/test.sh

View File

@ -7,23 +7,23 @@ set -o errexit
trap cleanup EXIT
cleanup() {
# Kill the testrpc instance that we started (if we started one and if it's still running).
if [ -n "$testrpc_pid" ] && ps -p $testrpc_pid > /dev/null; then
kill -9 $testrpc_pid
# Kill the ganache-cli instance that we started (if we started one and if it's still running).
if [ -n "$ganache_pid" ] && ps -p $ganache_pid > /dev/null; then
kill -9 $ganache_pid
fi
}
if [ "$SOLIDITY_COVERAGE" = true ]; then
testrpc_port=8555
ganache_port=8555
else
testrpc_port=8544
ganache_port=8544
fi
testrpc_running() {
nc -z localhost "$testrpc_port"
ganache_running() {
nc -z localhost "$ganache_port"
}
start_testrpc() {
start_ganache() {
# We define 10 accounts with balance 1M ether, needed for high-value tests.
local accounts=(
--account="0x2bdd21761a483f71054e14f5b827213567971c676928d9a1808cbfa4b7501200,1000000000000000000000000"
@ -39,19 +39,19 @@ start_testrpc() {
)
if [ "$SOLIDITY_COVERAGE" = true ]; then
node_modules/.bin/testrpc-sc --gasLimit 0xfffffffffff --port "$testrpc_port" "${accounts[@]}" > /dev/null &
node_modules/.bin/testrpc-sc --gasLimit 0xfffffffffff --port "$ganache_port" "${accounts[@]}" > /dev/null &
else
node_modules/.bin/testrpc --gasLimit 0xfffffffffff "${accounts[@]}" > /dev/null &
node_modules/.bin/ganache-cli --gasLimit 0xfffffffffff "${accounts[@]}" > /dev/null &
fi
testrpc_pid=$!
ganache_pid=$!
}
if testrpc_running; then
echo "Using existing testrpc instance"
if ganache_running; then
echo "Using existing ganache-cli instance"
else
echo "Starting our own testrpc instance"
start_testrpc
echo "Starting our own ganache-cli instance"
start_ganache
fi
if [ "$SOLIDITY_COVERAGE" = true ]; then