git ssb

4+

Dominic / scuttlebot



Tree: 3f99bb4d8aafc51133acb53c3ff0b7d52f71aa1a

Files: 3f99bb4d8aafc51133acb53c3ff0b7d52f71aa1a / test / block2.js

1456 bytesRaw
1var cont = require('cont')
2var tape = require('tape')
3var pull = require('pull-stream')
4var ssbKeys = require('ssb-keys')
5var u = require('./util')
6
7var createSbot = require('../')
8 .use(require('ssb-friends'))
9 .use(require('../plugins/replicate'))
10
11var alice = createSbot({
12 temp: 'test-block-alice', //timeout: 1400,
13 keys: ssbKeys.generate()
14 })
15
16var bob = createSbot({
17 temp: 'test-block-bob', //timeout: 600,
18 keys: ssbKeys.generate()
19 })
20
21tape('alice blocks bob while he is connected, she should disconnect him', function (t) {
22
23 //in the beginning alice and bob follow each other
24 cont.para([
25 alice.publish(u.follow(bob.id)),
26 bob .publish(u.follow(alice.id))
27 ]) (function (err) {
28 if(err) throw err
29
30 var n = 3, rpc
31
32 bob.connect(alice.getAddress(), function (err, rpc) {
33 if(err) throw err
34 //replication will begin immediately.
35 })
36
37 bob.on('replicate:finish', function (vclock) {
38 console.log(vclock)
39 t.equal(vclock[alice.id], 1)
40 alice.close()
41 bob.close()
42 t.end()
43 })
44
45 var once = false
46 var bobCancel = bob.post(function (op) {
47 console.log('BOB RECV', op)
48 if(once) throw new Error('should only be called once')
49 once = true
50 //should be the alice's follow(bob) message.
51
52 t.equal(op.value.content.contact, bob.id)
53 alice.publish(u.block(bob.id))
54 (function (err) { if(err) throw err })
55 }, false)
56
57 })
58})
59
60
61

Built with git-ssb-web