Skip to content

Commit 4783ce4

Browse files
Jorge-Lopesanilhelvaci
authored andcommitted
test: swap BLD for OSMO with receiver on CosmosHub
ref: #8863
1 parent 3aba31f commit 4783ce4

File tree

4 files changed

+282
-163
lines changed

4 files changed

+282
-163
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
#!/bin/bash
2+
3+
set -euo pipefail
4+
shopt -s expand_aliases
5+
6+
alias osmosis-exec="kubectl exec -i osmosislocal-genesis-0 -c validator -- osmosisd"
7+
alias osmosis-cli="kubectl exec -i osmosislocal-genesis-0 -c validator -- /bin/bash -c"
8+
alias hermes-exec="kubectl exec -i hermes-agoric-osmosis-0 -c relayer -- hermes"
9+
10+
REGISTRY_ADDRESS=$(osmosis-cli "jq -r '.crosschain_registry.address' /contract-info.json")
11+
12+
CHAIN_A="$1"
13+
CHAIN_B="$2"
14+
15+
CHANNEL_INFO=$(hermes-exec --json query channels --show-counterparty --chain "${CHAIN_A}local" \
16+
| jq --arg CHAIN_B_LOCAL "${CHAIN_B}local" '.result[] | select(.chain_id_b == $CHAIN_B_LOCAL)')
17+
18+
CHAIN_A_CHAIN_B_CHANNEL=$(echo "$CHANNEL_INFO" | jq -r '.channel_a')
19+
CHAIN_B_CHAIN_A_CHANNEL=$(echo "$CHANNEL_INFO" | jq -r '.channel_b')
20+
21+
OSMOSIS_GENESIS_WALLET="genesis"
22+
OSMOSIS_GENESIS_ADDRESS=$(osmosis-exec keys show ${OSMOSIS_GENESIS_WALLET} -a)
23+
24+
MAX_RETRIES="5"
25+
DELAY="5"
26+
27+
MODIFY_CHAIN_CHANNEL_LINKS=$(jq -n \
28+
--arg chainA "$CHAIN_A" \
29+
--arg chainB "$CHAIN_B" \
30+
--arg channelA "$CHAIN_A_CHAIN_B_CHANNEL" \
31+
--arg channelB "$CHAIN_B_CHAIN_A_CHANNEL" \
32+
'{
33+
modify_chain_channel_links: {
34+
operations: [
35+
{
36+
operation: "set",
37+
source_chain: $chainA,
38+
destination_chain: $chainB,
39+
channel_id: $channelA
40+
},
41+
{
42+
operation: "set",
43+
source_chain: $chainB,
44+
destination_chain: $chainA,
45+
channel_id: $channelB
46+
}
47+
]}
48+
}')
49+
50+
GET_CHAIN_CHANNEL_LINKS=$(jq -n \
51+
--arg chainA "$CHAIN_A" \
52+
--arg chainB "$CHAIN_B" \
53+
'{
54+
get_channel_from_chain_pair: {
55+
source_chain: $chainA,
56+
destination_chain: $chainB,
57+
}
58+
}')
59+
60+
echo "Modifying chain channel links ..."
61+
osmosis-exec tx wasm execute "$REGISTRY_ADDRESS" "$MODIFY_CHAIN_CHANNEL_LINKS" --from "$OSMOSIS_GENESIS_ADDRESS" --keyring-backend=test --gas=auto --gas-prices 0.1uosmo --gas-adjustment 1.3 --yes --chain-id osmosislocal
62+
63+
echo "Querying chain channel links ..."
64+
(
65+
set +e
66+
67+
for ((i = 1; i <= MAX_RETRIES; i++)); do
68+
echo "Attempt $i of $MAX_RETRIES..."
69+
chain_channel_link=$(osmosis-exec query wasm contract-state smart "$REGISTRY_ADDRESS" "$GET_CHAIN_CHANNEL_LINKS" 2> /dev/null)
70+
71+
if [[ $? -eq 0 && $chain_channel_link = "{\"data\":\"$CHAIN_A_CHAIN_B_CHANNEL\"}" ]]; then
72+
echo "Chain channel link found:"
73+
echo "$chain_channel_link"
74+
break
75+
fi
76+
77+
if [[ $i -eq MAX_RETRIES ]]; then
78+
echo "Chain channel link not registered after $MAX_RETRIES attempts."
79+
exit 1
80+
fi
81+
82+
echo "Query failed. Waiting $DELAY seconds before retrying..."
83+
sleep "$DELAY"
84+
done
85+
)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
#!/bin/bash
2+
3+
set -euo pipefail
4+
shopt -s expand_aliases
5+
6+
alias osmosis-exec="kubectl exec -i osmosislocal-genesis-0 -c validator -- osmosisd"
7+
alias osmosis-cli="kubectl exec -i osmosislocal-genesis-0 -c validator -- /bin/bash -c"
8+
alias hermes-exec="kubectl exec -i hermes-agoric-osmosis-0 -c relayer -- hermes"
9+
10+
REGISTRY_ADDRESS=$(osmosis-cli "jq -r '.crosschain_registry.address' /contract-info.json")
11+
12+
OSMOSIS_GENESIS_WALLET="genesis"
13+
OSMOSIS_GENESIS_ADDRESS=$(osmosis-exec keys show ${OSMOSIS_GENESIS_WALLET} -a)
14+
15+
MAX_RETRIES="5"
16+
DELAY="5"
17+
18+
MODIFY_BECH32_PREFIXES=$(jq -n \
19+
'{
20+
modify_bech32_prefixes: {
21+
operations: [
22+
{
23+
operation: "set",
24+
chain_name: "osmosis",
25+
prefix: "osmo"
26+
},
27+
{
28+
operation: "set",
29+
chain_name: "agoric",
30+
prefix: "agoric"
31+
},
32+
{
33+
operation: "set",
34+
chain_name: "cosmoshub",
35+
prefix: "cosmos"
36+
}
37+
]
38+
}
39+
}')
40+
41+
GET_BECH32_PREFIXES=$(jq -n \
42+
'{
43+
get_bech32_prefix_from_chain_name: {
44+
chain_name: "osmosis",
45+
}
46+
}')
47+
48+
echo "Modifying prefixes ..."
49+
osmosis-exec tx wasm execute "$REGISTRY_ADDRESS" "$MODIFY_BECH32_PREFIXES" --from "$OSMOSIS_GENESIS_ADDRESS" --keyring-backend=test --gas=auto --gas-prices 0.1uosmo --gas-adjustment 1.3 --yes --chain-id osmosislocal
50+
51+
echo "Querying prefixes ..."
52+
(
53+
set +e
54+
55+
for ((i = 1; i <= MAX_RETRIES; i++)); do
56+
echo "Attempt $i of $MAX_RETRIES..."
57+
chain_channel_link=$(osmosis-exec query wasm contract-state smart "$REGISTRY_ADDRESS" "$GET_BECH32_PREFIXES" 2> /dev/null)
58+
59+
if [[ $? -eq 0 && $chain_channel_link = '{"data":"osmo"}' ]]; then
60+
echo "Prefixes found:"
61+
echo "$chain_channel_link"
62+
break
63+
fi
64+
65+
if [[ $i -eq MAX_RETRIES ]]; then
66+
echo "Prefixes not registered after $MAX_RETRIES attempts."
67+
exit 1
68+
fi
69+
70+
echo "Query failed. Waiting $DELAY seconds before retrying..."
71+
sleep "$DELAY"
72+
done
73+
)

multichain-testing/scripts/setup-xcs-state.sh

-129
This file was deleted.

0 commit comments

Comments
 (0)