File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -25,14 +25,15 @@ Install with `yarn add @chainsafe/libp2p-noise` or `npm i @chainsafe/libp2p-nois
2525Example of using default noise configuration and passing it to the libp2p config:
2626
2727``` js
28- import {Noise } from " @chainsafe/libp2p-noise"
28+ import {noise } from " @chainsafe/libp2p-noise"
2929
3030// custom noise configuration, pass it instead of `new Noise()`
31- const noise = new Noise (privateKey, Buffer .alloc (x));
31+ // x25519 private key
32+ const n = noise (privateKey);
3233
3334const libp2p = new Libp2p ({
3435 modules: {
35- connEncryption: [new Noise ()],
36+ connEncryption: [noise ()],
3637 },
3738});
3839```
Original file line number Diff line number Diff line change @@ -3,6 +3,7 @@ import { expect } from 'aegir/chai'
33import { duplexPair } from 'it-pair/duplex'
44import { pbStream } from 'it-pb-stream'
55import sinon from 'sinon'
6+ import { noise } from '../src/index.js'
67import { Noise } from '../src/noise.js'
78import { createPeerIdsFromFixtures } from './fixtures/peer.js'
89
@@ -15,10 +16,10 @@ function createCounterSpy () {
1516
1617describe ( 'Index' , ( ) => {
1718 it ( 'should expose class with tag and required functions' , ( ) => {
18- const noise = new Noise ( )
19- expect ( noise . protocol ) . to . equal ( '/noise' )
20- expect ( typeof ( noise . secureInbound ) ) . to . equal ( 'function' )
21- expect ( typeof ( noise . secureOutbound ) ) . to . equal ( 'function' )
19+ const noiseInstance = noise ( ) ( )
20+ expect ( noiseInstance . protocol ) . to . equal ( '/noise' )
21+ expect ( typeof ( noiseInstance . secureInbound ) ) . to . equal ( 'function' )
22+ expect ( typeof ( noiseInstance . secureOutbound ) ) . to . equal ( 'function' )
2223 } )
2324
2425 it ( 'should collect metrics' , async ( ) => {
You can’t perform that action at this time.
0 commit comments