From 248bcc30084ff6b8668a4e217178d2a1dd55c0fd Mon Sep 17 00:00:00 2001 From: noot <36753753+noot@users.noreply.github.com> Date: Fri, 18 Sep 2020 12:50:08 -0400 Subject: [PATCH] add test-solidity to github actions, create test script (#510) --- .github/workflows/test.yml | 17 ++++++++++ Makefile | 6 +++- app/ethermint.go | 1 + scripts/run-solidity-tests.sh | 61 +++++++++++++++++++++++++++++++++++ 4 files changed, 84 insertions(+), 1 deletion(-) create mode 100755 scripts/run-solidity-tests.sh diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 8ead5643..4be6dbde 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -210,3 +210,20 @@ jobs: run: | make test-import if: "env.GIT_DIFF != ''" + + test-solidity: + runs-on: ubuntu-latest + timeout-minutes: 10 + steps: + - uses: actions/checkout@v2 + - uses: technote-space/get-diff-action@v3.1 + id: git_diff + with: + SUFFIX_FILTER: | + .go + .mod + .sum + - name: test-solidity + run: | + make test-solidity + if: "env.GIT_DIFF != ''" diff --git a/Makefile b/Makefile index f55418c5..a3a81c48 100644 --- a/Makefile +++ b/Makefile @@ -292,7 +292,11 @@ test-sim-multi-seed-short: runsim @echo "Running multi-seed application simulation. This may take awhile!" @$(BINDIR)/runsim -Jobs=4 -SimAppPkg=$(SIMAPP) -ExitOnFail 50 10 TestFullAppSimulation -.PHONY: test test-unit test-race test-import test-rpc test-contract +test-solidity: + @echo "Beginning solidity tests..." + ./scripts/run-solidity-tests.sh + +.PHONY: test test-unit test-race test-import test-rpc test-contract test-solidity .PHONY: test-sim-nondeterminism test-sim-custom-genesis-fast test-sim-import-export test-sim-after-import \ test-sim-custom-genesis-multi-seed test-sim-multi-seed-long test-sim-multi-seed-short diff --git a/app/ethermint.go b/app/ethermint.go index 6ee05307..65d71a04 100644 --- a/app/ethermint.go +++ b/app/ethermint.go @@ -396,5 +396,6 @@ func GetMaccPerms() map[string][]string { for k, v := range maccPerms { dupMaccPerms[k] = v } + return dupMaccPerms } diff --git a/scripts/run-solidity-tests.sh b/scripts/run-solidity-tests.sh new file mode 100755 index 00000000..891e5ca5 --- /dev/null +++ b/scripts/run-solidity-tests.sh @@ -0,0 +1,61 @@ +#!/bin/bash + +export GOPATH=~/go +export PATH=$PATH:$GOPATH/bin +go build -o ./build/ethermintd ./cmd/ethermintd +go build -o ./build/ethermintcli ./cmd/ethermintcli +mkdir $GOPATH/bin +cp ./build/ethermintd $GOPATH/bin +cp ./build/ethermintcli $GOPATH/bin + +cd tests-solidity + +if command -v yarn &> /dev/null; then + yarn install +else + curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add - + echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list + sudo apt update && sudo apt install yarn + yarn install +fi + +chmod +x ./init-test-node.sh +./init-test-node.sh > ethermintd.log & +sleep 5 +ethermintcli rest-server --laddr "tcp://localhost:8545" --unlock-key localkey,user1,user2 --chain-id 1337 --trace --wsport 8546 > ethermintcli.log & + +cd suites/initializable +yarn test-ethermint + +ok=$? + +if (( $? != 0 )); then + echo "initializable test failed: exit code $?" +fi + +killall ethermintcli +killall ethermintd + +echo "Script exited with code $ok" +exit $ok + +# initializable-buidler fails on CI, re-add later + +./../../init-test-node.sh > ethermintd.log & +sleep 5 +ethermintcli rest-server --laddr "tcp://localhost:8545" --unlock-key localkey,user1,user2 --chain-id 1337 --trace --wsport 8546 > ethermintcli.log & + +cd ../initializable-buidler +yarn test-ethermint + +ok=$(($? + $ok)) + +if (( $? != 0 )); then + echo "initializable-buidler test failed: exit code $?" +fi + +killall ethermintcli +killall ethermintd + +echo "Script exited with code $ok" +exit $ok \ No newline at end of file