mirror of
https://github.com/ether/etherpad-lite.git
synced 2025-02-08 11:12:01 +01:00
Add assertions for the results of CHANGESET_REQ
fails nearly all the time :/ The assertions are most likely not broken, so I think the code is. Conflicts: src/node/handler/PadMessageHandler.js
This commit is contained in:
parent
1e0456c7ed
commit
c03c6beb73
1 changed files with 43 additions and 0 deletions
|
@ -1257,6 +1257,49 @@ function handleChangesetRequest(client, message)
|
||||||
{
|
{
|
||||||
if(err) return console.error('Error while handling a changeset request for '+padIds.padId, err, message.data);
|
if(err) return console.error('Error while handling a changeset request for '+padIds.padId, err, message.data);
|
||||||
|
|
||||||
|
// Assert that the paths are correct
|
||||||
|
var assert = require('assert')
|
||||||
|
padManager.getPad(message.padId, function(err, pad) {
|
||||||
|
if(err) return
|
||||||
|
var headRev = pad.getHeadRevisionNumber()
|
||||||
|
, fend = start-(granularity*changesetInfo.forwardsChangesets.length)
|
||||||
|
, bend = start+(granularity*changesetInfo.backwardsChangesets.length)
|
||||||
|
|
||||||
|
if(start > headRev || fend > headRev || bend > headRev) return console.log('Cannot vet from ', start, 'to', end)
|
||||||
|
|
||||||
|
pad.getInternalRevisionAText(start, function(err, atextStart) {
|
||||||
|
ERR(err)
|
||||||
|
pad.getInternalRevisionAText(fend, function(err, atextFend) {
|
||||||
|
ERR(err)
|
||||||
|
pad.getInternalRevisionAText(bend, function(err, atextBend) {
|
||||||
|
ERR(err)
|
||||||
|
console.log(changesetInfo)
|
||||||
|
|
||||||
|
// check forward
|
||||||
|
console.log('Vetting revision path from ', fend, 'to', start)
|
||||||
|
var atext = atextFend
|
||||||
|
changesetInfo.forwardsChangesets.forEach(function(cs) {
|
||||||
|
atext = Changeset.applyToAText(cs, atext)
|
||||||
|
})
|
||||||
|
assert(atext.text == atextStart.text)
|
||||||
|
assert(atext.attribs == atextStart.attribs)
|
||||||
|
console.log('OK')
|
||||||
|
|
||||||
|
// check backward /*/
|
||||||
|
console.log('Vetting revision path from ', bend, 'to', start)
|
||||||
|
atext = atextBend
|
||||||
|
changesetInfo.backwardsChangesets.forEach(function(cs) {
|
||||||
|
atext = Changeset.applyToAText(cs, atext)
|
||||||
|
})
|
||||||
|
assert(atext.text == atextStart.text)
|
||||||
|
assert(atext.attribs == atextStart.attribs)
|
||||||
|
console.log('OK')
|
||||||
|
|
||||||
|
})
|
||||||
|
})
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
var data = changesetInfo;
|
var data = changesetInfo;
|
||||||
data.requestID = message.data.requestID;
|
data.requestID = message.data.requestID;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue