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

e2e: transfer memo tests #2306

Conversation

nicolaslara
Copy link
Contributor

@nicolaslara nicolaslara commented Sep 19, 2022

Description

adds e2e tests for the transfer memo addition


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 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.
  • Wrote unit and integration tests
  • Updated relevant documentation (docs/) or specification (x/<module>/spec/)
  • Added relevant godoc comments.
  • Added a relevant changelog entry to the Unreleased section in CHANGELOG.md
  • Re-reviewed Files changed in the Github PR explorer
  • Review Codecov Report in the comment section below once CI passes

modules/apps/transfer/keeper/relay.go Outdated Show resolved Hide resolved
modules/apps/transfer/keeper/relay_test.go Outdated Show resolved Hide resolved
modules/apps/transfer/keeper/msg_server_test.go Outdated Show resolved Hide resolved
e2e/tests/transfer/metadata_test.go Outdated Show resolved Hide resolved
@chatton
Copy link
Contributor

chatton commented Sep 28, 2022

Hi @nicolaslara thanks for the contribution!

Regarding CI, currently, the smallest unit of exclusion/inclusion is a test suite. Since we don't want to run this on PRs (just during compatibility testing as @colin-axner suggested) I recommend the following steps.

  1. Create a new test suite with the test you are adding. (the test should be in the same file as the test suite)
  2. Add an exclusion here and here Note: this is the name of the function that triggers the test suite, not the name of the test suite.

The compatibility tests are currently a WIP, so we can add your test to them once it is fully up and running!

@nicolaslara
Copy link
Contributor Author

@chatton @colin-axner I started modifying the tests the way you suggested, but after merging main I noticed that it got updated to v6 while the e2e tests are still on v5. Should I keep this PR on v5? or should I update the e2e tests to v6 (which probably should be done in a separate PR)?

@colin-axner
Copy link
Contributor

Should I keep this PR on v5? or should I update the e2e tests to v6 (which probably should be done in a separate PR)?

I believe we need to update the ibc-go version used in the ibctest repository first. See strangelove-ventures/interchaintest#315. I'll be bumping this in a separate pr, you are welcome to use the commit in the linked pr in the meantime to get tests passing

e2e/tests/transfer/metadata_test.go Outdated Show resolved Hide resolved
e2e/tests/transfer/metadata_test.go Outdated Show resolved Hide resolved
@colin-axner colin-axner marked this pull request as ready for review October 26, 2022 13:38
@colin-axner colin-axner changed the title Packet metadata integration and tests e2e: transfer memo tests Oct 26, 2022
Copy link
Contributor

@chatton chatton left a comment

Choose a reason for hiding this comment

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

Really nice work, thanks @colin-axner & @nicolaslara ❤️

Comment on lines 382 to 385
var memoFeatureRelease = testsuite.FeatureReleases{
MajorVersion: "v6",
MinorVersions: []string{"v2.5, v3.4, v4.2, v5.1"},
}
Copy link
Contributor

Choose a reason for hiding this comment

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

👍

s.Require().NoError(err)

