git ssb

2+

Dominic / ssb-client



Tree: a2def96f193dc31487faf92e6066dfd427c9d41f

Files: a2def96f193dc31487faf92e6066dfd427c9d41f / test / index.js

889 bytesRaw
1var scuttlebot = require('scuttlebot')
2var ssbkeys = require('ssb-keys')
3var tape = require('tape')
4var ssbclient = require('../index')
5
6tape('test api', function (t) {
7
8 var db = require('level-sublevel')(require('levelup')('/testdb', { db: require('memdown') }))
9 var ssb = require('secure-scuttlebutt')(db, require('secure-scuttlebutt/defaults'))
10 var server = scuttlebot({ port: 45451, host: 'localhost' }, ssb, ssb.createFeed()).use(require('scuttlebot/plugins/logging'))
11
12 var keys = ssbkeys.generate()
13 var client = ssbclient(keys)
14 client.connect({ port: 45451, host: 'localhost' }, function (err) {
15 if (err)
16 throw err
17 })
18 client.publish({type: 'post', text: 'hello'}, function (err, data) {
19 if(err) throw err
20 t.equal(data.value.content.text, 'hello')
21 console.log(data)
22 client.close(function() {
23 server.close()
24 t.end()
25 })
26 })
27})
28

Built with git-ssb-web