mirror of
https://github.com/fluencelabs/js-libp2p
synced 2025-06-15 18:21:22 +00:00
revert: reapply "fix: throw if no conn encryption module provided (#665)"
This reapplies commit b621fbdfdc
.
This commit is contained in:
57
test/core/encryption.spec.js
Normal file
57
test/core/encryption.spec.js
Normal file
@ -0,0 +1,57 @@
|
||||
'use strict'
|
||||
/* eslint-env mocha */
|
||||
|
||||
const chai = require('chai')
|
||||
chai.use(require('dirty-chai'))
|
||||
chai.use(require('chai-as-promised'))
|
||||
const { expect } = chai
|
||||
|
||||
const Transport = require('libp2p-websockets')
|
||||
const { NOISE: Crypto } = require('libp2p-noise')
|
||||
|
||||
const Libp2p = require('../../src')
|
||||
const { codes: ErrorCodes } = require('../../src/errors')
|
||||
const { createPeerId } = require('../utils/creators/peer')
|
||||
|
||||
describe('Connection encryption configuration', () => {
|
||||
let peerId
|
||||
|
||||
before(async () => {
|
||||
[peerId] = await createPeerId()
|
||||
})
|
||||
|
||||
it('is required', async () => {
|
||||
const config = {
|
||||
peerId,
|
||||
modules: {
|
||||
transport: [Transport]
|
||||
}
|
||||
}
|
||||
|
||||
await expect(Libp2p.create(config)).to.eventually.be.rejected()
|
||||
.and.to.have.property('code', ErrorCodes.CONN_ENCRYPTION_REQUIRED)
|
||||
})
|
||||
|
||||
it('is required and needs at least one module', async () => {
|
||||
const config = {
|
||||
peerId,
|
||||
modules: {
|
||||
transport: [Transport],
|
||||
connEncryption: []
|
||||
}
|
||||
}
|
||||
await expect(Libp2p.create(config)).to.eventually.be.rejected()
|
||||
.and.to.have.property('code', ErrorCodes.CONN_ENCRYPTION_REQUIRED)
|
||||
})
|
||||
|
||||
it('can be created', async () => {
|
||||
const config = {
|
||||
peerId,
|
||||
modules: {
|
||||
transport: [Transport],
|
||||
connEncryption: [Crypto]
|
||||
}
|
||||
}
|
||||
await Libp2p.create(config)
|
||||
})
|
||||
})
|
Reference in New Issue
Block a user