Files: 0e94992aa8bedac43906183f616bff699ec2484b / test / will-replicate.js
1625 bytesRaw
1 | var ssbKeys = require('ssb-keys') |
2 | var tape = require('tape') |
3 | |
4 | var createSbot = require('ssb-server') |
5 | .use(require('ssb-links')) |
6 | .use({ |
7 | name: 'replicate', version: '1.0.0', |
8 | manifest: { request: 'sync' }, |
9 | init: function () { |
10 | return { request: function () {} } |
11 | } |
12 | }) |
13 | .use(require('ssb-query')) |
14 | .use(require('ssb-device-address')) |
15 | .use(require('ssb-identities')) |
16 | .use(require('ssb-friends')) |
17 | .use(require('../')) |
18 | |
19 | var caps = require('./randcaps')() |
20 | |
21 | var alice = createSbot({ |
22 | temp: true, |
23 | timeout: 1000, |
24 | port: 12342, |
25 | keys:ssbKeys.generate(), |
26 | caps: caps |
27 | }) |
28 | var bob = createSbot({ |
29 | temp: true, |
30 | timeout: 1000, |
31 | port: 12343, |
32 | keys:ssbKeys.generate(), |
33 | caps: caps |
34 | }) |
35 | |
36 | tape("alice will replicate bob's guests", function (t) { |
37 | alice.publish({ |
38 | type: 'contact', contact: bob.id, |
39 | following: true |
40 | }, function (err, data) { |
41 | if(err) throw err |
42 | t.ok(data) |
43 | console.log(data) |
44 | bob.connect(alice.getAddress(), function (err, _alice) { |
45 | if(err) throw err |
46 | _alice.peerInvites.willReplicate(function (err, wr) { |
47 | if(err) throw err |
48 | t.ok(wr) //alice should replicate for bob's guests |
49 | _alice.close() |
50 | t.end() |
51 | }) |
52 | }) |
53 | }) |
54 | }) |
55 | |
56 | tape("bob won't replicate alice's guests", function (t) { |
57 | alice.connect(bob.getAddress(), function (err, _bob) { |
58 | if(err) throw err |
59 | _bob.peerInvites.willReplicate(function (err, wr) { |
60 | if(err) throw err |
61 | t.notOk(wr) //alice should replicate for bob's guests |
62 | _bob.close() |
63 | t.end() |
64 | }) |
65 | }) |
66 | }) |
67 | |
68 | tape('clean up', function (t) { |
69 | alice.close() |
70 | bob.close() |
71 | t.end() |
72 | }) |
73 |
Built with git-ssb-web