Skip to content

Commit

Permalink
serialize compactRange() start and end
Browse files Browse the repository at this point in the history
  • Loading branch information
vweevers committed Oct 20, 2018
1 parent 758a257 commit 0e3cda4
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
3 changes: 3 additions & 0 deletions leveldown.js
Expand Up @@ -76,6 +76,9 @@ LevelDOWN.prototype.approximateSize = function (start, end, callback) {
}

LevelDOWN.prototype.compactRange = function (start, end, callback) {
start = this._serializeKey(start)
end = this._serializeKey(end)

this.binding.compactRange(start, end, callback)
}

Expand Down
16 changes: 16 additions & 0 deletions test/compact-range-test.js
Expand Up @@ -43,6 +43,22 @@ test('test compactRange() frees disk space after key deletion', function (t) {
})
})

test('test compactRange() serializes start and end', function (t) {
t.plan(3)

var clone = Object.create(db)
var count = 0

clone._serializeKey = function (key) {
t.is(key, count++)
return db._serializeKey(key)
}

clone.compactRange(0, 1, function (err) {
t.ifError(err, 'no compactRange error')
})
})

test('tearDown', function (t) {
db.close(testCommon.tearDown.bind(null, t))
})

0 comments on commit 0e3cda4

Please sign in to comment.