Skip to content

Commit

Permalink
unitests wip
Browse files Browse the repository at this point in the history
  • Loading branch information
omerlavanet committed Nov 28, 2024
1 parent c2fc7bc commit 212c6c4
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 1 deletion.
2 changes: 1 addition & 1 deletion testutil/keeper/dualstaking.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ func DualstakingKeeper(t testing.TB) (*keeper.Keeper, sdk.Context) {
memStoreKey,
paramsSubspace,
&mockBankKeeper{},
nil,
&mockStakingKeeperEmpty{},
&mockAccountKeeper{},
epochstorageKeeper,
speckeeper.NewKeeper(cdc, nil, nil, paramsSubspaceSpec, nil),
Expand Down
53 changes: 53 additions & 0 deletions testutil/keeper/mock_keepers.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@ import (
"fmt"
"time"

"cosmossdk.io/math"
tenderminttypes "github.com/cometbft/cometbft/types"
sdk "github.com/cosmos/cosmos-sdk/types"
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"
)

// account keeper mock
Expand Down Expand Up @@ -36,6 +38,57 @@ func (k mockAccountKeeper) SetModuleAccount(sdk.Context, authtypes.ModuleAccount
// mock bank keeper
var balance map[string]sdk.Coins = make(map[string]sdk.Coins)

type mockStakingKeeperEmpty struct{}

func (k mockStakingKeeperEmpty) ValidatorByConsAddr(sdk.Context, sdk.ConsAddress) stakingtypes.ValidatorI {
return nil
}

Check failure on line 45 in testutil/keeper/mock_keepers.go

View workflow job for this annotation

GitHub Actions / lint

File is not `gofumpt`-ed (gofumpt)
func (k mockStakingKeeperEmpty) UnbondingTime(ctx sdk.Context) time.Duration {
return time.Duration(0)
}

Check failure on line 48 in testutil/keeper/mock_keepers.go

View workflow job for this annotation

GitHub Actions / lint

File is not `gofumpt`-ed (gofumpt)
func (k mockStakingKeeperEmpty) GetAllDelegatorDelegations(ctx sdk.Context, delegator sdk.AccAddress) []stakingtypes.Delegation {
return nil
}

Check failure on line 51 in testutil/keeper/mock_keepers.go

View workflow job for this annotation

GitHub Actions / lint

File is not `gofumpt`-ed (gofumpt)
func (k mockStakingKeeperEmpty) GetDelegatorValidator(ctx sdk.Context, delegatorAddr sdk.AccAddress, validatorAddr sdk.ValAddress) (validator stakingtypes.Validator, err error) {
return stakingtypes.Validator{}, nil
}

func (k mockStakingKeeperEmpty) GetDelegation(ctx sdk.Context, delAddr sdk.AccAddress, valAddr sdk.ValAddress) (delegation stakingtypes.Delegation, found bool) {
return stakingtypes.Delegation{}, false
}

func (k mockStakingKeeperEmpty) GetValidator(ctx sdk.Context, addr sdk.ValAddress) (validator stakingtypes.Validator, found bool) {
return stakingtypes.Validator{}, false
}

func (k mockStakingKeeperEmpty) GetValidatorDelegations(ctx sdk.Context, valAddr sdk.ValAddress) (delegations []stakingtypes.Delegation) {
return []stakingtypes.Delegation{}
}

func (k mockStakingKeeperEmpty) BondDenom(ctx sdk.Context) string {
return "ulava"
}

func (k mockStakingKeeperEmpty) ValidateUnbondAmount(ctx sdk.Context, delAddr sdk.AccAddress, valAddr sdk.ValAddress, amt math.Int) (shares sdk.Dec, err error) {
return sdk.Dec{}, nil
}

func (k mockStakingKeeperEmpty) Undelegate(ctx sdk.Context, delAddr sdk.AccAddress, valAddr sdk.ValAddress, sharesAmount sdk.Dec) (time.Time, error) {
return time.Time{}, nil
}

func (k mockStakingKeeperEmpty) Delegate(ctx sdk.Context, delAddr sdk.AccAddress, bondAmt math.Int, tokenSrc stakingtypes.BondStatus, validator stakingtypes.Validator, subtractAccount bool) (newShares sdk.Dec, err error) {
return sdk.Dec{}, nil
}

func (k mockStakingKeeperEmpty) GetBondedValidatorsByPower(ctx sdk.Context) []stakingtypes.Validator {
return []stakingtypes.Validator{}
}

func (k mockStakingKeeperEmpty) GetAllValidators(ctx sdk.Context) (validators []stakingtypes.Validator) {
return []stakingtypes.Validator{}
}

type mockBankKeeper struct{}

func init_balance() {
Expand Down

0 comments on commit 212c6c4

Please sign in to comment.