Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: update ipfs-http-client peer dep #41

Merged
merged 8 commits into from
Oct 21, 2020
Merged
Show file tree
Hide file tree
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
10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@
"coverage": "aegir coverage"
},
"devDependencies": {
"aegir": "^26.0.0",
"go-ipfs": "0.6.0",
"ipfs-http-client": "^46.0.0",
"ipfs-utils": "^3.0.0",
"aegir": "^28.0.2",
"go-ipfs": "^0.7.0",
"ipfs-http-client": "^47.0.1",
"ipfs-utils": "^4.0.0",
"ipfsd-ctl": "^7.0.0",
"it-all": "^1.0.2"
},
Expand All @@ -37,7 +37,7 @@
"peer-id": "^0.14.0"
},
"peerDependencies": {
"ipfs-http-client": "^46.0.0"
"ipfs-http-client": "^47.0.1"
},
"browser": {
"go-ipfs": false
Expand Down
7 changes: 4 additions & 3 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class DelegatedPeerRouting {
*
* @param {PeerID} id
* @param {object} options
* @param {number} options.timeout How long the query can take. Defaults to 30 seconds
* @param {number} options.timeout - How long the query can take. Defaults to 30 seconds
* @returns {Promise<{ id: PeerId, multiaddrs: Multiaddr[] }>}
*/
async findPeer (id, options = {}) {
Expand Down Expand Up @@ -82,9 +82,10 @@ class DelegatedPeerRouting {

/**
* Attempt to find the closest peers on the network to the given key
* @param {Uint8Array} key A CID like key
*
* @param {Uint8Array} key - A CID like key
* @param {object} [options]
* @param {number} [options.timeout=30e3] How long the query can take.
* @param {number} [options.timeout=30e3] - How long the query can take.
* @returns {AsyncIterable<{ id: PeerId, multiaddrs: Multiaddr[] }>}
*/
async * getClosestPeers (key, options = {}) {
Expand Down
25 changes: 15 additions & 10 deletions test/index.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,16 @@ const factory = createFactory({
ipfsHttpModule: require('ipfs-http-client'),
ipfsBin: isNode ? require('go-ipfs').path() : undefined,
test: true,
disposable: true,
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should really clean up after ourselves

endpoint: 'http://localhost:57483'
})

async function spawnNode (boostrap = []) {
async function spawnNode (bootstrap = []) {
const node = await factory.spawn({
// Lock down the nodes so testing can be deterministic
ipfsOptions: {
config: {
Bootstrap: boostrap,
Discovery: {
MDNS: {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MDNS is disabled already when ipfsd is passed the test: true config option

Enabled: false
}
}
Bootstrap: bootstrap
}
}
})
Expand Down Expand Up @@ -107,7 +103,10 @@ describe('DelegatedPeerRouting', function () {
host: opts.host
}))

const { id, multiaddrs } = await router.findPeer(peerIdToFind.id)
const peer = await router.findPeer(peerIdToFind.id)
expect(peer).to.be.ok()

const { id, multiaddrs } = peer
expect(id).to.exist()
expect(multiaddrs).to.exist()
expect(id).to.eql(peerIdToFind.id)
Expand All @@ -121,7 +120,10 @@ describe('DelegatedPeerRouting', function () {
host: opts.host
}))

const { id, multiaddrs } = await router.findPeer(PeerID.createFromB58String(peerIdToFind.id))
const peer = await router.findPeer(PeerID.createFromB58String(peerIdToFind.id))
expect(peer).to.be.ok()

const { id, multiaddrs } = peer
expect(id).to.exist()
expect(multiaddrs).to.exist()

Expand All @@ -136,7 +138,10 @@ describe('DelegatedPeerRouting', function () {
host: opts.host
}))

const { id, multiaddrs } = await router.findPeer(PeerID.createFromB58String(peerIdToFind.id), { timeout: 2000 })
const peer = await router.findPeer(PeerID.createFromB58String(peerIdToFind.id), { timeout: 2000 })
expect(peer).to.be.ok()

const { id, multiaddrs } = peer
expect(id).to.exist()
expect(multiaddrs).to.exist()

Expand Down