-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into 123-refactor-replace-orders_used-for-orders_…
…pending
- Loading branch information
Showing
20 changed files
with
1,055 additions
and
252 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
name: ETH YABTransfer Tests | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
pull_request: | ||
types: [opened, synchronize, reopened] | ||
|
||
jobs: | ||
test-ETH: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
- name: Install Foundry | ||
uses: foundry-rs/foundry-toolchain@v1 | ||
|
||
- name: Run tests | ||
run: make ethereum-test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,178 @@ | ||
name: Integration Test | ||
on: | ||
push: | ||
branches: | ||
- main | ||
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/solidity | ||
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 ${ETH_RPC_URL} | ||
# 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, set withdraw selector and test complete flow | ||
- name: Deploy and test complete flow | ||
run: | | ||
export ETH_RPC_URL=${{vars.ETH_RPC_URL}} | ||
export ETHERSCAN_API_KEY=${{vars.ETHERSCAN_API_KEY}} | ||
export ETH_PRIVATE_KEY=${{vars.ETH_PRIVATE_KEY}} | ||
export SN_MESSAGING_ADDRESS=${{vars.SN_MESSAGING_ADDRESS}} | ||
export MM_ETHEREUM_WALLET=${{vars.MM_ETHEREUM_WALLET}} | ||
export SKIP_VERIFY=true | ||
. ./contracts/solidity/deploy.sh | ||
export STARKNET_RPC=${{vars.STARKNET_RPC}} | ||
source ./contracts/cairo/.env.test | ||
. ./contracts/cairo/deploy.sh | ||
. ./contracts/solidity/set_escrow.sh | ||
. ./contracts/solidity/set_withdraw_selector.sh | ||
export AMOUNT=1000000000000000000 | ||
. ./.github/workflows/scripts/set_order.sh | ||
. ./.github/workflows/scripts/transfer.sh | ||
. ./.github/workflows/scripts/withdraw.sh | ||
. ./.github/workflows/scripts/assert.sh | ||
# Run mm-bot (it should run a single process order listening to the contract once) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
#!/bin/bash | ||
|
||
. contracts/utils/colors.sh #for ANSI colors | ||
|
||
assert() { | ||
# Usage: assert <condition> <placeholder_text> <expected_value> <obtained_value> | ||
if eval "$1"; then | ||
printf "${GREEN}✓ $2 passed.${RESET}\n" | ||
else | ||
printf "${RED}⨯ $2 assertion failed: Expected value: $3, Obtained value: $4.${RESET}\n" | ||
exit 1 | ||
fi | ||
} | ||
|
||
echo "" | ||
|
||
DESTINATION_FINAL_BALANCE=$(cast balance --rpc-url $ETH_RPC_URL $DESTINATION_ADDRESS) | ||
EXPECTED_DESTINATION_FINAL_BALANCE=10001000000000000000000 | ||
assert "[[ $DESTINATION_FINAL_BALANCE -eq $EXPECTED_DESTINATION_FINAL_BALANCE ]]" "Destination balance" "$EXPECTED_DESTINATION_FINAL_BALANCE" "$DESTINATION_FINAL_BALANCE" | ||
|
||
ESCROW_FINAL_BALANCE=$(starkli balance --raw $ESCROW_CONTRACT_ADDRESS) | ||
EXPECTED_ESCROW_FINAL_BALANCE=0 | ||
assert "[[ $ESCROW_FINAL_BALANCE -eq $EXPECTED_ESCROW_FINAL_BALANCE ]]" "Escrow balance" "$EXPECTED_ESCROW_FINAL_BALANCE" "$ESCROW_FINAL_BALANCE" | ||
|
||
MM_FINAL_BALANCE=$(starkli balance --raw $MM_SN_WALLET_ADDR) | ||
EXPECTED_MM_FINAL_BALANCE=1001000025000000000000 | ||
assert "[[ $MM_FINAL_BALANCE -eq $EXPECTED_MM_FINAL_BALANCE ]]" "MM balance" "$EXPECTED_MM_FINAL_BALANCE" "$MM_FINAL_BALANCE" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
#!/bin/bash | ||
|
||
. contracts/utils/colors.sh #for ANSI colors | ||
|
||
#fee=24044002524012 | ||
FEE=25000000000000 | ||
APPROVE_AMOUNT=$((${AMOUNT}+${FEE})) | ||
|
||
echo -e "${GREEN}\n=> [SN] Making transfer to Escrow${COLOR_RESET}" | ||
|
||
starkli invoke \ | ||
$NATIVE_TOKEN_ETH_STARKNET approve $ESCROW_CONTRACT_ADDRESS u256:$APPROVE_AMOUNT \ | ||
/ $ESCROW_CONTRACT_ADDRESS set_order 0x70997970C51812dc3A010C7d01b50e0d17dc79C8 \ | ||
u256:$AMOUNT u256:$FEE --private-key $STARKNET_PRIVATE_KEY --account $STARKNET_ACCOUNT |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
#!/bin/bash | ||
|
||
. contracts/utils/colors.sh #for ANSI colors | ||
|
||
source .github/workflows/katana/katana.env | ||
set -e | ||
|
||
export STARKNET_ACCOUNT=$ACCOUNT_SRC | ||
export STARKNET_RPC=$RPC_URL | ||
|
||
# Check if the JSON file exists | ||
if [ ! -f "$ACCOUNT_SRC" ]; then | ||
$(starkli account fetch --output $ACCOUNT_SRC $ACCOUNT_ADDRESS) | ||
echo -e "$GREEN\n==> Katana JSON account file created at: $ACCOUNT_SRC$RESET" | ||
else | ||
echo -e "$GREEN\n==> Katana JSON account file already exists at: $ACCOUNT_SRC$RESET" | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
#!/bin/bash | ||
|
||
. contracts/utils/colors.sh #for ANSI colors | ||
|
||
DESTINATION_ADDRESS=0x70997970C51812dc3A010C7d01b50e0d17dc79C8 | ||
DESTINATION_ADDRESS_UINT=642829559307850963015472508762062935916233390536 | ||
|
||
echo -e "${GREEN}\n=> [SN] Making transfer to Destination account${COLOR_RESET}" # 0x70997970C51812dc3A010C7d01b50e0d17dc79C8 -> 642829559307850963015472508762062935916233390536 | ||
|
||
MM_INITIAL_BALANCE=$(cast balance --rpc-url $ETH_RPC_URL --ether $MM_ETHEREUM_WALLET) | ||
DESTINATION_INITIAL_BALANCE=$(cast balance --rpc-url $ETH_RPC_URL --ether $DESTINATION_ADDRESS) | ||
echo "Initial MM balance: $MM_INITIAL_BALANCE" | ||
echo "Initial Destination balance: $DESTINATION_INITIAL_BALANCE" | ||
|
||
echo "Transferring $AMOUNT to $DESTINATION_ADDRESS" | ||
cast send --rpc-url $ETH_RPC_URL --private-key $ETH_PRIVATE_KEY \ | ||
$YAB_TRANSFER_PROXY_ADDRESS "transfer(uint256, uint256, uint256)" \ | ||
"0" "$DESTINATION_ADDRESS_UINT" "$AMOUNT" \ | ||
--value $AMOUNT >> /dev/null | ||
|
||
MM_FINAL_BALANCE=$(cast balance --rpc-url $ETH_RPC_URL --ether $MM_ETHEREUM_WALLET) | ||
DESTINATION_FINAL_BALANCE=$(cast balance --rpc-url $ETH_RPC_URL --ether $DESTINATION_ADDRESS) | ||
echo "Final MM balance: $MM_FINAL_BALANCE" | ||
echo "Final Destination balance: $DESTINATION_FINAL_BALANCE" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
#!/bin/bash | ||
|
||
. contracts/utils/colors.sh #for ANSI colors | ||
|
||
echo -e "${GREEN}\n=> [SN] Making withdraw${COLOR_RESET}" # 0x70997970C51812dc3A010C7d01b50e0d17dc79C8 -> 642829559307850963015472508762062935916233390536 | ||
|
||
ESCROW_INITIAL_BALANCE=$(starkli balance $ESCROW_CONTRACT_ADDRESS) | ||
MM_INITIAL_BALANCE=$(starkli balance $MM_SN_WALLET_ADDR) | ||
echo "Initial Escrow balance: $ESCROW_INITIAL_BALANCE" | ||
echo "Initial MM balance: $MM_INITIAL_BALANCE" | ||
|
||
echo "Withdrawing $AMOUNT" | ||
cast send --rpc-url $ETH_RPC_URL --private-key $ETH_PRIVATE_KEY \ | ||
$YAB_TRANSFER_PROXY_ADDRESS "withdraw(uint256, uint256, uint256)" \ | ||
"0" "642829559307850963015472508762062935916233390536" "$AMOUNT" \ | ||
--value $AMOUNT >> /dev/null | ||
|
||
sleep 15 | ||
|
||
starkli call $ESCROW_CONTRACT_ADDRESS get_order_used u256:0 | ||
|
||
ESCROW_FINAL_BALANCE=$(starkli balance $ESCROW_CONTRACT_ADDRESS) | ||
MM_FINAL_BALANCE=$(starkli balance $MM_SN_WALLET_ADDR) | ||
echo "Final Escrow balance: $ESCROW_FINAL_BALANCE" | ||
echo "Final MM balance: $MM_FINAL_BALANCE" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
name: SN Escrow Tests | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
pull_request: | ||
types: [opened, synchronize, reopened] | ||
|
||
jobs: | ||
test-SN: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
- 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: Install snFoundry | ||
uses: foundry-rs/setup-snfoundry@v2 | ||
with: | ||
starknet-foundry-version: 0.12.0 | ||
|
||
- name: Run make starknet-test | ||
run: | | ||
make starknet-test |
Oops, something went wrong.