-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
Mock Refactor #4851
Mock Refactor #4851
Conversation
// ModuleAccount defines an account for modules that holds coins on a pool | ||
type ModuleAccount struct { | ||
*MockBaseAccount | ||
name string `json:"name" yaml:"name"` // name of the module |
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.
structtag: struct field name has json tag but is not exported (from govet
)
type ModuleAccount struct { | ||
*MockBaseAccount | ||
name string `json:"name" yaml:"name"` // name of the module | ||
permissions []string `json:"permissions" yaml"permissions"` // permissions of module account |
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.
structtag: struct field tag json:"permissions" yaml"permissions"
not compatible with reflect.StructTag.Get: bad syntax for struct tag pair (from govet
)
) | ||
|
||
type Subspace struct { | ||
cdc *codec.Codec |
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.
U1000: field cdc
is unused (from unused
)
|
||
type Subspace struct { | ||
cdc *codec.Codec | ||
key sdk.StoreKey // []byte -> []byte, stores parameter |
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.
U1000: field key
is unused (from unused
)
type Subspace struct { | ||
cdc *codec.Codec | ||
key sdk.StoreKey // []byte -> []byte, stores parameter | ||
tkey sdk.StoreKey // []byte -> bool, stores parameter change |
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.
U1000: field tkey
is unused (from unused
)
key sdk.StoreKey // []byte -> []byte, stores parameter | ||
tkey sdk.StoreKey // []byte -> bool, stores parameter change | ||
|
||
name []byte |
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.
U1000: field name
is unused (from unused
)
|
||
name []byte | ||
|
||
table KeyTable |
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.
U1000: field table
is unused (from unused
)
table KeyTable | ||
} | ||
|
||
type attribute struct { |
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.
U1000: type attribute
is unused (from unused
)
} | ||
|
||
type KeyTable struct { | ||
m map[string]attribute |
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.
U1000: field m
is unused (from unused
)
closing see #4875 |
fixes #1555
The aim here is to have mock module return an application with fields for each exported keeper interface, which can be swapped/set by the receiving module for integration testing. The account, param, and supply keeper will be mock'd in
mock
to provide the base functionality for initializing this application, but should be swapped for fully implemented versions by the receiving application if they are going to be used more extensively.There is no need to fully mock all the modules since the receiving module will only be using the modules it will already be importing. For example, assume the receiving module uses account, supply, bank, and staking keeper. It will already be importing auth, bank, supply, and staking and so it can simply initialize those keepers and set them in the returned mock app which will have fields for each keeper. A swap function will be added so developers can swap the partially mock'd account/supply/param keepers for their directly imported ones.
The mock module will follow the module spec structure for consistency and readability.
Types/Keepers that are mock'd will have a
Mock
prefix so developers can easily tell when testing if the type being used comes from the mock module.This module will not import any
x/
packages except forexported
Targeted PR against correct branch (see CONTRIBUTING.md)
Linked to github-issue with discussion and accepted design OR link to spec that describes this work.
Wrote tests
Updated relevant documentation (
docs/
)Added a relevant changelog entry:
clog add [section] [-t <tag>] [-m <msg>]
Re-reviewed
Files changed
in the github PR explorerFor Admin Use: