@@ -20,9 +20,9 @@ const { IdentifyService, multicodecs } = require('../../src/identify')
2020const Peers = require ( '../fixtures/peers' )
2121const Libp2p = require ( '../../src' )
2222const Envelope = require ( '../../src/record/envelope' )
23- const PeerRecord = require ( '../../src/record/peer-record' )
2423const PeerStore = require ( '../../src/peer-store' )
2524const baseOptions = require ( '../utils/base-options.browser' )
25+ const { updateSelfPeerRecord } = require ( '../../src/record/utils' )
2626const pkg = require ( '../../package.json' )
2727
2828const { MULTIADDRS_WEBSOCKETS } = require ( '../fixtures/browser' )
@@ -80,7 +80,7 @@ describe('Identify', () => {
8080 sinon . spy ( localIdentify . peerStore . protoBook , 'set' )
8181
8282 // Transport Manager creates signed peer record
83- await _createSelfPeerRecord ( remoteIdentify . _libp2p )
83+ await updateSelfPeerRecord ( remoteIdentify . _libp2p )
8484
8585 // Run identify
8686 await Promise . all ( [
@@ -244,8 +244,8 @@ describe('Identify', () => {
244244 sinon . spy ( remoteIdentify . peerStore . protoBook , 'set' )
245245
246246 // Transport Manager creates signed peer record
247- await _createSelfPeerRecord ( localIdentify . _libp2p )
248- await _createSelfPeerRecord ( remoteIdentify . _libp2p )
247+ await updateSelfPeerRecord ( localIdentify . _libp2p )
248+ await updateSelfPeerRecord ( remoteIdentify . _libp2p )
249249
250250 // Run identify
251251 await Promise . all ( [
@@ -389,8 +389,6 @@ describe('Identify', () => {
389389
390390 const connection = await libp2p . dialer . connectToPeer ( remoteAddr )
391391 expect ( connection ) . to . exist ( )
392- // Wait for nextTick to trigger the identify call
393- await delay ( 1 )
394392
395393 // Wait for identify to finish
396394 await libp2p . identifyService . identify . firstCall . returnValue
@@ -426,8 +424,6 @@ describe('Identify', () => {
426424
427425 const connection = await libp2p . dialer . connectToPeer ( remoteAddr )
428426 expect ( connection ) . to . exist ( )
429- // Wait for nextTick to trigger the identify call
430- await delay ( 1 )
431427
432428 // Wait for identify to finish
433429 await libp2p . identifyService . identify . firstCall . returnValue
@@ -450,15 +446,3 @@ describe('Identify', () => {
450446 } )
451447 } )
452448} )
453-
454- // Self peer record creating on Transport Manager simulation
455- const _createSelfPeerRecord = async ( libp2p ) => {
456- try {
457- const peerRecord = new PeerRecord ( {
458- peerId : libp2p . peerId ,
459- multiaddrs : libp2p . multiaddrs
460- } )
461- const envelope = await Envelope . seal ( peerRecord , libp2p . peerId )
462- libp2p . peerStore . addressBook . consumePeerRecord ( envelope )
463- } catch ( _ ) { }
464- }
0 commit comments