mirror of
https://github.com/fluencelabs/js-libp2p-secio
synced 2025-03-15 18:00:52 +00:00
test: add test for handshake to expose error bubbling issue
This commit is contained in:
parent
b6e1baa8ca
commit
0e23874730
@ -18,6 +18,8 @@ const Listener = ms.Listener
|
|||||||
const Dialer = ms.Dialer
|
const Dialer = ms.Dialer
|
||||||
|
|
||||||
const secio = require('../src')
|
const secio = require('../src')
|
||||||
|
const State = require('../src/state')
|
||||||
|
const handshake = require('../src/handshake')
|
||||||
|
|
||||||
describe('secio', () => {
|
describe('secio', () => {
|
||||||
let peerA
|
let peerA
|
||||||
@ -144,4 +146,30 @@ describe('secio', () => {
|
|||||||
secio.encrypt(peerA, new Connection(p[0]), peerC, check)
|
secio.encrypt(peerA, new Connection(p[0]), peerC, check)
|
||||||
secio.encrypt(peerB, new Connection(p[1]), peerA, 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
|
||||||
|
)
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
Loading…
x
Reference in New Issue
Block a user