mirror of
https://github.com/fluencelabs/js-libp2p
synced 2025-04-25 10:32:14 +00:00
fix: onConnect should not add addr to the addressBook
This commit is contained in:
parent
8bf5a70bb8
commit
2b45fee0ed
@ -182,7 +182,6 @@ class ConnectionManager extends EventEmitter {
|
|||||||
this.emit('peer:connect', connection)
|
this.emit('peer:connect', connection)
|
||||||
}
|
}
|
||||||
|
|
||||||
this._libp2p.peerStore.addressBook.add(peerId, [connection.remoteAddr])
|
|
||||||
this._libp2p.peerStore.keyBook.set(peerId, peerId.pubKey)
|
this._libp2p.peerStore.keyBook.set(peerId, peerId.pubKey)
|
||||||
|
|
||||||
if (!this._peerValues.has(peerIdStr)) {
|
if (!this._peerValues.has(peerIdStr)) {
|
||||||
|
@ -242,8 +242,8 @@ describe('Identify', () => {
|
|||||||
expect(connection).to.exist()
|
expect(connection).to.exist()
|
||||||
|
|
||||||
// Wait for peer store to be updated
|
// Wait for peer store to be updated
|
||||||
// Dialer._createDialTarget (add), Connected (add), Identify (replace)
|
// Dialer._createDialTarget (add), Identify (replace)
|
||||||
await pWaitFor(() => peerStoreSpySet.callCount === 1 && peerStoreSpyAdd.callCount === 2)
|
await pWaitFor(() => peerStoreSpySet.callCount === 1 && peerStoreSpyAdd.callCount === 1)
|
||||||
expect(libp2p.identifyService.identify.callCount).to.equal(1)
|
expect(libp2p.identifyService.identify.callCount).to.equal(1)
|
||||||
|
|
||||||
// The connection should have no open streams
|
// The connection should have no open streams
|
||||||
|
@ -24,7 +24,6 @@ describe('libp2p.peerStore', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
it('adds peer address to AddressBook and keys to the keybook when establishing connection', async () => {
|
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 remoteIdStr = remoteLibp2p.peerId.toB58String()
|
||||||
|
|
||||||
const spyAddressBook = sinon.spy(libp2p.peerStore.addressBook, 'add')
|
const spyAddressBook = sinon.spy(libp2p.peerStore.addressBook, 'add')
|
||||||
@ -44,9 +43,7 @@ describe('libp2p.peerStore', () => {
|
|||||||
// const publicKeyInLocalPeer = localPeers.get(remoteIdStr).id.pubKey
|
// const publicKeyInLocalPeer = localPeers.get(remoteIdStr).id.pubKey
|
||||||
// expect(publicKeyInLocalPeer.bytes).to.equalBytes(remoteLibp2p.peerId.pubKey.bytes)
|
// expect(publicKeyInLocalPeer.bytes).to.equalBytes(remoteLibp2p.peerId.pubKey.bytes)
|
||||||
|
|
||||||
const remotePeers = remoteLibp2p.peerStore.peers
|
const publicKeyInRemotePeer = remoteLibp2p.peerStore.keyBook.get(libp2p.peerId)
|
||||||
expect(remotePeers.size).to.equal(1)
|
|
||||||
const publicKeyInRemotePeer = remotePeers.get(idStr).id.pubKey
|
|
||||||
expect(publicKeyInRemotePeer).to.exist()
|
expect(publicKeyInRemotePeer).to.exist()
|
||||||
expect(publicKeyInRemotePeer.bytes).to.equalBytes(libp2p.peerId.pubKey.bytes)
|
expect(publicKeyInRemotePeer.bytes).to.equalBytes(libp2p.peerId.pubKey.bytes)
|
||||||
})
|
})
|
||||||
|
Loading…
x
Reference in New Issue
Block a user