Skip to content
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

Merged
merged 18 commits into from
Feb 18, 2020
Merged

Add additional IBC Channel Tests #5578

merged 18 commits into from
Feb 18, 2020

Conversation

jackzampolin
Copy link
Member

Closes: #5470

This PR adds tests for the x/ibc/04-channel/keeper/packet.go and x/ibc/04-channel/keeper/timeout.go files.

x/ibc/04-channel/keeper/packet_test.go Outdated Show resolved Hide resolved
x/ibc/04-channel/keeper/packet_test.go Outdated Show resolved Hide resolved
)

testCases := []testCase{
// {"success", func() {
Copy link
Member Author

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?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not yet

@fedekunze fedekunze self-assigned this Feb 17, 2020
@fedekunze fedekunze added this to the IBC Implementation milestone Feb 17, 2020
Copy link
Member

@AdityaSripal AdityaSripal left a 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))
Copy link
Member

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?

Copy link
Member Author

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

Copy link
Member

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))
Copy link
Member

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() {
Copy link
Member

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?

Copy link
Member Author

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)
Copy link
Member

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)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto

@fedekunze fedekunze added R4R and removed WIP labels Feb 18, 2020
Copy link
Collaborator

@fedekunze fedekunze left a 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

Copy link
Contributor

@cwgoes cwgoes left a 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

x/ibc/04-channel/keeper/packet.go Outdated Show resolved Hide resolved
tc.malleate()

var err error
if tc.expPass {
Copy link
Contributor

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()
Copy link
Contributor

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) {
Copy link
Contributor

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.

Copy link
Collaborator

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() {
Copy link
Member

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?

Copy link
Collaborator

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

@fedekunze fedekunze merged commit e73caba into ibc-alpha Feb 18, 2020
@fedekunze fedekunze deleted the jack/ibc-channel-tests branch February 18, 2020 11:36
@fedekunze fedekunze mentioned this pull request Feb 18, 2020
11 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants