mirror of
https://github.com/fluencelabs/js-libp2p
synced 2025-06-22 05:21:35 +00:00
fix: use placeholder dht/pubsub (#1193)
Instead of making the `.dht` and `.pubsub` properties optional, use dummy implementations that throw exceptions if they are not configured. This way we don't have to null guard everywhere they are accessed.
This commit is contained in:
@ -13,15 +13,17 @@ describe('DHT subsystem is configurable', () => {
|
||||
}
|
||||
})
|
||||
|
||||
it('should not exist if no module is provided', async () => {
|
||||
it('should throw if no module is provided', async () => {
|
||||
libp2p = await createLibp2p(createSubsystemOptions({
|
||||
dht: undefined
|
||||
}))
|
||||
expect(libp2p.dht).to.not.exist()
|
||||
await libp2p.start()
|
||||
await expect(libp2p.dht.getMode()).to.eventually.be.rejected()
|
||||
})
|
||||
|
||||
it('should exist if the module is provided', async () => {
|
||||
it('should not throw if the module is provided', async () => {
|
||||
libp2p = await createLibp2p(createSubsystemOptions())
|
||||
expect(libp2p.dht).to.exist()
|
||||
await libp2p.start()
|
||||
await expect(libp2p.dht.getMode()).to.eventually.equal('client')
|
||||
})
|
||||
})
|
||||
|
Reference in New Issue
Block a user