Skip to content

IRISHUB-317,318: realize the depositProcedureParameter and its UnitTest#210

Merged
wukongcheng merged 5 commits intoirisnet:feature/govfrom
MrXJC:jiacheng/gov
Sep 14, 2018
Merged

IRISHUB-317,318: realize the depositProcedureParameter and its UnitTest#210
wukongcheng merged 5 commits intoirisnet:feature/govfrom
MrXJC:jiacheng/gov

Conversation

@MrXJC
Copy link
Contributor

@MrXJC MrXJC commented Sep 13, 2018

No description provided.

Copy link
Contributor

@wukongcheng wukongcheng left a 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

}

func (param *DepositProcedureParam) InitGenesis(genesisState interface{}) {
if value, ok := genesisState.(DepositProcedure); ok {
Copy link
Contributor

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?

Copy link
Contributor Author

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.

type DepositProcedureParam struct {
Value DepositProcedure
ps params.Setter
pg params.Getter
Copy link
Contributor

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

}

func (param *DepositProcedureParam) Update(ctx sdk.Context, jsonStr string) {
if err := json.Unmarshal([]byte(jsonStr), &param.Value); err == nil {
Copy link
Contributor

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?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function Valid have done !

if err = json.Unmarshal([]byte(jsonStr), &param.Value); err == nil {

if param.Value.MinDeposit[0].Denom != "iris" {
return sdk.NewError(DefaultCodespace, 102, fmt.Sprintf("It should be iris "))
Copy link
Contributor

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

Copy link
Contributor Author

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.

{"Test Proposal", "the purpose of this proposal is to test", ProposalTypeText, addrs[0], coinsMulti, true},
}

var params Params
Copy link
Contributor

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

Copy link
Contributor Author

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.

@wukongcheng wukongcheng merged commit f462548 into irisnet:feature/gov Sep 14, 2018
wangjiulian pushed a commit that referenced this pull request Nov 7, 2024
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.

2 participants