Skip to content
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

Merged
merged 5 commits into from
Sep 14, 2018
Merged

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.

@@ -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
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
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