Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

fix tests: mostly bugs from not understanding what I was doing when I…

… first wrote this...
  • Loading branch information...
commit 2f105efa16a6fa60af7f730714296702a8d2cb47 1 parent 3f7a679
@dominictarr authored
View
5 test/eventually-consistent.js
@@ -10,15 +10,14 @@ var doc = new crdt.Doc()
var hoc = new crdt.Doc()
doc.sync = hoc.sync = true
-var ds = crdt.createStream(doc)
-var hs = crdt.createStream(hoc)
-
var piped = false
var consistent = false
setTimeout(function () {
piped = true
console.log('pipe')
+ var ds = crdt.createStream(doc)
+ var hs = crdt.createStream(hoc)
ds.pipe(hs).pipe(ds)
}, Math.random()*10)
View
14 test/persist.js
@@ -7,10 +7,6 @@ var randomUpdates = help.randomUpdates
var clone = help.clone
var validateUpdates = help.validateUpdates
-/*function test (name, test) {
- exports[name] = test
-}*/
-
var next = process.nextTick
function test(n,t) {
@@ -22,8 +18,9 @@ test('simple', function (t) {
var a = new crdt.Doc()
randomUpdates(a)
-console.log('simple')
- a.createReadStream({wrapper: 'raw'})
+ console.log('simple')
+
+ a.createReadStream({wrapper: 'raw', tail: false})
.pipe(es.writeArray(function (err, array) {
console.log('array', array)
array.forEach(function(v, i) {
@@ -55,14 +52,13 @@ console.log('simple')
}))
})
-
test('JSON', function (t) {
var a = new crdt.Doc()
randomUpdates(a)
-console.log('simple')
- a.createReadStream({wrapper: 'json'})
+
+ a.createReadStream({wrapper: 'json', tail: false})
.pipe(es.writeArray(function (err, array) {
console.log('array', array)
array.forEach(function(v, i) {
View
10 test/simple.js
@@ -68,8 +68,10 @@ exports.listen = function (t) {
a.equal(thing.get('random'), random)
t.end()
})
-
- hoc.createStream({wrapper: 'json'}).pipe(doc.createStream({wrapper: 'json'}))
+ var hs
+ (hs = hoc.createStream({wrapper: 'json'}))
+ .pipe(doc.createStream({wrapper: 'json'}))
+ .pipe(hs)
hoc.add({id: 'thing', random: random })
}
@@ -86,8 +88,10 @@ exports.single = function (t) {
//this should replicate only one document.
- hoc.createStream({id: 'thing', wrapper: 'raw'})
+ var hs
+ (hs = hoc.createStream({id: 'thing', wrapper: 'raw'}))
.pipe(doc.createStream({id: 'thing', wrapper: 'raw'}))
+ .pipe(hs)
var thing = hoc.get('thing')
View
2  test/streaming.js
@@ -25,7 +25,7 @@ test('random', function (t) {
var as = crdt.createStream(a, {wrapper: 'raw'})
var bs = crdt.createStream(b, {wrapper: 'raw'})
- bs.pipe(as)
+ bs.pipe(as).pipe(bs)
randomUpdates(b)
View
4 test/tcp.js
@@ -14,9 +14,7 @@ var assert = require('assert')
*/
var a = new crdt.Doc()
-var as = a.createStream()
var b = new crdt.Doc()
-var bs = b.createStream()
a.sync = b.sync = true
@@ -53,6 +51,7 @@ var allChanges = 10
exports.test = function (t) {
var server = net.createServer(function (sock) {
+ var as = a.createStream()
toJSON(as, 'A>').pipe(sock).pipe(fromJSON(as, 'A<'))
// **************************************************
@@ -78,6 +77,7 @@ var server = net.createServer(function (sock) {
// a.pipe(b).pipe(a)
}).listen(6464, function () {
var client
+var bs = b.createStream()
toJSON(bs, 'B>').pipe(client = net.connect(6464)).pipe(fromJSON(bs, 'B<'))
b.on('update', eventually(function () {
Please sign in to comment.
Something went wrong with that request. Please try again.