if !memoFeatureRelease.IsSupported(chainAVersion) {
s.Require().Equal(transferTxResp.Code, uint32(2))
Copy link
Contributor

Choose a reason for hiding this comment

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

[nit] we should have arguments in the order of expected / actual

Copy link
Contributor

Choose a reason for hiding this comment

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

yup, nice catch


chainBIBCToken := testsuite.GetIBCToken(chainADenom, channelA.Counterparty.PortID, channelA.Counterparty.ChannelID)

t.Run("packets relayed?", func(t *testing.T) {
Copy link
Contributor

Choose a reason for hiding this comment

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

[nit] this punctuation is a bit strange in test names, is this intentional?

Copy link
Contributor

Choose a reason for hiding this comment

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

don't think so

Copy link
Contributor

@charleenfei charleenfei left a comment

Choose a reason for hiding this comment

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

lgtm! just a nit on replacing with local ibc-go version

@@ -214,4 +214,4 @@ replace (
)

// uncomment to use the local version of ibc-go, you will need to run `go mod tidy` in e2e directory.
// replace github.com/cosmos/ibc-go/v6 => ../
replace github.com/cosmos/ibc-go/v6 => ../
Copy link
Contributor

Choose a reason for hiding this comment

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

should we recomment this?

Copy link
Contributor

Choose a reason for hiding this comment

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

we want this commented out as this comment is simply here for convenience to allow for testing against local ibc-go changes.

Copy link
Contributor

Choose a reason for hiding this comment

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

ibc-go doesn't have a release with the memo changes yet so the constructors would break otherwise

@@ -304,9 +304,9 @@ func (s *E2ETestSuite) RecoverRelayerWallets(ctx context.Context, relayer ibc.Re

// Transfer broadcasts a MsgTransfer message.
func (s *E2ETestSuite) Transfer(ctx context.Context, chain *cosmos.CosmosChain, user *ibc.Wallet,
portID, channelID string, token sdk.Coin, sender, receiver string, timeoutHeight clienttypes.Height, timeoutTimestamp uint64,
portID, channelID string, token sdk.Coin, sender, receiver string, timeoutHeight clienttypes.Height, timeoutTimestamp uint64, memo string,
Copy link
Contributor

Choose a reason for hiding this comment

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

decided to make this default behaviour going forward. In the future we should add a type to send default ibc transfers to cut down on args here. Think you could have something like endpoint.SendIBCTransfer(receiver)

// If the chains contain a version of FungibleTokenPacketData with memo, both send and receive should succeed.
// If one of the chains contains a version of FungibleTokenPacketData without memo, then receiving a packet with
// memo should fail in that chain
func (s *TransferTestSuite) TestMsgTransfer_WithMemo() {
Copy link
Contributor

Choose a reason for hiding this comment

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

moved into base_test.go since this should work for any version of ibc-go

s.Require().NoError(err)

if !memoFeatureRelease.IsSupported(chainAVersion) {
s.Require().Equal(transferTxResp.Code, uint32(2))
Copy link
Contributor

Choose a reason for hiding this comment

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

yup, nice catch


chainBIBCToken := testsuite.GetIBCToken(chainADenom, channelA.Counterparty.PortID, channelA.Counterparty.ChannelID)

t.Run("packets relayed?", func(t *testing.T) {
Copy link
Contributor

Choose a reason for hiding this comment

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

don't think so

@@ -214,4 +214,4 @@ replace (
)

// uncomment to use the local version of ibc-go, you will need to run `go mod tidy` in e2e directory.
// replace github.com/cosmos/ibc-go/v6 => ../
replace github.com/cosmos/ibc-go/v6 => ../
Copy link
Contributor

Choose a reason for hiding this comment

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

ibc-go doesn't have a release with the memo changes yet so the constructors would break otherwise

@chatton
Copy link
Contributor

chatton commented Oct 26, 2022

@colin-axner the TestInterTxTestSuite wasn't yet added to test exclusions for forks, these will be expected to fail here as they should only work with icad. We can update the workflows to exclude them after this PR 👍

Comment on lines 428 to 430
if !memoFeatureRelease.IsSupported(chainAVersion) {
// transfer not sent, end test
return
Copy link
Contributor

Choose a reason for hiding this comment

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

since the checks are run in t.Run(), we need a check here to properly return. I left the code as is because I think it is nice doing assertions in t.Run()

Copy link
Member

@damiannolan damiannolan 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 to me! Thanks a lot @nicolaslara and @colin-axner 🚀

chainAVersion := chainA.Config().Images[0].Version
chainBVersion := chainB.Config().Images[0].Version

t.Logf("Running memo tests versions chainA: %s, chainB: %s", chainAVersion, chainBVersion)
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 also remove? :D

Copy link
Contributor

Choose a reason for hiding this comment

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

sure!

Comment on lines 381 to 382
// memoFeatureReleases represents the releases the memo field was released in.
var memoFeatureRelease = testsuite.FeatureReleases{
Copy link
Member

Choose a reason for hiding this comment

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

mega nit: should the var be the same as in the godoc or vice versa?

@colin-axner colin-axner merged commit 8991eaa into cosmos:main Oct 26, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants