test: add test for handshake to expose error bubbling issue

This commit is contained in:
Jacob Heun 2018-03-28 20:42:28 +02:00 committed by David Dias
parent b6e1baa8ca
commit 0e23874730

View File

@ -18,6 +18,8 @@ const Listener = ms.Listener
const Dialer = ms.Dialer
const secio = require('../src')
const State = require('../src/state')
const handshake = require('../src/handshake')
describe('secio', () => {
let peerA
@ -144,4 +146,30 @@ describe('secio', () => {
secio.encrypt(peerA, new Connection(p[0]), peerC, check)
secio.encrypt(peerB, new Connection(p[1]), peerA, check)
})
it('bubbles errors from handshake failures properly', (done) => {
const p = pair()
const timeout = 60 * 1000 * 5
const stateA = new State(peerA, peerC, timeout, () => { })
const stateB = new State(peerB, peerA, timeout, () => { })
const connA = new Connection(p[0])
const connB = new Connection(p[1])
function finish (err) {
expect(err).to.exist()
done()
}
pull(
connA,
handshake(stateA, finish),
connA
)
pull(
connB,
handshake(stateB, finish),
connB
)
})
})