mirror of
https://github.com/overleaf/overleaf.git
synced 2025-02-02 17:11:29 +00:00
Merge branch 'bg-verify-writes-II'
This commit is contained in:
commit
8d1b11f37a
2 changed files with 11 additions and 8 deletions
|
@ -185,5 +185,8 @@ module.exports = RedisManager =
|
||||||
return JSON.parse(ranges)
|
return JSON.parse(ranges)
|
||||||
|
|
||||||
_computeHash: (docLines) ->
|
_computeHash: (docLines) ->
|
||||||
# use sha1 checksum of doclines to detect data corruption
|
# use sha1 checksum of doclines to detect data corruption.
|
||||||
return crypto.createHash('sha1').update(docLines).digest('hex')
|
#
|
||||||
|
# note: must specify 'utf8' encoding explicitly, as the default is
|
||||||
|
# binary in node < v5
|
||||||
|
return crypto.createHash('sha1').update(docLines, 'utf8').digest('hex')
|
||||||
|
|
|
@ -37,10 +37,10 @@ describe "RedisManager", ->
|
||||||
|
|
||||||
describe "getDoc", ->
|
describe "getDoc", ->
|
||||||
beforeEach ->
|
beforeEach ->
|
||||||
@lines = ["one", "two", "three"]
|
@lines = ["one", "two", "three", "これは"] # include some utf8
|
||||||
@jsonlines = JSON.stringify @lines
|
@jsonlines = JSON.stringify @lines
|
||||||
@version = 42
|
@version = 42
|
||||||
@hash = crypto.createHash('sha1').update(@jsonlines).digest('hex')
|
@hash = crypto.createHash('sha1').update(@jsonlines,'utf8').digest('hex')
|
||||||
@ranges = { comments: "mock", entries: "mock" }
|
@ranges = { comments: "mock", entries: "mock" }
|
||||||
@json_ranges = JSON.stringify @ranges
|
@json_ranges = JSON.stringify @ranges
|
||||||
@rclient.get = sinon.stub()
|
@rclient.get = sinon.stub()
|
||||||
|
@ -200,10 +200,10 @@ describe "RedisManager", ->
|
||||||
@rclient.eval = sinon.stub()
|
@rclient.eval = sinon.stub()
|
||||||
@RedisManager.getDocVersion = sinon.stub()
|
@RedisManager.getDocVersion = sinon.stub()
|
||||||
|
|
||||||
@lines = ["one", "two", "three"]
|
@lines = ["one", "two", "three", "これは"]
|
||||||
@ops = [{ op: [{ i: "foo", p: 4 }] },{ op: [{ i: "bar", p: 8 }] }]
|
@ops = [{ op: [{ i: "foo", p: 4 }] },{ op: [{ i: "bar", p: 8 }] }]
|
||||||
@version = 42
|
@version = 42
|
||||||
@hash = crypto.createHash('sha1').update(JSON.stringify(@lines)).digest('hex')
|
@hash = crypto.createHash('sha1').update(JSON.stringify(@lines),'utf8').digest('hex')
|
||||||
@ranges = { comments: "mock", entries: "mock" }
|
@ranges = { comments: "mock", entries: "mock" }
|
||||||
|
|
||||||
@rclient.exec = sinon.stub().callsArg(0, null, [@hash])
|
@rclient.exec = sinon.stub().callsArg(0, null, [@hash])
|
||||||
|
@ -323,9 +323,9 @@ describe "RedisManager", ->
|
||||||
@rclient.sadd = sinon.stub().yields()
|
@rclient.sadd = sinon.stub().yields()
|
||||||
@rclient.del = sinon.stub()
|
@rclient.del = sinon.stub()
|
||||||
@rclient.eval = sinon.stub()
|
@rclient.eval = sinon.stub()
|
||||||
@lines = ["one", "two", "three"]
|
@lines = ["one", "two", "three", "これは"]
|
||||||
@version = 42
|
@version = 42
|
||||||
@hash = crypto.createHash('sha1').update(JSON.stringify(@lines)).digest('hex')
|
@hash = crypto.createHash('sha1').update(JSON.stringify(@lines),'utf8').digest('hex')
|
||||||
@rclient.exec = sinon.stub().callsArgWith(0, null, [@hash])
|
@rclient.exec = sinon.stub().callsArgWith(0, null, [@hash])
|
||||||
@ranges = { comments: "mock", entries: "mock" }
|
@ranges = { comments: "mock", entries: "mock" }
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue