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

Refactor testutil/keeper.FungibleKeeper to use mocks for dependent modules #901

Closed
lumtis opened this issue Aug 2, 2023 · 0 comments · Fixed by #909
Closed

Refactor testutil/keeper.FungibleKeeper to use mocks for dependent modules #901

lumtis opened this issue Aug 2, 2023 · 0 comments · Fixed by #909
Assignees

Comments

@lumtis
Copy link
Member

lumtis commented Aug 2, 2023

Part of #878

Fungible test keeper currently use empty instances for dependences

bankkeeper := bankkeeper2.BaseKeeper{}
authkeeper := authkeeper2.AccountKeeper{}
evmKeeper := evmkeeper.Keeper{}

which makes it not usable for most unit tests. The ideal model for unit tests would be to use mocking for the dependent modules.

Example using Mockery https://github.com/vektra/mockery

  • Use the mockery commands to generate the module mocks under mocks
testutil/
  keeper/
    fungiblemocks/
      bank.go
      auth.go
      evm.go

Returns the mocks along with the test keeper in FungibleKeeper

func FungibleKeeper(t testing.TB) (
  *keeper.Keeper,
  fungiblemocks.BankKeeperMock,
  fungiblemocks.AccountKeeperMock,
  fungiblemocks.EVMKeeperMock,
  sdk.Context,
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant