fix: onConnect should not add addr to the addressBook

This commit is contained in:
Vasco Santos 2020-05-13 10:30:57 +02:00 committed by Jacob Heun
parent 8bf5a70bb8
commit 2b45fee0ed
3 changed files with 3 additions and 7 deletions

View File

@ -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)) {

View File

@ -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

View File

@ -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')
@ -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)
})