-
Notifications
You must be signed in to change notification settings - Fork 616
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
(test) Test that tokens are successfully forwarded from A to C through B #6758
Conversation
channelBToCCallback := func() ibc.ChannelOutput { | ||
ctx := context.TODO() | ||
// Creating a new path between chain B and chain C with a ICS20-v1 channel | ||
opts := s.TransferChannelOptions() | ||
opts.Version = transfertypes.V1 | ||
chains := s.GetAllChains() | ||
channelBtoC, _ := s.CreatePath(ctx, chains[1], chains[2], ibc.DefaultClientOpts(), opts) | ||
s.Require().Equal(transfertypes.V1, channelBtoC.Version, "the channel version is not ics20-1") | ||
return channelBtoC | ||
} | ||
s.testForwardingThreeChains(channelBToCCallback) | ||
} |
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.
These two tests are identical, they only differ in the fact that the channel from B to C in one is the regular one we create in the setup, while in this one is a v1 channel.
I extracted all to a common function which accepts a parameter that specifies how the channel from B to C is obtained. This test overrides it, while the other one (below) simply returns the one already created.
e2e/testsuite/testsuite.go
Outdated
type ChainChannelPair struct { | ||
ChainIdx int | ||
ChannelIdx 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.
This might bloat a bit the file, but I'm not a fan of passing magic numbers around (it would be easy to switch them by mistake)
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.
agree. don't know if we have consistency on this atm, though. might need replacements elsewhere (admittedly mixed usage would be worse)
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.
Good thinking by reusing the existing test with a small modification!
}) | ||
} | ||
|
||
func (s *TransferForwardingTestSuite) testForwardingThreeChains(channelBToCCallback func() ibc.ChannelOutput) { |
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 feel like callback is more appropriate when you want to execute something based on something that has happened. But this is just an option, happy to go with it:
func (s *TransferForwardingTestSuite) testForwardingThreeChains(channelBToCCallback func() ibc.ChannelOutput) { | |
func (s *TransferForwardingTestSuite) testForwardingThreeChains(createChannelBToC func() ibc.ChannelOutput) { |
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 makes sense, though I was talking to Cian on Thursday and it does not actually make sense to over-complicate by passing a function, we can leave the logic in the test (see newest commit)
e2e/testsuite/testsuite.go
Outdated
ChainIdx int | ||
ChannelIdx 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.
think negative values aren't handled atm (plus uints just make sense as the type for indices)
ChainIdx int | |
ChannelIdx int | |
ChainIdx uint64 | |
ChannelIdx uint64 |
e2e/testsuite/testsuite.go
Outdated
type ChainChannelPair struct { | ||
ChainIdx int | ||
ChannelIdx 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.
agree. don't know if we have consistency on this atm, though. might need replacements elsewhere (admittedly mixed usage would be worse)
Quality Gate passed for 'ibc-go'Issues Measures |
…h B (#6758) * Create new forwarding test * Use a struct rather than raw fields * better docstring * Change a type and remove callback * Fix type
Description
This was very similar to the test that performs the same but with C being
ics20-1
.Since the two tests are almost identical, I refactored in a single function and just wrap them into two tests that differ slightly.
ref: #6578
Before we can merge this PR, please make sure that all the following items have been
checked off. If any of the checklist items are not applicable, please leave them but
write a little note why.
docs/
).godoc
comments.Files changed
in the GitHub PR explorer.SonarCloud Report
in the comment section below once CI passes.