Require threshold and weights in signers settings (#909)

Fixes #908
This commit is contained in:
Brandon Wilson
2018-07-02 18:27:03 -05:00
committed by Elliot Lee
parent 2112d4c0b3
commit 4e30b9b2fa
5 changed files with 46 additions and 3 deletions

View File

@@ -93,7 +93,9 @@
"minItems": 1, "minItems": 1,
"maxItems": 8 "maxItems": 8
} }
} },
"required": ["threshold", "weights"],
"additionalProperties": false
}, },
"transferRate": { "transferRate": {
"description": " The fee to charge when users transfer this accounts issuances, as the decimal amount that must be sent to deliver 1 unit. Has precision up to 9 digits beyond the decimal point. Use `null` to set no fee.", "description": " The fee to charge when users transfer this accounts issuances, as the decimal amount that must be sent to deliver 1 unit. Has precision up to 9 digits beyond the decimal point. Use `null` to set no fee.",

View File

@@ -561,12 +561,26 @@ describe('RippleAPI', function () {
}); });
it('prepareSettings - set signers', function () { it('prepareSettings - set signers', function () {
const settings = requests.prepareSettings.signers; const settings = requests.prepareSettings.signers.normal;
return this.api.prepareSettings(address, settings, instructions).then( return this.api.prepareSettings(address, settings, instructions).then(
_.partial(checkResult, responses.prepareSettings.signers, _.partial(checkResult, responses.prepareSettings.signers,
'prepare')); 'prepare'));
}); });
it('prepareSettings - signers no threshold', function () {
const settings = requests.prepareSettings.signers.noThreshold;
assert.throws(() => {
this.api.prepareSettings(address, settings, instructions);
}, this.api.errors.ValidationError);
});
it('prepareSettings - signers no weights', function () {
const settings = requests.prepareSettings.signers.noWeights;
assert.throws(() => {
this.api.prepareSettings(address, settings, instructions);
}, this.api.errors.ValidationError);
});
it('prepareSettings - fee for multisign', function () { it('prepareSettings - fee for multisign', function () {
const localInstructions = _.defaults({ const localInstructions = _.defaults({
signersCount: 4 signersCount: 4

View File

@@ -22,7 +22,11 @@ module.exports = {
}, },
prepareSettings: { prepareSettings: {
domain: require('./prepare-settings'), domain: require('./prepare-settings'),
signers: require('./prepare-settings-signers') signers: {
normal: require('./prepare-settings-signers'),
noThreshold: require('./prepare-settings-signers-no-threshold'),
noWeights: require('./prepare-settings-signers-no-weights')
}
}, },
prepareEscrowCreation: { prepareEscrowCreation: {
normal: require('./prepare-escrow-creation'), normal: require('./prepare-escrow-creation'),

View File

@@ -0,0 +1,18 @@
{
"signers": {
"weights": [
{
"address": "r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59",
"weight": 1
},
{
"address": "rpZc4mVfWUif9CRoHRKKcmhu1nx2xktxBo",
"weight": 1
},
{
"address": "rwBYyfufTzk77zUSKEu4MvixfarC35av1J",
"weight": 1
}
]
}
}

View File

@@ -0,0 +1,5 @@
{
"signers": {
"threshold": 2
}
}