diff --git a/lib/constants.js b/lib/constants.js index eee04330..59c219a9 100644 --- a/lib/constants.js +++ b/lib/constants.js @@ -54,6 +54,7 @@ module.exports = { OTHER: 'adjustment' }, MIN_SHARD_SIZE: 15360, + MAX_SHARD_SIZE: 4294967296, MAX_REPUTATION_POINTS: 5000, MIN_REPUTATION_POINTS: 0, POINTS: { diff --git a/lib/models/frame.js b/lib/models/frame.js index 50a028c2..0c6c1e1d 100644 --- a/lib/models/frame.js +++ b/lib/models/frame.js @@ -89,6 +89,11 @@ Frame.statics.validShardSizes = function(shards) { return false; } } + for (let i = 0; i < shards.length; i++) { + if (shards[i].size > constants.MAX_SHARD_SIZE) { + return false; + } + } } return true; }; diff --git a/test/frame.unit.js b/test/frame.unit.js index 0933fc0c..0eb92be1 100644 --- a/test/frame.unit.js +++ b/test/frame.unit.js @@ -395,6 +395,34 @@ describe('Storage/models/Frame', function() { expect(Frame.validShardSizes(shards)).to.equal(false); }); + it('it should reject max shard sizes', function() { + const shards = [ + { + index: 0, + size: 4294967297 + }, + { + index: 1, + size: 4294967297 + }, + { + index: 2, + size: 30000 + }, + { + index: 3, + size: 4294967297, + parity: true + }, + { + index: 4, + size: 4294967297, + parity: true + } + ]; + expect(Frame.validShardSizes(shards)).to.equal(false); + }); + }); describe('#addShard', function() {