git ssb

2+

ev / minsbot



Tree: 3d269c98d409d84e87895f410008a8df9e94f15d

Files: 3d269c98d409d84e87895f410008a8df9e94f15d / test / block2.js

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

Built with git-ssb-web