Skip to content

ibc testing using emerynet and local chain #12

ibc testing using emerynet and local chain

ibc testing using emerynet and local chain #12

name: IBC Testing with Emerynet and Local Chain
on:
push:
branches: [main]
pull_request:
branches: [main]
workflow_dispatch:
jobs:
ibc-testing:
runs-on: ubuntu-latest
env:
EMERYNET_BALANCE_FILE: emerynet_balance.txt
EMERYNET_CHAIN_ID: agoric-emerynet-8
LOCAL_CHAIN_ID: agoric-local
WALLET_ADDRESS_EMERYNET: agoric10emrzln03exuc9uv98mjwmp95735mjm6k2n9xm
WALLET_ADDRESS_LOCAL: agoric1myfpdaxyj34lqexe9cypu6vrf34xemtfq2a0nt
RELAYER_CONFIG: /workspace/relayer/config-testnet.toml
TRANSFER_AMOUNT_FROM_EMERYNET: 100
TRANSFER_AMOUNT_FROM_LOCAL: 50
steps:
- name: Checkout Repository
uses: actions/checkout@v4
- name: Start Agoric Local Chain
run: docker-compose -f docker-compose-testnet.yaml up -d agoric-local
- name: Wait for Local container to be ready
run: |
timeout 300 bash -c '
TARGET_HEIGHT=1261
SLEEP=10
echo "Waiting for the Agoric service to be fully ready..."
echo "Target block height: $TARGET_HEIGHT"
while true; do
response=$(curl -s http://localhost:26657/abci_info);
height=$(echo $response | jq -r ".result.response.last_block_height | tonumber");
if [ "$height" -ge $TARGET_HEIGHT ]; then
echo "Service is ready! Last block height: $height";
break;
else
echo "Waiting for last block height to reach $TARGET_HEIGHT. Current height: $height";
fi;
sleep $SLEEP;
done
'
- name: Start Relayer Service
run: docker-compose -f docker-compose-testnet.yaml up -d relayer
- name: Check if Hermes relayer has started
run: |
timeout 540 bash -c "\
until docker logs relayer 2>&1 | grep -q 'Hermes has started'; do
echo 'waiting for relayer to start...'
done"
- name: Store Emerynet Wallet Balance in a file
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
- name: Monitor Channel Initialization
run: |
timeout 360 bash -c "\
until line=\$(docker logs relayer 2>&1 | grep 'OpenInitChannel'); do
echo 'Waiting for channel initialization...'
sleep 1
done
if [[ -n \$line ]]; then
channel_id=\$(echo \$line | awk -F'channel_id: ' '{print \$2}' | awk -F', ' '{print \$1}')
echo \"Channel ID extracted: \$channel_id\"
echo \$channel_id > channel_id.txt
else
echo 'Channel initialization timed out.'
exit 1
fi"
- name: Confirm Channel Status
run: |
channel_id=$(cat channel_id.txt)
timeout 600 bash -c "\
until docker logs relayer 2>&1 | grep -q 'OpenConfirmChannel.*$channel_id'; do
echo 'Awaiting confirmation for channel ID: $channel_id...'
sleep 1
done
echo 'Channel ID $channel_id confirmed.'"
- name: Execute IBC Token Transfer from Emerynet to Local Chain
run: |
docker exec relayer hermes --config $RELAYER_CONFIG tx ft-transfer --src-chain $EMERYNET_CHAIN_ID --src-channel $(cat channel_id.txt) \
--dst-chain $LOCAL_CHAIN_ID --src-port transfer --amount $TRANSFER_AMOUNT_FROM_EMERYNET --denom 'ubld' --timeout-seconds 1000 && \
sleep 5
- name: Check Token Balance on Emerynet after transfer
run: |
NEW_EMERYNET_BALANCE=$(curl https://emerynet.api.agoric.net/cosmos/bank/v1beta1/balances/$WALLET_ADDRESS_EMERYNET |
jq -r '.balances[] | select(.denom == "ubld") | .amount | tonumber')
ORIGINAL_EMERYNET_BALANCE=$(cat $EMERYNET_BALANCE_FILE)
BALANCE_DIFFERENCE=$((ORIGINAL_EMERYNET_BALANCE - NEW_EMERYNET_BALANCE))
if [ "$BALANCE_DIFFERENCE" -ne 100 ]; then
echo "Token transfer discrepancy detected: Expected 100, found $BALANCE_DIFFERENCE."
exit 1
else
echo "Token transfer validated: Balance difference is exactly 100ubld."
fi
- name: Check Token Balance on Local Chain after transfer
uses: ./.github/actions/check-balances
with:
container: ${{ env.LOCAL_CHAIN_ID }}
address: ${{ env.WALLET_ADDRESS_LOCAL }}
expected_amount: ${{ env.TRANSFER_AMOUNT_FROM_EMERYNET }}
expected_denom: 'ibc/49C630713B2AB60653F76C0C58D43C2A64956803B4D422CACB6DD4AD016ED846'
expected_length: '2'
- name: Store Emerynet Wallet Balance in a file
run: |
curl https://emerynet.api.agoric.net/cosmos/bank/v1beta1/balances/$WALLET_ADDRESS_EMERYNET |
jq -r '.balances[] | select(.denom == "ubld") | .amount' > $EMERYNET_BALANCE_FILE
- name: Execute IBC Token Transfer from Local Chain to Emerynet
run: |
docker exec relayer hermes --config $RELAYER_CONFIG tx ft-transfer --src-chain $LOCAL_CHAIN_ID --src-channel channel-0 \
--dst-chain $EMERYNET_CHAIN_ID --src-port transfer --amount $TRANSFER_AMOUNT_FROM_LOCAL --denom 'ibc/49C630713B2AB60653F76C0C58D43C2A64956803B4D422CACB6DD4AD016ED846' --timeout-seconds 1000 && \
sleep 5
- name: Check Token Balance on Local Chain after transfer
uses: ./.github/actions/check-balances
with:
container: ${{ env.LOCAL_CHAIN_ID }}
address: ${{ env.WALLET_ADDRESS_LOCAL }}
expected_amount: '50'
expected_denom: 'ibc/49C630713B2AB60653F76C0C58D43C2A64956803B4D422CACB6DD4AD016ED846'
expected_length: '2'
- name: Check Token Balance on Emerynet after transfer
run: |
timeout 120 bash -c "\
OLD_BALANCE=\$(cat \"\$EMERYNET_BALANCE_FILE\")
NEW_BALANCE=\$(curl -s https://emerynet.api.agoric.net/cosmos/bank/v1beta1/balances/\"\$WALLET_ADDRESS_EMERYNET\" | jq -r '.balances[] | select(.denom == \"ubld\") | .amount')
until [ \"\$NEW_BALANCE\" -gt \"\$OLD_BALANCE\" ]; do
NEW_BALANCE=\$(curl -s https://emerynet.api.agoric.net/cosmos/bank/v1beta1/balances/\"\$WALLET_ADDRESS_EMERYNET\" | jq -r '.balances[] | select(.denom == \"ubld\") | .amount')
echo \"Old Balance: \$OLD_BALANCE\"
echo \"New Balance: \$NEW_BALANCE\"
done
"