mirror of
https://github.com/fluencelabs/js-libp2p-interfaces
synced 2025-06-23 06:21:47 +00:00
feat: add topology interfaces (#7)
* 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>
This commit is contained in:
40
test/topology/multicodec-topology.spec.js
Normal file
40
test/topology/multicodec-topology.spec.js
Normal file
@ -0,0 +1,40 @@
|
||||
/* 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()
|
||||
}
|
||||
})
|
||||
})
|
Reference in New Issue
Block a user