mirror of
https://github.com/fluencelabs/js-libp2p
synced 2025-06-19 04:01:24 +00:00
refactor(async): add dialer and upgrader (#462)
* chore(deps): update connection and multistream * feat: add basic dial support for addresses and peers * test: automatically require all node test files * fix: dont catch and log in the wrong place * test: add direct spec test fix: improve dial error consistency * feat: add dial timeouts and concurrency Queue timeouts will result in aborts of the dials * chore: fix linting * test: verify dialer defaults * feat: add initial upgrader * fix: add more test coverage and fix bugs * feat: libp2p creates the upgrader * feat: hook up handle to the upgrader * feat: hook up the dialer to libp2p test: add node dialer libp2p tests * feat: add connection listeners to upgrader * feat: emit connect and disconnect events * chore: use libp2p-interfaces * fix: address review feedback * fix: correct import * refactor: dedupe connection creation code
This commit is contained in:
24
test/utils/mockCrypto.js
Normal file
24
test/utils/mockCrypto.js
Normal file
@ -0,0 +1,24 @@
|
||||
'use strict'
|
||||
|
||||
const PeerId = require('peer-id')
|
||||
const Peers = require('../fixtures/peers')
|
||||
|
||||
module.exports = {
|
||||
tag: '/insecure',
|
||||
secureInbound: (localPeer, stream) => {
|
||||
return {
|
||||
conn: stream,
|
||||
remotePeer: localPeer
|
||||
}
|
||||
},
|
||||
secureOutbound: async (localPeer, stream, remotePeer) => {
|
||||
// Crypto should always return a remotePeer
|
||||
if (!remotePeer) {
|
||||
remotePeer = await PeerId.createFromJSON(Peers[0])
|
||||
}
|
||||
return {
|
||||
conn: stream,
|
||||
remotePeer: remotePeer
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user