-
Notifications
You must be signed in to change notification settings - Fork 657
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
chore: modify connection keeper GetTimestampAtHeight to use the client state interface function #1666
chore: modify connection keeper GetTimestampAtHeight to use the client state interface function #1666
Changes from 4 commits
cba4192
fa2af5d
596b4bf
f61a154
3cd84ad
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,10 +4,10 @@ import ( | |
"fmt" | ||
"testing" | ||
|
||
"github.com/stretchr/testify/suite" | ||
|
||
"github.com/cosmos/ibc-go/v3/modules/core/03-connection/types" | ||
"github.com/cosmos/ibc-go/v3/modules/core/exported" | ||
ibctesting "github.com/cosmos/ibc-go/v3/testing" | ||
"github.com/stretchr/testify/suite" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: the |
||
) | ||
|
||
type KeeperTestSuite struct { | ||
|
@@ -112,7 +112,10 @@ func (suite KeeperTestSuite) TestGetAllClientConnectionPaths() { | |
// TestGetTimestampAtHeight verifies if the clients on each chain return the | ||
// correct timestamp for the other chain. | ||
func (suite *KeeperTestSuite) TestGetTimestampAtHeight() { | ||
var connection types.ConnectionEnd | ||
var ( | ||
connection types.ConnectionEnd | ||
height exported.Height | ||
) | ||
|
||
cases := []struct { | ||
msg string | ||
|
@@ -123,10 +126,14 @@ func (suite *KeeperTestSuite) TestGetTimestampAtHeight() { | |
path := ibctesting.NewPath(suite.chainA, suite.chainB) | ||
suite.coordinator.SetupConnections(path) | ||
connection = path.EndpointA.GetConnection() | ||
height = suite.chainB.LastHeader.GetHeight() | ||
}, true}, | ||
{"client state not found", func() {}, false}, | ||
{"consensus state not found", func() { | ||
// any non-nil value of connection is valid | ||
suite.Require().NotNil(connection) | ||
path := ibctesting.NewPath(suite.chainA, suite.chainB) | ||
suite.coordinator.SetupConnections(path) | ||
connection = path.EndpointA.GetConnection() | ||
height = suite.chainB.LastHeader.GetHeight().Increment() | ||
}, false}, | ||
} | ||
|
||
|
@@ -137,7 +144,7 @@ func (suite *KeeperTestSuite) TestGetTimestampAtHeight() { | |
tc.malleate() | ||
|
||
actualTimestamp, err := suite.chainA.App.GetIBCKeeper().ConnectionKeeper.GetTimestampAtHeight( | ||
suite.chainA.GetContext(), connection, suite.chainB.LastHeader.GetHeight(), | ||
suite.chainA.GetContext(), connection, height, | ||
) | ||
|
||
if tc.expPass { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -177,6 +177,23 @@ func (suite *KeeperTestSuite) TestSendPacket() { | |
packet = types.NewPacket(ibctesting.MockPacketData, 1, path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID, path.EndpointB.ChannelConfig.PortID, path.EndpointB.ChannelID, disabledTimeoutHeight, timestamp) | ||
channelCap = suite.chainA.GetChannelCapability(path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID) | ||
}, false}, | ||
{"timeout timestamp passed with solomachine", func() { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. should we open an issue to add solomachine tests for timeout_test.go functions? |
||
suite.coordinator.Setup(path) | ||
// swap client with solomachine | ||
solomachine := ibctesting.NewSolomachine(suite.T(), suite.chainA.Codec, "solomachinesingle", "testing", 1) | ||
path.EndpointA.ClientID = clienttypes.FormatClientIdentifier(exported.Solomachine, 10) | ||
path.EndpointA.SetClientState(solomachine.ClientState()) | ||
connection := path.EndpointA.GetConnection() | ||
connection.ClientId = path.EndpointA.ClientID | ||
path.EndpointA.SetConnection(connection) | ||
|
||
clientState := path.EndpointA.GetClientState() | ||
timestamp, err := suite.chainA.App.GetIBCKeeper().ConnectionKeeper.GetTimestampAtHeight(suite.chainA.GetContext(), connection, clientState.GetLatestHeight()) | ||
suite.Require().NoError(err) | ||
|
||
packet = types.NewPacket(ibctesting.MockPacketData, 1, path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID, path.EndpointB.ChannelConfig.PortID, path.EndpointB.ChannelID, disabledTimeoutHeight, timestamp) | ||
channelCap = suite.chainA.GetChannelCapability(path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID) | ||
}, false}, | ||
{"next sequence send not found", func() { | ||
path := ibctesting.NewPath(suite.chainA, suite.chainB) | ||
suite.coordinator.SetupConnections(path) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We already have
ErrClientNotFound
above so I think we can probably just use that!There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd also be okay with renaming
ErrClientNotFound
toErrClientStateNotFound
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i'll do that, it's more explicit