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

(test) Test that tokens are successfully forwarded from A to C through B #6758

Merged
merged 8 commits into from
Jul 8, 2024

Conversation

bznein
Copy link
Contributor

@bznein bznein commented Jul 3, 2024

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.

  • Targeted PR against the correct branch (see CONTRIBUTING.md).
  • Linked to GitHub issue with discussion and accepted design, OR link to spec that describes this work.
  • Code follows the module structure standards and Go style guide.
  • Wrote unit and integration tests.
  • Updated relevant documentation (docs/).
  • Added relevant godoc comments.
  • Provide a conventional commit message to follow the repository standards.
  • Include a descriptive changelog entry when appropriate. This may be left to the discretion of the PR reviewers. (e.g. chores should be omitted from changelog)
  • Re-reviewed Files changed in the GitHub PR explorer.
  • Review SonarCloud Report in the comment section below once CI passes.

Comment on lines 36 to 47
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)
}
Copy link
Contributor Author

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.

Comment on lines 261 to 265
type ChainChannelPair struct {
ChainIdx int
ChannelIdx int
}

Copy link
Contributor Author

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)

Copy link
Contributor

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)

Copy link
Contributor

@crodriguezvega crodriguezvega left a 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) {
Copy link
Contributor

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:

Suggested change
func (s *TransferForwardingTestSuite) testForwardingThreeChains(channelBToCCallback func() ibc.ChannelOutput) {
func (s *TransferForwardingTestSuite) testForwardingThreeChains(createChannelBToC func() ibc.ChannelOutput) {

Copy link
Contributor Author

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)

Comment on lines 262 to 263
ChainIdx int
ChannelIdx int
Copy link
Contributor

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)

Suggested change
ChainIdx int
ChannelIdx int
ChainIdx uint64
ChannelIdx uint64

Comment on lines 261 to 265
type ChainChannelPair struct {
ChainIdx int
ChannelIdx int
}

Copy link
Contributor

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)

@crodriguezvega crodriguezvega added the priority PRs that need prompt reviews label Jul 8, 2024
@bznein bznein added this pull request to the merge queue Jul 8, 2024
@bznein bznein removed this pull request from the merge queue due to a manual request Jul 8, 2024
Copy link

sonarcloud bot commented Jul 8, 2024

@bznein bznein added this pull request to the merge queue Jul 8, 2024
Merged via the queue into main with commit d0305b6 Jul 8, 2024
81 checks passed
@bznein bznein deleted the bznein/6578/forwardinge2etest branch July 8, 2024 10:17
crodriguezvega pushed a commit that referenced this pull request Jul 8, 2024
…h B (#6758)

* Create new forwarding test

* Use a struct rather than raw fields

* better docstring

* Change a type and remove callback

* Fix type
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
priority PRs that need prompt reviews
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants