mirror of
https://github.com/fluencelabs/js-libp2p-interfaces
synced 2025-04-08 19:08:23 +00:00
* feat: topology * feat: multicodec-topology * chore: address review Co-Authored-By: Jacob Heun <jacobheun@gmail.com> * chore: remove error from disconnect * docs: topology * chore: apply suggestions from code review Co-Authored-By: Jacob Heun <jacobheun@gmail.com>
41 lines
911 B
JavaScript
41 lines
911 B
JavaScript
/* eslint-env mocha */
|
|
'use strict'
|
|
|
|
const tests = require('../../src/topology/tests/multicodec-topology')
|
|
const MulticodecTopology = require('../../src/topology/multicodec-topology')
|
|
const MockPeerStore = require('./mock-peer-store')
|
|
|
|
describe('multicodec topology compliance tests', () => {
|
|
tests({
|
|
setup (properties, registrar) {
|
|
const multicodecs = ['/echo/1.0.0']
|
|
const handlers = {
|
|
onConnect: () => { },
|
|
onDisconnect: () => { }
|
|
}
|
|
|
|
const topology = new MulticodecTopology({
|
|
multicodecs,
|
|
handlers,
|
|
...properties
|
|
})
|
|
|
|
if (!registrar) {
|
|
const peerStore = new MockPeerStore([])
|
|
|
|
registrar = {
|
|
peerStore,
|
|
getConnection: () => { }
|
|
}
|
|
}
|
|
|
|
topology.registrar = registrar
|
|
|
|
return topology
|
|
},
|
|
teardown () {
|
|
// cleanup resources created by setup()
|
|
}
|
|
})
|
|
})
|