git ssb

4+

Dominic / scuttlebot



Commit 78008493427a069cce680c9494eb59be4b23024c

more relaxed block tests

Dominic Tarr committed on 10/3/2016, 4:01:36 AM
Parent: 6a7d492d58470cc1653ff2879a1f385f03008e11

Files changed

test/block.jschanged
test/block3.jschanged
test/block.jsView
@@ -55,15 +55,17 @@
5555
5656 //get the next messages that are replicated to alice and bob,
5757 //and check that these are the correct follow messages.
5858 var bobCancel = bob.post(function (op) {
59 + console.log('BOB_POST', op)
5960 //should be the alice's follow(bob) message.
6061 t.equal(op.value.author, alice.id)
6162 t.equal(op.value.content.contact, bob.id)
6263 next()
6364 })
6465
6566 var aliceCancel = alice.post(function (op) {
67 + console.log('ALICE_POST', op)
6668 //should be the bob's follow(alice) message.
6769 t.equal(op.value.author, bob.id)
6870 t.equal(op.value.content.contact, alice.id)
6971 next()
@@ -100,17 +102,45 @@
100102
101103 //since bob is blocked, he should not be able to connect
102104 bob.connect(alice.getAddress(), function (err, rpc) {
103105 t.ok(err, 'bob is blocked, should fail to connect to alice')
106 +
107 +
108 + carol.post(function (msg) {
109 + console.log('CAROL RECV', msg, alice.id)
110 + if(msg.author === alice.id) {
111 + if(msg.sequence == 2)
112 + t.end()
113 + }
114 + })
115 +
104116 //but carol, should, because she is not blocked.
105- carol.connect(alice.getAddress(), function (err) {
106- t.notOk(err)
117 + carol.connect(alice.getAddress(), function (err, rpc) {
118 + if(err) throw err
119 + console.log('CAROL CONNECTED TO ALICE', carol.id, alice.id)
120 +// pull(
121 +// alice.createHistoryStream({id: alice.id, seq: 0}),
122 +// pull.collect(console.log)
123 +// )
124 +
125 + rpc.on('closed', function () {
126 + pull(
127 + carol.createHistoryStream({id: alice.id, seq: 0, live: false}),
128 + pull.collect(function (err, ary) {
129 + if(err) throw err
130 +
131 + t.ok(ary.length, 'carol replicated data from alice')
132 + console.log(alice.id, carol.id, err, ary)
133 + t.end()
134 + })
135 + )
136 + })
107137 })
108- carol.once('replicate:finish', function (vclock) {
109- t.equal(vclock[alice.id], 2)
110- //in next test, bob connects to carol...
111- t.end()
112- })
138 +// carol.once('replicate:finish', function (vclock) {
139 +// t.equal(vclock[alice.id], 2)
140 +// //in next test, bob connects to carol...
141 +// t.end()
142 +// })
113143 })
114144 })
115145 )
116146 })
@@ -142,4 +172,12 @@
142172 tape('cleanup!', function (t) {
143173 alice.close(true); bob.close(true); carol.close(true)
144174 t.end()
145175 })
176 +
177 +
178 +
179 +
180 +
181 +
182 +
183 +
test/block3.jsView
@@ -60,17 +60,17 @@
6060 if(err) throw err
6161 })
6262
6363 bob.on('replicate:finish', function (vclock) {
64- t.equal(vclock[alice.id], 1)
65- console.log('OKAY')
64 + //I don't care which messages bob doesn't have of alice's
65 + t.ok(vclock[alice.id] < 2, 'bob has alices first message')
6666 alice.close();bob.close();carol.close()
6767 t.end()
6868 })
6969
7070 var once = false
7171 var bobCancel = bob.post(function (op) {
72- console.log('BOB RECV', op)
72 + console.log('BOB RECV', op, bob.id)
7373 if(once) throw new Error('should only be called once')
7474 once = true
7575 //should be the alice's follow(bob) message.
7676
@@ -80,4 +80,8 @@
8080 (function (err) { if(err) throw err })
8181 })
8282 })
8383 })
84 +
85 +
86 +
87 +

Built with git-ssb-web