git ssb

2+

Dominic / ssb-client



Tree: 231808394d23c64c26293d6f914c30beb963f78c

Files: 231808394d23c64c26293d6f914c30beb963f78c / test / index.js

976 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' }, iferr)
15 client.auth(ssbkeys.createAuth(keys), iferr)
16
17 var feed = client.createFeed(keys)
18 feed.add({type: 'post', text: 'hello'}, function (err, data) {
19 iferr(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 function iferr (err) {
29 if (err)
30 throw err
31 }
32})
33

Built with git-ssb-web