mirror of
https://github.com/fluencelabs/js-libp2p-interfaces
synced 2025-07-14 15:41:45 +00:00
Compare commits
1 Commits
v0.8.4
...
chore/add-
Author | SHA1 | Date | |
---|---|---|---|
d3559f0e60 |
@ -1,12 +1,3 @@
|
|||||||
## [0.8.4](https://github.com/libp2p/js-interfaces/compare/v0.8.3...v0.8.4) (2021-03-22)
|
|
||||||
|
|
||||||
|
|
||||||
### Bug Fixes
|
|
||||||
|
|
||||||
* specify connection direction ([#86](https://github.com/libp2p/js-interfaces/issues/86)) ([3b960d5](https://github.com/libp2p/js-interfaces/commit/3b960d516f70f7e198574a736cb09000ddd7a94c))
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
## [0.8.3](https://github.com/libp2p/js-interfaces/compare/v0.8.2...v0.8.3) (2021-01-26)
|
## [0.8.3](https://github.com/libp2p/js-interfaces/compare/v0.8.2...v0.8.3) (2021-01-26)
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "libp2p-interfaces",
|
"name": "libp2p-interfaces",
|
||||||
"version": "0.8.4",
|
"version": "0.8.3",
|
||||||
"description": "Interfaces for JS Libp2p",
|
"description": "Interfaces for JS Libp2p",
|
||||||
"leadMaintainer": "Jacob Heun <jacobheun@gmail.com>",
|
"leadMaintainer": "Jacob Heun <jacobheun@gmail.com>",
|
||||||
"main": "src/index.js",
|
"main": "src/index.js",
|
||||||
|
@ -19,7 +19,7 @@ const connectionSymbol = Symbol.for('@libp2p/interface-connection/connection')
|
|||||||
* @property {number} [close]
|
* @property {number} [close]
|
||||||
*
|
*
|
||||||
* @typedef {Object} ConectionStat
|
* @typedef {Object} ConectionStat
|
||||||
* @property {'inbound' | 'outbound'} direction - connection establishment direction
|
* @property {string} direction - connection establishment direction ("inbound" or "outbound").
|
||||||
* @property {Timeline} timeline - connection relevant events timestamp.
|
* @property {Timeline} timeline - connection relevant events timestamp.
|
||||||
* @property {string} [multiplexer] - connection multiplexing identifier.
|
* @property {string} [multiplexer] - connection multiplexing identifier.
|
||||||
* @property {string} [encryption] - connection encryption method identifier.
|
* @property {string} [encryption] - connection encryption method identifier.
|
||||||
|
@ -307,9 +307,71 @@ module.exports = (common) => {
|
|||||||
// line
|
// line
|
||||||
// ◉────◎────◉
|
// ◉────◎────◉
|
||||||
// a b c
|
// a b c
|
||||||
|
// A subscribes and C publishes
|
||||||
|
|
||||||
before(() => { })
|
let psA, psB, psC
|
||||||
after(() => { })
|
|
||||||
|
// Create and start pubsub nodes
|
||||||
|
beforeEach(async () => {
|
||||||
|
[psA, psB, psC] = await common.setup(3)
|
||||||
|
|
||||||
|
// Start pubsub mpdes
|
||||||
|
;[psA, psB, psC].map((p) => p.start())
|
||||||
|
})
|
||||||
|
|
||||||
|
// Connect nodes
|
||||||
|
beforeEach(async () => {
|
||||||
|
await psA._libp2p.dial(psB.peerId)
|
||||||
|
await psB._libp2p.dial(psC.peerId)
|
||||||
|
|
||||||
|
// Wait for peers to be ready in pubsub
|
||||||
|
await pWaitFor(() =>
|
||||||
|
psA.peers.size === 1 &&
|
||||||
|
psC.peers.size === 1 &&
|
||||||
|
psA.peers.size === 1
|
||||||
|
)
|
||||||
|
})
|
||||||
|
|
||||||
|
afterEach(async () => {
|
||||||
|
sinon.restore()
|
||||||
|
|
||||||
|
;[psA, psB, psC].map((p) => p.stop())
|
||||||
|
await common.teardown()
|
||||||
|
})
|
||||||
|
|
||||||
|
it('exchange pubsub messages', async () => {
|
||||||
|
const defer = pDefer()
|
||||||
|
let counter = 0
|
||||||
|
const topic = 'Z'
|
||||||
|
|
||||||
|
function incMsg (msg) {
|
||||||
|
expect(uint8ArrayToString(msg.data)).to.equal('hey')
|
||||||
|
check()
|
||||||
|
}
|
||||||
|
|
||||||
|
function check () {
|
||||||
|
if (++counter === 1) {
|
||||||
|
psA.removeListener(topic, incMsg)
|
||||||
|
psB.removeListener(topic, incMsg)
|
||||||
|
psC.removeListener(topic, incMsg)
|
||||||
|
defer.resolve()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
psA.on(topic, incMsg)
|
||||||
|
psA.subscribe(topic)
|
||||||
|
|
||||||
|
// await subscription change
|
||||||
|
await Promise.all([
|
||||||
|
new Promise(resolve => psB.once('pubsub:subscription-change', () => resolve(null)))
|
||||||
|
])
|
||||||
|
|
||||||
|
// await a cycle
|
||||||
|
await delay(1000)
|
||||||
|
psC.publish(topic, uint8ArrayFromString('hey'))
|
||||||
|
|
||||||
|
return defer.promise
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('1 level tree', () => {
|
describe('1 level tree', () => {
|
||||||
|
Reference in New Issue
Block a user