Skip to content

Commit

Permalink
Run E2E shielder tests in the CI.
Browse files Browse the repository at this point in the history
  • Loading branch information
deuszx committed Mar 27, 2023
1 parent 103347d commit e0f7113
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 7 deletions.
28 changes: 28 additions & 0 deletions .github/workflows/integration_tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: E2E Shielder tests.

on:
pull_request:
push:
branches:
- main

concurrency:
group: ${{ github.ref }}
cancel-in-progress: true

jobs:
rust-checks:
runs-on: self-hosted
steps:
- name: Checkout source code
uses: actions/checkout@v3

- name: Install Rust toolchain
uses: actions-rs/toolchain@v1

- name: Install WASM target
run: rustup target add wasm32-unknown-unknown

- name: Run e2e tests for shielder
run: |
cd shielder && make test-shielder-clean
4 changes: 1 addition & 3 deletions shielder/cli/tests/setup_local.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,7 @@ get_timestamp() {
}

log_progress() {
bold=$(tput bold)
normal=$(tput sgr0)
echo "[$(get_timestamp)] [INFO] ${bold}${1}${normal}"
echo "[$(get_timestamp)] [INFO] ${1}"
}

function setup_testdir() {
Expand Down
27 changes: 23 additions & 4 deletions shielder/deploy/deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ set -euo pipefail

# Check if run in e2e shielder test context. Defaults to unset.
E2E_TEST_CONTEXT=${E2E_TEST:-}
# Check if running in CI context.
CI=${CI:-}

SCRIPT_DIR=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" &>/dev/null && pwd)

Expand Down Expand Up @@ -43,9 +45,7 @@ get_timestamp() {
}

log_progress() {
bold=$(tput bold)
normal=$(tput sgr0)
echo "[$(get_timestamp)] [INFO] ${bold}${1}${normal}"
echo "[$(get_timestamp)] [INFO] ${1}"
}

random_salt() {
Expand Down Expand Up @@ -134,6 +134,14 @@ move_keys() {
}

docker_cargo() {
if [[ -z "${CI}" ]]; then
local_docker_cargo "$@"
else
ci_docker_cargo "$@"
fi
}

local_docker_cargo() {
docker run --rm \
-u "${DOCKER_USER}" \
-v "${PWD}":/code \
Expand All @@ -145,6 +153,15 @@ docker_cargo() {
-c "cargo ${1}"
}

ci_docker_cargo() {
docker run --rm \
-v "${PWD}":/code \
--network host \
--entrypoint /bin/sh \
"${CARGO_IMAGE}" \
-c "cargo ${1}"
}

build() {
cd "${SCRIPT_DIR}"/..

Expand Down Expand Up @@ -185,6 +202,7 @@ prefund_users() {
for recipient in "${DAMIAN_PUBKEY}" "${HANS_PUBKEY}"; do
transfer ${recipient}
done
log_progress "✅ Test accounts prefunded with SNZERO tokens."
}

# Distribute TOKEN_PER_PERSON of TOKEN_A and TOKEN_B to DAMIAN and HANS.
Expand All @@ -196,13 +214,14 @@ distribute_tokens() {
contract_call "--contract ${token} --message PSP22::transfer --args ${recipient} ${TOKEN_PER_PERSON} 0x00 --suri ${ADMIN}" 1>/dev/null
done
done
log_progress "✅ PSP22 tokens distributed"
}

deploy_shielder_contract() {
cd "${SCRIPT_DIR}"/..
SHIELDER_ADDRESS=$(contract_instantiate "--args ${MERKLE_LEAVES} --manifest-path contract/Cargo.toml" | jq -r '.contract')
export SHIELDER_ADDRESS
log_progress "Shielder address: ${SHIELDER_ADDRESS}"
log_progress "Shielder address: ${SHIELDER_ADDRESS}"
}

# Set allowance at TOKEN_ALLOWANCE on TOKEN_A and TOKEN_B from SHIELDER, from DAMIAN and HANS.
Expand Down

0 comments on commit e0f7113

Please sign in to comment.