Skip to content

Commit

Permalink
Merge pull request #468 from irisnet/feature/e2e
Browse files Browse the repository at this point in the history
Upgrade cosmos-sdk in irismod to v0.50.10
  • Loading branch information
mitch1024 authored Dec 2, 2024
2 parents 6bbbf8c + 8cd1de9 commit ae2ffd0
Show file tree
Hide file tree
Showing 30 changed files with 642 additions and 564 deletions.
20 changes: 5 additions & 15 deletions e2e/app_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import (
authmodulev1 "cosmossdk.io/api/cosmos/auth/module/v1"
authzmodulev1 "cosmossdk.io/api/cosmos/authz/module/v1"
bankmodulev1 "cosmossdk.io/api/cosmos/bank/module/v1"
capabilitymodulev1 "cosmossdk.io/api/cosmos/capability/module/v1"
consensusmodulev1 "cosmossdk.io/api/cosmos/consensus/module/v1"
crisismodulev1 "cosmossdk.io/api/cosmos/crisis/module/v1"
distrmodulev1 "cosmossdk.io/api/cosmos/distribution/module/v1"
Expand All @@ -25,25 +24,24 @@ import (
upgrademodulev1 "cosmossdk.io/api/cosmos/upgrade/module/v1"
vestingmodulev1 "cosmossdk.io/api/cosmos/vesting/module/v1"
"cosmossdk.io/core/appconfig"
evidencetypes "cosmossdk.io/x/evidence/types"
"cosmossdk.io/x/feegrant"
_ "cosmossdk.io/x/upgrade" // import for side-effects
upgradetypes "cosmossdk.io/x/upgrade/types"
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
vestingtypes "github.com/cosmos/cosmos-sdk/x/auth/vesting/types"
"github.com/cosmos/cosmos-sdk/x/authz"
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
capabilitytypes "github.com/cosmos/cosmos-sdk/x/capability/types"
consensustypes "github.com/cosmos/cosmos-sdk/x/consensus/types"
crisistypes "github.com/cosmos/cosmos-sdk/x/crisis/types"
distrtypes "github.com/cosmos/cosmos-sdk/x/distribution/types"
evidencetypes "github.com/cosmos/cosmos-sdk/x/evidence/types"
"github.com/cosmos/cosmos-sdk/x/feegrant"
genutiltypes "github.com/cosmos/cosmos-sdk/x/genutil/types"
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types"
"github.com/cosmos/cosmos-sdk/x/group"
minttypes "github.com/cosmos/cosmos-sdk/x/mint/types"
paramstypes "github.com/cosmos/cosmos-sdk/x/params/types"
slashingtypes "github.com/cosmos/cosmos-sdk/x/slashing/types"
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"
_ "github.com/cosmos/cosmos-sdk/x/upgrade" // import for side-effects
upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types"
"google.golang.org/protobuf/types/known/durationpb"

coinswapmodule "mods.irisnet.org/api/irismod/coinswap/module/v1"
Expand Down Expand Up @@ -87,7 +85,7 @@ var (
// so that other modules that want to create or claim capabilities afterwards in InitChain
// can do so safely.
genesisModuleOrder = []string{
capabilitytypes.ModuleName, authtypes.ModuleName, banktypes.ModuleName,
authtypes.ModuleName, banktypes.ModuleName,
distrtypes.ModuleName, stakingtypes.ModuleName, slashingtypes.ModuleName, govtypes.ModuleName,
minttypes.ModuleName, crisistypes.ModuleName, genutiltypes.ModuleName, evidencetypes.ModuleName, authz.ModuleName,
feegrant.ModuleName, group.ModuleName, paramstypes.ModuleName, upgradetypes.ModuleName,
Expand Down Expand Up @@ -148,7 +146,6 @@ var (
// NOTE: capability module's beginblocker must come before any modules using capabilities (e.g. IBC)
BeginBlockers: []string{
upgradetypes.ModuleName,
capabilitytypes.ModuleName,
minttypes.ModuleName,
distrtypes.ModuleName,
slashingtypes.ModuleName,
Expand Down Expand Up @@ -180,7 +177,6 @@ var (
crisistypes.ModuleName,
govtypes.ModuleName,
stakingtypes.ModuleName,
capabilitytypes.ModuleName,
authtypes.ModuleName,
banktypes.ModuleName,
distrtypes.ModuleName,
Expand Down Expand Up @@ -272,12 +268,6 @@ var (
Name: distrtypes.ModuleName,
Config: appconfig.WrapAny(&distrmodulev1.Module{}),
},
{
Name: capabilitytypes.ModuleName,
Config: appconfig.WrapAny(&capabilitymodulev1.Module{
SealKeeper: true,
}),
},
{
Name: evidencetypes.ModuleName,
Config: appconfig.WrapAny(&evidencemodulev1.Module{}),
Expand Down
43 changes: 22 additions & 21 deletions e2e/coinswap/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"fmt"
"time"

"cosmossdk.io/math"
"github.com/cosmos/cosmos-sdk/testutil"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/gogoproto/proto"
Expand Down Expand Up @@ -61,7 +62,7 @@ func (s *QueryTestSuite) TestCoinswap() {

// _ = tokentestutil.IssueTokenExec(s.T(), s.Network, clientCtx, from.String(), args...)

balances := simapp.QueryBalancesExec(s.T(), s.Network, clientCtx, from.String())
balances := simapp.QueryBalancesExec(s.T(), clientCtx, from.String())
s.Require().Equal("100000000", balances.AmountOf(symbol).String())
s.Require().Equal("399986975", balances.AmountOf(sdk.DefaultBondDenom).String())

Expand All @@ -71,15 +72,15 @@ func (s *QueryTestSuite) TestCoinswap() {
deadline := status.SyncInfo.LatestBlockTime.Add(time.Minute)

msgAddLiquidity := &coinswaptypes.MsgAddLiquidity{
MaxToken: sdk.NewCoin(symbol, sdk.NewInt(1000)),
ExactStandardAmt: sdk.NewInt(1000),
MinLiquidity: sdk.NewInt(1000),
MaxToken: sdk.NewCoin(symbol, math.NewInt(1000)),
ExactStandardAmt: math.NewInt(1000),
MinLiquidity: math.NewInt(1000),
Deadline: deadline.Unix(),
Sender: from.String(),
}
s.SendMsgs(s.T(), msgAddLiquidity)

balances = simapp.QueryBalancesExec(s.T(), s.Network, clientCtx, from.String())
balances = simapp.QueryBalancesExec(s.T(), clientCtx, from.String())
s.Require().Equal("99999000", balances.AmountOf(symbol).String())
s.Require().Equal("399980965", balances.AmountOf(sdk.DefaultBondDenom).String())
s.Require().Equal("1000", balances.AmountOf(lptDenom).String())
Expand All @@ -101,15 +102,15 @@ func (s *QueryTestSuite) TestCoinswap() {
deadline = status.SyncInfo.LatestBlockTime.Add(time.Minute)

msgAddLiquidity = &coinswaptypes.MsgAddLiquidity{
MaxToken: sdk.NewCoin(symbol, sdk.NewInt(2001)),
ExactStandardAmt: sdk.NewInt(2000),
MinLiquidity: sdk.NewInt(2000),
MaxToken: sdk.NewCoin(symbol, math.NewInt(2001)),
ExactStandardAmt: math.NewInt(2000),
MinLiquidity: math.NewInt(2000),
Deadline: deadline.Unix(),
Sender: from.String(),
}
s.SendMsgs(s.T(), msgAddLiquidity)

balances = simapp.QueryBalancesExec(s.T(), s.Network, clientCtx, from.String())
balances = simapp.QueryBalancesExec(s.T(), clientCtx, from.String())
s.Require().Equal("99996999", balances.AmountOf(symbol).String())
s.Require().Equal("399978955", balances.AmountOf(sdk.DefaultBondDenom).String())
s.Require().Equal("3000", balances.AmountOf(lptDenom).String())
Expand All @@ -127,7 +128,7 @@ func (s *QueryTestSuite) TestCoinswap() {
msgSellOrder := &coinswaptypes.MsgSwapOrder{
Input: coinswaptypes.Input{
Address: from.String(),
Coin: sdk.NewCoin(symbol, sdk.NewInt(1000)),
Coin: sdk.NewCoin(symbol, math.NewInt(1000)),
},
Output: coinswaptypes.Output{
Address: from.String(),
Expand All @@ -138,7 +139,7 @@ func (s *QueryTestSuite) TestCoinswap() {
}
s.SendMsgs(s.T(), msgSellOrder)

balances = simapp.QueryBalancesExec(s.T(), s.Network, clientCtx, from.String())
balances = simapp.QueryBalancesExec(s.T(), clientCtx, from.String())
s.Require().Equal("99995999", balances.AmountOf(symbol).String())
s.Require().Equal("399979693", balances.AmountOf(sdk.DefaultBondDenom).String())
s.Require().Equal("3000", balances.AmountOf(lptDenom).String())
Expand All @@ -160,14 +161,14 @@ func (s *QueryTestSuite) TestCoinswap() {
},
Output: coinswaptypes.Output{
Address: from.String(),
Coin: sdk.NewCoin(symbol, sdk.NewInt(1000)),
Coin: sdk.NewCoin(symbol, math.NewInt(1000)),
},
Deadline: deadline.Unix(),
IsBuyOrder: true,
}
s.SendMsgs(s.T(), msgBuyOrder)

balances = simapp.QueryBalancesExec(s.T(), s.Network, clientCtx, from.String())
balances = simapp.QueryBalancesExec(s.T(), clientCtx, from.String())
s.Require().Equal("99996999", balances.AmountOf(symbol).String())
s.Require().Equal("399978930", balances.AmountOf(sdk.DefaultBondDenom).String())
s.Require().Equal("3000", balances.AmountOf(lptDenom).String())
Expand All @@ -183,17 +184,17 @@ func (s *QueryTestSuite) TestCoinswap() {

// Test remove liquidity (remove part)
msgRemoveLiquidity := &coinswaptypes.MsgRemoveLiquidity{
WithdrawLiquidity: sdk.NewCoin(lptDenom, sdk.NewInt(2000)),
MinToken: sdk.NewInt(2000),
MinStandardAmt: sdk.NewInt(2000),
WithdrawLiquidity: sdk.NewCoin(lptDenom, math.NewInt(2000)),
MinToken: math.NewInt(2000),
MinStandardAmt: math.NewInt(2000),
Deadline: deadline.Unix(),
Sender: from.String(),
}

// prepare txBuilder with msg
s.SendMsgs(s.T(), msgRemoveLiquidity)

balances = simapp.QueryBalancesExec(s.T(), s.Network, clientCtx, from.String())
balances = simapp.QueryBalancesExec(s.T(), clientCtx, from.String())
s.Require().Equal("99998999", balances.AmountOf(symbol).String())
s.Require().Equal("399980923", balances.AmountOf(sdk.DefaultBondDenom).String())
s.Require().Equal("1000", balances.AmountOf(lptDenom).String())
Expand All @@ -209,17 +210,17 @@ func (s *QueryTestSuite) TestCoinswap() {

// Test remove liquidity (remove all)
msgRemoveLiquidity = &coinswaptypes.MsgRemoveLiquidity{
WithdrawLiquidity: sdk.NewCoin(lptDenom, sdk.NewInt(1000)),
MinToken: sdk.NewInt(1000),
MinStandardAmt: sdk.NewInt(1000),
WithdrawLiquidity: sdk.NewCoin(lptDenom, math.NewInt(1000)),
MinToken: math.NewInt(1000),
MinStandardAmt: math.NewInt(1000),
Deadline: deadline.Unix(),
Sender: from.String(),
}

// prepare txBuilder with msg
s.SendMsgs(s.T(), msgRemoveLiquidity)

balances = simapp.QueryBalancesExec(s.T(), s.Network, clientCtx, from.String())
balances = simapp.QueryBalancesExec(s.T(), clientCtx, from.String())
s.Require().Equal("100000000", balances.AmountOf(symbol).String())
s.Require().Equal("399981915", balances.AmountOf(sdk.DefaultBondDenom).String())
s.Require().Equal("0", balances.AmountOf(lptDenom).String())
Expand Down
19 changes: 10 additions & 9 deletions e2e/farm/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"fmt"
"time"

"cosmossdk.io/math"
"github.com/cosmos/cosmos-sdk/client/flags"
"github.com/cosmos/cosmos-sdk/testutil"
sdk "github.com/cosmos/cosmos-sdk/types"
Expand Down Expand Up @@ -43,9 +44,9 @@ func (s *QueryTestSuite) TestQueryCmd() {
creator := val.Address
description := "iris-atom farm pool"
startHeight := s.latestHeight() + 2
rewardPerBlock := sdk.NewCoins(sdk.NewCoin(s.BondDenom, sdk.NewInt(10)))
rewardPerBlock := sdk.NewCoins(sdk.NewCoin(s.BondDenom, math.NewInt(10)))
lpTokenDenom := "lpt-1"
totalReward := sdk.NewCoins(sdk.NewCoin(s.BondDenom, sdk.NewInt(1000)))
totalReward := sdk.NewCoins(sdk.NewCoin(s.BondDenom, math.NewInt(1000)))
editable := true

globalFlags := []string{
Expand All @@ -54,7 +55,7 @@ func (s *QueryTestSuite) TestQueryCmd() {
fmt.Sprintf(
"--%s=%s",
flags.FlagFees,
sdk.NewCoins(sdk.NewCoin(s.BondDenom, sdk.NewInt(10))).String(),
sdk.NewCoins(sdk.NewCoin(s.BondDenom, math.NewInt(10))).String(),
),
}

Expand Down Expand Up @@ -90,7 +91,7 @@ func (s *QueryTestSuite) TestQueryCmd() {
EndHeight: startHeight + 100,
Editable: editable,
Expired: false,
TotalLptLocked: sdk.NewCoin(lpTokenDenom, sdk.ZeroInt()),
TotalLptLocked: sdk.NewCoin(lpTokenDenom, math.ZeroInt()),
TotalReward: totalReward,
RemainingReward: totalReward,
RewardPerBlock: rewardPerBlock,
Expand All @@ -109,7 +110,7 @@ func (s *QueryTestSuite) TestQueryCmd() {
s.Require().NoError(err)
s.Require().NoError(s.WaitForNextBlock())

lpToken := sdk.NewCoin(lpTokenDenom, sdk.NewInt(100))
lpToken := sdk.NewCoin(lpTokenDenom, math.NewInt(100))
txResult = StakeExec(
s.T(),
s.Network,
Expand All @@ -136,7 +137,7 @@ func (s *QueryTestSuite) TestQueryCmd() {

if farmer.Height-txResult.Height > 0 {
expectFarmer.PendingReward = rewardPerBlock.MulInt(
sdk.NewInt(farmer.Height - txResult.Height),
math.NewInt(farmer.Height - txResult.Height),
)
}
s.Require().EqualValues(expectFarmer, *farmer.List[0])
Expand Down Expand Up @@ -181,9 +182,9 @@ func (s *QueryTestSuite) setup() {
deadline := status.SyncInfo.LatestBlockTime.Add(time.Minute)

msgAddLiquidity := &coinswaptypes.MsgAddLiquidity{
MaxToken: sdk.NewCoin(symbol, sdk.NewInt(1000)),
ExactStandardAmt: sdk.NewInt(1000),
MinLiquidity: sdk.NewInt(1000),
MaxToken: sdk.NewCoin(symbol, math.NewInt(1000)),
ExactStandardAmt: math.NewInt(1000),
MinLiquidity: math.NewInt(1000),
Deadline: deadline.Unix(),
Sender: val.Address.String(),
}
Expand Down
25 changes: 13 additions & 12 deletions e2e/farm/tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"fmt"
"time"

"cosmossdk.io/math"
"github.com/cosmos/cosmos-sdk/client/flags"
sdk "github.com/cosmos/cosmos-sdk/types"

Expand Down Expand Up @@ -32,8 +33,8 @@ func (s *TxTestSuite) TestTxCmd() {
creator := val.Address
description := "iris-atom farm pool"
startHeight := s.latestHeight() + 2
rewardPerBlock := sdk.NewCoins(sdk.NewCoin(s.Network.BondDenom, sdk.NewInt(10)))
totalReward := sdk.NewCoins(sdk.NewCoin(s.Network.BondDenom, sdk.NewInt(1000)))
rewardPerBlock := sdk.NewCoins(sdk.NewCoin(s.Network.BondDenom, math.NewInt(10)))
totalReward := sdk.NewCoins(sdk.NewCoin(s.Network.BondDenom, math.NewInt(1000)))
editable := true
lptDenom := "lpt-1"

Expand All @@ -43,7 +44,7 @@ func (s *TxTestSuite) TestTxCmd() {
fmt.Sprintf(
"--%s=%s",
flags.FlagFees,
sdk.NewCoins(sdk.NewCoin(s.Network.BondDenom, sdk.NewInt(10))).String(),
sdk.NewCoins(sdk.NewCoin(s.Network.BondDenom, math.NewInt(10))).String(),
),
}

Expand Down Expand Up @@ -79,7 +80,7 @@ func (s *TxTestSuite) TestTxCmd() {
EndHeight: startHeight + 100,
Editable: editable,
Expired: false,
TotalLptLocked: sdk.NewCoin(lptDenom, sdk.ZeroInt()),
TotalLptLocked: sdk.NewCoin(lptDenom, math.ZeroInt()),
TotalReward: totalReward,
RemainingReward: totalReward,
RewardPerBlock: rewardPerBlock,
Expand All @@ -88,7 +89,7 @@ func (s *TxTestSuite) TestTxCmd() {
respType := QueryFarmPoolExec(s.T(), s.Network, val.ClientCtx, poolID)
s.Require().EqualValues(expectedContents, respType.Pool)

reward := sdk.NewCoins(sdk.NewCoin(s.Network.BondDenom, sdk.NewInt(1000)))
reward := sdk.NewCoins(sdk.NewCoin(s.Network.BondDenom, math.NewInt(1000)))
args = []string{
fmt.Sprintf("--%s=%v", farmcli.FlagAdditionalReward, reward.String()),
}
Expand All @@ -103,7 +104,7 @@ func (s *TxTestSuite) TestTxCmd() {
)
s.Require().EqualValues(txResult.Code, 0, txResult.Log)

lpToken := sdk.NewCoin(lptDenom, sdk.NewInt(100))
lpToken := sdk.NewCoin(lptDenom, math.NewInt(100))
txResult = StakeExec(
s.T(),
s.Network,
Expand All @@ -116,7 +117,7 @@ func (s *TxTestSuite) TestTxCmd() {
s.Require().EqualValues(txResult.Code, 0, txResult.Log)
beginHeight := txResult.Height

unstakeLPToken := sdk.NewCoin(lptDenom, sdk.NewInt(50))
unstakeLPToken := sdk.NewCoin(lptDenom, math.NewInt(50))
txResult = UnstakeExec(
s.T(),
s.Network,
Expand All @@ -134,7 +135,7 @@ func (s *TxTestSuite) TestTxCmd() {
farmtypes.AttributeValueReward,
txResult.Events,
)
expectedReward := rewardPerBlock.MulInt(sdk.NewInt(endHeight - beginHeight))
expectedReward := rewardPerBlock.MulInt(math.NewInt(endHeight - beginHeight))
s.Require().Equal(expectedReward.String(), rewardGot)

txResult = HarvestExec(
Expand All @@ -153,7 +154,7 @@ func (s *TxTestSuite) TestTxCmd() {
farmtypes.AttributeValueReward,
txResult.Events,
)
expectedReward = rewardPerBlock.MulInt(sdk.NewInt(endHeight1 - endHeight))
expectedReward = rewardPerBlock.MulInt(math.NewInt(endHeight1 - endHeight))
s.Require().Equal(expectedReward.String(), rewardGot)

queryFarmerArgs := []string{
Expand Down Expand Up @@ -217,9 +218,9 @@ func (s *TxTestSuite) setup() {
deadline := status.SyncInfo.LatestBlockTime.Add(time.Minute)

msgAddLiquidity := &coinswaptypes.MsgAddLiquidity{
MaxToken: sdk.NewCoin(symbol, sdk.NewInt(1000)),
ExactStandardAmt: sdk.NewInt(1000),
MinLiquidity: sdk.NewInt(1000),
MaxToken: sdk.NewCoin(symbol, math.NewInt(1000)),
ExactStandardAmt: math.NewInt(1000),
MinLiquidity: math.NewInt(1000),
Deadline: deadline.Unix(),
Sender: val.Address.String(),
}
Expand Down
Loading

0 comments on commit ae2ffd0

Please sign in to comment.