Skip to content
Draft
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions tests/cases/eth2eth/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,15 @@ test-single:
./scripts/handshake
./scripts/test-channel-upgrade single
./scripts/test-tx
./scripts/test-timeout

.PHONY: test-ordered
test-ordered:
./scripts/fixture single
./scripts/init-rly path-ordered.json
./scripts/handshake
./scripts/test-tx
./scripts/test-timeout

.PHONY: network-down
network-down:
Expand Down
23 changes: 23 additions & 0 deletions tests/cases/eth2eth/configs/path-ordered.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"src": {
"chain-id": "ibc0",
"client-id": "",
"connection-id": "",
"channel-id": "",
"port-id": "mockapp",
"order": "ordered",
"version": "mockapp-1"
},
"dst": {
"chain-id": "ibc1",
"client-id": "",
"connection-id": "",
"channel-id": "",
"port-id": "mockapp",
"order": "ordered",
"version": "mockapp-1"
},
"strategy": {
"type": "naive"
}
}
4 changes: 3 additions & 1 deletion tests/cases/eth2eth/scripts/init-rly
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
set -eu

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

rm -rf ${RELAYER_CONF} &> /dev/null
Expand All @@ -13,4 +14,5 @@ ${RLY} config init
${RLY} chains add-dir ${CONF_DIR}/chains/

# add a path between chain0 and chain1
$RLY paths add $CHAINID_ONE $CHAINID_TWO $PATH_NAME --file=${CONF_DIR}/path.json
$RLY paths add $CHAINID_ONE $CHAINID_TWO $PATH_NAME --file=${CONF_DIR}/${PATH_JSON}

51 changes: 51 additions & 0 deletions tests/cases/eth2eth/scripts/test-timeout
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
#!/bin/bash

set -eux

SCRIPT_DIR=$(cd $(dirname ${BASH_SOURCE:-$0}); pwd)
FIXTURES_DIR=${SCRIPT_DIR}/../fixtures

source ${SCRIPT_DIR}/util/relayer-util

ADDRESSES_DIR_A="${FIXTURES_DIR}/ethereum/ibc0/addresses"
ADDRESSES_DIR_B="${FIXTURES_DIR}/ethereum/ibc1/addresses"
MOCKAPP_A=`cat ${ADDRESSES_DIR_A}/AppV1`
MOCKAPP_B=`cat ${ADDRESSES_DIR_B}/AppV1`

CONFIG_JSON=${RELAYER_CONF}/config/config.json

MNEMONIC_A=$(jq -r '.chains[] | select(.chain.chain_id == "ibc0").chain.signer.mnemonic' ${CONFIG_JSON})
MNEMONIC_B=$(jq -r '.chains[] | select(.chain.chain_id == "ibc1").chain.signer.mnemonic' ${CONFIG_JSON})

RPC_ADDRESS_A=$(jq -r '.chains[] | select(.chain.chain_id == "ibc0").chain.rpc_addr' ${CONFIG_JSON})
RPC_ADDRESS_B=$(jq -r '.chains[] | select(.chain.chain_id == "ibc1").chain.rpc_addr' ${CONFIG_JSON})

PORT_A=$(jq -r '.paths.ibc01.src."port-id"' ${CONFIG_JSON})
PORT_B=$(jq -r '.paths.ibc01.dst."port-id"' ${CONFIG_JSON})
CHANNEL_A=$(jq -r '.paths.ibc01.src."channel-id"' ${CONFIG_JSON})
CHANNEL_B=$(jq -r '.paths.ibc01.dst."channel-id"' ${CONFIG_JSON})

# send a packet from ibc0 to ibc1
echo "!!! ibc0 alice -> ibc1 bob !!!"
ALICE_INDEX=1
cast send \
--rpc-url $RPC_ADDRESS_A \
--mnemonic "$MNEMONIC_A" \
--mnemonic-index ${ALICE_INDEX} \
$MOCKAPP_A \
'sendPacket(bytes,string,string,(uint64,uint64),uint64)' \
$(cast from-utf8 'mock packet data') \
$PORT_A \
$CHANNEL_A \
'(0,100000)' \
$(date -d 1sec +%s%N)

sleep 5
TMPFILE=$0.log
waitRelay "sendPacket" "unrelayed-packets" "src"
${RLY} tx relay ${PATH_NAME} 2>&1 | tee $TMPFILE
if grep -i 'Error' $TMPFILE; then exit 1; fi
grep -e 'core\.(\*RelayMsgs)\.Send' $TMPFILE | grep ProofUnreceived
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There may be better checking method.




1 change: 1 addition & 0 deletions tests/cases/tm2eth/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ test:
./scripts/test-channel-upgrade
./scripts/test-mockapp-packet-relay
./scripts/test-ics20-packet-relay
./scripts/test-mockapp-packet-timeout

.PHONY: network-down
network-down:
Expand Down
51 changes: 51 additions & 0 deletions tests/cases/tm2eth/scripts/test-mockapp-packet-timeout
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
#!/bin/bash

set -eux

TMPFILE=$0.log
SCRIPT_DIR=$(cd $(dirname ${BASH_SOURCE:-$0}); pwd)
FIXTURES_DIR=${SCRIPT_DIR}/../fixtures

RELAYER_CONF="$HOME/.yui-relayer"
RLY_BINARY=${SCRIPT_DIR}/../../../../build/yrly
RLY="${RLY_BINARY} --debug"

PATH_NAME=mockapp-path

ADDRESSES_DIR_B="${FIXTURES_DIR}/ethereum/ibc1/addresses"
MOCKAPP_CONTRACT_B=`cat ${ADDRESSES_DIR_B}/AppV1`

MNEMONIC_B=$($RLY config show | jq -r '.chains[] | select(.chain.chain_id == "ibc1").chain.signer.mnemonic')
RPC_ADDRESS_B=$($RLY config show | jq -r '.chains[] | select(.chain.chain_id == "ibc1").chain.rpc_addr')
PORT_B=$($RLY paths list --json | jq -r --arg path $PATH_NAME '.[$path].dst."port-id"')
CHANNEL_B=$($RLY paths list --json | jq -r --arg path $PATH_NAME '.[$path].dst."channel-id"')

TX_INTERVAL=3

echo "!!! ibc0 -> ibc1 !!!"
TM_ADDRESS=$(${RLY} tendermint keys show ibc0 testkey)
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"
sleep ${TX_INTERVAL}
${RLY} tx relay $PATH_NAME 2>&1 | tee $TMPFILE
sleep ${TX_INTERVAL}
if grep -i 'Error' $TMPFILE; then exit 1; fi
grep -e 'core\.(\*RelayMsgs)\.Send' $TMPFILE | grep ProofUnreceived

echo "!!! ibc1 -> ibc0 !!!"
BOB_INDEX=2
cast send \
--rpc-url $RPC_ADDRESS_B \
--mnemonic "$MNEMONIC_B" \
--mnemonic-index ${BOB_INDEX} \
$MOCKAPP_CONTRACT_B \
'sendPacket(bytes,string,string,(uint64,uint64),uint64)' \
$(cast from-utf8 'mock packet data') \
$PORT_B \
$CHANNEL_B \
'(0,100000)' \
$(date -d 1sec +%s%N)
sleep ${TX_INTERVAL}
${RLY} tx relay $PATH_NAME 2>&1 | tee $TMPFILE
sleep ${TX_INTERVAL}
if grep -i 'Error' $TMPFILE; then exit 1; fi
grep -e 'core\.(\*RelayMsgs)\.Send' $TMPFILE | grep ProofUnreceived
12 changes: 11 additions & 1 deletion tests/cases/tm2tm/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,22 @@ network:
up -d \
tendermint-chain0 tendermint-chain1

.PHONY: test
.PHONY: test test-unorderd test-ordered
test:
$(MAKE) test-unordered test-ordered

test-unordered:
./scripts/fixture
./scripts/init-rly
./scripts/handshake
./scripts/test-tx
./scripts/test-timeout transfer

test-ordered:
./scripts/fixture
./scripts/init-rly
./scripts/handshake path-ordered.json
./scripts/test-timeout mockapp

.PHONY: network-down
network-down:
Expand Down
23 changes: 23 additions & 0 deletions tests/cases/tm2tm/configs/path-ordered.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"src": {
"chain-id": "ibc0",
"client-id": "",
"connection-id": "",
"channel-id": "",
"port-id": "mockapp",
"order": "ordered",
"version": "mockapp-1"
},
"dst": {
"chain-id": "ibc1",
"client-id": "",
"connection-id": "",
"channel-id": "",
"port-id": "mockapp",
"order": "ordered",
"version": "mockapp-1"
},
"strategy": {
"type": "naive"
}
}
3 changes: 2 additions & 1 deletion tests/cases/tm2tm/scripts/handshake
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ set -eux
source $(cd $(dirname "$0"); pwd)/../../../scripts/util

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

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

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

retry 5 $RLY tx clients $PATH_NAME
$RLY query client $PATH_NAME $CHAINID_ONE 2>/dev/null | jq -Rs 'fromjson'
Expand Down
40 changes: 40 additions & 0 deletions tests/cases/tm2tm/scripts/test-timeout
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#!/bin/bash

set -eux

SCRIPT_DIR=$(cd $(dirname $0); pwd)
APP=$1
RLY_BINARY=${SCRIPT_DIR}/../../../../build/yrly
RLY="${RLY_BINARY} --debug"

# XXX set proper value
TX_INTERVAL=3

TM_ADDRESS0=$(${RLY} tendermint keys show ibc0 testkey)
TM_ADDRESS1=$(${RLY} tendermint keys show ibc1 testkey)

echo "!!! ibc0 -> ibc1 !!!"

echo "Before ibc0 balance: $(${RLY} query balance ibc0 ${TM_ADDRESS0})"
echo "Before ibc1 balance: $(${RLY} query balance ibc1 ${TM_ADDRESS1})"

PATH_NAME=ibc01
if [[ $APP = "transfer" ]]; then
${RLY} tx transfer --timeout-height-offset 1 ibc01 ibc0 ibc1 100samoleans ${TM_ADDRESS1}
else
CHANNEL_NAME=$(${RLY} query channel ${PATH_NAME} ibc0 | jq -r '.counterparty.channelId')
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"
fi
sleep ${TX_INTERVAL}

TMPFILE=$0.log
${RLY} tx relay ibc01 2>&1 | tee $TMPFILE
sleep ${TX_INTERVAL}

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

echo "After ibc0 balance: $(${RLY} query balance ibc0 ${TM_ADDRESS0})"
echo "After ibc1 balance: $(${RLY} query balance ibc1 ${TM_ADDRESS1})"


1 change: 1 addition & 0 deletions tests/chains/ethereum/contracts/contracts/App.sol
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ contract AppV1 is IBCContractUpgradableUUPSMockApp {

function __AppV1_init(string memory initialVersion) public initializer {
__IBCContractUpgradableUUPSMockApp_init(initialVersion);
allowCloseChannel(true);
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

An ordered channel is to close when it receive a timeout notify, so this granting is required.

}
}

Expand Down
2 changes: 1 addition & 1 deletion tests/chains/tendermint/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ require (
github.com/cosmos/ibc-go/modules/capability v1.0.0
github.com/cosmos/ibc-go/v8 v8.2.1
github.com/datachainlab/ibc-mock-app v0.1.1
github.com/datachainlab/ibc-mock-client v0.4.2
github.com/datachainlab/ibc-mock-client v0.4.3
github.com/spf13/cast v1.6.0
github.com/spf13/cobra v1.8.0
github.com/spf13/viper v1.18.2
Expand Down
4 changes: 2 additions & 2 deletions tests/chains/tendermint/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -385,8 +385,8 @@ github.com/danieljoos/wincred v1.1.2 h1:QLdCxFs1/Yl4zduvBdcHB8goaYk9RARS2SgLLRuA
github.com/danieljoos/wincred v1.1.2/go.mod h1:GijpziifJoIBfYh+S7BbkdUTU4LfM+QnGqR5Vl2tAx0=
github.com/datachainlab/ibc-mock-app v0.1.1 h1:ylaFuuC7iQP4QH0Tvlt2ibQCBYvXP22S3KvUOXmMRlk=
github.com/datachainlab/ibc-mock-app v0.1.1/go.mod h1:mxOiHsKNduLy9FAa5MsAv7qun9WkWww4DmYuLlLqVG8=
github.com/datachainlab/ibc-mock-client v0.4.2 h1:0BbQFwLUUbKknCsUO6m80VogRbJop5kA0u9/3Hma9n0=
github.com/datachainlab/ibc-mock-client v0.4.2/go.mod h1:Fn37FzeevLp5gmla4TSoDY56Jm2tBcqz+p0lIyRCOsg=
github.com/datachainlab/ibc-mock-client v0.4.3 h1:vFl8P4lx0aAgvnZIMfmwhDcj8atps1aP+sthzKdVNo8=
github.com/datachainlab/ibc-mock-client v0.4.3/go.mod h1:Fn37FzeevLp5gmla4TSoDY56Jm2tBcqz+p0lIyRCOsg=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1VwoXQT9A3Wy9MM3WgvqSxFWenqJduM=
Expand Down
Loading