Skip to content

chore: add testing configuration #447

chore: add testing configuration

chore: add testing configuration #447

name: Integration Test
on:
push:
branches:
- main
- develop
pull_request:
types: [opened, synchronize, reopened]
workflow_dispatch:
defaults:
run:
shell: bash
jobs:
Test:
runs-on: ubuntu-latest
environment: Test
services:
postgres:
image: postgres:latest
env:
POSTGRES_DB: postgres_db # optional (defaults to `postgres`)
POSTGRES_PASSWORD: postgres_password # required
POSTGRES_PORT: 5432 # optional (defaults to `5432`)
POSTGRES_USER: postgres_user # optional (defaults to `postgres`)
# `POSTGRES_HOST` is `localhost`
ports:
- 5432:5432 # maps tcp port 5432 on service container to the host
options: >- # set health checks to wait until postgres has started
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
steps:
- uses: actions/checkout@v4
# Python setup TODO activate when mm-bot is ready
# - name: Setup Python
# uses: actions/setup-python@v5
# with:
# python-version: 3.10.12
# architecture: x64
#
# - name: Install dependencies
# run: |
# python -m pip install --upgrade pip
# pip install -r mm-bot/requirements.txt
# Postgres setup TODO activate when mm-bot is ready
# - name: Install PSQL
# run: |
# sudo apt-get update
# sudo apt-get install --yes postgresql-client
#
# - name: Create tables
# run: |
# psql -h localhost -d postgres_db -U postgres_user -f mm-bot/resources/schema.sql
# psql -h localhost -d postgres_db -U postgres_user -c "SELECT * FROM block;"
# env:
# PGPASSWORD: postgres_password
# Ethereum Setup
- name: Install Foundry
uses: foundry-rs/foundry-toolchain@v1
- name: Install Forge
run: |
cd contracts/ethereum
forge install
# Starknet Setup
- name: Install scarb
uses: software-mansion/setup-scarb@v1
with:
scarb-version: "2.3.1"
- name: Install starkliup
run: curl https://get.starkli.sh | sh
- name: Install Starkli
run: |
/home/runner/.config/.starkli/bin/starkliup --version 0.1.20
sudo mv /home/runner/.config/.starkli/bin/starkli /usr/local/bin/
- name: Setup Katana .env
run: |
cp .github/workflows/katana/katana.env .env
- name: Download Katana
run: |
wget https://github.com/dojoengine/dojo/releases/download/v0.4.4/dojo_v0.4.4_linux_amd64.tar.gz
tar -xzvf dojo_v0.4.4_linux_amd64.tar.gz
rm sozo torii dojo-language-server
# Run Anvil
- name: Run Anvil
run: |
anvil &
# Deploy Starknet Messaging Contract in L1
- name: Clone https://github.com/glihm/starknet-messaging-dev
uses: GuillaumeFalourd/[email protected]
with:
branch: 'main'
owner: 'glihm'
repository: 'starknet-messaging-dev'
- name: Install Forge
run: |
cd starknet-messaging-dev/solidity
forge install
- name: Deploy Starknet Messaging Contract
run: |
cd starknet-messaging-dev/solidity
cp anvil.env .env
source .env
forge script script/LocalTesting.s.sol:LocalSetup --broadcast --rpc-url ${{vars.ETHEREUM_RPC}}
# Run Katana
- name: Run Katana
run: |
./katana --messaging starknet-messaging-dev/anvil.messaging.json &
- name: Setup Katana Account
run: |
.github/workflows/scripts/setup_katana_account.sh
# Setup Starknet messaging
- name: Setup Starknet messaging
run: |
cd starknet-messaging-dev/cairo
source katana.env
scarb build
starkli declare ./target/dev/messaging_tuto_contract_msg.contract_class.json --keystore-password ""
starkli deploy 0x02d6b666ade3a9ee98430d565830604b90954499c590fa05a9844bdf4d3a574b \
--salt 0x1234 \
--keystore-password ""
# Build Ethereum Contract
- name: Build Ethereum Contract
run: |
make ethereum-build
# Build Starknet Contract
- name: Build Starknet Contract
run: |
make starknet-build
# Deploy PaymentRegistry, Escrow, set escrow, and test complete flow
- name: Deploy and test complete flow
run: |
export ETHEREUM_RPC=${{vars.ETHEREUM_RPC}}
export ETHERSCAN_API_KEY=${{vars.ETHERSCAN_API_KEY}}
export ETHEREUM_PRIVATE_KEY=${{vars.ETHEREUM_PRIVATE_KEY}}
export STARKNET_MESSAGING_ADDRESS=${{vars.STARKNET_MESSAGING_ADDRESS}}
export MM_ETHEREUM_WALLET_ADDRESS=${{vars.MM_ETHEREUM_WALLET_ADDRESS}}
export ZKSYNC_DIAMOND_PROXY_ADDRESS=${{vars.ZKSYNC_DIAMOND_PROXY_ADDRESS}}
export STARKNET_CHAIN_ID=${{vars.STARKNET_CHAIN_ID}}
export ZKSYNC_CHAIN_ID=${{vars.ZKSYNC_CHAIN_ID}}
export STARKNET_CLAIM_PAYMENT_SELECTOR=${{vars.STARKNET_CLAIM_PAYMENT_SELECTOR}}
export STARKNET_CLAIM_PAYMENT_BATCH_SELECTOR=${{vars.STARKNET_CLAIM_PAYMENT_BATCH_SELECTOR}}
export ZKSYNC_CLAIM_PAYMENT_SELECTOR=${{vars.ZKSYNC_CLAIM_PAYMENT_SELECTOR}}
export ZKSYNC_CLAIM_PAYMENT_BATCH_SELECTOR=${{vars.ZKSYNC_CLAIM_PAYMENT_BATCH_SELECTOR}}
export SKIP_VERIFY=true
. ./contracts/ethereum/deploy.sh
export STARKNET_RPC=${{vars.STARKNET_RPC}}
source ./contracts/starknet/.env.test
. ./contracts/starknet/scripts/deploy.sh
. ./contracts/ethereum/set_starknet_escrow.sh
export AMOUNT=1000000000000000000
. ./.github/workflows/scripts/set_order.sh
. ./.github/workflows/scripts/transfer.sh
. ./.github/workflows/scripts/claim_payment.sh
. ./.github/workflows/scripts/assert.sh
# Run mm-bot (it should run a single process order listening to the contract once)