-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
Add additional IBC Channel Tests #5578
Conversation
) | ||
|
||
testCases := []testCase{ | ||
// {"success", func() { |
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.
Do we still not have a working success case here?
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.
not yet
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.
Looks good, have a couple questions
packet, err = suite.app.IBCKeeper.ChannelKeeper.RecvPacket(suite.ctx, packet, ibctypes.ValidProof{}, uint64(suite.ctx.BlockHeader().Height)) | ||
suite.Require().NoError(err) | ||
} else { | ||
packet, err = suite.app.IBCKeeper.ChannelKeeper.RecvPacket(suite.ctx, packet, ibctypes.InvalidProof{}, uint64(suite.ctx.BlockHeader().Height)) |
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.
Should proof be part of testCase so that we know this is erroring for expected reason, and not always because we pass in invalid proof?
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.
Ideally yes, was difficult to write them that way. If you see a path to change that please push changes
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 think i may have a way, will look into it once all the ICS-7 stuff is merged. Doesn't have to block this pr tho
suite.Require().NoError(err) | ||
suite.Require().NotNil(packetOut) | ||
} else { | ||
packetOut, err := suite.app.IBCKeeper.ChannelKeeper.AcknowledgePacket(suite.ctx, packet, ack, ibctypes.InvalidProof{}, uint64(suite.ctx.BlockHeader().Height)) |
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.
ditto
packet = types.NewPacket(mockSuccessPacket{}, 1, testPort1, testChannel1, counterparty.GetPortID(), counterparty.GetChannelID()) | ||
suite.createChannel(testPort1, testChannel1, testPort2, testChannel2, exported.OPEN, exported.ORDERED, testConnectionID1) | ||
}, false}, | ||
{"connection not OPEN", func() { |
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.
should we have another test case with channel not open?
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.
Yes
suite.Require().NoError(err) | ||
suite.Require().NotNil(packetOut) | ||
} else { | ||
packetOut, err := suite.app.IBCKeeper.ChannelKeeper.CleanupPacket(suite.ctx, packet, ibctypes.InvalidProof{}, uint64(suite.ctx.BlockHeader().Height), nextSeqRecv, ack) |
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.
ditto
suite.Require().NoError(err) | ||
suite.Require().NotNil(packetOut) | ||
} else { | ||
packetOut, err := suite.app.IBCKeeper.ChannelKeeper.TimeoutPacket(suite.ctx, packet, ibctypes.InvalidProof{}, proofHeight, nextSeqRecv) |
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.
ditto
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.
ACK. We'll replace the mocked proofs with abci store queries (with proofs) everywhere on x/ibc
once the demo requirements are completed
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.
ACK modulo comment fix
tc.malleate() | ||
|
||
var err error | ||
if tc.expPass { |
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.
Using the variable on range scope tc
in function literal (from scopelint
)
for i, tc := range testCases { | ||
suite.Run(fmt.Sprintf("Case %s, %d/%d tests", tc.msg, i, len(testCases)), func() { | ||
suite.SetupTest() // reset | ||
tc.malleate() |
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.
Using the variable on range scope tc
in function literal (from scopelint
)
func (suite *KeeperTestSuite) createClient(clientID string) { | ||
suite.app.Commit() | ||
commitID := suite.app.LastCommitID() | ||
func (suite *KeeperTestSuite) commitNBlocks(n int) { |
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 am not familiar with the codebase yet, but this commit N blocks looks like it can be a nice thing to have maybe in the SimApp? Or the simapp helpers if we don't want to add other methods than the abci in SimApp.
I dont know if this is used a lot though.
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.
It would be helpful for testing purposes, yes
{"channel not found", func() {}, false}, | ||
{"channel not open", func() { |
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.
why was this test case removed?
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.
TimeoutOnClose
doesn't check for the state of the channel
Closes: #5470
This PR adds tests for the
x/ibc/04-channel/keeper/packet.go
andx/ibc/04-channel/keeper/timeout.go
files.