From cb7446623029dec92ad11f632fd448fea56ea950 Mon Sep 17 00:00:00 2001 From: Masanori Yoshida Date: Wed, 21 Aug 2024 05:37:33 +0900 Subject: [PATCH] add more test cases related to timeout Signed-off-by: Masanori Yoshida --- .../cases/tm2tm/scripts/test-channel-upgrade | 28 +++++++++---------- tests/chains/tendermint/scripts/entrypoint.sh | 1 + tests/chains/tendermint/simapp/app.go | 10 ++++++- 3 files changed, 24 insertions(+), 15 deletions(-) diff --git a/tests/cases/tm2tm/scripts/test-channel-upgrade b/tests/cases/tm2tm/scripts/test-channel-upgrade index 0a86569f..6a16d4eb 100755 --- a/tests/cases/tm2tm/scripts/test-channel-upgrade +++ b/tests/cases/tm2tm/scripts/test-channel-upgrade @@ -125,17 +125,17 @@ $RLY tx channel-upgrade init ibc01 ibc1 $origDstOpts # ibc1 re-initiates new upg $RLY tx channel-upgrade execute ibc01 # The upgrade initiated by ibc1 should be completed after ibc0's one is cancelled. checkResult orig -# echo '##### case 8 #####' -# $RLY tx channel-upgrade init ibc01 ibc0 $altSrcOpts -# $RLY tx channel-upgrade execute ibc01 --target-src-state FLUSHCOMPLETE --target-dst-state FLUSHING -# sleep ??? -# $RLY tx channel-upgrade execute -# checkResult orig - -# echo '##### case 9 #####' -# $RLY tx channel-upgrade init ibc01 ibc0 $altSrcOpts -# $RLY tx channel-upgrade init ibc01 ibc1 $altDstOpts -# $RLY tx channel-upgrade execute ibc01 --target-src-state FLUSHING --target-dst-state FLUSHING -# sleep ??? -# $RLY tx channel-upgrade execute -# checkResult orig +echo '##### case 8 #####' +$RLY tx channel-upgrade init ibc01 ibc0 $altSrcOpts +$RLY tx channel-upgrade execute ibc01 --target-src-state FLUSHCOMPLETE --target-dst-state FLUSHING +sleep 20 # ibc1 exceeds upgrade.timeout.timestamp +$RLY tx channel-upgrade execute ibc01 # ibc0 <= chanUpgradeTimeout, ibc1 <= chanUpgradeCancel +checkResult orig + +echo '##### case 9 #####' +$RLY tx channel-upgrade init ibc01 ibc0 $altSrcOpts +$RLY tx channel-upgrade init ibc01 ibc1 $altDstOpts +$RLY tx channel-upgrade execute ibc01 --target-src-state FLUSHING --target-dst-state FLUSHING +sleep 20 # Both chains exceed upgrade.timeout.timestamp +$RLY tx channel-upgrade execute ibc01 # ibc0,ibc1 <= chanUpgradeTimeout +checkResult orig diff --git a/tests/chains/tendermint/scripts/entrypoint.sh b/tests/chains/tendermint/scripts/entrypoint.sh index b34f52e0..c92e58f8 100755 --- a/tests/chains/tendermint/scripts/entrypoint.sh +++ b/tests/chains/tendermint/scripts/entrypoint.sh @@ -1,5 +1,6 @@ #!/bin/sh export IBC_AUTHORITY=`jq -r .address /root/${CHAINDIR}/${CHAINID}/key_seed.json` +export IBC_CHANNEL_UPGRADE_TIMEOUT=20000000000 # 20sec = 20_000_000_000nsec simd --home /root/${CHAINDIR}/${CHAINID} start --pruning=nothing --grpc.address="0.0.0.0:${GRPCPORT}" diff --git a/tests/chains/tendermint/simapp/app.go b/tests/chains/tendermint/simapp/app.go index 80bf7226..ee73ca1f 100644 --- a/tests/chains/tendermint/simapp/app.go +++ b/tests/chains/tendermint/simapp/app.go @@ -6,6 +6,7 @@ import ( "io" "os" "path/filepath" + "strconv" dbm "github.com/cosmos/cosmos-db" "github.com/cosmos/gogoproto/proto" @@ -896,8 +897,15 @@ func (app *SimApp) InitChainer(ctx sdk.Context, req *abci.RequestInitChain) (*ab ibcGenesisState.ClientGenesis.Params.AllowedClients = append( ibcGenesisState.ClientGenesis.Params.AllowedClients, mockclienttypes.Mock) - genesisState[ibcexported.ModuleName] = app.appCodec.MustMarshalJSON(&ibcGenesisState) } + if upgTimeout := os.Getenv("IBC_CHANNEL_UPGRADE_TIMEOUT"); len(upgTimeout) > 0 { + upgTimeoutTimestampNsec, err := strconv.ParseInt(upgTimeout, 10, 64) + if err != nil { + panic(err) + } + ibcGenesisState.ChannelGenesis.Params.UpgradeTimeout.Timestamp = uint64(upgTimeoutTimestampNsec) + } + genesisState[ibcexported.ModuleName] = app.appCodec.MustMarshalJSON(&ibcGenesisState) } if err := app.UpgradeKeeper.SetModuleVersionMap(ctx, app.ModuleManager.GetVersionMap()); err != nil {