Improves test coverage.

This commit is contained in:
Stephen Whitmore
2016-04-21 15:44:26 -07:00
parent 6d1b729fcd
commit c456326515

View File

@ -15,6 +15,19 @@ describe('libp2p-tcp', function () {
done()
})
it('create without new', (done) => {
tcp = TCPlibp2p()
expect(tcp).to.exist
done()
})
it('close /wo listeners', (done) => {
tcp = new TCPlibp2p()
expect(tcp).to.exist
expect(function () { tcp.close() }).to.throw(Error)
done()
})
it('listen', (done) => {
const mh = multiaddr('/ip4/127.0.0.1/tcp/9090')
tcp.createListener(mh, (socket) => {
@ -88,5 +101,14 @@ describe('libp2p-tcp', function () {
done()
})
it('filter a valid addr for this transport', (done) => {
const mh1 = multiaddr('/ip4/127.0.0.1/tcp/9090')
const valid = tcp.filter(mh1)
expect(valid.length).to.equal(1)
expect(valid[0]).to.deep.equal(mh1)
done()
})
it.skip('listen on IPv6', (done) => {})
})