Skip to content

ibc testing using emerynet and local chain #6

ibc testing using emerynet and local chain

ibc testing using emerynet and local chain #6

name: IBC Testing with Emerynet and Devnet
on:
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
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
WALLET_ADDRESS_EMERYNET: agoric10emrzln03exuc9uv98mjwmp95735mjm6k2n9xm
WALLET_ADDRESS_DEVNET: agoric1khw65emzav9t0cdhj3aw9x2v7m60jekjdf4whl
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
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: Fetch Devnet Wallet Balance
run: |
curl https://devnet.api.agoric.net/cosmos/bank/v1beta1/balances/$WALLET_ADDRESS_DEVNET |
jq -r '.balances | length' > $DEVNET_BALANCE_FILE
- name: Confirm Connection Status
run: |
timeout 600 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")
echo "Line: $line" # Debugging statement
connection_id=$(echo $line | grep -oP "connection_id: \K[^,]*")
counterparty_connection_id=$(echo $line | grep -oP "counterparty_connection_id: \K[^,]*")
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"
echo $connection_id > connection_id.txt
# Configuration file path
config_file="$HOME/.ibc-setup/app.yaml"
# Replace the srcConnection and destConnection values in the configuration file
sed -i "s/^srcConnection: .*/srcConnection: $connection_id/" "$config_file"
sed -i "s/^destConnection: .*/destConnection: $counterparty_connection_id/" "$config_file"
'
- name: Start Agoric Relayer
run: agoric ibc-relayer start --poll 10 &
- 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 300 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
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 && \
sleep 5
- name: Verify Token Transfer on Emerynet
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 100."
fi
- name: Verify Token Transfer on Devnet
run: |
sleep 180
OLD_BALANCE_LENGTH=$(cat $DEVNET_BALANCE_FILE)
NEW_BALANCE_LENGTH=$(curl https://devnet.api.agoric.net/cosmos/bank/v1beta1/balances/$WALLET_ADDRESS_DEVNET | jq -r '.balances | length')
if [ $OLD_BALANCE_LENGTH -gt $NEW_BALANCE_LENGTH ]
then
exit 0
else
exit 1
fi