Skip to content

Commit

Permalink
test: Added Github actions
Browse files Browse the repository at this point in the history
Signed-off-by: carlos.vdr <carlos.vdr@semiotic.ai>
  • Loading branch information
carlosvdr committed Oct 23, 2023
1 parent d1b5553 commit 43c176b
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 2 deletions.
42 changes: 42 additions & 0 deletions .github/workflows/local_tests.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: Local chain tests
on:
push:
branches: [ master ]
pull_request:
jobs:
tests:
strategy:
fail-fast: true
runs-on: ubuntu-latest
name: Build and Test
steps:
- uses: actions/checkout@v3
name: Check out repository
- name: Checkout submodules
run: git submodule update --init --recursive
- uses: actions/setup-node@v2
name: Set up Node.js
with:
node-version: "lts/gallium"
- name: Install graph CLI
run: |
npm install -g @graphprotocol/graph-cli
- uses: actions/setup-python@v4
with:
python-version: '3.8'
cache: pip
- name: Install Foundry
uses: foundry-rs/foundry-toolchain@v1
- name: Start Docker Compose
run: |
docker-compose up -d
working-directory: ./tests
- name: Installing python requirements
run: |
pip install -r requirements.txt
working-directory: ./tests
- run: |
yarn
./contract_init.sh
name: Build and Test
working-directory: ./tests
8 changes: 6 additions & 2 deletions tests/contract_init.sh
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,19 @@ ESCROW_AD=$(echo $ESCROW_VAR | jq -r '.deployedTo')
echo "Escrow address: $ESCROW_AD"

cd $current_dir
cd ..

echo "Deploying locally the subgraph"
yq ".dataSources[].source.address=\"$ESCROW_AD\"" ../subgraph.yaml -i
yq ".dataSources[].source.address=\"$ESCROW_AD\"" subgraph.yaml -i
yarn codegen
yarn build
yarn create-local
yarn deploy-local

cd $current_dir
echo "Running escrow contract calls"
python local_contract_calls.py "$ESCROW_AD" "$TAP_VERIFIER_AD" "$GRAPH_TOKEN" "$ISTAKING_AD"


if [ $? -ne 0 ]; then
exit 1
fi
9 changes: 9 additions & 0 deletions tests/local_contract_calls.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,10 @@ class ReceiptAggregateVoucher(EIP712Message):
except ContractCustomError as e:
print("Custom Error: %s" % e)
print(decode_custom_error(erc20_abi_json, str(e), w3))
sys.exit(1)
except ContractLogicError as e:
print("Logic Error: %s" % e)
sys.exit(1)

# MOCK STAKING CONTRACT CALLS
try:
Expand All @@ -101,8 +103,10 @@ class ReceiptAggregateVoucher(EIP712Message):
except ContractCustomError as e:
print("Custom Error: %s" % e)
print(decode_custom_error(mockStaking_abi_json, str(e), w3))
sys.exit(1)
except ContractLogicError as e:
print("Logic Error: %s" % e)
sys.exit(1)

# ESCROW CONTRACT CALLS
try:
Expand Down Expand Up @@ -164,6 +168,7 @@ class ReceiptAggregateVoucher(EIP712Message):
print("Skip, signer already authorized")
else:
print(error)
sys.exit(1)
check_subgraph_signer(SIGNER, True, False)

print("--- Executing deposit for redeem")
Expand Down Expand Up @@ -206,6 +211,7 @@ class ReceiptAggregateVoucher(EIP712Message):
time.sleep(time_left + 1)
else:
print(error)
sys.exit(1)
print("Done revoking")

check_subgraph_signer(SIGNER, False, False)
Expand All @@ -214,7 +220,10 @@ class ReceiptAggregateVoucher(EIP712Message):
except ContractCustomError as e:
print("Custom Error: %s" % e)
print(decode_custom_error(escrow_abi_json, str(e), w3))
sys.exit(1)
except ContractLogicError as e:
print("Logic Error: %s" % e)
sys.exit(1)
except Exception as e:
print(e)
sys.exit(1)

0 comments on commit 43c176b

Please sign in to comment.