Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cicd test #1

Open
wants to merge 36 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
a76bf99
cicd test
carlosvdr Oct 16, 2023
0d6188d
added custom label for testing
carlosvdr Oct 17, 2023
1a78818
add more ci stuff
carlosvdr Oct 17, 2023
24b19ae
test fix
carlosvdr Oct 17, 2023
586ade6
add foundry install and requiremnts
carlosvdr Oct 17, 2023
bfd0803
dir change
carlosvdr Oct 17, 2023
b86e46e
added lts node version
carlosvdr Oct 17, 2023
797f234
fix
carlosvdr Oct 17, 2023
e0a8c98
added submodules
carlosvdr Oct 17, 2023
71b1fc4
submodue
carlosvdr Oct 17, 2023
be94b7e
check error
carlosvdr Oct 17, 2023
7d47037
install grah protocol
carlosvdr Oct 17, 2023
e351b70
test
carlosvdr Oct 17, 2023
2790090
changed location
carlosvdr Oct 17, 2023
b44c510
path changes
carlosvdr Oct 17, 2023
a0ea97e
added tests piece
carlosvdr Oct 17, 2023
e44d7a8
changed contract init
carlosvdr Oct 17, 2023
04d5ace
addedd dots to go up the root
carlosvdr Oct 17, 2023
ac2008e
fix
carlosvdr Oct 17, 2023
b6bc106
fixed
carlosvdr Oct 17, 2023
858b642
fixed name
carlosvdr Oct 17, 2023
db95fd2
v
carlosvdr Oct 17, 2023
ce49832
removed typo
carlosvdr Oct 17, 2023
8f14dbd
t
carlosvdr Oct 17, 2023
13c1647
fix path
carlosvdr Oct 17, 2023
f99920c
added logs
carlosvdr Oct 18, 2023
ba8409c
added yarn
carlosvdr Oct 18, 2023
bbe0c6c
final tests
carlosvdr Oct 18, 2023
b96375a
test
carlosvdr Oct 25, 2023
8abc359
force a version in docker compose
carlosvdr Oct 25, 2023
8ada661
push version
carlosvdr Oct 25, 2023
691eaa4
push foundry nightly
carlosvdr Oct 25, 2023
ad15019
try retrying
carlosvdr Oct 26, 2023
8d40fb9
test
carlosvdr Oct 26, 2023
5da76cd
again
carlosvdr Oct 26, 2023
9c57897
adding retry
carlosvdr Oct 26, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 48 additions & 0 deletions .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
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@v4
name: Check out repository
with:
submodules: recursive
- 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: Checking graph-node availability
uses: nick-fields/retry@v2
with:
max_attempts: 3
retry_on: error
timeout_seconds: 5
command: nc -zv 127.0.0.1 8030
- 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
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
"name": "tap-subgraph",
"version": "1.0.0",
"main": "index.js",
"license": "Apache-2.0 license",
"license": "Apache-2.0",
"scripts": {
"codegen": "graph codegen --output-dir src/types/",
"build": "graph build",
"create-local": "graph create semiotic/tap --node http://127.0.0.1:8020",
"deploy-local": "graph deploy semiotic/tap --ipfs http://127.0.0.1:5001 --node http://127.0.0.1:8020"
"deploy-local": "graph deploy semiotic/tap --ipfs http://127.0.0.1:5001 --node http://127.0.0.1:8020 -l v0"
},
"dependencies": {
"@graphprotocol/graph-cli": "^0.54.0",
Expand Down
3 changes: 1 addition & 2 deletions subgraph.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ dataSources:
name: Escrow
network: mainnet
source:
address: '0x63De3720298826EB4EC14F1214b33a2808e5DADf'
address: '0x45F97e4bEe19580807501C32a71D06f7F7c72f4f'
abi: Escrow
startBlock: 0
mapping:
Expand All @@ -34,4 +34,3 @@ dataSources:
handler: handleSignerAuthorization
- event: RevokeAuthorizedSigner(indexed address,indexed address)
handler: handleRevokeSignerAuthorization

12 changes: 11 additions & 1 deletion tests/contract_calls.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from web3.exceptions import ContractCustomError, ContractLogicError
import json
from eth_account.messages import encode_defunct
import sys
import time
from helpers import decode_custom_error, time_remaining
from helpers import (
Expand All @@ -18,6 +19,7 @@
import sys
from eip712.messages import EIP712Message


# This script will help test that the subgraph is actually catching the required information
ESCROW_ADDRESS = sys.argv[1]
TAP_ADDRESS = sys.argv[2]
Expand Down Expand Up @@ -85,8 +87,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)
print ('Logic Error: %s' % e)
sys.exit(1)

# MOCK STAKING CONTRACT CALLS
try:
Expand All @@ -95,8 +99,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 @@ -145,6 +151,7 @@ class ReceiptAggregateVoucher(EIP712Message):
print("Skip, signer already authorized")
else:
print(error)
sys.exit(1)
check_subgraph_signer(SIGNER, True)

print("Executing deposit for redeem")
Expand Down Expand Up @@ -181,7 +188,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)
13 changes: 9 additions & 4 deletions tests/contract_init.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ RECEIVER=0x22d491Bde2303f2f43325b2108D26f1eAbA1e32b

# Obtain curren dir
current_dir=$(pwd)

echo "Step 1: Run graph contracts"
cd $current_dir/contracts
yarn
Expand All @@ -15,7 +14,7 @@ FULL_CMD_LOG="$(yes | yarn deploy-localhost --auto-mine)"
echo "Obtaining Graph address token"
GRAPH_TOKEN=$(jq '."1337".GraphToken.address' addresses.json -r)


FULL_TAP_CONTRACT_PATH = $current_dir/timeline-aggregation-protocol-contracts
command cd $current_dir/timeline-aggregation-protocol-contracts
command yarn
command forge install
Expand All @@ -42,15 +41,21 @@ 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 contract_calls.py "$ESCROW_AD" "$TAP_VERIFIER_AD" "$GRAPH_TOKEN" "$ISTAKING_AD"
python local_contract_calls.py "$ESCROW_AD" "$TAP_VERIFIER_AD" "$GRAPH_TOKEN" "$ISTAKING_AD"

if [ $? -ne 0 ]; then
exit 1
fi


4 changes: 2 additions & 2 deletions tests/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
version: '3'
services:
graph-node:
image: graphprotocol/graph-node
image: graphprotocol/graph-node:v0.32.0
ports:
- '8000:8000'
- '8001:8001'
Expand Down Expand Up @@ -42,7 +42,7 @@ services:
PGDATA: "/var/lib/postgresql/data"
POSTGRES_INITDB_ARGS: "-E UTF8 --locale=C"
anvil:
image: ghcr.io/foundry-rs/foundry:latest
image: ghcr.io/foundry-rs/foundry:nightly-602460eb99e1645eab970bacc5a6d01368a07457
ports:
- '8545:8545'
command:
Expand Down
Loading
Loading