IRISHUB-317,318: realize the depositProcedureParameter and its UnitTest#210
IRISHUB-317,318: realize the depositProcedureParameter and its UnitTest#210wukongcheng merged 5 commits intoirisnet:feature/govfrom MrXJC:jiacheng/gov
Conversation
wukongcheng
left a comment
There was a problem hiding this comment.
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.
What happens if the genesisState is nil?
There was a problem hiding this comment.
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.
psetter & pgetter will be more readable
| } | ||
|
|
||
| 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.
Should return error if Unmarshal failed?
There was a problem hiding this comment.
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.
Should use the enum instead of the magic number 102
There was a problem hiding this comment.
It maybe need more design.
| {"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.
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.
Ok, I will do it tomorrow.
No description provided.