Skip to content

Commit

Permalink
chore: rename functions for consistency (#6017)
Browse files Browse the repository at this point in the history
Co-authored-by: Charly <[email protected]>
  • Loading branch information
2 people authored and damiannolan committed Mar 20, 2024
1 parent c3341a1 commit 6e35c18
Show file tree
Hide file tree
Showing 8 changed files with 16 additions and 16 deletions.
8 changes: 4 additions & 4 deletions modules/core/02-client/keeper/keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -407,9 +407,9 @@ func (k Keeper) GetClientStatus(ctx sdk.Context, clientID string) exported.Statu
return clientModule.Status(ctx, clientID)
}

// GetLatestHeight returns the latest height of a client state for a given client identifier. If the client type is not in the allowed
// GetClientLatestHeight returns the latest height of a client state for a given client identifier. If the client type is not in the allowed
// clients param field, a zero value height is returned, otherwise the client state latest height is returned.
func (k Keeper) GetLatestHeight(ctx sdk.Context, clientID string) types.Height {
func (k Keeper) GetClientLatestHeight(ctx sdk.Context, clientID string) types.Height {
clientType, _, err := types.ParseClientIdentifier(clientID)
if err != nil {
return types.ZeroHeight()
Expand All @@ -427,8 +427,8 @@ func (k Keeper) GetLatestHeight(ctx sdk.Context, clientID string) types.Height {
return clientModule.LatestHeight(ctx, clientID).(types.Height)
}

// GetTimestampAtHeight returns the timestamp in nanoseconds of the consensus state at the given height.
func (k Keeper) GetTimestampAtHeight(ctx sdk.Context, clientID string, height exported.Height) (uint64, error) {
// GetClientTimestampAtHeight returns the timestamp in nanoseconds of the consensus state at the given height.
func (k Keeper) GetClientTimestampAtHeight(ctx sdk.Context, clientID string, height exported.Height) (uint64, error) {
clientType, _, err := types.ParseClientIdentifier(clientID)
if err != nil {
return 0, errorsmod.Wrapf(err, "clientID (%s)", clientID)
Expand Down
6 changes: 3 additions & 3 deletions modules/core/02-client/keeper/keeper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,7 @@ func (suite *KeeperTestSuite) TestIterateClientStates() {
}
}

func (suite *KeeperTestSuite) TestGetLatestHeight() {
func (suite *KeeperTestSuite) TestGetClientLatestHeight() {
var path *ibctesting.Path

cases := []struct {
Expand Down Expand Up @@ -385,7 +385,7 @@ func (suite *KeeperTestSuite) TestGetLatestHeight() {

tc.malleate()

height := suite.chainA.App.GetIBCKeeper().ClientKeeper.GetLatestHeight(suite.chainA.GetContext(), path.EndpointA.ClientID)
height := suite.chainA.App.GetIBCKeeper().ClientKeeper.GetClientLatestHeight(suite.chainA.GetContext(), path.EndpointA.ClientID)

if tc.expPass {
suite.Require().Equal(suite.chainB.LatestCommittedHeader.GetHeight().(types.Height), height)
Expand Down Expand Up @@ -457,7 +457,7 @@ func (suite *KeeperTestSuite) TestGetTimestampAtHeight() {

tc.malleate()

actualTimestamp, err := suite.chainA.App.GetIBCKeeper().ClientKeeper.GetTimestampAtHeight(suite.chainA.GetContext(), path.EndpointA.ClientID, height)
actualTimestamp, err := suite.chainA.App.GetIBCKeeper().ClientKeeper.GetClientTimestampAtHeight(suite.chainA.GetContext(), path.EndpointA.ClientID, height)

expPass := tc.expError == nil
if expPass {
Expand Down
4 changes: 2 additions & 2 deletions modules/core/04-channel/keeper/packet.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,8 @@ func (k Keeper) SendPacket(
return 0, errorsmod.Wrapf(clienttypes.ErrClientNotActive, "cannot send packet using client (%s) with status %s", connectionEnd.ClientId, status)
}

latestHeight := k.clientKeeper.GetLatestHeight(ctx, connectionEnd.ClientId)
latestTimestamp, err := k.clientKeeper.GetTimestampAtHeight(ctx, connectionEnd.ClientId, latestHeight)
latestHeight := k.clientKeeper.GetClientLatestHeight(ctx, connectionEnd.ClientId)
latestTimestamp, err := k.clientKeeper.GetClientTimestampAtHeight(ctx, connectionEnd.ClientId, latestHeight)
if err != nil {
return 0, err
}
Expand Down
4 changes: 2 additions & 2 deletions modules/core/04-channel/keeper/packet_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ func (suite *KeeperTestSuite) TestSendPacket() {
sourceChannel = path.EndpointA.ChannelID

connection := path.EndpointA.GetConnection()
timestamp, err := suite.chainA.App.GetIBCKeeper().ClientKeeper.GetTimestampAtHeight(suite.chainA.GetContext(), connection.ClientId, path.EndpointA.GetClientLatestHeight())
timestamp, err := suite.chainA.App.GetIBCKeeper().ClientKeeper.GetClientTimestampAtHeight(suite.chainA.GetContext(), connection.ClientId, path.EndpointA.GetClientLatestHeight())
suite.Require().NoError(err)

timeoutHeight = disabledTimeoutHeight
Expand All @@ -175,7 +175,7 @@ func (suite *KeeperTestSuite) TestSendPacket() {
path.EndpointA.UpdateConnection(func(c *connectiontypes.ConnectionEnd) { c.ClientId = path.EndpointA.ClientID })

connection := path.EndpointA.GetConnection()
timestamp, err := suite.chainA.App.GetIBCKeeper().ClientKeeper.GetTimestampAtHeight(suite.chainA.GetContext(), connection.ClientId, path.EndpointA.GetClientLatestHeight())
timestamp, err := suite.chainA.App.GetIBCKeeper().ClientKeeper.GetClientTimestampAtHeight(suite.chainA.GetContext(), connection.ClientId, path.EndpointA.GetClientLatestHeight())
suite.Require().NoError(err)

sourceChannel = path.EndpointA.ChannelID
Expand Down
2 changes: 1 addition & 1 deletion modules/core/04-channel/keeper/timeout.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ func (k Keeper) TimeoutPacket(
}

// check that timeout height or timeout timestamp has passed on the other end
proofTimestamp, err := k.clientKeeper.GetTimestampAtHeight(ctx, connectionEnd.ClientId, proofHeight)
proofTimestamp, err := k.clientKeeper.GetClientTimestampAtHeight(ctx, connectionEnd.ClientId, proofHeight)
if err != nil {
return err
}
Expand Down
2 changes: 1 addition & 1 deletion modules/core/04-channel/keeper/upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -745,7 +745,7 @@ func (k Keeper) ChanUpgradeTimeout(
return errorsmod.Wrapf(connectiontypes.ErrInvalidConnectionState, "connection state is not OPEN (got %s)", connection.State)
}

proofTimestamp, err := k.clientKeeper.GetTimestampAtHeight(ctx, connection.ClientId, proofHeight)
proofTimestamp, err := k.clientKeeper.GetClientTimestampAtHeight(ctx, connection.ClientId, proofHeight)
if err != nil {
return err
}
Expand Down
4 changes: 2 additions & 2 deletions modules/core/04-channel/types/expected_keepers.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ type ClientKeeper interface {
GetClientStatus(ctx sdk.Context, clientID string) exported.Status
GetClientState(ctx sdk.Context, clientID string) (exported.ClientState, bool)
GetClientConsensusState(ctx sdk.Context, clientID string, height exported.Height) (exported.ConsensusState, bool)
GetLatestHeight(ctx sdk.Context, clientID string) clienttypes.Height
GetTimestampAtHeight(ctx sdk.Context, clientID string, height exported.Height) (uint64, error)
GetClientLatestHeight(ctx sdk.Context, clientID string) clienttypes.Height
GetClientTimestampAtHeight(ctx sdk.Context, clientID string, height exported.Height) (uint64, error)
}

// ConnectionKeeper expected account IBC connection keeper
Expand Down
2 changes: 1 addition & 1 deletion testing/chain.go
Original file line number Diff line number Diff line change
Expand Up @@ -614,7 +614,7 @@ func (chain *TestChain) GetChannelCapability(portID, channelID string) *capabili
// GetClientLatestHeight returns the latest height for the client state with the given client identifier.
// If an invalid client identifier is provided then a zero value height will be returned and testing wil fail.
func (chain *TestChain) GetClientLatestHeight(clientID string) exported.Height {
latestHeight := chain.App.GetIBCKeeper().ClientKeeper.GetLatestHeight(chain.GetContext(), clientID)
latestHeight := chain.App.GetIBCKeeper().ClientKeeper.GetClientLatestHeight(chain.GetContext(), clientID)
require.False(chain.TB, latestHeight.IsZero())
return latestHeight
}
Expand Down

0 comments on commit 6e35c18

Please sign in to comment.