Skip to content

Commit

Permalink
test: fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
snobbee committed Dec 15, 2023
1 parent af0613b commit 6c41d63
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 5 deletions.
2 changes: 1 addition & 1 deletion x/clp/keeper/swap_fee_params.go
Original file line number Diff line number Diff line change
Expand Up @@ -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, &params)
return params
Expand Down
16 changes: 13 additions & 3 deletions x/clp/types/genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
}
}

Expand Down
6 changes: 6 additions & 0 deletions x/clp/types/keys.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
7 changes: 6 additions & 1 deletion x/ethbridge/genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
6 changes: 6 additions & 0 deletions x/margin/keeper/msg_server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions x/margin/types/genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,6 @@ func DefaultGenesis() *GenesisState {
WhitelistingEnabled: false,
RowanCollateralEnabled: true,
},
MtpList: []*MTP{},
}
}

0 comments on commit 6c41d63

Please sign in to comment.