Skip to content

Commit

Permalink
Merge pull request #13 from hadronlabs-org/feat/integration-tests
Browse files Browse the repository at this point in the history
Add integration tests #LIDO-71
  • Loading branch information
ratik authored Dec 12, 2023
2 parents a0ed4f5 + b15ebdb commit 89ce726
Show file tree
Hide file tree
Showing 68 changed files with 8,305 additions and 5 deletions.
39 changes: 36 additions & 3 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,6 @@ jobs:
os: [ubuntu-latest]
steps:
- uses: actions/checkout@v1
with:
fetch-depth: 1
- uses: actions-rs/toolchain@v1
with:
toolchain: 1.73.0
Expand All @@ -55,4 +53,39 @@ jobs:
- run: cargo build
- run: cargo test --verbose --all
env:
RUST_BACKTRACE: 1
RUST_BACKTRACE: 1
integration-test:
name: Actions - integration test
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest]
steps:
- name: Upgrade docker compose to use v2
run: sudo curl -L "https://github.com/docker/compose/releases/download/v2.23.0/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose && sudo chmod +x /usr/local/bin/docker-compose
- uses: actions/checkout@v1
with:
fetch-depth: 1
- uses: actions-rs/toolchain@v1
with:
toolchain: 1.73.0
profile: minimal
override: true
- name: Setup node
uses: actions/setup-node@v3
with:
cache: 'yarn'
cache-dependency-path: integration_tests/yarn.lock
- name: Lint
run: cd integration_tests && yarn --ignore-engines && yarn lint
# - name: Build images
# run: |
# cd integration_tests
# cat package.json | grep -e "build-[a-z]*-image\"" | awk -F: '{print $1}' | tr -d ' ",{}' | xargs -I % -P 3 yarn %
- name: Build images
run: |
cd integration_tests
yarn build-images
- run: make compile
- name: Run tests
run: cd integration_tests && yarn test
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.idea/
target/
artifacts/
**/schema/
**/schema/
/artifacts/
6 changes: 6 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"editor.formatOnSave": true,
"editor.codeActionsOnSave": {
"source.fixAll.eslint": "explicit"
}
}
8 changes: 8 additions & 0 deletions integration_tests/.eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
node_modules

/.jest
/packages/**/dist/

/.yarn/*
/.pnp.*
/src/generated/*
46 changes: 46 additions & 0 deletions integration_tests/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
{
"env": {
"browser": true,
"es2021": true,
"node": true
},
"extends": [
"eslint:recommended",
"plugin:@typescript-eslint/recommended",
"plugin:prettier/recommended"
],
"parser": "@typescript-eslint/parser",
"parserOptions": {
"ecmaVersion": 12,
"sourceType": "module"
},
"plugins": ["@typescript-eslint"],
"rules": {
"prettier/prettier": ["error", {}, { "usePrettierrc": true }],
"@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/no-var-requires": "off",
"@typescript-eslint/no-empty-interface": "off",
"@typescript-eslint/no-unused-vars": [
"error",
{ "ignoreRestSiblings": true }
],
"no-useless-return": ["error"],
"arrow-body-style": ["error", "as-needed"],
"require-await": ["error"]
},
"overrides": [
{
"files": ["*.ts", "*.tsx"],
"rules": {
"@typescript-eslint/no-explicit-any": "off"
}
},
{
"files": ["*.js"],
"rules": {
"@typescript-eslint/explicit-module-boundary-types": "off"
}
}
],
"settings": {}
}
3 changes: 3 additions & 0 deletions integration_tests/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
node_modules
/docker-compose-*.yml
.idea/
6 changes: 6 additions & 0 deletions integration_tests/.prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"useTabs": false,
"singleQuote": true,
"tabWidth": 2,
"trailingComma": "all"
}
30 changes: 30 additions & 0 deletions integration_tests/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# integration-tests

This repository contains tests for Lido on Cosmos implementation.

## How to run

### Prerequisites

- node v16.19+
- Docker engine
- yarn

### Prepare

1. run `yarn`
2. run `yarn build-images`

### Run

Execute `yarn test` to run all tests.

Note: if tests fail, run:

```bash
docker-compose -f ./docker-compose-first.yml -p first down --remove-orphans
docker-compose -f ./docker-compose-second.yml -p second down --remove-orphans
docker-compose -f ./docker-compose-satellite.yml -p second down --remove-orphans
```

and then try `yarn test` again.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
22 changes: 22 additions & 0 deletions integration_tests/artifacts/scripts/init-gaia.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/bin/bash

declare -A ADDR_TO_NAME_MAP

sleep 10 #trying to deal with runtime error: invalid memory address or nil pointer dereference: panic

while IFS=" " read -r ADDR NAME; do
TRIMMED_ADDR=${ADDR:0:-6}
ADDR_TO_NAME_MAP["$TRIMMED_ADDR"]=$NAME
done < <(gaiad keys list --keyring-backend=test --home=/opt --output json | jq -r '.[] | .address + " " + .name')

gaiad query staking validators --output json | jq -r '.validators | .[] | .operator_address' | while read -r VAL_ADDRESS; do
KEY_ADDRESS="cosmos${VAL_ADDRESS:13:-6}"

KEY_NAME=${ADDR_TO_NAME_MAP["$KEY_ADDRESS"]}

if [ -n "$KEY_NAME" ]; then
gaiad tx staking validator-bond "$VAL_ADDRESS" --from "$KEY_NAME" --chain-id testgaia --home=/opt --keyring-backend=test --broadcast-mode=block -y >> /opt/gaiad.log 2>&1
else
echo "No key name found for address: $KEY_ADDRESS"
fi
done
22 changes: 22 additions & 0 deletions integration_tests/artifacts/scripts/init-lsm.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/bin/bash

declare -A ADDR_TO_NAME_MAP

sleep 10 #trying to deal with runtime error: invalid memory address or nil pointer dereference: panic

while IFS=" " read -r ADDR NAME; do
TRIMMED_ADDR=${ADDR:0:-6}
ADDR_TO_NAME_MAP["$TRIMMED_ADDR"]=$NAME
done < <(liquidstakingd keys list --keyring-backend=test --home=/opt --output json | jq -r '.[] | .address + " " + .name')

liquidstakingd query staking validators --output json | jq -r '.validators | .[] | .operator_address' | while read -r VAL_ADDRESS; do
KEY_ADDRESS="cosmos${VAL_ADDRESS:13:-6}"

KEY_NAME=${ADDR_TO_NAME_MAP["$KEY_ADDRESS"]}

if [ -n "$KEY_NAME" ]; then
liquidstakingd tx staking validator-bond "$VAL_ADDRESS" --from "$KEY_NAME" --chain-id testlsm --home=/opt --keyring-backend=test --broadcast-mode=block -y >> /opt/liquidstakingd.log 2>&1
else
echo "No key name found for address: $KEY_ADDRESS"
fi
done
Loading

0 comments on commit 89ce726

Please sign in to comment.