git ssb

4+

Dominic / scuttlebot



Tree: b3923852a5471785a61c33094414b62fa845b7b5

Files: b3923852a5471785a61c33094414b62fa845b7b5 / test / end2end.js

1907 bytesRaw
1var tape = require('tape')
2var pull = require('pull-stream')
3var ssbKeys = require('ssb-keys')
4
5var createSbot = require('../')
6 .use(require('../plugins/master'))
7 .use(require('../plugins/private'))
8
9var alice = ssbKeys.generate()
10var bob = ssbKeys.generate()
11
12var aliceDb = createSbot({
13 temp: 'test-alice',
14 keys: alice
15})
16
17tape('end2end a message, and test that indexes work', function (t) {
18
19 aliceDb.publish(
20 ssbKeys.box({
21 type: 'post',
22 text: 'a scary secret'
23 }, [alice.public, bob.public]),
24 function (err, msg) {
25 console.log(msg)
26
27 aliceDb.publish(
28 ssbKeys.box({
29 type: 'post',
30 reply: msg.key,
31 text: 'oh wow crazy'
32 }, [alice.public, bob.public]),
33 function (err, msg) {
34 pull(
35 aliceDb.links({type: 'msg'}),
36 pull.collect(function (err, ary) {
37 t.end()
38 })
39 )
40 })
41 })
42})
43
44tape('private.publish', function (t) {
45
46 aliceDb.private.publish(
47 {
48 type: 'post',
49 text: 'a scary secret'
50 }, [alice.public, bob.public],
51 function (err, msg) {
52 console.log(msg)
53
54 aliceDb.private.publish(
55 {
56 type: 'post',
57 reply: msg.key,
58 text: 'oh wow crazy'
59 }, [alice.public, bob.public],
60 function (err, msg) {
61 pull(
62 aliceDb.links({type: 'msg'}),
63 pull.collect(function (err, ary) {
64 t.end()
65 })
66 )
67 })
68 })
69})
70
71tape('private.unbox', function (t) {
72
73 aliceDb.private.publish(
74 {
75 type: 'post',
76 text: 'a scary secret'
77 }, [alice.public, bob.public],
78 function (err, msg) {
79 console.log(msg)
80
81 var plain = aliceDb.private.unbox(msg.value.content)
82 t.equal(plain.type, 'post')
83 t.equal(plain.text, 'a scary secret')
84 t.end()
85 aliceDb.close(true)
86 })
87})

Built with git-ssb-web