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

Conversation

lumtis
Copy link
Member

@lumtis lumtis commented Aug 4, 2023

Description

Replace empty keeper instances with mocks in fungible keepers for isolated unit testing.

The mocking system uses mockery utility: https://vektra.github.io/mockery/latest/

The mocks are generated by running the generation commands in testutil/keeper/mocks.go:

//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
}

The generated structures are located in ..../mocks/[modulename]/[mockedmodule].go

The generated structures can be initialized with the New... methods

Dependent on #900

Closes: #901

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

How Has This Been Tested?

Please describe the tests that you ran to verify your changes. Include instructions and any relevant details so others can reproduce.

  • Tested CCTX in localnet
  • Tested in development environment
  • Go unit tests
  • Go integration tests
  • Tested via GitHub Actions

Checklist:

  • I have added unit tests that prove my fix feature works

@lumtis lumtis self-assigned this Aug 4, 2023
@lumtis lumtis changed the title WIP - test(testutil): add keeper reference mocks in fungible test keeper test(testutil): add keeper reference mocks in fungible test keeper Aug 8, 2023
@lumtis lumtis marked this pull request as ready for review August 8, 2023 09:52
@lumtis lumtis merged commit b0d8cc8 into develop Aug 11, 2023
15 checks passed
@lumtis lumtis deleted the fungible-test-mock branch August 11, 2023 06:14
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 this pull request may close these issues.

Refactor testutil/keeper.FungibleKeeper to use mocks for dependent modules
3 participants