-
Notifications
You must be signed in to change notification settings - Fork 445
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
revert: reapply "fix: throw if no conn encryption module provided (#665…
…)" This reapplies commit b621fbd.
- Loading branch information
Showing
8 changed files
with
91 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters