Skip to content

Commit

Permalink
Merge pull request #3 from agoric-labs/rs-local-chain-ibc-testing
Browse files Browse the repository at this point in the history
local chain ibc testing
  • Loading branch information
rabi-siddique authored Jul 22, 2024
2 parents d7ee503 + ddbb598 commit 65d7efe
Show file tree
Hide file tree
Showing 2 changed files with 111 additions and 0 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
70 changes: 70 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
name: IBC Testing with Local Chains

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

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

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

- name: Build Docker image
run: docker build -t a3p:local .

- name: Start Docker Compose services
run: docker-compose up -d

- name: Check if Hermes relayer has started
run: |
timeout 240 bash -c "\
until docker logs relayer 2>&1 | grep -q 'Hermes has started'; do
echo 'waiting for relayer to start...'
done"
- name: Check token balance on chain 1
uses: ./.github/actions/check-balances
with:
container: 'agoric-local-1'
address: 'agoric1myfpdaxyj34lqexe9cypu6vrf34xemtfq2a0nt'
expected_amount: '500000000'
expected_denom: 'ubld'
expected_length: '1'

- name: Check token balance on chain 2
uses: ./.github/actions/check-balances
with:
container: 'agoric-local-2'
address: 'agoric1aczzle80960fc0vq8gemjuu8ydrql07az7fmur'
expected_amount: '500000000'
expected_denom: 'ubld'
expected_length: '1'

- name: Transfer tokens via IBC
run: |
docker exec relayer hermes --config /workspace/relayer/config.toml tx ft-transfer --src-chain agoric-local-1 --src-channel channel-0 \
--dst-chain agoric-local-2 --src-port transfer --amount 100 --denom 'ubld' --timeout-seconds 1000 && \
sleep 5
- name: Check token balance on chain 1 after transfer
uses: ./.github/actions/check-balances
with:
container: 'agoric-local-1'
address: 'agoric1myfpdaxyj34lqexe9cypu6vrf34xemtfq2a0nt'
expected_amount: '499999900'
expected_denom: 'ubld'
expected_length: '1'

- name: Check token balance on chain 2 after tansfer
uses: ./.github/actions/check-balances
with:
container: 'agoric-local-2'
address: 'agoric1aczzle80960fc0vq8gemjuu8ydrql07az7fmur'
expected_amount: '100'
expected_denom: 'ibc/49C630713B2AB60653F76C0C58D43C2A64956803B4D422CACB6DD4AD016ED846'
expected_length: '2'

0 comments on commit 65d7efe

Please sign in to comment.