git ssb

2+

Dominic / ssb-client



Tree: 4062644a7f2a55d2f9039f4151d26d2d30c06bcf

Files: 4062644a7f2a55d2f9039f4151d26d2d30c06bcf / test / index.js

871 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())
11
12 var keys = ssbkeys.generate()
13 var client = ssbclient(keys, {port: 45451, host: 'localhost'}, function (err, authed) {
14 if(err) throw err
15 t.ok(authed.granted)
16 client.publish({type: 'post', text: 'hello'}, function (err, data) {
17 if(err) throw err
18 t.equal(data.value.content.text, 'hello')
19 console.log(data)
20 client.close(function() {
21 server.close()
22 t.end()
23 })
24 })
25 })
26})
27

Built with git-ssb-web