Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test(testutil): add keeper reference mocks in fungible test keeper #909

Merged
merged 14 commits into from
Aug 11, 2023
26 changes: 13 additions & 13 deletions testutil/keeper/fungible.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,15 @@ import (
"github.com/cosmos/cosmos-sdk/store"
storetypes "github.com/cosmos/cosmos-sdk/store/types"
sdk "github.com/cosmos/cosmos-sdk/types"
authkeeper2 "github.com/cosmos/cosmos-sdk/x/auth/keeper"
bankkeeper2 "github.com/cosmos/cosmos-sdk/x/bank/keeper"
typesparams "github.com/cosmos/cosmos-sdk/x/params/types"
evmkeeper "github.com/evmos/ethermint/x/evm/keeper"
"github.com/stretchr/testify/require"
"github.com/tendermint/tendermint/libs/log"
tmproto "github.com/tendermint/tendermint/proto/tendermint/types"
tmdb "github.com/tendermint/tm-db"

fungiblemocks "github.com/zeta-chain/zetacore/testutil/keeper/mocks/fungible"
"github.com/zeta-chain/zetacore/x/fungible/keeper"
"github.com/zeta-chain/zetacore/x/fungible/types"
zetaObserverModuleKeeper "github.com/zeta-chain/zetacore/x/observer/keeper"
)

func FungibleKeeper(t testing.TB) (*keeper.Keeper, sdk.Context) {
Expand All @@ -41,21 +39,23 @@ func FungibleKeeper(t testing.TB) (*keeper.Keeper, sdk.Context) {
"FungibleParams",
)

bankkeeper := bankkeeper2.BaseKeeper{}
authkeeper := authkeeper2.AccountKeeper{}
evmKeeper := &evmkeeper.Keeper{}
zetaObserverKeeper := zetaObserverModuleKeeper.Keeper{}
keeper := keeper.NewKeeper(
// Initialize mocks from expected keeper interfaces
bankKeeper := fungiblemocks.NewFungibleBankKeeper(t)
authKeeper := fungiblemocks.NewFungibleAccountKeeper(t)
observerKeeper := fungiblemocks.NewFungibleObserverKeeper(t)
evmKeeper := fungiblemocks.NewFungibleEVMKeeper(t)

k := keeper.NewKeeper(
codec.NewProtoCodec(registry),
storeKey,
memStoreKey,
paramsSubspace,
authkeeper,
authKeeper,
evmKeeper,
bankkeeper,
zetaObserverKeeper,
bankKeeper,
observerKeeper,
)

ctx := sdk.NewContext(stateStore, tmproto.Header{}, false, log.NewNopLogger())
return keeper, ctx
return k, ctx
}
25 changes: 25 additions & 0 deletions testutil/keeper/mocks.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package keeper

import (
fungibletypes "github.com/zeta-chain/zetacore/x/fungible/types"
)

//go:generate mockery --name FungibleAccountKeeper --filename account.go --case underscore --output ./mocks/fungible
type FungibleAccountKeeper interface {
fungibletypes.AccountKeeper
}

//go:generate mockery --name FungibleBankKeeper --filename fungible.go --case underscore --output ./mocks/fungible
type FungibleBankKeeper interface {
fungibletypes.BankKeeper
}

//go:generate mockery --name FungibleObserverKeeper --filename observer.go --case underscore --output ./mocks/fungible
type FungibleObserverKeeper interface {
fungibletypes.ObserverKeeper
}

//go:generate mockery --name FungibleEVMKeeper --filename evm.go --case underscore --output ./mocks/fungible
type FungibleEVMKeeper interface {
fungibletypes.EVMKeeper
}
86 changes: 86 additions & 0 deletions testutil/keeper/mocks/fungible/account.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

150 changes: 150 additions & 0 deletions testutil/keeper/mocks/fungible/evm.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading