diff --git a/Makefile b/Makefile index 3cf09644c..93a238312 100644 --- a/Makefile +++ b/Makefile @@ -477,3 +477,11 @@ build-verif-proxy-wrapper: test-verif-proxy-wrapper: CGO_CFLAGS="$(CGO_CFLAGS)" go test -v github.com/status-im/status-go/rpc -tags gowaku_skip_migrations,nimbus_light_client -run ^TestProxySuite$$ -testify.m TestRun -ldflags $(LDFLAGS) + +run-integration-tests: SHELL := /bin/sh +run-integration-tests: + docker-compose -f integration-tests/docker-compose.anvil.yml -f integration-tests/docker-compose.test.status-go.yml up --remove-orphans --build + +run-anvil: SHELL := /bin/sh +run-anvil: + docker-compose -f integration-tests/docker-compose.anvil.yml up --remove-orphans diff --git a/integration-tests/Dockerfile b/integration-tests/Dockerfile new file mode 100644 index 000000000..2c56a7745 --- /dev/null +++ b/integration-tests/Dockerfile @@ -0,0 +1,12 @@ +FROM ghcr.io/foundry-rs/foundry:latest + +RUN apk update && \ + apk add git + +WORKDIR /app + +COPY entrypoint.sh /app +RUN chmod +x /app/entrypoint.sh + +ENTRYPOINT [ "/app/entrypoint.sh" ] +WORKDIR /app/$GITHUB_REPO diff --git a/integration-tests/README.MD b/integration-tests/README.MD index bdd2b2513..4d98a82ba 100644 --- a/integration-tests/README.MD +++ b/integration-tests/README.MD @@ -13,22 +13,23 @@ Integration tests for status-go ## How to Install * Install [Docker](https://docs.docker.com/engine/install/) and [Docker Compose](https://docs.docker.com/compose/install/) -- Checkout all listed contract repositories into one folder: - - [Status Network Token V2](https://github.com/status-im/status-network-token-v2) - - [Communities Contracts](https://github.com/status-im/communities-contracts?tab=readme-ov-file#installation-and-development) -* Add environment variable, path to contract repos e.g. `export PATH_TO_CONTRACT_REPOS=~/directory-with-every-contract-repo` * Install [Python 3.10.14](https://www.python.org/downloads/) * In `integration-tests` directory, run `pip install -r requirements.txt` * **Optional (for test development)**: Use Python virtual environment for better dependency management. You can follow the guide [here](https://akrabat.com/creating-virtual-environments-with-pyenv/): ## How to Run -- In `integration-tests/tests` run `docker compose up --build`, as result: - * a container with [status-go as deamon](https://github.com/status-im/status-go/issues/5175) will be created with APIModules exposed on `0.0.0.0:3333` - * status-go will use [anvil](https://book.getfoundry.sh/reference/anvil/) as RPCURL with ChainID 31337 - * also all Status-im contracts are going to be deployed to the new network +### Running dev RPC (anvil with contracts) +- In `integration-tests` run `docker compose -f docker-compose.anvil.yml up --remove-orphans --build`, as result: + * an [anvil](https://book.getfoundry.sh/reference/anvil/) container with ChainID 31337 exposed on `0.0.0.0:8545` will start running + * all Status-im contracts will be deployed to the network + +### Run tests +- In `integration-tests` run `docker compose -f docker-compose.anvil.yml -f docker-compose.test.status-go.yml up --remove-orphans`, as result: + * a container with [status-go as daemon](https://github.com/status-im/status-go/issues/5175) will be created with APIModules exposed on `0.0.0.0:3333` + * status-go will use [anvil](https://book.getfoundry.sh/reference/anvil/) as RPCURL with ChainID 31337 + * all Status-im contracts will be deployed to the network -### Running Tests * In `integration-tests/tests` directory run `pytest -m wallet` ## Implementation details diff --git a/integration-tests/docker-compose.anvil.yml b/integration-tests/docker-compose.anvil.yml new file mode 100644 index 000000000..ac3fecfb8 --- /dev/null +++ b/integration-tests/docker-compose.anvil.yml @@ -0,0 +1,47 @@ +services: + anvil: + image: ghcr.io/foundry-rs/foundry:latest + platform: linux/amd64 + command: + - anvil --host 0.0.0.0 + ports: + - 8545:8545 + + deploy-sntv2: + platform: linux/amd64 + environment: + - API_KEY_ETHERSCAN="" # API_KEY env var is required, but value isn't used + - GITHUB_ORG=status-im + - GITHUB_REPO=status-network-token-v2 + depends_on: + - anvil + build: + context: . + dockerfile: Dockerfile + command: | + forge script script/Deploy.s.sol + --broadcast + --fork-url=http://anvil:8545 + --private-key=0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80 + + deploy-communities-contracts: + platform: linux/amd64 + environment: + # API_KEY_* env vars are required, but values aren't used + - API_KEY_ETHERSCAN="" + - API_KEY_ARBISCAN="" + - API_KEY_OPTIMISTIC_ETHERSCAN="" + - GITHUB_ORG=status-im + - GITHUB_REPO=communities-contracts + depends_on: + deploy-sntv2: + condition: service_completed_successfully + build: + context: . + dockerfile: Dockerfile + command: | + forge script script/DeployContracts.s.sol + --broadcast + --fork-url=http://anvil:8545 + --private-key=0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80 + --sender=0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266 diff --git a/integration-tests/docker-compose.test.status-go.yml b/integration-tests/docker-compose.test.status-go.yml new file mode 100644 index 000000000..2cdab3e1b --- /dev/null +++ b/integration-tests/docker-compose.test.status-go.yml @@ -0,0 +1,16 @@ +services: + status-go: + build: + context: ../ + dockerfile: _assets/build/Dockerfile + args: + build_tags: gowaku_no_rln + build_target: statusd + build_flags: -ldflags="-X github.com/status-im/status-go/params.Version= -X github.com/status-im/status-go/params.GitCommit=11f83780d -X github.com/status-im/status-go/params.IpfsGatewayURL=https://ipfs.status.im/ -X github.com/status-im/status-go/vendor/github.com/ethereum/go-ethereum/metrics.EnabledStr=true" + ports: + - 3333:3333 + - 8080:8080 + - 30303:30303 + - 30303:30303/udp + - 30304:30304/udp + entrypoint: ["statusd", "-c", "/static/configs/config.json", "--seed-phrase=test test test test test test test test test test test junk", "--password=Strong12345"] diff --git a/integration-tests/docker-compose.yml b/integration-tests/docker-compose.yml deleted file mode 100644 index f5db88735..000000000 --- a/integration-tests/docker-compose.yml +++ /dev/null @@ -1,56 +0,0 @@ -services: - - anvil: - image: ghcr.io/foundry-rs/foundry:latest - platform: linux/amd64 - command: - - anvil --host 0.0.0.0 - ports: - - 8545:8545 - - deploy-sntv2: - environment: - - API_KEY_ETHERSCAN="" # value isn't used, but env var is required - depends_on: - - anvil - image: ghcr.io/foundry-rs/foundry:latest - platform: linux/amd64 - working_dir: /usr/local/bin/status-network-token-v2 - command: - - forge clean && forge build && forge script script/Deploy.s.sol --broadcast --fork-url http://anvil:8545 --private-key="0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80" - volumes: - - ${PATH_TO_CONTRACT_REPOS}/status-network-token-v2:/usr/local/bin/status-network-token-v2 - - deploy-communities-contracts: - environment: - # values arn't used, but env vars are required - - API_KEY_ETHERSCAN="" - - API_KEY_ARBISCAN="" - - API_KEY_OPTIMISTIC_ETHERSCAN="" - depends_on: - - anvil - - deploy-sntv2 - image: ghcr.io/foundry-rs/foundry:latest - platform: linux/amd64 - working_dir: /usr/local/bin/communities-contracts - command: - - forge clean && forge build && forge script script/DeployContracts.s.sol --broadcast --fork-url http://anvil:8545 --private-key="0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80" - volumes: - - ${PATH_TO_CONTRACT_REPOS}/communities-contracts:/usr/local/bin/communities-contracts - - status-go: - build: - context: ../ - dockerfile: _assets/build/Dockerfile - args: - build_tags: gowaku_no_rln - build_target: statusd - build_flags: -ldflags="-X github.com/status-im/status-go/params.Version= -X github.com/status-im/status-go/params.GitCommit=11f83780d -X github.com/status-im/status-go/params.IpfsGatewayURL=https://ipfs.status.im/ -X github.com/status-im/status-go/vendor/github.com/ethereum/go-ethereum/metrics.EnabledStr=true" - ports: - - 3333:3333 - - 8080:8080 - - 30303:30303 - - 30303:30303/udp - - 30304:30304/udp - entrypoint: ["statusd", "-c", "/static/configs/config.json", "--seed-phrase=test test test test test test test test test test test junk", "--password=Strong12345"] - diff --git a/integration-tests/entrypoint.sh b/integration-tests/entrypoint.sh new file mode 100644 index 000000000..b97891f4f --- /dev/null +++ b/integration-tests/entrypoint.sh @@ -0,0 +1,9 @@ +#!/bin/sh + +git clone https://github.com/$GITHUB_ORG/$GITHUB_REPO +cd $GITHUB_REPO +git submodule deinit --force . +git submodule update --init --recursive + +forge build +exec "$@"