Skip to content

Commit

Permalink
Fixed MsgEditValidator
Browse files Browse the repository at this point in the history
  • Loading branch information
cdc-Hitesh committed Jun 11, 2021
1 parent 34fdbf0 commit b96ed43
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
12 changes: 8 additions & 4 deletions lib/src/transaction/msg/staking/MsgEditValidator.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -182,19 +182,23 @@ describe('Testing MsgEditValidator', function () {
);
});

it('should throw Error when the `commission_rate` field is missing', function () {
it('should NOT throw Error when the `commission_rate` field is missing', function () {
const json =
'{"@type":"/cosmos.staking.v1beta1.MsgEditValidator","description":{"moniker":"hiteshTest","identity":"","website":"","security_contact":"[email protected]","details":""},"validator_address":"tcrocncl1j7pej8kplem4wt50p4hfvndhuw5jprxxxtenvr","min_self_delegation":"1"}';
expect(() => cro.staking.MsgEditValidator.fromCosmosMsgJSON(json, CroNetwork.Testnet)).to.throw(
expect(() => cro.staking.MsgEditValidator.fromCosmosMsgJSON(json, CroNetwork.Testnet)).to.not.throw(
'Expected `commissionRate` to be of type `null` but received type `undefined` in object `options`',
);
const msgEdit = cro.staking.MsgEditValidator.fromCosmosMsgJSON(json, CroNetwork.Testnet);
expect(msgEdit.commissionRate).to.be.null;
});
it('should throw Error when the `min_self_delegation` field is missing', function () {
it('should NOT throw Error when the `min_self_delegation` field is missing', function () {
const json =
'{"@type":"/cosmos.staking.v1beta1.MsgEditValidator","description":{"moniker":"hiteshTest","identity":"","website":"","security_contact":"[email protected]","details":""},"validator_address":"tcrocncl1j7pej8kplem4wt50p4hfvndhuw5jprxxxtenvr","commission_rate":"0.100000000000000000"}';
expect(() => cro.staking.MsgEditValidator.fromCosmosMsgJSON(json, CroNetwork.Testnet)).to.throw(
expect(() => cro.staking.MsgEditValidator.fromCosmosMsgJSON(json, CroNetwork.Testnet)).to.not.throw(
'Expected `minSelfDelegation` to be of type `null` but received type `undefined` in object `options`',
);
const msgEdit = cro.staking.MsgEditValidator.fromCosmosMsgJSON(json, CroNetwork.Testnet);
expect(msgEdit.minSelfDelegation).to.be.null;
});

it('should return the MsgEditValidator corresponding to the JSON', function () {
Expand Down
4 changes: 2 additions & 2 deletions lib/src/transaction/msg/staking/MsgEditValidator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,8 @@ export const msgEditValidator = function (config: InitConfigurations) {
details: parsedMsg.description.details,
},
validatorAddress: parsedMsg.validator_address,
commissionRate: parsedMsg.commission_rate,
minSelfDelegation: parsedMsg.min_self_delegation,
commissionRate: parsedMsg.commission_rate || null,
minSelfDelegation: parsedMsg.min_self_delegation || null,
});
}

Expand Down

0 comments on commit b96ed43

Please sign in to comment.