Skip to content

Commit

Permalink
fix: onConnect should not add addr to the addressBook
Browse files Browse the repository at this point in the history
  • Loading branch information
vasco-santos authored and jacobheun committed May 28, 2020
1 parent 8bf5a70 commit 2b45fee
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 7 deletions.
1 change: 0 additions & 1 deletion src/connection-manager/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,6 @@ class ConnectionManager extends EventEmitter {
this.emit('peer:connect', connection)
}

this._libp2p.peerStore.addressBook.add(peerId, [connection.remoteAddr])
this._libp2p.peerStore.keyBook.set(peerId, peerId.pubKey)

if (!this._peerValues.has(peerIdStr)) {
Expand Down
4 changes: 2 additions & 2 deletions test/identify/index.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -242,8 +242,8 @@ describe('Identify', () => {
expect(connection).to.exist()

// Wait for peer store to be updated
// Dialer._createDialTarget (add), Connected (add), Identify (replace)
await pWaitFor(() => peerStoreSpySet.callCount === 1 && peerStoreSpyAdd.callCount === 2)
// Dialer._createDialTarget (add), Identify (replace)
await pWaitFor(() => peerStoreSpySet.callCount === 1 && peerStoreSpyAdd.callCount === 1)
expect(libp2p.identifyService.identify.callCount).to.equal(1)

// The connection should have no open streams
Expand Down
5 changes: 1 addition & 4 deletions test/peer-store/peer-store.node.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ describe('libp2p.peerStore', () => {
})

it('adds peer address to AddressBook and keys to the keybook when establishing connection', async () => {
const idStr = libp2p.peerId.toB58String()
const remoteIdStr = remoteLibp2p.peerId.toB58String()

const spyAddressBook = sinon.spy(libp2p.peerStore.addressBook, 'add')
Expand All @@ -44,9 +43,7 @@ describe('libp2p.peerStore', () => {
// const publicKeyInLocalPeer = localPeers.get(remoteIdStr).id.pubKey
// expect(publicKeyInLocalPeer.bytes).to.equalBytes(remoteLibp2p.peerId.pubKey.bytes)

const remotePeers = remoteLibp2p.peerStore.peers
expect(remotePeers.size).to.equal(1)
const publicKeyInRemotePeer = remotePeers.get(idStr).id.pubKey
const publicKeyInRemotePeer = remoteLibp2p.peerStore.keyBook.get(libp2p.peerId)
expect(publicKeyInRemotePeer).to.exist()
expect(publicKeyInRemotePeer.bytes).to.equalBytes(libp2p.peerId.pubKey.bytes)
})
Expand Down

0 comments on commit 2b45fee

Please sign in to comment.