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