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: conditionally query total escrow based on release version #3605

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 3 additions & 25 deletions e2e/testconfig/testconfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import (
"gopkg.in/yaml.v2"

"github.com/cosmos/ibc-go/e2e/relayer"
"github.com/cosmos/ibc-go/e2e/semverutil"
"github.com/cosmos/ibc-go/e2e/testvalues"
)

Expand Down Expand Up @@ -64,13 +63,6 @@ const (
icadBinary = "icad"
)

// icadNewGenesisCommandsFeatureReleases represents the releases of icad using the new genesis commands.
var icadNewGenesisCommandsFeatureReleases = semverutil.FeatureReleases{
MinorVersions: []string{
"v0.5",
},
}

func getChainImage(binary string) string {
if binary == "" {
binary = defaultBinary
Expand Down Expand Up @@ -370,7 +362,7 @@ func newDefaultSimappConfig(cc ChainConfig, name, chainID, denom string, cometCf
tmTomlOverrides["log_level"] = cometCfg.LogLevel // change to debug in ~/.ibc-go-e2e-config.json to increase cometbft logging.
configFileOverrides["config/config.toml"] = tmTomlOverrides

useNewGenesisCommand := cc.Binary == icadBinary && icadNewGenesisCommandsFeatureReleases.IsSupported(cc.Tag)
useNewGenesisCommand := cc.Binary == icadBinary && testvalues.IcadNewGenesisCommandsFeatureReleases.IsSupported(cc.Tag)

return ibc.ChainConfig{
Type: "cosmos",
Expand Down Expand Up @@ -402,8 +394,8 @@ func getGenesisModificationFunction(cc ChainConfig) func(ibc.ChainConfig, []byte
binary := cc.Binary
version := cc.Tag

doesSimdSupportGovv1Genesis := binary == defaultBinary && govGenesisFeatureReleases.IsSupported(version)
doesIcadSupportGovv1Genesis := icadGovGenesisFeatureReleases.IsSupported(version)
doesSimdSupportGovv1Genesis := binary == defaultBinary && testvalues.GovGenesisFeatureReleases.IsSupported(version)
doesIcadSupportGovv1Genesis := testvalues.IcadGovGenesisFeatureReleases.IsSupported(version)

if doesSimdSupportGovv1Genesis || doesIcadSupportGovv1Genesis {
return defaultGovv1ModifyGenesis()
Expand All @@ -412,20 +404,6 @@ func getGenesisModificationFunction(cc ChainConfig) func(ibc.ChainConfig, []byte
return defaultGovv1Beta1ModifyGenesis()
}

// govGenesisFeatureReleases represents the releases the governance module genesis
// was upgraded from v1beta1 to v1.
var govGenesisFeatureReleases = semverutil.FeatureReleases{
MajorVersion: "v7",
}

// icadGovGenesisFeatureReleases represents the releases of icad where the governance module genesis
// was upgraded from v1beta1 to v1.
var icadGovGenesisFeatureReleases = semverutil.FeatureReleases{
MinorVersions: []string{
"v0.5",
},
}

// defaultGovv1ModifyGenesis will only modify governance params to ensure the voting period and minimum deposit
// are functional for e2e testing purposes.
func defaultGovv1ModifyGenesis() func(ibc.ChainConfig, []byte) ([]byte, error) {
Expand Down
47 changes: 22 additions & 25 deletions e2e/tests/transfer/base_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import (
test "github.com/strangelove-ventures/interchaintest/v7/testutil"
"github.com/stretchr/testify/suite"

"github.com/cosmos/ibc-go/e2e/semverutil"
"github.com/cosmos/ibc-go/e2e/testsuite"
"github.com/cosmos/ibc-go/e2e/testvalues"
transfertypes "github.com/cosmos/ibc-go/v7/modules/apps/transfer/types"
Expand Down Expand Up @@ -79,6 +78,9 @@ func (s *TransferTestSuite) TestMsgTransfer_Succeeds_Nonincentivized() {

s.Require().NoError(test.WaitForBlocks(ctx, 1, chainA, chainB), "failed to wait for blocks")

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

t.Run("native IBC token transfer from chainA to chainB, sender is source of tokens", func(t *testing.T) {
transferTxResp := s.Transfer(ctx, chainA, chainAWallet, channelA.PortID, channelA.ChannelID, testvalues.DefaultTransferAmount(chainADenom), chainAAddress, chainBAddress, s.GetTimeoutHeight(ctx, chainB), 0, "")
s.AssertTxSuccess(transferTxResp)
Expand All @@ -91,11 +93,13 @@ func (s *TransferTestSuite) TestMsgTransfer_Succeeds_Nonincentivized() {
expected := testvalues.StartingTokenAmount - testvalues.IBCTransferAmount
s.Require().Equal(expected, actualBalance)

actualTotalEscrow, err := s.QueryTotalEscrowForDenom(ctx, chainA, chainADenom)
s.Require().NoError(err)
if testvalues.TotalEscrowFeatureReleases.IsSupported(chainAVersion) {
actualTotalEscrow, err := s.QueryTotalEscrowForDenom(ctx, chainA, chainADenom)
s.Require().NoError(err)

expectedTotalEscrow := sdk.NewCoin(chainADenom, math.NewInt(testvalues.IBCTransferAmount))
s.Require().Equal(expectedTotalEscrow, actualTotalEscrow)
expectedTotalEscrow := sdk.NewCoin(chainADenom, math.NewInt(testvalues.IBCTransferAmount))
s.Require().Equal(expectedTotalEscrow, actualTotalEscrow)
}
})

t.Run("start relayer", func(t *testing.T) {
Expand Down Expand Up @@ -125,9 +129,11 @@ func (s *TransferTestSuite) TestMsgTransfer_Succeeds_Nonincentivized() {

s.Require().Equal(int64(0), actualBalance)

actualTotalEscrow, err := s.QueryTotalEscrowForDenom(ctx, chainB, chainBIBCToken.IBCDenom())
s.Require().NoError(err)
s.Require().Equal(sdk.NewCoin(chainBIBCToken.IBCDenom(), sdk.NewInt(0)), actualTotalEscrow) // total escrow is zero because sending chain is not source for tokens
if testvalues.TotalEscrowFeatureReleases.IsSupported(chainBVersion) {
actualTotalEscrow, err := s.QueryTotalEscrowForDenom(ctx, chainB, chainBIBCToken.IBCDenom())
s.Require().NoError(err)
s.Require().Equal(sdk.NewCoin(chainBIBCToken.IBCDenom(), sdk.NewInt(0)), actualTotalEscrow) // total escrow is zero because sending chain is not source for tokens
}
})

s.Require().NoError(test.WaitForBlocks(ctx, 5, chainA, chainB), "failed to wait for blocks")
Expand All @@ -143,9 +149,11 @@ func (s *TransferTestSuite) TestMsgTransfer_Succeeds_Nonincentivized() {
})

t.Run("tokens are un-escrowed", func(t *testing.T) {
actualTotalEscrow, err := s.QueryTotalEscrowForDenom(ctx, chainA, chainADenom)
s.Require().NoError(err)
s.Require().Equal(sdk.NewCoin(chainADenom, sdk.NewInt(0)), actualTotalEscrow) // total escrow is zero because tokens have come back
if testvalues.TotalEscrowFeatureReleases.IsSupported(chainAVersion) {
actualTotalEscrow, err := s.QueryTotalEscrowForDenom(ctx, chainA, chainADenom)
s.Require().NoError(err)
s.Require().Equal(sdk.NewCoin(chainADenom, sdk.NewInt(0)), actualTotalEscrow) // total escrow is zero because tokens have come back
}
})
}

Expand Down Expand Up @@ -391,17 +399,6 @@ func (s *TransferTestSuite) TestReceiveEnabledParam() {
})
}

// memoFeatureReleases represents the releases the memo field was released in.
var memoFeatureReleases = semverutil.FeatureReleases{
MajorVersion: "v6",
MinorVersions: []string{
"v2.5",
"v3.4",
"v4.2",
"v5.1",
},
}

// This can be used to test sending with a transfer packet with a memo given different combinations of
// ibc-go versions.
//
Expand Down Expand Up @@ -432,15 +429,15 @@ func (s *TransferTestSuite) TestMsgTransfer_WithMemo() {
t.Run("IBC token transfer with memo from chainA to chainB", func(t *testing.T) {
transferTxResp := s.Transfer(ctx, chainA, chainAWallet, channelA.PortID, channelA.ChannelID, testvalues.DefaultTransferAmount(chainADenom), chainAAddress, chainBAddress, s.GetTimeoutHeight(ctx, chainB), 0, "memo")

if memoFeatureReleases.IsSupported(chainAVersion) {
if testvalues.MemoFeatureReleases.IsSupported(chainAVersion) {
s.AssertTxSuccess(transferTxResp)
} else {
s.Require().Equal(uint32(2), transferTxResp.Code)
s.Require().Contains(transferTxResp.RawLog, "errUnknownField")
}
})

if !memoFeatureReleases.IsSupported(chainAVersion) {
if !testvalues.MemoFeatureReleases.IsSupported(chainAVersion) {
// transfer not sent, end test
return
}
Expand All @@ -465,7 +462,7 @@ func (s *TransferTestSuite) TestMsgTransfer_WithMemo() {
actualBalance, err := chainB.GetBalance(ctx, chainBAddress, chainBIBCToken.IBCDenom())
s.Require().NoError(err)

if memoFeatureReleases.IsSupported(chainBVersion) {
if testvalues.MemoFeatureReleases.IsSupported(chainBVersion) {
s.Require().Equal(testvalues.IBCTransferAmount, actualBalance)
} else {
s.Require().Equal(int64(0), actualBalance)
Expand Down
5 changes: 0 additions & 5 deletions e2e/tests/upgrades/upgrade_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -625,11 +625,6 @@ func (s *UpgradeTestSuite) TestV7ToV7_1ChainUpgrade() {

expected := testvalues.StartingTokenAmount - testvalues.IBCTransferAmount
s.Require().Equal(expected, actualBalance)

// Escrow amount for native denom is not stored in state because pre-upgrade version did not support this feature
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm missing some context here, can you explain why we remove this? Trying to navigate through the original PR that added this in order to find a discussion on it was more difficult than I thought 😄

Copy link
Contributor

Choose a reason for hiding this comment

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

I think it should be added back?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sorry, I should have added a comment in the PR to explain: I removed this because the starting version we are migrating from (i.e v7.0.0) does not support the endpoint to query the total escrow amount. It's only available in the target upgrade version (i.e. v7.1.0).

actualTotalEscrow, err := s.QueryTotalEscrowForDenom(ctx, chainA, chainADenom)
s.Require().NoError(err)
s.Require().Equal(math.ZeroInt(), actualTotalEscrow)
})

t.Run("start relayer", func(t *testing.T) {
Expand Down
40 changes: 40 additions & 0 deletions e2e/testvalues/values.go
Copy link
Member

Choose a reason for hiding this comment

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

Big ++ on grouping the feature releases together ❤️

Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/strangelove-ventures/interchaintest/v7/ibc"

"github.com/cosmos/ibc-go/e2e/semverutil"
feetypes "github.com/cosmos/ibc-go/v7/modules/apps/29-fee/types"
)

Expand Down Expand Up @@ -43,3 +44,42 @@ func TendermintClientID(id int) string {
func SolomachineClientID(id int) string {
return fmt.Sprintf("06-solomachine-%d", id)
}

// govGenesisFeatureReleases represents the releases the governance module genesis
// was upgraded from v1beta1 to v1.
var GovGenesisFeatureReleases = semverutil.FeatureReleases{
MajorVersion: "v7",
}

// icadGovGenesisFeatureReleases represents the releases of icad where the governance module genesis
// was upgraded from v1beta1 to v1.
var IcadGovGenesisFeatureReleases = semverutil.FeatureReleases{
MinorVersions: []string{
"v0.5",
},
}

// IcadNewGenesisCommandsFeatureReleases represents the releases of icad using the new genesis commands.
var IcadNewGenesisCommandsFeatureReleases = semverutil.FeatureReleases{
MinorVersions: []string{
"v0.5",
},
}

// MemoFeatureReleases represents the releases the memo field was released in.
var MemoFeatureReleases = semverutil.FeatureReleases{
MajorVersion: "v6",
MinorVersions: []string{
"v2.5",
"v3.4",
"v4.2",
"v5.1",
},
}

// TotalEscrowFeatureReleases represents the releases the total escrow state entry was released in.
var TotalEscrowFeatureReleases = semverutil.FeatureReleases{
MinorVersions: []string{
"v7.1",
},
}