Skip to content

Commit 3c596ef

Browse files
author
Daisuke Kanda
committed
add timeout test
Signed-off-by: Daisuke Kanda <daisuke.kanda@datachain.jp>
1 parent 6c48470 commit 3c596ef

File tree

3 files changed

+68
-0
lines changed

3 files changed

+68
-0
lines changed

tests/e2e/cases/tm2eth/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ test-channel-upgrade:
2828
.PHONY: test
2929
test:
3030
RLY_BIN=$(RLY_BIN) ./scripts/test-tx
31+
RLY_BIN=$(RLY_BIN) ./scripts/test-tx-timeout
3132

3233
.PHONY: restore
3334
restore:
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
#!/bin/bash
2+
set -eux
3+
4+
RLY="${RLY_BIN} --debug"
5+
6+
# XXX set proper value
7+
PATH_NAME=ibc01
8+
TX_INTERVAL=120
9+
TM_USER_ADDRESS=$(${RLY} tendermint keys show ibc0 testkey)
10+
11+
retry() {
12+
local -r -i max_attempts="$1"; shift
13+
local -r cmd="$@"
14+
local -i attempt_num=1
15+
16+
until $cmd
17+
do
18+
if (( attempt_num == max_attempts ))
19+
then
20+
echo "Attempt $attempt_num failed and there are no more attempts left!"
21+
return 1
22+
else
23+
echo "Attempt $attempt_num failed! Trying again in $attempt_num seconds..."
24+
sleep $(( attempt_num++ ))
25+
fi
26+
done
27+
}
28+
29+
TMPFILE=/tmp/tm2eth-test-tx-timeout.log
30+
31+
echo "!!! ibc0 -> ibc1 !!!"
32+
33+
docker exec tendermint-chain sh -c "simd --home /root/data/ibc0 tx --keyring-backend=test --from ${TM_USER_ADDRESS} --chain-id ibc0 mockapp send --packet-timeout-height 0-1 mockapp channel-0 'mock packet data' --yes"
34+
sleep ${TX_INTERVAL}
35+
retry 10 ${RLY} tx relay ${PATH_NAME} 2>&1 | tee $TMPFILE
36+
if grep -i 'Error' $TMPFILE; then exit 1; fi
37+
grep -e 'core\.(\*RelayMsgs)\.Send' $TMPFILE | grep ProofUnreceived
38+
39+
40+
echo "!!! ibc1 -> ibc0 !!!"
41+
RPC_ADDRESS_B=$($RLY config show | jq -r '.chains[] | select(.chain.chain_id == "ibc1").chain.rpc_addr')
42+
PORT_B=$($RLY paths list --json | jq -r --arg path $PATH_NAME '.[$path].dst."port-id"')
43+
CHANNEL_B=$($RLY paths list --json | jq -r --arg path $PATH_NAME '.[$path].dst."channel-id"')
44+
MNEMONIC_B=$($RLY config show | jq -r '.chains[] | select(.chain.chain_id == "ibc1").chain.signer.mnemonic')
45+
BOB_INDEX=2
46+
ADDRESSES_DIR_B=$(dirname $0)/../../../chains/ethereum/contracts/addresses
47+
MOCKAPP_CONTRACT_B=`cat ${ADDRESSES_DIR_B}/AppV1`
48+
49+
cast send \
50+
--rpc-url $RPC_ADDRESS_B \
51+
--mnemonic "$MNEMONIC_B" \
52+
--mnemonic-index ${BOB_INDEX} \
53+
$MOCKAPP_CONTRACT_B \
54+
'sendPacket(bytes,string,string,(uint64,uint64),uint64)' \
55+
$(cast from-utf8 'mock packet data') \
56+
$PORT_B \
57+
$CHANNEL_B \
58+
'(0,100000)' \
59+
$(date -d 1sec +%s%N)
60+
sleep ${TX_INTERVAL}
61+
sleep ${TX_INTERVAL}
62+
cast block-number --rpc-url $RPC_ADDRESS_B
63+
${RLY} tx relay $PATH_NAME 2>&1 | tee $TMPFILE
64+
65+
if grep -i 'Error' $TMPFILE; then exit 1; fi
66+
grep -e 'core\.(\*RelayMsgs)\.Send' $TMPFILE | grep ProofUnreceived

tests/e2e/chains/ethereum/contracts/contracts/App.sol

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ contract AppV1 is IBCContractUpgradableUUPSMockApp {
1010

1111
function __AppV1_init(string memory initialVersion) public initializer {
1212
__IBCContractUpgradableUUPSMockApp_init(initialVersion);
13+
allowCloseChannel(true);
1314
}
1415
}
1516

0 commit comments

Comments
 (0)