Skip to content

Commit

Permalink
Added osmosis to integration test framework (#1328)
Browse files Browse the repository at this point in the history
  • Loading branch information
sampocs authored Jan 28, 2025
1 parent cacbebf commit b5b9f02
Show file tree
Hide file tree
Showing 17 changed files with 233 additions and 80 deletions.
18 changes: 16 additions & 2 deletions integration-tests/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,21 @@ define build_and_push_docker
@$(DOCKER) push $(GCR_REPO)/$(3)
endef

install: typescript-install python-install

check-empty-namespace:
@POD_COUNT=$$($(KUBECTL) get pods --no-headers -n $(K8S_NAMESPACE) | wc -l); \
if [ $$POD_COUNT -eq 0 ]; then exit 0; else exit 1; fi

wait-for-startup:
@bash network/scripts/network-readiness.sh $(K8S_NAMESPACE)

typescript-install:
@(cd client && pnpm i)

python-install:
conda create --name $(VENV_NAME) python=3.11 -y
$(PYTHON) -m pip install -r api/requirements.txt
@conda create --name $(VENV_NAME) python=3.11 -y
@$(PYTHON) -m pip install -r api/requirements.txt

start-api: docker-bridge
@$(DOCKER) compose up api
Expand All @@ -49,6 +54,9 @@ build-stride:
build-cosmos:
$(call build_and_push_docker,cosmos,.,chains/cosmoshub:v18.1.0)

build-osmosis:
$(call build_and_push_docker,osmosis,.,chains/osmosis:v27.0.0)

build-relayer:
$(call build_and_push_docker,relayer,.,relayer:v2.5.2)

Expand All @@ -65,6 +73,12 @@ start:
@$(HELM) install $(HELM_CHART) $(HELM_CHART) --values $(HELM_CHART)/values.yaml -n $(K8S_NAMESPACE)
@$(MAKE) wait-for-startup

test:
@(cd client && pnpm test)

startup-logs:
@$(KUBECTL) exec -it $(POD_ID) -- cat logs/startup.log

stop:
@$(HELM) uninstall $(HELM_CHART) -n $(K8S_NAMESPACE)

Expand Down
66 changes: 62 additions & 4 deletions integration-tests/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,76 @@ This design for this integration test framework is heavily inspired by the Cosmo

## Setup

TODO
Install javascript and python dependencies

## Motivation
```bash
make install
```

TODO
IMPORTANT: `@cosmjs/*` dependencies must match the versions used by stridejs. To get those versions, run e.g. `pnpm why @cosmjs/amino`.

## Running Tests

Start the network

```bash
make start
```

Run the tests

```bash
make test
```

## Network

TODO
### Validator Startup Lifecycle

**initContainer**

- For context, the `initContainer` is a separate container that runs before the main process. In this case, it's used to handle the validator node setup before the main startup loop.
- The _first_ validator runs `init-chain.sh` which creates the `genesis.json` and all the validator keys
- The genesis file and validator keys are uploaded and stored in the API
- Then each validator runs `init-node.sh` which downloads the relevant files and sets up the config files in the validator's home directory
- **NOTE:** Logs from the `initContainer` are not natively viewable via the `kubectl` cli. As a workaround, they are piped to a file in the node and can be viewed by exec'ing into the container with `POD_ID={pod-id} make startup-logs`

**main**

- The main thread simply runs the `binaryd start` command

**postStart**

- As a `postStart` operation (run after the main thread is kicked off), the `create-validator.sh` script is run which runs the appropriate `staking` module transaction to create the validator using the previously acquired keys
- This is run after startup because the validator must sign the tx with their key

## Testing Client

### Debugging (VSCode)

- open command palette: `Shift + Command + P (Mac) / Ctrl + Shift + P (Windows/Linux)`
- run the `Debug: Create JavaScript Debug Terminal` command
- set breakpoints
- run `pnpm test`

### Test new protobuf

- go to https://github.com/Stride-Labs/stridejs
- remove `/dist` from `.gitignore`
- update the config in `scripts/clone_repos.ts` to point to the new `stride/cosmos-sdk/ibc-go` version
- run `pnpm i`
- run `pnpm codegen`
- run `pnpm build`
- run `git commit...`
- run `git push`
- get the current `stridejs` commit using `git rev-parse HEAD`
- in the integration tests (this project):
- update the `stridejs` dependency commit hash in `package.json`
- `pnpm i`
- `pnpm test`

## Motivation

TODO

## Design Decisions
Expand Down
35 changes: 0 additions & 35 deletions integration-tests/client/README.md

This file was deleted.

7 changes: 4 additions & 3 deletions integration-tests/client/package.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
{
"name": "stride-integration-tests",
"version": "1.0.0",
"type": "module",
"description": "integration tests for stride chain",
"scripts": {
"test": "vitest run",
"test-watch": "vitest watch"
"test": "NODE_OPTIONS=--conditions=node vitest run",
"test-watch": "NODE_OPTIONS=--conditions=node vitest watch"
},
"keywords": [
"wow",
Expand All @@ -25,7 +26,7 @@
"bech32": "2.0.0",
"jest": "29.7.0",
"prettier": "3.3.3",
"stridejs": "github:Stride-Labs/stridejs#f5ad6abac646aff015676fff508bc842f53951ef",
"stridejs": "github:Stride-Labs/stridejs#e949e35",
"typescript": "5.5.3",
"vitest": "2.0.3"
},
Expand Down
10 changes: 5 additions & 5 deletions integration-tests/client/pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 2 additions & 19 deletions integration-tests/client/test/core.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,24 +81,6 @@ describe("x/stakeibc", () => {
test("Registration", async () => {
const stridejs = accounts.admin;

console.log({
creator: stridejs.address,
bech32prefix: "cosmos",
hostDenom: "uatom",
ibcDenom: ibcDenom(
[{ incomingPortId: "transfer", incomingChannelId: "channel-0" }],
"uatom",
),
connectionId: "connection-0",
transferChannelId: "channel-0",
unbondingPeriod: BigInt(1),
minRedemptionRate: "0.9",
maxRedemptionRate: "1.5",
lsmLiquidStakeEnabled: true,
communityPoolTreasuryAddress: "",
maxMessagesPerIcaTx: BigInt(2),
});

const msg =
stridejs.types.stride.stakeibc.MessageComposer.withTypeUrl.registerHostZone(
{
Expand All @@ -115,7 +97,8 @@ describe("x/stakeibc", () => {
minRedemptionRate: "0.9",
maxRedemptionRate: "1.5",
lsmLiquidStakeEnabled: true,
communityPoolTreasuryAddress: "",
communityPoolTreasuryAddress:
"cosmos1kl8d29eadt93rfxmkf2q8msxwylaax9dxzr5lj",
maxMessagesPerIcaTx: BigInt(2),
},
);
Expand Down
27 changes: 27 additions & 0 deletions integration-tests/client/vitest.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import { defineConfig } from "vitest/config";

export default defineConfig({
test: {
globals: true,
environment: "node",
testTimeout: 30000,
hookTimeout: 30000,
pool: "forks",
poolOptions: {
forks: {
singleFork: true,
},
},
server: {
deps: {
inline: ["stridejs"],
},
},
reporters: ["verbose"],
},
resolve: {
alias: {
stridejs: "stridejs/dist/esm", // Force ESM path
},
},
});
32 changes: 32 additions & 0 deletions integration-tests/dockerfiles/Dockerfile.osmosis
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
FROM golang:1.23-alpine3.21 AS builder

WORKDIR /opt

RUN apk add --update curl make git libc-dev bash gcc linux-headers eudev-dev ca-certificates build-base git

ENV REPO=https://github.com/osmosis-labs/osmosis
ENV COMMIT_HASH=v27.0.0
ENV BINARY=osmosisd

RUN git clone ${REPO} chain \
&& cd chain \
&& git checkout $COMMIT_HASH

WORKDIR /opt/chain

RUN ARCH=$(uname -m) && WASMVM_VERSION=$(go list -m github.com/CosmWasm/wasmvm/v2 | sed 's/.* //') && \
wget https://github.com/CosmWasm/wasmvm/releases/download/$WASMVM_VERSION/libwasmvm_muslc.$ARCH.a \
-O /lib/libwasmvm_muslc.$ARCH.a

RUN BUILD_TAGS=muslc LINK_STATICALLY=true make install

FROM alpine:3.21
COPY --from=builder /go/bin/$BINARY /usr/local/bin/
RUN apk add bash vim sudo dasel jq curl \
&& addgroup -g 1000 validator \
&& adduser -S -h /home/validator -D validator -u 1000 -G validator

USER 1000
WORKDIR /home/validator

EXPOSE 26657 26656 1317 9090
17 changes: 17 additions & 0 deletions integration-tests/network/configs/hermes.toml
Original file line number Diff line number Diff line change
Expand Up @@ -61,3 +61,20 @@ clock_drift = '10s'
max_block_time = '10s'
address_type = { derivation = 'cosmos' }
memo_prefix = 'stride-tests'

[[chains]]
id = 'osmosis-test-1'
rpc_addr = 'http://osmosis-validator.integration.svc:26657'
grpc_addr = 'http://osmosis-validator.integration.svc:9090'
event_source = { mode = 'push', url = 'ws://osmosis-validator.integration.svc:26657/websocket', batch_delay = '500ms' }
rpc_timeout = '10s'
account_prefix = 'osmo'
key_name = 'osmosis'
store_prefix = 'ibc'
# TODO: investigate why this has to be set so high
gas_price = { price = 1, denom = 'uosmo' }
gas_multiplier = 1.3
clock_drift = '10s'
max_block_time = '10s'
address_type = { derivation = 'cosmos' }
memo_prefix = 'stride-tests'
8 changes: 8 additions & 0 deletions integration-tests/network/configs/keys.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,14 @@
{
"name": "rly2",
"mnemonic": "floor chicken advance degree paper arch sugar kit torch auction flash fish attitude clay museum treat favorite clinic verify dose safe bright vessel east"
},
{
"name": "rly3",
"mnemonic": "belt diet provide fish knee area explain section sword fancy rebel mix fiction urge float chat move device another tourist want tackle drip good"
},
{
"name": "rly4",
"mnemonic": "video stereo milk coyote various fantasy attract leaf elevator laundry upper clinic ready recipe wreck asset make before update pitch found board tissue sniff"
}
],
"users": [
Expand Down
24 changes: 23 additions & 1 deletion integration-tests/network/configs/relayer.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,31 @@ chains:
timeout: 20s
output-format: json
sign-mode: direct
osmosis:
type: cosmos
value:
key: osmosis
chain-id: osmosis-test-1
rpc-addr: http://osmosis-validator.integration.svc:26657
account-prefix: osmo
keyring-backend: test
gas-adjustment: 1.3
# TODO: investigate why this has to be set so high
gas-prices: 1uosmo
coin-type: 118
min-loop-duration: 1s
debug: false
timeout: 20s
output-format: json
sign-mode: direct
paths:
stride-cosmoshub:
src:
chain-id: stride-test-1
dst:
chain-id: cosmoshub-test-1
chain-id: cosmoshub-test-1
stride-osmosis:
src:
chain-id: stride-test-1
dst:
chain-id: osmosis-test-1
Loading

0 comments on commit b5b9f02

Please sign in to comment.