-
Notifications
You must be signed in to change notification settings - Fork 128
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
IRISHUB-317,318: realize the depositProcedureParameter and its UnitTest #210
Conversation
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.
InitGenesis() need the input param
modules/gov/gov_params.go
Outdated
} | ||
|
||
func (param *DepositProcedureParam) InitGenesis(genesisState interface{}) { | ||
if value, ok := genesisState.(DepositProcedure); ok { |
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.
What happens if the genesisState is nil?
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.
You can see the UnitTest. The value of ok
is false
.
modules/gov/gov_params.go
Outdated
type DepositProcedureParam struct { | ||
Value DepositProcedure | ||
ps params.Setter | ||
pg params.Getter |
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.
psetter & pgetter will be more readable
modules/gov/gov_params.go
Outdated
} | ||
|
||
func (param *DepositProcedureParam) Update(ctx sdk.Context, jsonStr string) { | ||
if err := json.Unmarshal([]byte(jsonStr), ¶m.Value); err == nil { |
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.
Should return error if Unmarshal failed?
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.
Function Valid
have done !
modules/gov/gov_params.go
Outdated
if err = json.Unmarshal([]byte(jsonStr), ¶m.Value); err == nil { | ||
|
||
if param.Value.MinDeposit[0].Denom != "iris" { | ||
return sdk.NewError(DefaultCodespace, 102, fmt.Sprintf("It should be iris ")) |
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.
Should use the enum instead of the magic number 102
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.
It maybe need more design.
@@ -39,8 +39,10 @@ func TestMsgSubmitProposal(t *testing.T) { | |||
{"Test Proposal", "the purpose of this proposal is to test", ProposalTypeText, addrs[0], coinsMulti, true}, | |||
} | |||
|
|||
var params Params |
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.
We should create a new folder "params" under the "gov", and put all these source files in it
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.
Ok, I will do it tomorrow.
No description provided.