Skip to content

Commit a6f077a

Browse files
author
Daisuke Kanda
committed
add timeout test cases
Signed-off-by: Daisuke Kanda <daisuke.kanda@datachain.jp>
1 parent 5062ac4 commit a6f077a

File tree

8 files changed

+110
-13
lines changed

8 files changed

+110
-13
lines changed

tests/cases/eth2eth/scripts/init-rly

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
set -eu
44

55
SCRIPT_DIR=$(cd $(dirname ${BASH_SOURCE:-$0}); pwd)
6-
source ${SCRIPT_DIR}/util/relayer-util
76
PATH_JSON=${1:-path.json}
7+
source ${SCRIPT_DIR}/util/relayer-util
88

99
rm -rf ${RELAYER_CONF} &> /dev/null
1010

@@ -14,4 +14,5 @@ ${RLY} config init
1414
${RLY} chains add-dir ${CONF_DIR}/chains/
1515

1616
# add a path between chain0 and chain1
17-
$RLY paths add $CHAINID_ONE $CHAINID_TWO $PATH_NAME --file=${CONF_DIR}/$PATH_JSON
17+
$RLY paths add $CHAINID_ONE $CHAINID_TWO $PATH_NAME --file=${CONF_DIR}/${PATH_JSON}
18+

tests/cases/eth2eth/scripts/test-timeout

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,11 @@ cast send \
4141
$(date -d 1sec +%s%N)
4242

4343
sleep 5
44-
tmpfile=$0.log
44+
TMPFILE=$0.log
4545
waitRelay "sendPacket" "unrelayed-packets" "src"
46-
${RLY} tx relay ${PATH_NAME} 2>&1 | tee $tmpfile
47-
grep -e 'core\.(\*RelayMsgs)\.Send' $tmpfile | grep ProofUnreceived
46+
${RLY} tx relay ${PATH_NAME} 2>&1 | tee $TMPFILE
47+
if grep -i 'Error' $TMPFILE; then exit 1; fi
48+
grep -e 'core\.(\*RelayMsgs)\.Send' $TMPFILE | grep ProofUnreceived
49+
4850

4951

tests/cases/tm2eth/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ test:
1515
./scripts/test-channel-upgrade
1616
./scripts/test-mockapp-packet-relay
1717
./scripts/test-ics20-packet-relay
18+
./scripts/test-mockapp-packet-timeout
1819

1920
.PHONY: network-down
2021
network-down:
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
#!/bin/bash
2+
3+
set -eux
4+
5+
TMPFILE=$0.log
6+
SCRIPT_DIR=$(cd $(dirname ${BASH_SOURCE:-$0}); pwd)
7+
FIXTURES_DIR=${SCRIPT_DIR}/../fixtures
8+
9+
RELAYER_CONF="$HOME/.yui-relayer"
10+
RLY_BINARY=${SCRIPT_DIR}/../../../../build/yrly
11+
RLY="${RLY_BINARY} --debug"
12+
13+
PATH_NAME=mockapp-path
14+
15+
ADDRESSES_DIR_B="${FIXTURES_DIR}/ethereum/ibc1/addresses"
16+
MOCKAPP_CONTRACT_B=`cat ${ADDRESSES_DIR_B}/AppV1`
17+
18+
MNEMONIC_B=$($RLY config show | jq -r '.chains[] | select(.chain.chain_id == "ibc1").chain.signer.mnemonic')
19+
RPC_ADDRESS_B=$($RLY config show | jq -r '.chains[] | select(.chain.chain_id == "ibc1").chain.rpc_addr')
20+
PORT_B=$($RLY paths list --json | jq -r --arg path $PATH_NAME '.[$path].dst."port-id"')
21+
CHANNEL_B=$($RLY paths list --json | jq -r --arg path $PATH_NAME '.[$path].dst."channel-id"')
22+
23+
TX_INTERVAL=3
24+
25+
echo "!!! ibc0 -> ibc1 !!!"
26+
TM_ADDRESS=$(${RLY} tendermint keys show ibc0 testkey)
27+
docker exec tendermint-chain0-mock sh -c "simd --home /root/data/ibc0 tx --keyring-backend=test --from ${TM_ADDRESS} --chain-id ibc0 mockapp send --packet-timeout-height 0-1 mockapp ${CHANNEL_B} 'mock packet data' --yes"
28+
sleep ${TX_INTERVAL}
29+
${RLY} tx relay $PATH_NAME 2>&1 | tee $TMPFILE
30+
sleep ${TX_INTERVAL}
31+
if grep -i 'Error' $TMPFILE; then exit 1; fi
32+
grep -e 'core\.(\*RelayMsgs)\.Send' $TMPFILE | grep ProofUnreceived
33+
34+
echo "!!! ibc1 -> ibc0 !!!"
35+
BOB_INDEX=2
36+
cast send \
37+
--rpc-url $RPC_ADDRESS_B \
38+
--mnemonic "$MNEMONIC_B" \
39+
--mnemonic-index ${BOB_INDEX} \
40+
$MOCKAPP_CONTRACT_B \
41+
'sendPacket(bytes,string,string,(uint64,uint64),uint64)' \
42+
$(cast from-utf8 'mock packet data') \
43+
$PORT_B \
44+
$CHANNEL_B \
45+
'(0,100000)' \
46+
$(date -d 1sec +%s%N)
47+
sleep ${TX_INTERVAL}
48+
${RLY} tx relay $PATH_NAME 2>&1 | tee $TMPFILE
49+
sleep ${TX_INTERVAL}
50+
if grep -i 'Error' $TMPFILE; then exit 1; fi
51+
grep -e 'core\.(\*RelayMsgs)\.Send' $TMPFILE | grep ProofUnreceived

tests/cases/tm2tm/Makefile

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,22 @@ network:
77
up -d \
88
tendermint-chain0 tendermint-chain1
99

10-
.PHONY: test
10+
.PHONY: test test-unorderd test-ordered
1111
test:
12+
$(MAKE) test-unordered test-ordered
13+
14+
test-unordered:
1215
./scripts/fixture
1316
./scripts/init-rly
1417
./scripts/handshake
1518
./scripts/test-tx
16-
./scripts/test-timeout
19+
./scripts/test-timeout transfer
20+
21+
test-ordered:
22+
./scripts/fixture
23+
./scripts/init-rly
24+
./scripts/handshake path-ordered.json
25+
./scripts/test-timeout mockapp
1726

1827
.PHONY: network-down
1928
network-down:
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{
2+
"src": {
3+
"chain-id": "ibc0",
4+
"client-id": "",
5+
"connection-id": "",
6+
"channel-id": "",
7+
"port-id": "mockapp",
8+
"order": "ordered",
9+
"version": "mockapp-1"
10+
},
11+
"dst": {
12+
"chain-id": "ibc1",
13+
"client-id": "",
14+
"connection-id": "",
15+
"channel-id": "",
16+
"port-id": "mockapp",
17+
"order": "ordered",
18+
"version": "mockapp-1"
19+
},
20+
"strategy": {
21+
"type": "naive"
22+
}
23+
}

tests/cases/tm2tm/scripts/handshake

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ set -eux
55
source $(cd $(dirname "$0"); pwd)/../../../scripts/util
66

77
SCRIPT_DIR=$(cd $(dirname $0); pwd)
8+
PATH_JSON=${1:-path.json}
89
RLY_BINARY=${SCRIPT_DIR}/../../../../build/yrly
910
RLY="${RLY_BINARY} --debug"
1011

@@ -25,7 +26,7 @@ retry 5 $RLY tendermint light init $CHAINID_TWO -f
2526
# $RLY q bal $CHAINID_TWO
2627

2728
# add a path between chain0 and chain1
28-
$RLY paths add $CHAINID_ONE $CHAINID_TWO $PATH_NAME --file=./configs/path.json
29+
$RLY paths add $CHAINID_ONE $CHAINID_TWO $PATH_NAME --file=./configs/${PATH_JSON}
2930

3031
retry 5 $RLY tx clients $PATH_NAME
3132
$RLY query client $PATH_NAME $CHAINID_ONE 2>/dev/null | jq -Rs 'fromjson'

tests/cases/tm2tm/scripts/test-timeout

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
set -eux
44

55
SCRIPT_DIR=$(cd $(dirname $0); pwd)
6+
APP=$1
67
RLY_BINARY=${SCRIPT_DIR}/../../../../build/yrly
78
RLY="${RLY_BINARY} --debug"
89

@@ -17,15 +18,23 @@ echo "!!! ibc0 -> ibc1 !!!"
1718
echo "Before ibc0 balance: $(${RLY} query balance ibc0 ${TM_ADDRESS0})"
1819
echo "Before ibc1 balance: $(${RLY} query balance ibc1 ${TM_ADDRESS1})"
1920

20-
${RLY} query channel ibc01 ibc0
21-
${RLY} tx transfer --timeout-height-offset 1 ibc01 ibc0 ibc1 100samoleans ${TM_ADDRESS1}
21+
PATH_NAME=ibc01
22+
if [[ $APP = "transfer" ]]; then
23+
${RLY} tx transfer --timeout-height-offset 1 ibc01 ibc0 ibc1 100samoleans ${TM_ADDRESS1}
24+
else
25+
CHANNEL_NAME=$(${RLY} query channel ${PATH_NAME} ibc0 | jq -r '.counterparty.channelId')
26+
docker exec tendermint-chain0 sh -c "simd --home /root/data/ibc0 tx --keyring-backend=test --from ${TM_ADDRESS0} --chain-id ibc0 mockapp send --packet-timeout-height 0-1 mockapp ${CHANNEL_NAME} 'mock packet data' --yes"
27+
fi
2228
sleep ${TX_INTERVAL}
2329

24-
tmpfile=$0.log
25-
${RLY} tx relay ibc01 2>&1 | tee $tmpfile
30+
TMPFILE=$0.log
31+
${RLY} tx relay ibc01 2>&1 | tee $TMPFILE
2632
sleep ${TX_INTERVAL}
2733

28-
grep -e 'core\.(\*RelayMsgs)\.Send' $tmpfile | grep ProofUnreceived
34+
if grep -i 'Error' $TMPFILE; then exit 1; fi
35+
grep -e 'core\.(\*RelayMsgs)\.Send' $TMPFILE | grep ProofUnreceived
2936

3037
echo "After ibc0 balance: $(${RLY} query balance ibc0 ${TM_ADDRESS0})"
3138
echo "After ibc1 balance: $(${RLY} query balance ibc1 ${TM_ADDRESS1})"
39+
40+

0 commit comments

Comments
 (0)