@@ -6,6 +6,7 @@ const dirtyChai = require('dirty-chai')
6
6
const expect = chai . expect
7
7
chai . use ( dirtyChai )
8
8
9
+ const PeerId = require ( 'peer-id' )
9
10
const duplexPair = require ( 'it-pair/duplex' )
10
11
const Handshake = require ( 'it-pb-rpc' )
11
12
const Secio = require ( '../src' )
@@ -32,7 +33,7 @@ describe('secio', () => {
32
33
33
34
it ( 'performs a spec compliant inbound exchange' , async ( ) => {
34
35
const [ inboundConnection , outboundConnection ] = duplexPair ( )
35
- await Promise . all ( [
36
+ const [ result ] = await Promise . all ( [
36
37
Secio . secureInbound ( remotePeer , inboundConnection , null ) ,
37
38
( async ( ) => {
38
39
const wrap = Handshake ( outboundConnection )
@@ -102,12 +103,16 @@ describe('secio', () => {
102
103
expect ( ourNonce . slice ( ) ) . to . eql ( state . proposal . out . rand )
103
104
} ) ( )
104
105
] )
106
+
107
+ expect ( result . remotePeer . pubKey ) . to . exist ( )
108
+ expect ( result . remotePeer . pubKey . bytes ) . to . eql ( localPeer . pubKey . bytes )
105
109
} )
106
110
107
111
it ( 'performs a spec compliant outbound exchange' , async ( ) => {
108
112
const [ inboundConnection , outboundConnection ] = duplexPair ( )
109
- await Promise . all ( [
110
- Secio . secureOutbound ( localPeer , outboundConnection , remotePeer ) ,
113
+ const cidOnlyPeerId = PeerId . createFromCID ( remotePeer . toB58String ( ) )
114
+ const [ result ] = await Promise . all ( [
115
+ Secio . secureOutbound ( localPeer , outboundConnection , cidOnlyPeerId ) ,
111
116
( async ( ) => {
112
117
const wrap = Handshake ( inboundConnection )
113
118
const state = new State ( remotePeer , localPeer )
@@ -176,5 +181,8 @@ describe('secio', () => {
176
181
expect ( ourNonce . slice ( ) ) . to . eql ( state . proposal . out . rand )
177
182
} ) ( )
178
183
] )
184
+
185
+ expect ( result . remotePeer . pubKey ) . to . exist ( )
186
+ expect ( result . remotePeer . pubKey . bytes ) . to . eql ( remotePeer . pubKey . bytes )
179
187
} )
180
188
} )
0 commit comments