git ssb

0+

Dominic / ssb-peer-invites



Tree: fe3ae12adbf9dfc9bd4146fa5708fee8f9297e46

Files: fe3ae12adbf9dfc9bd4146fa5708fee8f9297e46 / test / will-replicate.js

2013 bytesRaw
1
2
3var crypto = require('crypto')
4var I = require('../valid')
5var createClient = require('ssb-client')
6
7
8var ssbKeys = require('ssb-keys')
9var tape = require('tape')
10//var explain = require('explain-error')
11var pull = require('pull-stream')
12//var u = require('../lib/util')
13var ref = require('ssb-ref')
14
15var createSbot = require('scuttlebot')
16 .use(require('ssb-links'))
17 .use({
18 name: 'replicate', version: '1.0.0',
19 manifest: { request: 'sync' },
20 init: function () {
21 return { request: function () {} }
22 }
23 })
24 .use(require('ssb-query'))
25 .use(require('ssb-device-address'))
26 .use(require('ssb-identities'))
27 .use(require('ssb-friends'))
28 .use(require('../'))
29
30var caps = {
31 sign: crypto.randomBytes(32),//.toString('base64'),
32 userInvite: crypto.randomBytes(32),//.toString('base64'),
33 shs: crypto.randomBytes(32),//.toString('base64'),
34}
35
36var alice = createSbot({
37 temp: true,
38 timeout: 1000,
39 port: 12342,
40 keys:ssbKeys.generate(),
41 caps: caps
42})
43var bob = createSbot({
44 temp: true,
45 timeout: 1000,
46 port: 12343,
47 keys:ssbKeys.generate(),
48 caps: caps
49})
50
51tape("alice will replicate bob's guests", function (t) {
52 alice.publish({
53 type: 'contact', contact: bob.id,
54 following: true
55 }, function (err, data) {
56 if(err) throw err
57 t.ok(data)
58 console.log(data)
59 bob.connect(alice.getAddress(), function (err, _alice) {
60 if(err) throw err
61 _alice.userInvites.willReplicate(function (err, wr) {
62 if(err) throw err
63 t.ok(wr) //alice should replicate for bob's guests
64 _alice.close()
65 t.end()
66 })
67 })
68 })
69})
70
71tape("bob won't replicate alice's guests", function (t) {
72 alice.connect(bob.getAddress(), function (err, _bob) {
73 if(err) throw err
74 _bob.userInvites.willReplicate(function (err, wr) {
75 if(err) throw err
76 t.notOk(wr) //alice should replicate for bob's guests
77 _bob.close()
78 t.end()
79 })
80 })
81})
82
83tape('clean up', function (t) {
84 alice.close()
85 bob.close()
86 t.end()
87})
88

Built with git-ssb-web