29 lines
609 B
JavaScript
Raw Normal View History

2016-03-15 18:59:32 +00:00
/* eslint-env mocha */
const expect = require('chai').expect
2016-03-22 19:38:28 +00:00
const WSlibp2p = require('../../src')
2016-03-15 18:59:32 +00:00
const multiaddr = require('multiaddr')
describe('libp2p-websockets', function () {
this.timeout(10000)
var ws
it('create', (done) => {
ws = new WSlibp2p()
expect(ws).to.exist
done()
})
it('echo', (done) => {
const mh = multiaddr('/ip4/127.0.0.1/tcp/9090/websockets')
const conn = ws.dial(mh)
const message = 'Hello World!'
conn.write(message)
conn.on('data', (data) => {
expect(data.toString()).to.equal(message)
conn.end()
done()
})
})
})