Skip to content

Commit

Permalink
chore: improve code coverage and update nil check to IsAllPositive
Browse files Browse the repository at this point in the history
  • Loading branch information
jaybxyz committed Sep 24, 2021
1 parent 806abb0 commit cb3635c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
9 changes: 5 additions & 4 deletions x/farming/keeper/proposal_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ func (k Keeper) UpdatePublicPlanProposal(ctx sdk.Context, proposals []*types.Upd
if p.EpochAmount.IsAllPositive() {
if p.GetName() != "" {
if err := plan.SetName(p.GetName()); err != nil {
return err
return err // nolint:errcheck
}
}

Expand Down Expand Up @@ -151,7 +151,7 @@ func (k Keeper) UpdatePublicPlanProposal(ctx sdk.Context, proposals []*types.Upd
}

// change the plan to fixed amount plan if an epoch amount exists
if p.GetEpochAmount() != nil {
if p.GetEpochAmount().IsAllPositive() {
basePlan := types.NewBasePlan(
plan.GetId(),
plan.GetName(),
Expand All @@ -174,7 +174,7 @@ func (k Keeper) UpdatePublicPlanProposal(ctx sdk.Context, proposals []*types.Upd
} else if p.EpochRatio.IsPositive() {
if p.GetName() != "" {
if err := plan.SetName(p.GetName()); err != nil {
return err
return err // nolint:errcheck
}
}

Expand Down Expand Up @@ -217,7 +217,7 @@ func (k Keeper) UpdatePublicPlanProposal(ctx sdk.Context, proposals []*types.Upd
}

// change the plan to ratio plan if an epoch ratio exists
if !p.EpochRatio.IsZero() {
if p.EpochRatio.IsPositive() {
basePlan := types.NewBasePlan(
plan.GetId(),
plan.GetName(),
Expand All @@ -236,6 +236,7 @@ func (k Keeper) UpdatePublicPlanProposal(ctx sdk.Context, proposals []*types.Upd

logger := k.Logger(ctx)
logger.Info("updated public ratio plan", "ratio_plan", plan)

}
}

Expand Down
3 changes: 3 additions & 0 deletions x/farming/types/proposal.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ func (p PublicPlanProposal) String() string {
}

// NewAddRequestProposal creates a new AddRequestProposal object
// nolint:interfacer
func NewAddRequestProposal(
name string,
farmingPoolAddr string,
Expand Down Expand Up @@ -140,6 +141,7 @@ func (p *AddRequestProposal) Validate() error {
}

// NewUpdateRequestProposal creates a new UpdateRequestProposal object.
// nolint:interfacer
func NewUpdateRequestProposal(
id uint64,
name string,
Expand Down Expand Up @@ -199,6 +201,7 @@ func (p *UpdateRequestProposal) Validate() error {
}

// NewDeleteRequestProposal creates a new DeleteRequestProposal object.
// nolint:interfacer
func NewDeleteRequestProposal(id uint64) *DeleteRequestProposal {
return &DeleteRequestProposal{
PlanId: id,
Expand Down

0 comments on commit cb3635c

Please sign in to comment.