Skip to content
This repository has been archived by the owner on Apr 29, 2020. It is now read-only.

Support dialing without knowledge of the peerId (go-ipfs interop) #16

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 58 additions & 0 deletions test/libp2p.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,64 @@ describe('libp2p-ipfs', () => {
})
})

it('libp2p.dialByMultiaddr nodeA to nodeB without /ipfs/Qm on multiaddr', (done) => {
// TODO
// dial to nodeB (without the Id)
// hangup nodeB

const nodeBMultiaddrTCPStripped = nodeBMultiaddrTCP.decapsulate('ipfs')

nodeA.dialByMultiaddr(nodeBMultiaddrTCPStripped, (err) => {
expect(err).to.not.exist
// Some time for Identify to finish
setTimeout(check, 500)

function check () {
parallel([
(cb) => {
const peers = nodeA.peerBook.getAll()
expect(err).to.not.exist
expect(Object.keys(peers)).to.have.length(1)
cb()
},
(cb) => {
const peers = nodeB.peerBook.getAll()
expect(err).to.not.exist
expect(Object.keys(peers)).to.have.length(1)
cb()
}
], hangUp)
}
})

function hangUp () {
nodeA.hangUpByMultiaddr(nodeBMultiaddrTCP, (err) => {
expect(err).to.not.exist
setTimeout(check, 500)

function check () {
parallel([
(cb) => {
const peers = nodeA.peerBook.getAll()
expect(err).to.not.exist
expect(Object.keys(peers)).to.have.length(0)
expect(Object.keys(nodeA.swarm.muxedConns)).to.have.length(0)

cb()
},
(cb) => {
const peers = nodeB.peerBook.getAll()
expect(err).to.not.exist
expect(Object.keys(peers)).to.have.length(0)
expect(Object.keys(nodeB.swarm.muxedConns)).to.have.length(0)
cb()
}
], done)
}
})
}
})

it('libp2p.dialByPeerInfo nodeA to nodeB', (done) => {
nodeA.dialByPeerInfo(nodeB.peerInfo, (err) => {
expect(err).to.not.exist
Expand Down