mirror of
https://github.com/fluencelabs/js-libp2p-interfaces
synced 2025-06-14 09:31:33 +00:00
feat: interface pubsub (#60)
* feat: interface pubsub * chore: pubsub router tests * chore: move pubsub abstractions from gossipsub * chore: address review * chore: revamp docs * chore: add emit self tests to interface * chore: refactor base tests * chore: publish should only accept one topic per api call * chore: normalize msg before emit * chore: do not reset inbound stream * chore: apply suggestions from code review Co-authored-by: Jacob Heun <jacobheun@gmail.com> * chore: address review * fix: remove subscribe handler * chore: remove bits from create peerId Co-authored-by: Jacob Heun <jacobheun@gmail.com> * chore: remove delay from topic validators tests * chore: add event emitter information * fix: topic validator docs Co-authored-by: Jacob Heun <jacobheun@gmail.com>
This commit is contained in:
54
test/pubsub/instance.spec.js
Normal file
54
test/pubsub/instance.spec.js
Normal file
@ -0,0 +1,54 @@
|
||||
/* eslint-env mocha */
|
||||
'use strict'
|
||||
|
||||
const { expect } = require('aegir/utils/chai')
|
||||
|
||||
const PubsubBaseImpl = require('../../src/pubsub')
|
||||
const {
|
||||
createPeerId,
|
||||
mockRegistrar
|
||||
} = require('./utils')
|
||||
|
||||
describe('pubsub instance', () => {
|
||||
let peerId
|
||||
|
||||
before(async () => {
|
||||
peerId = await createPeerId()
|
||||
})
|
||||
|
||||
it('should throw if no debugName is provided', () => {
|
||||
expect(() => {
|
||||
new PubsubBaseImpl() // eslint-disable-line no-new
|
||||
}).to.throw()
|
||||
})
|
||||
|
||||
it('should throw if no multicodec is provided', () => {
|
||||
expect(() => {
|
||||
new PubsubBaseImpl({ // eslint-disable-line no-new
|
||||
debugName: 'pubsub'
|
||||
})
|
||||
}).to.throw()
|
||||
})
|
||||
|
||||
it('should throw if no libp2p is provided', () => {
|
||||
expect(() => {
|
||||
new PubsubBaseImpl({ // eslint-disable-line no-new
|
||||
debugName: 'pubsub',
|
||||
multicodecs: '/pubsub/1.0.0'
|
||||
})
|
||||
}).to.throw()
|
||||
})
|
||||
|
||||
it('should accept valid parameters', () => {
|
||||
expect(() => {
|
||||
new PubsubBaseImpl({ // eslint-disable-line no-new
|
||||
debugName: 'pubsub',
|
||||
multicodecs: '/pubsub/1.0.0',
|
||||
libp2p: {
|
||||
peerId: peerId,
|
||||
registrar: mockRegistrar
|
||||
}
|
||||
})
|
||||
}).not.to.throw()
|
||||
})
|
||||
})
|
Reference in New Issue
Block a user