Files: d42610e87a071fe62aa1d0ad3053db084fb8076d / test / master.js
1065 bytesRaw
1 | var tape = require('tape') |
2 | var util = require('../lib/util') |
3 | var ssbKeys = require('ssb-keys') |
4 | |
5 | var aliceKeys = ssbKeys.generate() |
6 | var bobKeys = ssbKeys.generate() |
7 | var carolKeys = ssbKeys.generate() |
8 | |
9 | var createSbot = require('../') |
10 | .use(require('../plugins/master')) |
11 | |
12 | var alice = createSbot({ |
13 | port: 45451, timeout: 2001, |
14 | temp: 'master', |
15 | host: 'localhost', |
16 | master: bobKeys.id, |
17 | keys: aliceKeys |
18 | }) |
19 | |
20 | tape('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 | |
33 | tape('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