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 querying total escrow based on release version #3655

Merged
Show file tree
Hide file tree
Changes from 2 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.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I moved this already in this PR to testvalues.

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

Choose a reason for hiding this comment

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

mega nit, I find using does in the name is confusing, to me it is more readable with a name like simdSupportsGovV1Genesis (statement rather than question)

I know this wasn't introduced in this PR so I don't feel too strongly about it.

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
56 changes: 24 additions & 32 deletions e2e/tests/transfer/base_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,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"
ibctesting "github.com/cosmos/ibc-go/v7/testing"
Expand All @@ -29,11 +28,6 @@ type TransferTestSuite struct {
testsuite.E2ETestSuite
}

// transferSelfParamsFeatureReleases represents the releases the transfer module started managing its own params.
var transferSelfParamsFeatureReleases = semverutil.FeatureReleases{
MajorVersion: "v8",
}

// QueryTransferSendEnabledParam queries the on-chain send enabled param for the transfer module
func (s *TransferTestSuite) QueryTransferParams(ctx context.Context, chain ibc.Chain) transfertypes.Params {
queryClient := s.GetChainGRCPClients(chain).TransferQueryClient
Expand Down Expand Up @@ -62,6 +56,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 @@ -74,11 +71,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 @@ -108,9 +107,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 @@ -126,9 +127,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) {
Copy link
Contributor

Choose a reason for hiding this comment

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

should the t.Run be put within the conditional? As it currently is this will be an empty test

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 @@ -242,7 +245,7 @@ func (s *TransferTestSuite) TestSendEnabledParam() {
chainBAddress := chainBWallet.FormattedAddress()

chainAVersion := chainA.Config().Images[0].Version
isSelfManagingParams := transferSelfParamsFeatureReleases.IsSupported(chainAVersion)
isSelfManagingParams := testvalues.TransferSelfParamsFeatureReleases.IsSupported(chainAVersion)

govModuleAddress, err := s.QueryModuleAccountAddress(ctx, govtypes.ModuleName, chainA)
s.Require().NoError(err)
Expand Down Expand Up @@ -305,7 +308,7 @@ func (s *TransferTestSuite) TestReceiveEnabledParam() {
)

chainAVersion := chainA.Config().Images[0].Version
isSelfManagingParams := transferSelfParamsFeatureReleases.IsSupported(chainAVersion)
isSelfManagingParams := testvalues.transferSelfParamsFeatureReleases.IsSupported(chainAVersion)

govModuleAddress, err := s.QueryModuleAccountAddress(ctx, govtypes.ModuleName, chainA)
s.Require().NoError(err)
Expand Down Expand Up @@ -398,17 +401,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 @@ -439,15 +431,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 @@ -472,7 +464,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
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
4 changes: 2 additions & 2 deletions e2e/testsuite/tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,8 @@ func (s *E2ETestSuite) AssertTxFailure(resp sdk.TxResponse, expectedError *error
// In older versions, the codespace and abci codes were different. So in compatibility tests
// we can not make assertions on them.
// TODO: bypass these checks only for compatibility tests.
//s.Require().Equal(expectedError.ABCICode(), resp.Code, errorMsg)
//s.Require().Equal(expectedError.Codespace(), resp.Codespace, errorMsg)
// s.Require().Equal(expectedError.ABCICode(), resp.Code, errorMsg)
// s.Require().Equal(expectedError.Codespace(), resp.Codespace, errorMsg)
s.Require().Contains(resp.RawLog, expectedError.Error(), errorMsg)
}

Expand Down
45 changes: 45 additions & 0 deletions e2e/testvalues/values.go
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,47 @@ 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",
},
}

// TransferSelfParamsFeatureReleases represents the releases the transfer module started managing its own params.
var TransferSelfParamsFeatureReleases = semverutil.FeatureReleases{
MajorVersion: "v8",
}

// 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",
},
}