Skip to content

Commit

Permalink
ci: changes to run pipeline with local chain
Browse files Browse the repository at this point in the history
  • Loading branch information
rabi-siddique committed Jul 23, 2024
1 parent 802f0e5 commit d386d41
Show file tree
Hide file tree
Showing 4 changed files with 68 additions and 64 deletions.
41 changes: 41 additions & 0 deletions .github/actions/check-balances/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: 'Check Token Balances'
description: 'Checks token balances on specified blockchain containers.'

inputs:
container:
description: 'Docker container name'
required: true
address:
description: 'Wallet address to check the balance'
required: true
expected_amount:
description: 'Expected token amount'
required: true
expected_denom:
description: 'Expected token denomination'
required: true
expected_length:
description: 'Expected number of balance entries'
required: true
default: '1'

runs:
using: 'composite'
steps:
- name: Check token balances and validate
shell: bash
run: |
# Fetch and process balances
json_output=$(docker exec ${{ inputs.container }} agd query bank balances ${{ inputs.address }} -o json)
balances=$(echo "$json_output" | jq '.balances')
length=$(echo "$balances" | jq 'length')
amount=$(echo "$balances" | jq -r '.[0].amount')
denom=$(echo "$balances" | jq -r '.[0].denom')
# Validate balances
if [ "$length" -ne "${{ inputs.expected_length }}" ] || [ "$amount" != "${{ inputs.expected_amount }}" ] || [ "$denom" != "${{ inputs.expected_denom }}" ]; then
echo "Failure: Expected ${{ inputs.expected_length }} entries with amount ${{ inputs.expected_amount }} and denom ${{ inputs.expected_denom }}, found length $length, amount $amount, denom $denom."
exit 1
else
echo "Success: Balance check passed with correct length and values."
fi
89 changes: 26 additions & 63 deletions .github/workflows/emerynet-devnet-test.yml
Original file line number Diff line number Diff line change
@@ -1,84 +1,47 @@
name: IBC Testing with Emerynet and Devnet
name: IBC Testing with Emerynet and Local Chain

on:
workflow_dispatch:

push:
branches: [main]
pull_request:
branches: [main]

jobs:
ibc-testing:
runs-on: ubuntu-latest

env:
EMERYNET_BALANCE_FILE: emerynet_file.txt
DEVNET_BALANCE_FILE: devnet_file.txt
LOCAL_BALANCE_FILE: local_file.txt
EMERYNET_CHAIN_ID: agoric-emerynet-8
DEVNET_CHAIN_ID: agoricdev-23
EMERYNET_NODE: https://emerynet.rpc.agoric.net:443
DEVNET_NODE: https://devnet.rpc.agoric.net
LOCAL_CHAIN_ID: agoric-local
WALLET_ADDRESS_EMERYNET: agoric10emrzln03exuc9uv98mjwmp95735mjm6k2n9xm
WALLET_ADDRESS_DEVNET: agoric1khw65emzav9t0cdhj3aw9x2v7m60jekjdf4whl
WALLET_ADDRESS_LOCAL: agoric1myfpdaxyj34lqexe9cypu6vrf34xemtfq2a0nt
RELAYER_CONFIG: /workspace/relayer/config-testnet.toml

steps:
- name: Checkout Repository
uses: actions/checkout@v4

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '18'

- name: Install Agoric globally
run: npm install -g agoric

- name: Locating files for Agoric Relayer
run: mkdir -p ~/.ibc-setup && cp -r ibc-setup/* ~/.ibc-setup/

- name: Start Testnet Docker Services
run: docker-compose -f docker-compose-testnet.yaml up -d

- name: Fetch Emerynet Wallet Balance
- name: Check if Hermes relayer has started
run: |
curl https://emerynet.api.agoric.net/cosmos/bank/v1beta1/balances/$WALLET_ADDRESS_EMERYNET |
jq -r '.balances[] | select(.denom == "ubld") | .amount | tonumber' > $EMERYNET_BALANCE_FILE
timeout 420 bash -c "\
until docker logs relayer 2>&1 | grep -q 'Hermes has started'; do
echo 'waiting for relayer to start...'
done"
- name: Fetch Devnet Wallet Balance
- name: Check Emerynet Wallet Balance
run: |
curl https://devnet.api.agoric.net/cosmos/bank/v1beta1/balances/$WALLET_ADDRESS_DEVNET |
jq -r '.balances | length' > $DEVNET_BALANCE_FILE
curl https://emerynet.api.agoric.net/cosmos/bank/v1beta1/balances/$WALLET_ADDRESS_EMERYNET |
jq -r '.balances[] | select(.denom == "ubld") | .amount | tonumber' > $EMERYNET_BALANCE_FILE
- name: Confirm Connection Status
- name: Verify Token Count in Local Chain Wallet
run: |
timeout 900 bash -c '
until docker logs relayer 2>&1 | grep -q "OpenConfirmConnection.*connection_id"; do
echo "Awaiting confirmation for connection..."
sleep 1
done
echo "Connection confirmed."
line=$(docker logs relayer 2>&1 | grep "OpenConfirmConnection.*connection_id")
connection_id=$(echo $line | awk -F "[ ,]" '\''{for(i=1;i<=NF;i++){if($i=="connection_id:"){print $(i+1)}}}'\'')
counterparty_connection_id=$(echo $line | awk -F "[ ,]" '\''{for(i=1;i<=NF;i++){if($i=="counterparty_connection_id:"){print $(i+1)}}}'\'')
if [[ -z "$connection_id" || -z "$counterparty_connection_id" ]]; then
echo "Error: Connection ID or Counterparty Connection ID is empty"
exit 1
fi
echo "Connection ID: $connection_id"
echo "Counterparty Connection ID: $counterparty_connection_id"
config_file="$HOME/.ibc-setup/app.yaml"
sed -i "s|^srcConnection: .*|srcConnection: $counterparty_connection_id|" "$config_file"
sed -i "s|^destConnection: .*|destConnection: $connection_id|" "$config_file"
cat "$config_file"
'
- name: Start Agoric Relayer
run: agoric ibc-relayer start --poll 10 &
curl http://localhost:1317/cosmos/bank/v1beta1/balances/$WALLET_ADDRESS_LOCAL |
jq -r '.balances | length' > $LOCAL_BALANCE_FILE
- name: Monitor Channel Initialization
run: |
Expand Down Expand Up @@ -109,7 +72,7 @@ jobs:
- name: Execute IBC Token Transfer
run: |
docker exec relayer hermes --config $RELAYER_CONFIG tx ft-transfer --src-chain $EMERYNET_CHAIN_ID --src-channel $(cat channel_id.txt) \
--dst-chain $DEVNET_CHAIN_ID --src-port transfer --amount 100 --denom 'ubld' --timeout-seconds 1000 && \
--dst-chain $LOCAL_CHAIN_ID --src-port transfer --amount 100 --denom 'ubld' --timeout-seconds 1000 && \
sleep 5
- name: Verify Token Transfer on Emerynet
Expand All @@ -122,14 +85,14 @@ jobs:
echo "Token transfer discrepancy detected: Expected 100, found $BALANCE_DIFFERENCE."
exit 1
else
echo "Token transfer validated: Balance difference is exactly 100."
echo "Token transfer validated: Balance difference is exactly 100ubld."
fi
- name: Verify Token Transfer on Devnet
- name: Verify Token Transfer on Local Chain
run: |
sleep 180
OLD_BALANCE_LENGTH=$(cat "$DEVNET_BALANCE_FILE")
NEW_BALANCE_LENGTH=$(curl -s https://devnet.api.agoric.net/cosmos/bank/v1beta1/balances/"$WALLET_ADDRESS_DEVNET" | jq -r '.balances | length')
sleep 120
OLD_BALANCE_LENGTH=$(cat "$LOCAL_BALANCE_FILE")
NEW_BALANCE_LENGTH=$(curl -s http://localhost:1317/cosmos/bank/v1beta1/balances/"$WALLET_ADDRESS_LOCAL" | jq -r '.balances | length')
echo "Old Balance Length: $OLD_BALANCE_LENGTH"
echo "New Balance Length: $NEW_BALANCE_LENGTH"
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion relayer/scripts/run-relayer.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ hermes --config $CONFIG_FILE keys add --chain $CHAIN1_ID --mnemonic-file $ALICE_
hermes --config $CONFIG_FILE keys add --chain $CHAIN2_ID --mnemonic-file $BOB_KEY

echo "Waiting for the local chain to start"
sleep 180
sleep 150
echo "Local chain started"

hermes --config $CONFIG_FILE create channel --a-chain $CHAIN1_ID --b-chain $CHAIN2_ID --a-port transfer --b-port transfer --new-client-connection --yes
Expand Down

0 comments on commit d386d41

Please sign in to comment.