mirror of
https://github.com/fluencelabs/js-libp2p-noise
synced 2025-04-25 07:22:36 +00:00
Additional check
This commit is contained in:
parent
36e3462a82
commit
a5c45bfc53
@ -181,8 +181,8 @@ export class Noise implements INoiseConnection {
|
||||
await handshake.exchange();
|
||||
await handshake.finish();
|
||||
|
||||
if (this.useNoisePipes && remotePeer) {
|
||||
KeyCache.store(remotePeer, handshake.getRemoteStaticKey());
|
||||
if (this.useNoisePipes && handshake.remotePeer) {
|
||||
KeyCache.store(handshake.remotePeer, handshake.getRemoteStaticKey());
|
||||
}
|
||||
} catch (e) {
|
||||
throw new Error(`Error occurred during XX handshake: ${e.message}`);
|
||||
|
@ -270,12 +270,13 @@ describe("Noise", () => {
|
||||
const staticKeysResponder = generateKeypair();
|
||||
|
||||
const noiseResp = new Noise(staticKeysResponder.privateKey);
|
||||
const ikInitSpy = sandbox.spy(noiseInit, "performIKHandshake");
|
||||
const xxFallbackInitSpy = sandbox.spy(noiseInit, "performXXFallbackHandshake");
|
||||
const xxRespSpy = sandbox.spy(noiseResp, "performXXHandshake");
|
||||
|
||||
// Prepare key cache for noise pipes
|
||||
KeyCache.resetStorage();
|
||||
KeyCache.store(localPeer, staticKeysResponder.publicKey);
|
||||
KeyCache.store(remotePeer, staticKeysResponder.publicKey);
|
||||
|
||||
const [inboundConnection, outboundConnection] = DuplexPair();
|
||||
|
||||
@ -291,6 +292,7 @@ describe("Noise", () => {
|
||||
const response = await wrappedInbound.readLP();
|
||||
expect(response.toString()).equal("test fallback");
|
||||
|
||||
assert(ikInitSpy.calledOnce, "IK handshake was not called.");
|
||||
assert(xxFallbackInitSpy.calledOnce, "XX Fallback method was not called.");
|
||||
assert(xxRespSpy.calledOnce, "XX method was not called.");
|
||||
} catch (e) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user