@@ -47,7 +47,7 @@ describe('Identify', () => {
4747 protocols,
4848 registrar : {
4949 peerStore : {
50- update : ( ) => { }
50+ replace : ( ) => { }
5151 }
5252 }
5353 } )
@@ -57,27 +57,27 @@ describe('Identify', () => {
5757 } )
5858
5959 const observedAddr = multiaddr ( '/ip4/127.0.0.1/tcp/1234' )
60- const localConnectionMock = { newStream : ( ) => { } }
60+ const localConnectionMock = { newStream : ( ) => { } , remotePeer : remotePeer . id }
6161 const remoteConnectionMock = { remoteAddr : observedAddr }
6262
6363 const [ local , remote ] = duplexPair ( )
6464 sinon . stub ( localConnectionMock , 'newStream' ) . returns ( { stream : local , protocol : multicodecs . IDENTIFY } )
6565
66- sinon . spy ( localIdentify . registrar . peerStore , 'update ' )
66+ sinon . spy ( localIdentify . registrar . peerStore , 'replace ' )
6767
6868 // Run identify
6969 await Promise . all ( [
70- localIdentify . identify ( localConnectionMock , remotePeer . id ) ,
70+ localIdentify . identify ( localConnectionMock ) ,
7171 remoteIdentify . handleMessage ( {
7272 connection : remoteConnectionMock ,
7373 stream : remote ,
7474 protocol : multicodecs . IDENTIFY
7575 } )
7676 ] )
7777
78- expect ( localIdentify . registrar . peerStore . update . callCount ) . to . equal ( 1 )
78+ expect ( localIdentify . registrar . peerStore . replace . callCount ) . to . equal ( 1 )
7979 // Validate the remote peer gets updated in the peer store
80- const call = localIdentify . registrar . peerStore . update . firstCall
80+ const call = localIdentify . registrar . peerStore . replace . firstCall
8181 expect ( call . args [ 0 ] . id . bytes ) . to . equal ( remotePeer . id . bytes )
8282 } )
8383
@@ -92,7 +92,7 @@ describe('Identify', () => {
9292 } )
9393
9494 const observedAddr = multiaddr ( '/ip4/127.0.0.1/tcp/1234' )
95- const localConnectionMock = { newStream : ( ) => { } }
95+ const localConnectionMock = { newStream : ( ) => { } , remotePeer }
9696 const remoteConnectionMock = { remoteAddr : observedAddr }
9797
9898 const [ local , remote ] = duplexPair ( )
@@ -128,7 +128,7 @@ describe('Identify', () => {
128128 peerInfo : remotePeer ,
129129 registrar : {
130130 peerStore : {
131- update : ( ) => { }
131+ replace : ( ) => { }
132132 }
133133 }
134134 } )
@@ -148,7 +148,7 @@ describe('Identify', () => {
148148
149149 sinon . spy ( IdentifyService , 'updatePeerAddresses' )
150150 sinon . spy ( IdentifyService , 'updatePeerProtocols' )
151- sinon . spy ( remoteIdentify . registrar . peerStore , 'update ' )
151+ sinon . spy ( remoteIdentify . registrar . peerStore , 'replace ' )
152152
153153 // Run identify
154154 await Promise . all ( [
@@ -163,8 +163,8 @@ describe('Identify', () => {
163163 expect ( IdentifyService . updatePeerAddresses . callCount ) . to . equal ( 1 )
164164 expect ( IdentifyService . updatePeerProtocols . callCount ) . to . equal ( 1 )
165165
166- expect ( remoteIdentify . registrar . peerStore . update . callCount ) . to . equal ( 1 )
167- const [ peerInfo ] = remoteIdentify . registrar . peerStore . update . firstCall . args
166+ expect ( remoteIdentify . registrar . peerStore . replace . callCount ) . to . equal ( 1 )
167+ const [ peerInfo ] = remoteIdentify . registrar . peerStore . replace . firstCall . args
168168 expect ( peerInfo . id . bytes ) . to . eql ( localPeer . id . bytes )
169169 expect ( peerInfo . multiaddrs . toArray ( ) ) . to . eql ( [ listeningAddr ] )
170170 expect ( peerInfo . protocols ) . to . eql ( localProtocols )
@@ -198,7 +198,7 @@ describe('Identify', () => {
198198 } )
199199
200200 sinon . spy ( libp2p . dialer . identifyService , 'identify' )
201- sinon . spy ( libp2p . peerStore , 'update ' )
201+ sinon . spy ( libp2p . peerStore , 'replace ' )
202202
203203 const connection = await libp2p . dialer . connectToMultiaddr ( remoteAddr )
204204 expect ( connection ) . to . exist ( )
@@ -207,7 +207,7 @@ describe('Identify', () => {
207207 expect ( libp2p . dialer . identifyService . identify . callCount ) . to . equal ( 1 )
208208 await libp2p . dialer . identifyService . identify . firstCall . returnValue
209209
210- expect ( libp2p . peerStore . update . callCount ) . to . equal ( 1 )
210+ expect ( libp2p . peerStore . replace . callCount ) . to . equal ( 1 )
211211 await connection . close ( )
212212 } )
213213
0 commit comments