git ssb

4+

Dominic / scuttlebot



Tree: 48efa4f4f1d44115cba007a5b04bff15044b44d1

Files: 48efa4f4f1d44115cba007a5b04bff15044b44d1 / test / master.js

1065 bytesRaw
1var tape = require('tape')
2var util = require('../lib/util')
3var ssbKeys = require('ssb-keys')
4
5var aliceKeys = ssbKeys.generate()
6var bobKeys = ssbKeys.generate()
7var carolKeys = ssbKeys.generate()
8
9var createSbot = require('../')
10 .use(require('../plugins/master'))
11
12var alice = createSbot({
13 port: 45451, timeout: 2001,
14 temp: 'master',
15 host: 'localhost',
16 master: bobKeys.id,
17 keys: aliceKeys
18})
19
20tape('connect remote master', function (t) {
21 createSbot.createClient({keys: bobKeys})
22 (alice.getAddress(), function (err, rpc) {
23 if(err) throw err
24 rpc.publish({
25 type: 'msg', value: 'written by bob', from: bobKeys.id
26 }, function (err) {
27 if(err) throw err
28 t.end()
29 })
30 })
31})
32
33tape('non-master cannot use same methods', function (t) {
34 createSbot.createClient({keys: carolKeys})
35 (alice.getAddress(), function (err, rpc) {
36 if(err) throw err
37 rpc.publish({
38 type: 'msg', value: 'written by ca', from: bobKeys.id
39 }, function (err) {
40 t.ok(err)
41 alice.close(true)
42 t.end()
43 })
44 })
45})
46
47
48

Built with git-ssb-web