-
Notifications
You must be signed in to change notification settings - Fork 3.8k
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(gov): Refactor x/gov keeper tests to use mocks #12988
Conversation
Codecov Report
@@ Coverage Diff @@
## main #12988 +/- ##
==========================================
- Coverage 55.87% 55.58% -0.30%
==========================================
Files 646 644 -2
Lines 54895 54935 +40
==========================================
- Hits 30675 30535 -140
- Misses 21762 21932 +170
- Partials 2458 2468 +10
|
// KeeperTestSuite only tests gov's keeper logic around tallying, since it | ||
// relies on complex interactions with x/staking. | ||
// | ||
// It also uses simapp (and not a depinjected app) because we manually set a | ||
// new app.StakingKeeper in `createValidators`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Only tallying tests have been moved here. I don't think it's easy to mock them.
// BondDenomProvider is a subset of the staking keeper's public interface that | ||
// provides the staking bond denom. It is used in arguments in this package's | ||
// functions so that a mock staking keeper can be passed instead of the real one. | ||
type BondDenomProvider interface { | ||
BondDenom(ctx sdk.Context) string | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any objections to this? Or better ideas?
) | ||
|
||
func (suite *KeeperTestSuite) TestSubmitProposalReq() { | ||
govAcct := suite.app.GovKeeper.GetGovernanceAccount(suite.ctx).GetAddress() | ||
suite.reset() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added this line in some tests. If I don't, I have an off-by-1 error in proposal ID, only when running the whole suite. Like some other test got run before and created a proposal or something
Resetting makes each test more independent.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm!
Description
ref: #12752
tests/integration/gov/keeper
, see test(gov): Refactor x/gov keeper tests to use mocks #12988 (comment)x/gov/keeper
tests, use mocks insteadsimapp
references from module tests and simulations #13043)Author Checklist
All items are required. Please add a note to the item if the item is not applicable and
please add links to any relevant follow up issues.
I have...
!
to the type prefix if API or client breaking changeCHANGELOG.md
Reviewers Checklist
All items are required. Please add a note if the item is not applicable and please add
your handle next to the items reviewed if you only reviewed selected items.
I have...
!
in the type prefix if API or client breaking change