Skip to content

Commit

Permalink
test: cleanup tests in 04-channel to use path.Endpoint.GetClientLates…
Browse files Browse the repository at this point in the history
…tHeight
  • Loading branch information
damiannolan committed Mar 6, 2024
1 parent e2936d1 commit cec25a6
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 14 deletions.
8 changes: 3 additions & 5 deletions modules/core/04-channel/keeper/grpc_query_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import (
"github.com/cosmos/ibc-go/v8/modules/core/04-channel/types"
host "github.com/cosmos/ibc-go/v8/modules/core/24-host"
"github.com/cosmos/ibc-go/v8/modules/core/exported"
ibctm "github.com/cosmos/ibc-go/v8/modules/light-clients/07-tendermint"
ibctesting "github.com/cosmos/ibc-go/v8/testing"
"github.com/cosmos/ibc-go/v8/testing/mock"
)
Expand Down Expand Up @@ -558,16 +557,15 @@ func (suite *KeeperTestSuite) TestQueryChannelConsensusState() {
err := path.EndpointA.ChanOpenInit()
suite.Require().NoError(err)

clientState := suite.chainA.GetClientState(path.EndpointA.ClientID).(*ibctm.ClientState)
expConsensusState, _ = suite.chainA.GetConsensusState(path.EndpointA.ClientID, clientState.LatestHeight)
expConsensusState, _ = suite.chainA.GetConsensusState(path.EndpointA.ClientID, path.EndpointA.GetClientLatestHeight())
suite.Require().NotNil(expConsensusState)
expClientID = path.EndpointA.ClientID

req = &types.QueryChannelConsensusStateRequest{
PortId: path.EndpointA.ChannelConfig.PortID,
ChannelId: path.EndpointA.ChannelID,
RevisionNumber: clientState.LatestHeight.GetRevisionNumber(),
RevisionHeight: clientState.LatestHeight.GetRevisionHeight(),
RevisionNumber: path.EndpointA.GetClientLatestHeight().GetRevisionNumber(),
RevisionHeight: path.EndpointA.GetClientLatestHeight().GetRevisionHeight(),
}
},
true,
Expand Down
12 changes: 3 additions & 9 deletions modules/core/04-channel/keeper/packet_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import (
commitmenttypes "github.com/cosmos/ibc-go/v8/modules/core/23-commitment/types"
host "github.com/cosmos/ibc-go/v8/modules/core/24-host"
"github.com/cosmos/ibc-go/v8/modules/core/exported"
smtypes "github.com/cosmos/ibc-go/v8/modules/light-clients/06-solomachine"
ibctm "github.com/cosmos/ibc-go/v8/modules/light-clients/07-tendermint"
ibctesting "github.com/cosmos/ibc-go/v8/testing"
ibcmock "github.com/cosmos/ibc-go/v8/testing/mock"
Expand Down Expand Up @@ -151,19 +150,15 @@ func (suite *KeeperTestSuite) TestSendPacket() {
path.Setup()
sourceChannel = path.EndpointA.ChannelID

// use client state latest height for timeout
clientState := path.EndpointA.GetClientState().(*ibctm.ClientState)
timeoutHeight = clientState.LatestHeight
timeoutHeight = path.EndpointA.GetClientLatestHeight().(clienttypes.Height)
channelCap = suite.chainA.GetChannelCapability(path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID)
}, false},
{"timeout timestamp passed", func() {
path.Setup()
sourceChannel = path.EndpointA.ChannelID

// use latest time on client state
clientState := path.EndpointA.GetClientState().(*ibctm.ClientState)
connection := path.EndpointA.GetConnection()
timestamp, err := suite.chainA.App.GetIBCKeeper().ClientKeeper.GetTimestampAtHeight(suite.chainA.GetContext(), connection.ClientId, clientState.LatestHeight)
timestamp, err := suite.chainA.App.GetIBCKeeper().ClientKeeper.GetTimestampAtHeight(suite.chainA.GetContext(), connection.ClientId, path.EndpointA.GetClientLatestHeight())
suite.Require().NoError(err)

timeoutHeight = disabledTimeoutHeight
Expand All @@ -179,9 +174,8 @@ func (suite *KeeperTestSuite) TestSendPacket() {

path.EndpointA.UpdateConnection(func(c *connectiontypes.ConnectionEnd) { c.ClientId = path.EndpointA.ClientID })

clientState := path.EndpointA.GetClientState().(*smtypes.ClientState)
connection := path.EndpointA.GetConnection()
timestamp, err := suite.chainA.App.GetIBCKeeper().ClientKeeper.GetTimestampAtHeight(suite.chainA.GetContext(), connection.ClientId, clientState.GetLatestHeight())
timestamp, err := suite.chainA.App.GetIBCKeeper().ClientKeeper.GetTimestampAtHeight(suite.chainA.GetContext(), connection.ClientId, path.EndpointA.GetClientLatestHeight())
suite.Require().NoError(err)

sourceChannel = path.EndpointA.ChannelID
Expand Down

0 comments on commit cec25a6

Please sign in to comment.