mirror of
https://github.com/fluencelabs/js-libp2p
synced 2025-04-30 13:02:15 +00:00
- Upgrades @multiformats/multiaddr to 11.0.0 - Removes ipfs-http-client and delegate router dependencies - Test delegation using interface stubs instead of implementations
52 lines
1.2 KiB
TypeScript
52 lines
1.2 KiB
TypeScript
/* eslint-env mocha */
|
|
|
|
import { WebSockets } from '@libp2p/websockets'
|
|
import { Plaintext } from '../../src/insecure/index.js'
|
|
import { createPeerId } from '../utils/creators/peer.js'
|
|
import { multiaddr } from '@multiformats/multiaddr'
|
|
import { createLibp2pNode, Libp2pNode } from '../../src/libp2p.js'
|
|
import type { Libp2pOptions } from '../../src/index.js'
|
|
|
|
describe('Consume peer record', () => {
|
|
let libp2p: Libp2pNode
|
|
|
|
beforeEach(async () => {
|
|
const peerId = await createPeerId()
|
|
const config: Libp2pOptions = {
|
|
peerId,
|
|
transports: [
|
|
new WebSockets()
|
|
],
|
|
connectionEncryption: [
|
|
new Plaintext()
|
|
]
|
|
}
|
|
libp2p = await createLibp2pNode(config)
|
|
})
|
|
|
|
afterEach(async () => {
|
|
await libp2p.stop()
|
|
})
|
|
|
|
it('should consume peer record when observed addrs are added', async () => {
|
|
let done: () => void
|
|
|
|
libp2p.components.getPeerStore().addressBook.consumePeerRecord = async () => {
|
|
done()
|
|
return true
|
|
}
|
|
|
|
const p = new Promise<void>(resolve => {
|
|
done = resolve
|
|
})
|
|
|
|
await libp2p.start()
|
|
|
|
libp2p.components.getAddressManager().addObservedAddr(multiaddr('/ip4/123.123.123.123/tcp/3983'))
|
|
|
|
await p
|
|
|
|
await libp2p.stop()
|
|
})
|
|
})
|