From 32b421ed09be320313116cc40f2ff0a9e3ab11fd Mon Sep 17 00:00:00 2001 From: Yijia Su Date: Tue, 13 Jul 2021 16:31:17 +0800 Subject: [PATCH 1/3] Fix CI --- .github/workflows/deploy-contract.yml | 2 +- Makefile | 13 ------ scripts/run-solidity-tests.sh | 60 ++------------------------- tests/solidity/test-helper.js | 6 +++ 4 files changed, 10 insertions(+), 71 deletions(-) diff --git a/.github/workflows/deploy-contract.yml b/.github/workflows/deploy-contract.yml index 0c0aa10adf..c60a6b884c 100644 --- a/.github/workflows/deploy-contract.yml +++ b/.github/workflows/deploy-contract.yml @@ -34,5 +34,5 @@ jobs: - name: Test contract run: | sudo make contract-tools - sudo make test-contract + sudo make test-solidity if: "env.GIT_DIFF != ''" diff --git a/Makefile b/Makefile index b1a58a2859..f179ae6db0 100755 --- a/Makefile +++ b/Makefile @@ -209,13 +209,6 @@ else @echo "protoc already installed; skipping..." endif -ifeq (, $(shell which solcjs)) - @echo "Installing solcjs..." - @npm install -g solc@0.5.11 -else - @echo "solcjs already installed; skipping..." -endif - docs-tools: ifeq (, $(shell which yarn)) @echo "Installing yarn..." @@ -316,12 +309,6 @@ test-rpc: test-rpc-pending: ./scripts/integration-test-all.sh -t "pending" -q 1 -z 1 -s 2 -m "pending" -r "true" -test-contract: - @type "npm" 2> /dev/null || (echo 'Npm does not exist. Please install node.js and npm."' && exit 1) - @type "solcjs" 2> /dev/null || (echo 'Solcjs does not exist. Please install solcjs using make contract-tools."' && exit 1) - @type "protoc" 2> /dev/null || (echo 'Failed to install protoc. Please reinstall protoc using make contract-tools.' && exit 1) - bash scripts/contract-test.sh - test-solidity: @echo "Beginning solidity tests..." ./scripts/run-solidity-tests.sh diff --git a/scripts/run-solidity-tests.sh b/scripts/run-solidity-tests.sh index 05765314d3..56a7389e35 100755 --- a/scripts/run-solidity-tests.sh +++ b/scripts/run-solidity-tests.sh @@ -1,16 +1,7 @@ #!/bin/bash -export GOPATH=~/go -export PATH=$PATH:$GOPATH/bin -go build -o ./build/ethermintd ./cmd/ethermintd -mkdir $GOPATH/bin -cp ./build/ethermintd $GOPATH/bin - -localKeyAddr=0x7cb61d4117ae31a12e393a1cfa3bac666481d02e -user1Addr=0xc6fe5d33615a1c52c08018c47e8bc53646a0e101 -user2Addr=0x963ebdf2e1f8db8707d05fc75bfeffba1b5bac17 - -CHAINID="ethermint-1337" +# remove existing daemon and client +rm -rf ~/.ethermintd* # build ethermint binary make install @@ -26,49 +17,4 @@ else yarn install fi -chmod +x ./init-test-node.sh -nohup ./init-test-node.sh > ethermintd.log 2>&1 & - -# give ethermintd node enough time to launch -echo "sleeping ..." -sleep 10 - -# show existing accounts -echo "account list: " -curl -X POST --data '{"jsonrpc":"2.0","method":"personal_listAccounts","params":[],"id":1}' -H "Content-Type: application/json" http://localhost:8545 - -# unlock localKey address -curl -X POST --data '{"jsonrpc":"2.0","method":"personal_unlockAccount","params":["'$localKeyAddr'", ""],"id":1}' -H "Content-Type: application/json" http://localhost:8545 - -# tests start -cd suites/initializable -yarn contract-migrate -yarn test-ethermint - -ok=$? - -if (( $? != 0 )); then - echo "initializable test failed: exit code $?" -fi - -killall ethermintd - -echo "Script exited with code $ok" -exit $ok - -# initializable-buidler fails on CI, re-add later - -./../../init-test-node.sh > ethermintd.log -cd ../initializable-buidler -yarn test-ethermint - -ok=$(($? + $ok)) - -if (( $? != 0 )); then - echo "initializable-buidler test failed: exit code $?" -fi - -killall ethermintd - -echo "Script exited with code $ok" -exit $ok \ No newline at end of file +yarn test --network ethermint \ No newline at end of file diff --git a/tests/solidity/test-helper.js b/tests/solidity/test-helper.js index b13a26fb5b..513341bf47 100644 --- a/tests/solidity/test-helper.js +++ b/tests/solidity/test-helper.js @@ -184,4 +184,10 @@ async function main() { process.exit(0); } +// Add handler to exit the program when UnhandledPromiseRejection + +process.on('unhandledRejection', () => { + process.exit(-1); +}); + main(); \ No newline at end of file From 82295aa03f4f6b159fb97c3f792a51d406d3ea84 Mon Sep 17 00:00:00 2001 From: Yijia Su Date: Tue, 13 Jul 2021 16:39:57 +0800 Subject: [PATCH 2/3] add test only initializable --- scripts/run-solidity-tests.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/run-solidity-tests.sh b/scripts/run-solidity-tests.sh index 56a7389e35..794dc5ad75 100755 --- a/scripts/run-solidity-tests.sh +++ b/scripts/run-solidity-tests.sh @@ -17,4 +17,4 @@ else yarn install fi -yarn test --network ethermint \ No newline at end of file +yarn test --network ethermint initializable \ No newline at end of file From dae5c3ddbbd92d0cb1f0ad11a0a68c2ce92faf63 Mon Sep 17 00:00:00 2001 From: Yijia Su Date: Tue, 13 Jul 2021 16:51:50 +0800 Subject: [PATCH 3/3] Fix CI --- .github/workflows/deploy-contract.yml | 2 +- Makefile | 13 ------ scripts/run-solidity-tests.sh | 58 ++------------------------- tests/solidity/test-helper.js | 6 +++ 4 files changed, 10 insertions(+), 69 deletions(-) diff --git a/.github/workflows/deploy-contract.yml b/.github/workflows/deploy-contract.yml index 0c0aa10adf..c60a6b884c 100644 --- a/.github/workflows/deploy-contract.yml +++ b/.github/workflows/deploy-contract.yml @@ -34,5 +34,5 @@ jobs: - name: Test contract run: | sudo make contract-tools - sudo make test-contract + sudo make test-solidity if: "env.GIT_DIFF != ''" diff --git a/Makefile b/Makefile index b1a58a2859..f179ae6db0 100755 --- a/Makefile +++ b/Makefile @@ -209,13 +209,6 @@ else @echo "protoc already installed; skipping..." endif -ifeq (, $(shell which solcjs)) - @echo "Installing solcjs..." - @npm install -g solc@0.5.11 -else - @echo "solcjs already installed; skipping..." -endif - docs-tools: ifeq (, $(shell which yarn)) @echo "Installing yarn..." @@ -316,12 +309,6 @@ test-rpc: test-rpc-pending: ./scripts/integration-test-all.sh -t "pending" -q 1 -z 1 -s 2 -m "pending" -r "true" -test-contract: - @type "npm" 2> /dev/null || (echo 'Npm does not exist. Please install node.js and npm."' && exit 1) - @type "solcjs" 2> /dev/null || (echo 'Solcjs does not exist. Please install solcjs using make contract-tools."' && exit 1) - @type "protoc" 2> /dev/null || (echo 'Failed to install protoc. Please reinstall protoc using make contract-tools.' && exit 1) - bash scripts/contract-test.sh - test-solidity: @echo "Beginning solidity tests..." ./scripts/run-solidity-tests.sh diff --git a/scripts/run-solidity-tests.sh b/scripts/run-solidity-tests.sh index 05765314d3..4e6366ef37 100755 --- a/scripts/run-solidity-tests.sh +++ b/scripts/run-solidity-tests.sh @@ -1,16 +1,9 @@ #!/bin/bash - export GOPATH=~/go export PATH=$PATH:$GOPATH/bin -go build -o ./build/ethermintd ./cmd/ethermintd -mkdir $GOPATH/bin -cp ./build/ethermintd $GOPATH/bin - -localKeyAddr=0x7cb61d4117ae31a12e393a1cfa3bac666481d02e -user1Addr=0xc6fe5d33615a1c52c08018c47e8bc53646a0e101 -user2Addr=0x963ebdf2e1f8db8707d05fc75bfeffba1b5bac17 -CHAINID="ethermint-1337" +# remove existing daemon and client +rm -rf ~/.ethermintd* # build ethermint binary make install @@ -26,49 +19,4 @@ else yarn install fi -chmod +x ./init-test-node.sh -nohup ./init-test-node.sh > ethermintd.log 2>&1 & - -# give ethermintd node enough time to launch -echo "sleeping ..." -sleep 10 - -# show existing accounts -echo "account list: " -curl -X POST --data '{"jsonrpc":"2.0","method":"personal_listAccounts","params":[],"id":1}' -H "Content-Type: application/json" http://localhost:8545 - -# unlock localKey address -curl -X POST --data '{"jsonrpc":"2.0","method":"personal_unlockAccount","params":["'$localKeyAddr'", ""],"id":1}' -H "Content-Type: application/json" http://localhost:8545 - -# tests start -cd suites/initializable -yarn contract-migrate -yarn test-ethermint - -ok=$? - -if (( $? != 0 )); then - echo "initializable test failed: exit code $?" -fi - -killall ethermintd - -echo "Script exited with code $ok" -exit $ok - -# initializable-buidler fails on CI, re-add later - -./../../init-test-node.sh > ethermintd.log -cd ../initializable-buidler -yarn test-ethermint - -ok=$(($? + $ok)) - -if (( $? != 0 )); then - echo "initializable-buidler test failed: exit code $?" -fi - -killall ethermintd - -echo "Script exited with code $ok" -exit $ok \ No newline at end of file +yarn test --network ethermint --verbose-log \ No newline at end of file diff --git a/tests/solidity/test-helper.js b/tests/solidity/test-helper.js index b13a26fb5b..513341bf47 100644 --- a/tests/solidity/test-helper.js +++ b/tests/solidity/test-helper.js @@ -184,4 +184,10 @@ async function main() { process.exit(0); } +// Add handler to exit the program when UnhandledPromiseRejection + +process.on('unhandledRejection', () => { + process.exit(-1); +}); + main(); \ No newline at end of file