-
Notifications
You must be signed in to change notification settings - Fork 637
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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" | ||
) | ||
|
||
|
@@ -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 | ||
|
@@ -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", | ||
|
@@ -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) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. mega nit, I find using 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() | ||
|
@@ -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) { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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" | ||
|
@@ -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 | ||
|
@@ -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) | ||
|
@@ -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) { | ||
|
@@ -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") | ||
|
@@ -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) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 | ||
} | ||
}) | ||
} | ||
|
||
|
@@ -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) | ||
|
@@ -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) | ||
|
@@ -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. | ||
// | ||
|
@@ -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 | ||
} | ||
|
@@ -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) | ||
|
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 moved this already in this PR to
testvalues
.