mirror of
https://github.com/fluencelabs/js-libp2p
synced 2025-06-15 18:21:22 +00:00
feat: address and proto books (#590)
* feat: address and proto books * chore: apply suggestions from code review Co-Authored-By: Jacob Heun <jacobheun@gmail.com> * chore: minor fixes and initial tests added * chore: integrate new peer-store with code using adapters for other modules * chore: do not use peerstore.put on get-peer-info * chore: apply suggestions from code review Co-Authored-By: Jacob Heun <jacobheun@gmail.com> * chore: add new peer store tests * chore: apply suggestions from code review Co-Authored-By: Jacob Heun <jacobheun@gmail.com> Co-authored-by: Jacob Heun <jacobheun@gmail.com>
This commit is contained in:
@ -100,7 +100,10 @@ describe('Dialing (direct, TCP)', () => {
|
||||
const dialer = new Dialer({
|
||||
transportManager: localTM,
|
||||
peerStore: {
|
||||
multiaddrsForPeer: () => [remoteAddr]
|
||||
addressBook: {
|
||||
add: () => {},
|
||||
getMultiaddrsForPeer: () => [remoteAddr]
|
||||
}
|
||||
}
|
||||
})
|
||||
const peerId = await PeerId.createFromJSON(Peers[0])
|
||||
@ -121,7 +124,7 @@ describe('Dialing (direct, TCP)', () => {
|
||||
const peerId = await PeerId.createFromJSON(Peers[0])
|
||||
const peerInfo = new PeerInfo(peerId)
|
||||
peerInfo.multiaddrs.add(remoteAddr)
|
||||
peerStore.put(peerInfo)
|
||||
peerStore.addressBook.set(peerInfo.id, peerInfo.multiaddrs.toArray())
|
||||
|
||||
const connection = await dialer.connectToPeer(peerInfo)
|
||||
expect(connection).to.exist()
|
||||
@ -132,7 +135,10 @@ describe('Dialing (direct, TCP)', () => {
|
||||
const dialer = new Dialer({
|
||||
transportManager: localTM,
|
||||
peerStore: {
|
||||
multiaddrsForPeer: () => [unsupportedAddr]
|
||||
addressBook: {
|
||||
add: () => {},
|
||||
getMultiaddrsForPeer: () => [unsupportedAddr]
|
||||
}
|
||||
}
|
||||
})
|
||||
const peerId = await PeerId.createFromJSON(Peers[0])
|
||||
@ -173,7 +179,10 @@ describe('Dialing (direct, TCP)', () => {
|
||||
transportManager: localTM,
|
||||
concurrency: 2,
|
||||
peerStore: {
|
||||
multiaddrsForPeer: () => addrs
|
||||
addressBook: {
|
||||
add: () => {},
|
||||
getMultiaddrsForPeer: () => addrs
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
|
Reference in New Issue
Block a user