Skip to content

Commit

Permalink
integration tools (#140)
Browse files Browse the repository at this point in the history
* Docker images for gaia chains

* Added GitHub Actions to run integration test with two chains

* Relayer GitHub Actions configuration and testing

* Integration test fixes

* Integration fixes

* HEIGHT fix

* Separated cargo runs

* Another test for build and config

* Moved chain_a creation into one shell space

* Fix for chain_b config

* Integration tests fail because they don't exist

* Trying test command

* Docs update

* Simapp and new genesis

* Added pruning=nothing for simd config

* Update ci/simapp/README.md

Co-authored-by: Ethan Buchman <ethan@coinculture.info>
  • Loading branch information
greg-szabo and ebuchman authored Jul 14, 2020
1 parent 6ef76fa commit f5469f1
Show file tree
Hide file tree
Showing 19 changed files with 1,139 additions and 0 deletions.
50 changes: 50 additions & 0 deletions .github/workflows/integration.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: Integration test
on: [push]
jobs:
test-integration-stable:
runs-on: ubuntu-latest
services:
chain1:
image: informaldev/chain_a
ports:
- 26656:26656
- 26657:26657
chain2:
image: informaldev/chain_b
ports:
- 26556:26656
- 26557:26657
steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true
- uses: actions-rs/cargo@v1
with:
command: build
args: -p relayer-cli --bins
- name: Set up chain_a
run: |
TRUSTED_HEADER="$(curl -s http://localhost:26657/status)"
HASH="$(echo "${TRUSTED_HEADER}" | jq -r .result.sync_info.latest_block_hash)"
HEIGHT="$(echo "${TRUSTED_HEADER}" | jq -r .result.sync_info.latest_block_height)"
cargo run --bin relayer -- -c relayer/relay/tests/config/fixtures/relayer_conf_example.toml light init -x "${HASH}" -h "${HEIGHT}" chain_A
- name: Set up chain_b
run: |
TRUSTED_HEADER="$(curl -s http://localhost:26557/status)"
HASH="$(echo "${TRUSTED_HEADER}" | jq -r .result.sync_info.latest_block_hash)"
HEIGHT="$(echo "${TRUSTED_HEADER}" | jq -r .result.sync_info.latest_block_height)"
cargo run --bin relayer -- -c relayer/relay/tests/config/fixtures/relayer_conf_example.toml light init -x "${HASH}" -h "${HEIGHT}" chain_B
- name: Run relayer in the background
run: |
cargo run --bin relayer -- -c relayer/relay/tests/config/fixtures/relayer_conf_example.toml start --reset &
sleep 3
- uses: actions-rs/cargo@v1
with:
command: run
args: --bin relayer -- -v -c relayer/relay/tests/config/fixtures/relayer_conf_example.toml query connection end chain_A testconnection
# - uses: actions-rs/cargo@v1
# with:
# command: test
# args: --test integration --no-fail-fast
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,14 @@ Requires Rust 1.42+ (might work on earlier versions but this has not been tested
These are instructions for setting up a local development environment with two
IBC-enabled local blockchains that the relayer can run against.

### Using Docker
For alternative setup using scripts, check the next section.
```shell script
docker run --rm -d -p 26656:26656 -p 26657:26657 informaldev/chain_a
docker run --rm -d -p 26556:26656 -p 26557:26657 informaldev/chain_b
```

### Using scripts
Dependencies:

- `jq`, a command-line JSON processor
Expand Down
2 changes: 2 additions & 0 deletions ci/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
gaia/
cosmos-sdk/
44 changes: 44 additions & 0 deletions ci/build-chains.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#!/usr/bin/env bash

## Programmatic list for creating Gaia Hub chains for testing IBC.
## Instead of blindly running this code, read it line by line and understand the dependecies and tasks.
## Prerequisites: Log into Docker Hub
set -eou pipefail
GAIA_BRANCH="master" # Requires a version with the `--keyring-backend` option. v2.1 and above.

echo "*** Requirements"
which git && which go && which make && which sed && which jq && which docker

echo "*** Fetch gaiad source code"
git clone https://github.com/cosmos/gaia || echo "Already cloned."
cd gaia
git checkout "${GAIA_BRANCH}" -q

echo "*** Build binary"
GOOS=linux make build

echo "*** Create config using the built binary"
docker run -it --rm -v $(pwd)/build:/root:z alpine /root/gaiad testnet -o /root/chain_a --v 1 --chain-id chain_A --keyring-backend test
sed -i.bak -e 's/^index_all_keys[[:space:]]*=.*/index_all_keys = true/' build/chain_a/node0/gaiad/config/config.toml
sed -i.bak -e 's/^timeout_commit[[:space:]]*=.*/timeout_commit = "1s"/' build/chain_a/node0/gaiad/config/config.toml
sed -i.bak -e 's/^timeout_propose[[:space:]]*=.*/timeout_propose = "1s"/' build/chain_a/node0/gaiad/config/config.toml

docker run -it --rm -v $(pwd)/build:/root:z alpine /root/gaiad testnet -o /root/chain_b --v 1 --chain-id chain_B --keyring-backend test
sed -i.bak -e 's/^index_all_keys[[:space:]]*=.*/index_all_keys = true/' build/chain_b/node0/gaiad/config/config.toml
sed -i.bak -e 's/^timeout_commit[[:space:]]*=.*/timeout_commit = "1s"/' build/chain_b/node0/gaiad/config/config.toml
sed -i.bak -e 's/^timeout_propose[[:space:]]*=.*/timeout_propose = "1s"/' build/chain_b/node0/gaiad/config/config.toml

echo "*** Create Docker image and upload to Docker Hub"
cd ..
docker build -t informaldev/chain_a -f chain_a.Dockerfile .
docker build -t informaldev/chain_b -f chain_b.Dockerfile .

# Get details from the config files
echo SECRET_A=$(jq -r .secret gaia/build/chain_a/node0/gaiacli/key_seed.json)
echo SECRET_B=$(jq -r .secret gaia/build/chain_b/node0/gaiacli/key_seed.json)
echo NODEID_A=$(jq -r .app_state.genutil.gentxs[0].value.memo gaia/build/chain_a/node0/gaiad/config/genesis.json)
echo NODEID_B=$(jq -r .app_state.genutil.gentxs[0].value.memo gaia/build/chain_b/node0/gaiad/config/genesis.json)

read -p "Press ENTER to push image to Docker Hub or CTRL-C to cancel. " dontcare
docker push informaldev/chain_a
docker push informaldev/chain_b
24 changes: 24 additions & 0 deletions ci/build-simd.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/usr/bin/env bash

## Programmatic list for creating a simd chain for testing IBC.
## Instead of blindly running this code, read it line by line and understand the dependecies and tasks.
## Prerequisites: Log into Docker Hub
set -eou pipefail
GAIA_BRANCH="master"

echo "*** Requirements"
which git && which go && which make && which docker

echo "*** Fetch gaiad source code"
git clone https://github.com/cosmos/cosmos-sdk || echo "Already cloned."
cd cosmos-sdk
git checkout "${GAIA_BRANCH}" -q

echo "*** Build binary"
GOOS=linux make build-simd

echo "*** Create Docker image and upload to Docker Hub"
cd ..
docker build -t informaldev/simd -f simd.Dockerfile .
read -p "Press ENTER to push image to Docker Hub or CTRL-C to cancel. " dontcare
docker push informaldev/simd
14 changes: 14 additions & 0 deletions ci/chain_a.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
FROM alpine
LABEL maintainer="hello@informal.systems"

EXPOSE 26656 26657 26660

ENTRYPOINT ["/usr/bin/gaiad"]

CMD ["start"]

VOLUME [ "/root" ]

COPY gaia/build/gaiad /usr/bin/gaiad
COPY gaia/build/chain_a/node0/gaiad /root/.gaiad
COPY gaia/build/chain_a/node0/gaiacli/key_seed.json /root/key_seed.json
14 changes: 14 additions & 0 deletions ci/chain_b.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
FROM alpine
LABEL maintainer="hello@informal.systems"

EXPOSE 26656 26657 26660

ENTRYPOINT ["/usr/bin/gaiad"]

CMD ["start"]

VOLUME [ "/root" ]

COPY gaia/build/gaiad /usr/bin/gaiad
COPY gaia/build/chain_b/node0/gaiad /root/.gaiad
COPY gaia/build/chain_b/node0/gaiacli/key_seed.json /root/key_seed.json
34 changes: 34 additions & 0 deletions ci/simapp/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# IBC Test

The `simapp` directory contains complete data for running an IBC enabled
blockchain using the `simd` app from the `Cosmos-SDK`.

It also comes with an account key for sending txs - the password is `asdfghjkl;'`

Run using Docker:
```
docker run --rm -p 26657:26657 informaldev/simd
```

Or install `simd` from the cosmos-sdk repo and run it with this genesis data:

```
git clone https://github.com/comsos/cosmos-sdk
cd cosmos-sdk
make build-simd
build/simd --home simapp start
```

This will start an IBC enabled blockchain with some initial IBC state that you
can then query. For instance:

```
curl 'localhost:26657/abci_query?path="store/ibc/key"&data="connections/connectionidone"'
curl 'localhost:26657/abci_query?path="store/ibc/key"&data="clients/ethbridge"'
curl 'localhost:26657/abci_query?path="store/ibc/key"&data="channels/firstchannel"'
```

will return the relevent proto encoded data.


:D
102 changes: 102 additions & 0 deletions ci/simapp/config/app.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
# This is a TOML config file.
# For more information, see https://github.com/toml-lang/toml

###############################################################################
### Base Configuration ###
###############################################################################

# The minimum gas prices a validator is willing to accept for processing a
# transaction. A transaction's fees must meet the minimum of any denomination
# specified in this config (e.g. 0.25token1;0.0001token2).
minimum-gas-prices = ""

# default: the last 100 states are kept in addition to every 500th state; pruning at 10 block intervals
# nothing: all historic states will be saved, nothing will be deleted (i.e. archiving node)
# everything: all saved states will be deleted, storing only the current state; pruning at 10 block intervals
# custom: allow pruning options to be manually specified through 'pruning-keep-recent', 'pruning-keep-every', and 'pruning-interval'
pruning = "nothing"

# These are applied if and only if the pruning strategy is custom.
pruning-keep-recent = "0"
pruning-keep-every = "0"
pruning-interval = "0"

# HaltHeight contains a non-zero block height at which a node will gracefully
# halt and shutdown that can be used to assist upgrades and testing.
#
# Note: Commitment of state will be attempted on the corresponding block.
halt-height = 0

# HaltTime contains a non-zero minimum block time (in Unix seconds) at which
# a node will gracefully halt and shutdown that can be used to assist upgrades
# and testing.
#
# Note: Commitment of state will be attempted on the corresponding block.
halt-time = 0

# InterBlockCache enables inter-block caching.
inter-block-cache = true

###############################################################################
### Telemetry Configuration ###
###############################################################################

[telemetry]

# Prefixed with keys to separate services
service-name = ""

# Enabled enables the application telemetry functionality. When enabled,
# an in-memory sink is also enabled by default. Operators may also enabled
# other sinks such as Prometheus.
enabled = false

# Enable prefixing gauge values with hostname
enable-hostname = false

# Enable adding hostname to labels
enable-hostname-label = false

# Enable adding service to labels
enable-service-label = false

# PrometheusRetentionTime, when positive, enables a Prometheus metrics sink.
prometheus-retention-time = 0

# GlobalLabels defines a global set of name/value label tuples applied to all
# metrics emitted using the wrapper functions defined in telemetry package.
#
# Example:
# [["chain_id", "cosmoshub-1"]]
global-labels = [
]

###############################################################################
### API Configuration ###
###############################################################################

[api]

# Enable defines if the API server should be enabled.
enable = false

# Swagger defines if swagger documentation should automatically be registered.
swagger = false

# Address defines the API server to listen on
address = "tcp://0.0.0.0:1317"

# MaxOpenConnections defines the number of maximum open connections
max-open-connections = 1000

# RPCReadTimeout defines the Tendermint RPC read timeout (in seconds)
rpc-read-timeout = 10

# RPCWriteTimeout defines the Tendermint RPC write timeout (in seconds)
rpc-write-timeout = 0

# RPCMaxBodyBytes defines the Tendermint maximum response body (in bytes)
rpc-max-body-bytes = 1000000

# EnableUnsafeCORS defines if CORS should be enabled (unsafe - use it at your own risk)
enabled-unsafe-cors = false
Loading

0 comments on commit f5469f1

Please sign in to comment.