mirror of
https://github.com/fluencelabs/js-libp2p
synced 2025-06-30 01:11:34 +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:
@ -35,7 +35,9 @@ describe('peer discovery', () => {
|
||||
...baseOptions,
|
||||
peerInfo
|
||||
})
|
||||
libp2p.peerStore.add(remotePeerInfo)
|
||||
libp2p.peerStore.addressBook.set(remotePeerInfo.id, remotePeerInfo.multiaddrs.toArray())
|
||||
libp2p.peerStore.protoBook.set(remotePeerInfo.id, Array.from(remotePeerInfo.protocols))
|
||||
|
||||
const deferred = defer()
|
||||
sinon.stub(libp2p.dialer, 'connectToPeer').callsFake((remotePeerInfo) => {
|
||||
expect(remotePeerInfo).to.equal(remotePeerInfo)
|
||||
@ -46,7 +48,9 @@ describe('peer discovery', () => {
|
||||
|
||||
libp2p.start()
|
||||
await deferred.promise
|
||||
expect(spy.getCall(0).args).to.eql([remotePeerInfo])
|
||||
|
||||
expect(spy.calledOnce).to.eql(true)
|
||||
expect(spy.getCall(0).args[0].id.toString()).to.eql(remotePeerInfo.id.toString())
|
||||
})
|
||||
|
||||
it('should stop discovery on libp2p start/stop', async () => {
|
||||
|
Reference in New Issue
Block a user