Skip to content

Commit

Permalink
Add Docker image of Ganache node for testing (#46)
Browse files Browse the repository at this point in the history
* add a script to build ganache image

Signed-off-by: Toshihiko Okubo <[email protected]>
  • Loading branch information
toshihiko-okubo authored Aug 4, 2021
1 parent f39b1f4 commit e464ebf
Show file tree
Hide file tree
Showing 33 changed files with 18,507 additions and 111 deletions.
79 changes: 79 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ env:
CACHE_DOCKER_FABRIC_DIR: /tmp/fabric
CACHE_DOCKER_TENDERMINT_KEY: docker-tendermint
CACHE_DOCKER_TENDERMINT_DIR: /tmp/tendermint
CACHE_DOCKER_ETHEREUM_GANACHE_KEY: docker-ethereum-ganache
CACHE_DOCKER_ETHEREUM_GANACHE_DIR: /tmp/ethereum/ganache

jobs:
relayer-build:
Expand Down Expand Up @@ -98,6 +100,43 @@ jobs:
fabric-peer0-org2:latest \
fabric-chaincode-org2:latest
ethereum-build:
name: ethereum-build
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: '12'
- uses: actions/cache@v2
id: cache-docker-ethereum-ganache
with:
path: ${{ env.CACHE_DOCKER_ETHEREUM_GANACHE_DIR }}
key: ${{ runner.os }}-${{ env.CACHE_DOCKER_ETHEREUM_GANACHE_KEY }}-${{ github.sha }}
- uses: actions/cache@v2
id: cache-ethereum-contract
if: steps.cache-docker-ethereum-ganache.outputs.cache-hit != 'true'
with:
path: tests/chains/ethereum/contract/node_modules
key: ${{ runner.os }}-ethereum-contract-${{ hashFiles('tests/chains/ethereum/contract/package-lock.json') }}
restore-keys: |
${{ runner.os }}-ethereum-contract-
- name: Install node_modules
if: steps.cache-docker-ethereum-ganache.outputs.cache-hit != 'true'
working-directory: ./tests/chains/ethereum/contract
run: |
npm install
- name: Build docker images
if: steps.cache-docker-ethereum-ganache.outputs.cache-hit != 'true'
working-directory: ./tests/chains/ethereum
run: |
make docker-images
- name: Save docker images
if: steps.cache-docker-ethereum-ganache.outputs.cache-hit != 'true'
working-directory: ./tests/scripts
run: |
./save_docker_images $CACHE_DOCKER_ETHEREUM_GANACHE_DIR ethereum-ganache0:latest ethereum-ganache1:latest
tm2tm-test:
name: tm2tm-test
runs-on: ubuntu-20.04
Expand Down Expand Up @@ -204,3 +243,43 @@ jobs:
make network
make test
make network-down
tm2eth-test:
name: tm2eth-test
runs-on: ubuntu-20.04
needs:
- relayer-build
- tendermint-build
- ethereum-build
steps:
- uses: actions/checkout@v2
- name: Restore relayer binary cache
uses: actions/cache@v2
with:
path: ${{ env.CACHE_BIN_RELAYER_PATH }}
key: ${{ runner.os }}-${{ env.CACHE_BIN_RELAYER_KEY }}-${{ github.sha }}
- name: Restore Tendermint docker image cache
uses: actions/cache@v2
with:
path: ${{ env.CACHE_DOCKER_TENDERMINT_DIR }}
key: ${{ runner.os }}-${{ env.CACHE_DOCKER_TENDERMINT_KEY }}-${{ github.sha }}
- name: Load Tendermint docker image
working-directory: ./tests/scripts
run: |
./load_docker_images $CACHE_DOCKER_TENDERMINT_DIR tendermint-chain0:latest
- name: Restore Ethereum docker image cache
uses: actions/cache@v2
with:
path: ${{ env.CACHE_DOCKER_ETHEREUM_GANACHE_DIR }}
key: ${{ runner.os }}-${{ env.CACHE_DOCKER_ETHEREUM_GANACHE_KEY }}-${{ github.sha }}
- name: Load Ethereum docker image
working-directory: ./tests/scripts
run: |
./load_docker_images $CACHE_DOCKER_ETHEREUM_GANACHE_DIR \
ethereum-ganache0:latest
- name: Run Test
working-directory: ./tests/cases/tm2eth
run: |
make network
make test
make network-down
12 changes: 2 additions & 10 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -198,12 +198,8 @@ github.com/danieljoos/wincred v1.0.2 h1:zf4bhty2iLuwgjgpraD2E9UbvO+fe54XXGJbOwe2
github.com/danieljoos/wincred v1.0.2/go.mod h1:SnuYRW9lp1oJrZX/dXJqr0cPK5gYXqx3EJbmjhLdK9U=
github.com/datachainlab/fabric-sdk-go v0.0.0-20200730074927-282a61dcd92e h1:Vr+tcT4FHYYUwOE4xU/H9XhIHAu+1j7lF6uv83DIjO8=
github.com/datachainlab/fabric-sdk-go v0.0.0-20200730074927-282a61dcd92e/go.mod h1:qWE9Syfg1KbwNjtILk70bJLilnmCvllIYFCSY/pa1RU=
github.com/datachainlab/ibc-mock-client v0.0.0-20210729090421-a068e70e733b h1:XnQRHEkBL1ZgHupeYc2E2c9xzxpoXROOmZBYlBI7fbE=
github.com/datachainlab/ibc-mock-client v0.0.0-20210729090421-a068e70e733b/go.mod h1:yz5E2DpB3FJZZjagC4HcW51km5HesF1tFQRr6k0HQvA=
github.com/datachainlab/ibc-mock-client v0.0.0-20210730150559-e9334c30b8c6 h1:o3WWUALD3GtjszeTApmfqVDh2KRmfQuAvrlkkxYR0eQ=
github.com/datachainlab/ibc-mock-client v0.0.0-20210730150559-e9334c30b8c6/go.mod h1:yz5E2DpB3FJZZjagC4HcW51km5HesF1tFQRr6k0HQvA=
github.com/datachainlab/ibc-mock-client v0.0.0-20210801010718-05f8b1087574 h1:5m6ylWxSPVPawO7yEdvxjeKixNN4X2ueYs7g+i9JGTM=
github.com/datachainlab/ibc-mock-client v0.0.0-20210801010718-05f8b1087574/go.mod h1:yz5E2DpB3FJZZjagC4HcW51km5HesF1tFQRr6k0HQvA=
github.com/datachainlab/ibc-mock-client v0.0.0-20210801020446-f9dbe7320294 h1:pRUeO7K9GreilvFiasPyV5Ia5eGHrH/A5qWCnOUoeis=
github.com/datachainlab/ibc-mock-client v0.0.0-20210801020446-f9dbe7320294/go.mod h1:yz5E2DpB3FJZZjagC4HcW51km5HesF1tFQRr6k0HQvA=
github.com/davecgh/go-spew v0.0.0-20171005155431-ecdeabc65495/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
Expand Down Expand Up @@ -486,10 +482,6 @@ github.com/hyperledger-labs/yui-corda-ibc/go v0.0.0-20210708002039-e07ff163f660
github.com/hyperledger-labs/yui-corda-ibc/go v0.0.0-20210708002039-e07ff163f660/go.mod h1:Lzjc/wAuoo0kJ5doB/BIH8L/FZVKjHFfBNOe2oPFDgs=
github.com/hyperledger-labs/yui-fabric-ibc v0.2.0 h1:ARJ7Rxse9sP6Wf/UGuUnsOV3nS8er78Rit7slmz9OcE=
github.com/hyperledger-labs/yui-fabric-ibc v0.2.0/go.mod h1:0ey1+ANFpyz+8m9e7XqFk9+75VsECKBWPPp4Yf3cTZI=
github.com/hyperledger-labs/yui-ibc-solidity v0.0.0-20210729081912-2f7ddf319320 h1:cddCtPiav/ci0gF9a/xRAlQfJCpj/idW28LNdYDeKEE=
github.com/hyperledger-labs/yui-ibc-solidity v0.0.0-20210729081912-2f7ddf319320/go.mod h1:Y3rEZX46slCFPSXzTRZsbj6F3OgbM+6VvDnnUBmi2mI=
github.com/hyperledger-labs/yui-ibc-solidity v0.0.0-20210731143941-601d9e76a859 h1:lok/BOFV/oyt1AyEhSRAqthmUZ39glZPRzmg4Noair0=
github.com/hyperledger-labs/yui-ibc-solidity v0.0.0-20210731143941-601d9e76a859/go.mod h1:Y3rEZX46slCFPSXzTRZsbj6F3OgbM+6VvDnnUBmi2mI=
github.com/hyperledger-labs/yui-ibc-solidity v0.0.0-20210801023756-05047b73f120 h1:Fz5GVT+paFhLpUNK+odK0r11rqhHcPX/DaCguAmFlVE=
github.com/hyperledger-labs/yui-ibc-solidity v0.0.0-20210801023756-05047b73f120/go.mod h1:Y3rEZX46slCFPSXzTRZsbj6F3OgbM+6VvDnnUBmi2mI=
github.com/hyperledger/fabric v1.4.0-rc1.0.20200416031218-eff2f9306191 h1:e2Np9BoOHxufPGnGm3qyTh9sIarBpg57RlIvE62yCYE=
Expand Down
34 changes: 29 additions & 5 deletions tests/cases/docker-compose-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ services:
- 6060:6060
- 9090:9090
healthcheck:
test: "wget -q -O - http://localhost:26657/health || exit1"
test: "wget -q -O - http://localhost:26657/health || exit 1"
interval: 30s
timeout: 10s
retries: 5
Expand All @@ -30,7 +30,7 @@ services:
- 6061:6060
- 9091:9090
healthcheck:
test: "wget -q -O - http://localhost:26657/health || exit1"
test: "wget -q -O - http://localhost:26657/health || exit 1"
interval: 30s
timeout: 10s
retries: 5
Expand All @@ -57,7 +57,7 @@ services:
- 7050:7050
- 8443:8443
healthcheck:
test: "wget -q -O - http://localhost:8443/healthz || exit1"
test: "wget -q -O - http://localhost:8443/healthz || exit 1"
interval: 30s
timeout: 10s
retries: 5
Expand Down Expand Up @@ -97,7 +97,7 @@ services:
- 7053:7053
- 9443:9443
healthcheck:
test: "wget -q -O - http://localhost:9443/healthz || exit1"
test: "wget -q -O - http://localhost:9443/healthz || exit 1"
interval: 30s
timeout: 10s
retries: 5
Expand Down Expand Up @@ -136,7 +136,7 @@ services:
- 8053:8053
- 9444:9443
healthcheck:
test: "wget -q -O - http://localhost:9443/healthz || exit1"
test: "wget -q -O - http://localhost:9443/healthz || exit 1"
interval: 30s
timeout: 10s
retries: 5
Expand All @@ -150,3 +150,27 @@ services:
- 18051:18051
networks:
- *network-common

# Ethereum - ganache
ethereum-ganache0:
container_name: ethereum-ganache0
image: ethereum-ganache0:${TAG}
ports:
- 8545:8545
networks:
- *network-common
healthcheck: &healthcheck-ganache
test: ["CMD", "wget", "--spider", "--post-data", '{"jsonrpc": "2.0", "id": 1, "method": "net_version"}', "http://localhost:8545"]
interval: 5s
timeout: 3s
retries: 10
start_period: 5s
ethereum-ganache1:
container_name: ethereum-ganache1
image: ethereum-ganache1:${TAG}
ports:
- 8645:8545
networks:
- *network-common
healthcheck:
*healthcheck-ganache
2 changes: 1 addition & 1 deletion tests/cases/fab2fab/scripts/handshake
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

set -eux

source $(cd $(dirname "$0"); pwd)/util
source $(cd $(dirname "$0"); pwd)/../../../scripts/util

SCRIPT_DIR=$(cd $(dirname $0); pwd)
RLY_BINARY=${SCRIPT_DIR}/../../../../build/uly
Expand Down
21 changes: 0 additions & 21 deletions tests/cases/fab2fab/scripts/util

This file was deleted.

2 changes: 1 addition & 1 deletion tests/cases/tm2eth/.gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
fixtures/
output/
configs/demo/ibc-1.json
7 changes: 4 additions & 3 deletions tests/cases/tm2eth/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,18 @@ network:
-f ../docker-compose-test.yaml \
up -d \
tendermint-chain0 \
# ganache0
ethereum-ganache0
make wait-for-launch ATTEMPT=10 CONTAINER=ethereum-ganache0

.PHONY: test
test:
./scripts/fixture
./scripts/init-rly
./scripts/handshake
./scripts/test-tx
#./scripts/test-tx

.PHONY: network-down
network-down:
TAG=${DOCKER_TAG} $(DOCKER_COMPOSE) \
-f ../docker-compose-test.yaml \
down --volume --remove-orphans
down -v --remove-orphans
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
"rpc_addr": "http://localhost:8545",
"hdw_mnemonic": "math razor capable expose worth grape metal sunset metal sudden usage scheme",
"hdw_path": "m/44'/60'/0'/0/0",
"ibc_host_address": "0xff77D90D6aA12db33d3Ba50A34fB25401f6e4c4F",
"ibc_handler_address": "0x2F5703804E29F4252FA9405B8D357220d11b3bd9"
"ibc_host_address": "",
"ibc_handler_address": ""
},
"prover": {
"@type": "/relayer.provers.mock.config.ProverConfig"
Expand Down
15 changes: 13 additions & 2 deletions tests/cases/tm2eth/scripts/fixture
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,19 @@ rm -rf ${FIXTURES_DIR}
# for tendermint

mkdir -p ${FIXTURES_DIR}/tendermint/ibc0
# retrive the mnemonic from the container to the local
# retrieve the mnemonic from the container to the local
${DOCKER} cp tendermint-chain0:/root/data/ibc0/key_seed.json ${FIXTURES_DIR}/tendermint/ibc0/key_seed.json

# for ethereum
# TODO implements
mkdir -p ${FIXTURES_DIR}/ethereum/chain0/contracts
# retrieve the mnemonic and files with contract address from the container to the local
${DOCKER} cp ethereum-ganache0:/root/mnemonic ${FIXTURES_DIR}/ethereum/chain0/
${DOCKER} cp ethereum-ganache0:/root/contracts ${FIXTURES_DIR}/ethereum/chain0/

# generate a json file for Relayer configuration from a template file
IBCHostAddress=$(cat ${FIXTURES_DIR}/ethereum/chain0/contracts/IBCHost)
IBCHandlerAddress=$(cat ${FIXTURES_DIR}/ethereum/chain0/contracts/IBCHandler)

sed -e "s/\"ibc_host_address\": \"\"/\"ibc_host_address\": \"${IBCHostAddress}\"/" \
-e "s/\"ibc_handler_address\": \"\"/\"ibc_handler_address\": \"${IBCHandlerAddress}\"/" \
configs/tpl/ibc-1.json.tpl > configs/demo/ibc-1.json
2 changes: 1 addition & 1 deletion tests/cases/tm2eth/scripts/handshake
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

set -eux

source $(cd $(dirname "$0"); pwd)/util
source $(cd $(dirname "$0"); pwd)/../../../scripts/util

SCRIPT_DIR=$(cd $(dirname $0); pwd)
RLY_BINARY=${SCRIPT_DIR}/../../../../build/uly
Expand Down
21 changes: 0 additions & 21 deletions tests/cases/tm2eth/scripts/util

This file was deleted.

2 changes: 1 addition & 1 deletion tests/cases/tm2fab/scripts/handshake
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

set -eux

source $(cd $(dirname "$0"); pwd)/util
source $(cd $(dirname "$0"); pwd)/../../../scripts/util

SCRIPT_DIR=$(cd $(dirname $0); pwd)
RLY_BINARY=${SCRIPT_DIR}/../../../../build/uly
Expand Down
21 changes: 0 additions & 21 deletions tests/cases/tm2fab/scripts/util

This file was deleted.

2 changes: 1 addition & 1 deletion tests/cases/tm2tm/scripts/handshake
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

set -eux

source $(cd $(dirname "$0"); pwd)/util
source $(cd $(dirname "$0"); pwd)/../../../scripts/util

SCRIPT_DIR=$(cd $(dirname $0); pwd)
RLY_BINARY=${SCRIPT_DIR}/../../../../build/uly
Expand Down
21 changes: 0 additions & 21 deletions tests/cases/tm2tm/scripts/util

This file was deleted.

6 changes: 6 additions & 0 deletions tests/chains/ethereum/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
contract
node_modules
scripts
Makefile

!contract/build
Loading

0 comments on commit e464ebf

Please sign in to comment.