From 6c41d637b0b76761ded78d1b42f4f25e1c3c72ee Mon Sep 17 00:00:00 2001 From: Snobbish Bee <125891987+snobbee@users.noreply.github.com> Date: Fri, 15 Dec 2023 06:56:39 +0100 Subject: [PATCH] test: fix tests --- x/clp/keeper/swap_fee_params.go | 2 +- x/clp/types/genesis.go | 16 +++++++++++++--- x/clp/types/keys.go | 6 ++++++ x/ethbridge/genesis.go | 7 ++++++- x/margin/keeper/msg_server_test.go | 6 ++++++ x/margin/types/genesis.go | 1 + 6 files changed, 33 insertions(+), 5 deletions(-) diff --git a/x/clp/keeper/swap_fee_params.go b/x/clp/keeper/swap_fee_params.go index 41747615e0..4b6b6d503e 100644 --- a/x/clp/keeper/swap_fee_params.go +++ b/x/clp/keeper/swap_fee_params.go @@ -15,7 +15,7 @@ func (k Keeper) GetSwapFeeParams(ctx sdk.Context) types.SwapFeeParams { store := ctx.KVStore(k.storeKey) bz := store.Get(types.SwapFeeParamsPrefix) if bz == nil { - return types.SwapFeeParams{DefaultSwapFeeRate: sdk.NewDecWithPrec(3, 3)} //0.003 + return *types.GetDefaultSwapFeeParams() } k.cdc.MustUnmarshal(bz, ¶ms) return params diff --git a/x/clp/types/genesis.go b/x/clp/types/genesis.go index 6784ba1c9d..c69412ea72 100644 --- a/x/clp/types/genesis.go +++ b/x/clp/types/genesis.go @@ -11,9 +11,19 @@ import ( func DefaultGenesisState() *GenesisState { admin := GetDefaultCLPAdmin() return &GenesisState{ - Params: DefaultParams(), - AddressWhitelist: []string{admin.String()}, - RewardsBucketList: []RewardsBucket{}, + Params: DefaultParams(), + AddressWhitelist: []string{admin.String()}, + PoolList: []*Pool{}, + LiquidityProviders: []*LiquidityProvider{}, + RewardsBucketList: []RewardsBucket{}, + RewardParams: *GetDefaultRewardParams(), + PmtpParams: *GetDefaultPmtpParams(), + PmtpEpoch: PmtpEpoch{}, + PmtpRateParams: PmtpRateParams{}, + LiquidityProtectionParams: *GetDefaultLiquidityProtectionParams(), + LiquidityProtectionRateParams: LiquidityProtectionRateParams{}, + SwapFeeParams: *GetDefaultSwapFeeParams(), + ProviderDistributionParams: *GetDefaultProviderDistributionParams(), } } diff --git a/x/clp/types/keys.go b/x/clp/types/keys.go index a9d92e85d3..4cab268d99 100644 --- a/x/clp/types/keys.go +++ b/x/clp/types/keys.go @@ -105,6 +105,12 @@ func GetDefaultProviderDistributionParams() *ProviderDistributionParams { } } +func GetDefaultSwapFeeParams() *SwapFeeParams { + return &SwapFeeParams{ + DefaultSwapFeeRate: sdk.NewDecWithPrec(3, 3), // 0.003 + } +} + // GetRemovalRequestKey generates a key to store a removal request, // the key is in the format: lpaddress_id func GetRemovalRequestKey(request RemovalRequest) []byte { diff --git a/x/ethbridge/genesis.go b/x/ethbridge/genesis.go index 37bd32632d..cb7adcfd1b 100644 --- a/x/ethbridge/genesis.go +++ b/x/ethbridge/genesis.go @@ -9,7 +9,12 @@ import ( ) func DefaultGenesis() *types.GenesisState { - return &types.GenesisState{} + return &types.GenesisState{ + CethReceiveAccount: "", + PeggyTokens: []string{}, + Blacklist: []string{}, + Pause: &types.Pause{IsPaused: false}, + } } func InitGenesis(ctx sdk.Context, keeper keeper.Keeper, data types.GenesisState) (res []abci.ValidatorUpdate) { diff --git a/x/margin/keeper/msg_server_test.go b/x/margin/keeper/msg_server_test.go index cae691fc28..7056e61303 100644 --- a/x/margin/keeper/msg_server_test.go +++ b/x/margin/keeper/msg_server_test.go @@ -838,6 +838,8 @@ func TestKeeper_OpenClose(t *testing.T) { ctx, app := test.CreateTestAppMargin(false) marginKeeper := app.MarginKeeper + app.ClpKeeper.SetSwapFeeParams(ctx, clptypes.GetDefaultSwapFeeParams()) + app.TokenRegistryKeeper.SetToken(ctx, &tokenregistrytypes.RegistryEntry{ Denom: tt.externalAsset, Decimals: 18, @@ -1156,6 +1158,8 @@ func TestKeeper_OpenThenClose(t *testing.T) { marginKeeper := app.MarginKeeper msgServer := keeper.NewMsgServerImpl(marginKeeper) + app.ClpKeeper.SetSwapFeeParams(ctx, clptypes.GetDefaultSwapFeeParams()) + msgOpen := types.MsgOpen{ Signer: signer, CollateralAsset: externalAsset, @@ -1874,6 +1878,8 @@ func TestKeeper_EC(t *testing.T) { marginKeeper := app.MarginKeeper msgServer := keeper.NewMsgServerImpl(marginKeeper) + app.ClpKeeper.SetSwapFeeParams(ctx, clptypes.GetDefaultSwapFeeParams()) + for i, chunkItem := range testItem.chunks { i := i chunkItem := chunkItem diff --git a/x/margin/types/genesis.go b/x/margin/types/genesis.go index e7021d5843..e18203e65c 100644 --- a/x/margin/types/genesis.go +++ b/x/margin/types/genesis.go @@ -27,5 +27,6 @@ func DefaultGenesis() *GenesisState { WhitelistingEnabled: false, RowanCollateralEnabled: true, }, + MtpList: []*MTP{}, } }