diff --git a/modules/farm/go.mod b/modules/farm/go.mod index a4e1af2e..bdc70f29 100644 --- a/modules/farm/go.mod +++ b/modules/farm/go.mod @@ -22,7 +22,6 @@ require ( google.golang.org/grpc v1.60.1 google.golang.org/protobuf v1.32.0 mods.irisnet.org/api v1.0.0-beta - mods.irisnet.org/modules/coinswap v1.0.0-beta mods.irisnet.org/simapp v1.0.0-beta sigs.k8s.io/yaml v1.3.0 ) diff --git a/modules/farm/keeper/depinject_test.go b/modules/farm/keeper/depinject_test.go index 2df6a0a5..1b8a9eb5 100644 --- a/modules/farm/keeper/depinject_test.go +++ b/modules/farm/keeper/depinject_test.go @@ -1,6 +1,7 @@ package keeper_test import ( + "fmt" "time" runtimev1alpha1 "cosmossdk.io/api/cosmos/app/runtime/v1alpha1" @@ -27,6 +28,7 @@ import ( "cosmossdk.io/core/appconfig" "google.golang.org/protobuf/types/known/durationpb" + sdk "github.com/cosmos/cosmos-sdk/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" @@ -46,12 +48,9 @@ import ( stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types" - coinswapmodule "mods.irisnet.org/api/irismod/coinswap/module/v1" farmmodule "mods.irisnet.org/api/irismod/farm/module/v1" - coinswaptypes "mods.irisnet.org/modules/coinswap/types" farmtypes "mods.irisnet.org/modules/farm/types" - _ "mods.irisnet.org/modules/coinswap" _ "mods.irisnet.org/modules/farm" ) @@ -68,7 +67,7 @@ var ( 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, - vestingtypes.ModuleName, consensustypes.ModuleName, coinswaptypes.ModuleName, farmtypes.ModuleName, + vestingtypes.ModuleName, consensustypes.ModuleName, farmtypes.ModuleName, } // module account permissions @@ -79,7 +78,6 @@ var ( {Account: stakingtypes.BondedPoolName, Permissions: []string{authtypes.Burner, stakingtypes.ModuleName}}, {Account: stakingtypes.NotBondedPoolName, Permissions: []string{authtypes.Burner, stakingtypes.ModuleName}}, {Account: govtypes.ModuleName, Permissions: []string{authtypes.Burner}}, - {Account: coinswaptypes.ModuleName, Permissions: []string{authtypes.Minter, authtypes.Burner}}, {Account: farmtypes.ModuleName, Permissions: []string{authtypes.Burner}}, {Account: farmtypes.RewardCollector}, {Account: farmtypes.EscrowCollector}, @@ -126,7 +124,6 @@ var ( group.ModuleName, paramstypes.ModuleName, vestingtypes.ModuleName, - coinswaptypes.ModuleName, farmtypes.ModuleName, consensustypes.ModuleName, }, @@ -148,7 +145,6 @@ var ( paramstypes.ModuleName, consensustypes.ModuleName, upgradetypes.ModuleName, - coinswaptypes.ModuleName, farmtypes.ModuleName, vestingtypes.ModuleName, }, @@ -255,12 +251,6 @@ var ( Name: consensustypes.ModuleName, Config: appconfig.WrapAny(&consensusmodulev1.Module{}), }, - { - Name: coinswaptypes.ModuleName, - Config: appconfig.WrapAny(&coinswapmodule.Module{ - FeeCollectorName: authtypes.FeeCollectorName, - }), - }, { Name: farmtypes.ModuleName, Config: appconfig.WrapAny(&farmmodule.Module{ @@ -271,3 +261,10 @@ var ( }, }) ) + +type mockCoinswapKeeper struct {} + +func (mck *mockCoinswapKeeper) ValidatePool(ctx sdk.Context, lptDenom string) error { + fmt.Println("mock coinswap keeper") + return nil +} \ No newline at end of file diff --git a/modules/farm/keeper/keeper_test.go b/modules/farm/keeper/keeper_test.go index 24164e7e..c66e4dfa 100644 --- a/modules/farm/keeper/keeper_test.go +++ b/modules/farm/keeper/keeper_test.go @@ -50,7 +50,9 @@ func TestKeeperTestSuite(t *testing.T) { func (suite *KeeperTestSuite) SetupTest() { depInjectOptions := simapp.DepinjectOptions{ Config: AppConfig, - Providers: []interface{}{}, + Providers: []interface{}{ + &mockCoinswapKeeper{}, + }, Consumers: []interface{}{&suite.keeper}, } app := simapp.Setup(suite.T(), isCheckTx,depInjectOptions) @@ -444,7 +446,7 @@ func (suite *KeeperTestSuite) TestHarvest() { } func (suite *KeeperTestSuite) AssertStake( - poolId string, + poolID string, height int64, stakeCoin sdk.Coin, locked sdk.Int, @@ -452,18 +454,18 @@ func (suite *KeeperTestSuite) AssertStake( rewardPerShare sdk.Dec, ) { ctx := suite.app.BaseApp.NewContext(isCheckTx, tmproto.Header{Height: height}) - reward, err := suite.keeper.Stake(ctx, poolId, stakeCoin, testFarmer1) + reward, err := suite.keeper.Stake(ctx, poolID, stakeCoin, testFarmer1) suite.Require().NoError(err) suite.Require().Equal(expectReward, reward) - info, exist := suite.keeper.GetFarmInfo(ctx, poolId, testFarmer1.String()) + info, exist := suite.keeper.GetFarmInfo(ctx, poolID, testFarmer1.String()) suite.Require().True(exist) suite.Require().Equal(debt, info.RewardDebt) suite.Require().Equal(locked, info.Locked) //check reward rules again - rules := suite.keeper.GetRewardRules(ctx, poolId) + rules := suite.keeper.GetRewardRules(ctx, poolID) suite.Require().Len(rules, len(testRewardPerBlock)) for _, r := range rules { suite.Require().Equal(rewardPerShare, r.RewardPerShare) @@ -471,7 +473,7 @@ func (suite *KeeperTestSuite) AssertStake( } func (suite *KeeperTestSuite) AssertUnstake( - poolId string, + poolID string, height int64, unstakeCoin sdk.Coin, expectReward, expectDebt sdk.Coins, @@ -481,16 +483,16 @@ func (suite *KeeperTestSuite) AssertUnstake( ctx := suite.app.BaseApp.NewContext(isCheckTx, tmproto.Header{Height: height}) //check farm pool - poolSrc, _ := suite.keeper.GetPool(ctx, poolId) + poolSrc, _ := suite.keeper.GetPool(ctx, poolID) //check farm information - farmInfoSrc, _ := suite.keeper.GetFarmInfo(ctx, poolId, testFarmer1.String()) + farmInfoSrc, _ := suite.keeper.GetFarmInfo(ctx, poolID, testFarmer1.String()) - reward, err := suite.keeper.Unstake(ctx, poolId, unstakeCoin, testFarmer1) + reward, err := suite.keeper.Unstake(ctx, poolID, unstakeCoin, testFarmer1) suite.Require().NoError(err) suite.Require().Equal(expectReward, reward) //check farm information - farmInfo, exist := suite.keeper.GetFarmInfo(ctx, poolId, testFarmer1.String()) + farmInfo, exist := suite.keeper.GetFarmInfo(ctx, poolID, testFarmer1.String()) if unstakeAll { suite.Require().False(exist) } else { @@ -500,13 +502,13 @@ func (suite *KeeperTestSuite) AssertUnstake( } //check farm pool - pool, exist := suite.keeper.GetPool(ctx, poolId) + pool, exist := suite.keeper.GetPool(ctx, poolID) suite.Require().True(exist) suite.Require(). Equal(pool.TotalLptLocked.String(), poolSrc.TotalLptLocked.Sub(unstakeCoin).String()) //check reward rules again - rules := suite.keeper.GetRewardRules(ctx, poolId) + rules := suite.keeper.GetRewardRules(ctx, poolID) suite.Require().Len(rules, len(testRewardPerBlock)) for _, r := range rules { suite.Require().Equal(rewardPerShare, r.RewardPerShare) @@ -514,7 +516,7 @@ func (suite *KeeperTestSuite) AssertUnstake( } func (suite *KeeperTestSuite) AssertHarvest( - poolId string, + poolID string, index int64, height int64, expectReward sdk.Coins, @@ -522,17 +524,17 @@ func (suite *KeeperTestSuite) AssertHarvest( rewardPerShare sdk.Dec, ) { ctx := suite.app.BaseApp.NewContext(isCheckTx, tmproto.Header{Height: height}) - reward, err := suite.keeper.Harvest(ctx, poolId, testFarmer1) + reward, err := suite.keeper.Harvest(ctx, poolID, testFarmer1) suite.Require().NoError(err) suite.Require().Equal(expectReward, reward) - info, exist := suite.keeper.GetFarmInfo(ctx, poolId, testFarmer1.String()) + info, exist := suite.keeper.GetFarmInfo(ctx, poolID, testFarmer1.String()) suite.Require().True(exist) suite.Require().Equal(debt, info.RewardDebt) //check reward rules again - rules := suite.keeper.GetRewardRules(ctx, poolId) + rules := suite.keeper.GetRewardRules(ctx, poolID) suite.Require().Len(rules, len(testRewardPerBlock)) for _, r := range rules { suite.Require().Equal(rewardPerShare, r.RewardPerShare)