@@ -6,6 +6,7 @@ const dirtyChai = require('dirty-chai')
66const expect = chai . expect
77chai . use ( dirtyChai )
88
9+ const PeerId = require ( 'peer-id' )
910const duplexPair = require ( 'it-pair/duplex' )
1011const Handshake = require ( 'it-pb-rpc' )
1112const Secio = require ( '../src' )
@@ -32,7 +33,7 @@ describe('secio', () => {
3233
3334 it ( 'performs a spec compliant inbound exchange' , async ( ) => {
3435 const [ inboundConnection , outboundConnection ] = duplexPair ( )
35- await Promise . all ( [
36+ const [ result ] = await Promise . all ( [
3637 Secio . secureInbound ( remotePeer , inboundConnection , null ) ,
3738 ( async ( ) => {
3839 const wrap = Handshake ( outboundConnection )
@@ -102,12 +103,16 @@ describe('secio', () => {
102103 expect ( ourNonce . slice ( ) ) . to . eql ( state . proposal . out . rand )
103104 } ) ( )
104105 ] )
106+
107+ expect ( result . remotePeer . pubKey ) . to . exist ( )
108+ expect ( result . remotePeer . pubKey . bytes ) . to . eql ( localPeer . pubKey . bytes )
105109 } )
106110
107111 it ( 'performs a spec compliant outbound exchange' , async ( ) => {
108112 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 ) ,
111116 ( async ( ) => {
112117 const wrap = Handshake ( inboundConnection )
113118 const state = new State ( remotePeer , localPeer )
@@ -176,5 +181,8 @@ describe('secio', () => {
176181 expect ( ourNonce . slice ( ) ) . to . eql ( state . proposal . out . rand )
177182 } ) ( )
178183 ] )
184+
185+ expect ( result . remotePeer . pubKey ) . to . exist ( )
186+ expect ( result . remotePeer . pubKey . bytes ) . to . eql ( remotePeer . pubKey . bytes )
179187 } )
180188} )
0 commit comments