diff --git a/package.json b/package.json index bd10e42d64..7c797de833 100644 --- a/package.json +++ b/package.json @@ -72,7 +72,7 @@ "execa": "^1.0.0", "form-data": "^2.3.3", "hat": "0.0.3", - "interface-ipfs-core": "~0.104.0", + "interface-ipfs-core": "~0.104.2", "ipfsd-ctl": "~0.42.0", "libp2p-websocket-star": "~0.10.2", "ncp": "^2.0.0", diff --git a/src/core/components/libp2p.js b/src/core/components/libp2p.js index 3ca4b525f3..179abfb67b 100644 --- a/src/core/components/libp2p.js +++ b/src/core/components/libp2p.js @@ -66,10 +66,9 @@ function defaultBundle ({ datastore, peerInfo, peerBook, options, config }) { }, dht: { kBucketSize: get(options, 'dht.kBucketSize', 20), - // enabled: !get(options, 'offline', false), // disable if offline, on by default - enabled: false, + enabled: !get(options, 'offline', false), // disable if offline, on by default randomWalk: { - enabled: false // disabled waiting for https://github.com/libp2p/js-libp2p-kad-dht/issues/86 + enabled: true }, validators: { ipns: ipnsUtils.validator diff --git a/src/core/ipns/routing/config.js b/src/core/ipns/routing/config.js index 7faa469258..2407c0d3cb 100644 --- a/src/core/ipns/routing/config.js +++ b/src/core/ipns/routing/config.js @@ -22,7 +22,7 @@ module.exports = (ipfs) => { } // DHT should not be added as routing if we are offline or it is disabled - if (get(ipfs._options, 'offline') || !get(ipfs._options, 'libp2p.dht.enabled', false)) { + if (get(ipfs._options, 'offline') || !get(ipfs._options, 'libp2p.dht.enabled', true)) { const offlineDatastore = new OfflineDatastore(ipfs._repo) ipnsStores.push(offlineDatastore) } else { diff --git a/src/core/runtime/config-browser.js b/src/core/runtime/config-browser.js index 1ddbc0d717..c6282c01fb 100644 --- a/src/core/runtime/config-browser.js +++ b/src/core/runtime/config-browser.js @@ -28,8 +28,8 @@ module.exports = () => ({ ], Swarm: { ConnMgr: { - LowWater: 200, - HighWater: 500 + LowWater: 20, + HighWater: 50 } } }) diff --git a/src/core/runtime/libp2p-browser.js b/src/core/runtime/libp2p-browser.js index f05f87cebc..3d2def0df9 100644 --- a/src/core/runtime/libp2p-browser.js +++ b/src/core/runtime/libp2p-browser.js @@ -62,7 +62,15 @@ class Node extends libp2p { } }, dht: { - enabled: false + enabled: true, + concurrency: 3, + kBucketSize: 20, + randomWalk: { + enabled: false, + interval: 600e3, // 10minutes + delay: 10e3, + timeout: 30e3 + } }, EXPERIMENTAL: { pubsub: false diff --git a/src/core/runtime/libp2p-nodejs.js b/src/core/runtime/libp2p-nodejs.js index eb281a034a..26ee66cb91 100644 --- a/src/core/runtime/libp2p-nodejs.js +++ b/src/core/runtime/libp2p-nodejs.js @@ -62,9 +62,13 @@ class Node extends libp2p { }, dht: { kBucketSize: 20, - enabled: false, + enabled: true, + concurrency: 4, randomWalk: { - enabled: false + enabled: true, + interval: 600e3, + delay: 5e3, + timeout: 20e3 } }, EXPERIMENTAL: { diff --git a/test/cli/dht.js b/test/cli/dht.js index f772ebc6af..9a1e9923e7 100644 --- a/test/cli/dht.js +++ b/test/cli/dht.js @@ -31,8 +31,7 @@ const daemonOpts = { initOptions: { bits: 512 } } -// TODO: unskip when DHT is enabled in 0.36 -describe.skip('dht', () => { +describe('dht', () => { let nodes = [] let ipfsA let ipfsB diff --git a/test/core/dht.spec.js b/test/core/dht.spec.js index ba437a28bc..b1a3207429 100644 --- a/test/core/dht.spec.js +++ b/test/core/dht.spec.js @@ -12,8 +12,7 @@ const isNode = require('detect-node') const IPFSFactory = require('ipfsd-ctl') const IPFS = require('../../src/core') -// TODO: unskip when DHT is enabled in 0.36 -describe.skip('dht', () => { +describe('dht', () => { describe('enabled', () => { let ipfsd, ipfs diff --git a/test/core/interface.spec.js b/test/core/interface.spec.js index df572c19e2..c323b1be31 100644 --- a/test/core/interface.spec.js +++ b/test/core/interface.spec.js @@ -57,9 +57,7 @@ describe('interface-ipfs-core tests', function () { initOptions: { bits: 512 } } }), { - skip: { - reason: 'TODO: unskip when DHT is enabled in 0.36' - } + skip: !isNode }) tests.filesRegular(defaultCommonFactory, { diff --git a/test/core/name.js b/test/core/name.js index 99b8257251..74d8b492b0 100644 --- a/test/core/name.js +++ b/test/core/name.js @@ -196,8 +196,7 @@ describe('name', function () { }) }) - // TODO: unskip when DHT is enabled in 0.36 - describe.skip('work with dht', () => { + describe('work with dht', () => { let nodes let nodeA let nodeB @@ -538,8 +537,16 @@ describe('name', function () { }) describe('ipns.routing', function () { - it('should use only the offline datastore by default', function (done) { - const ipfs = {} + it('should use offline datastore if DHT is disabled', function (done) { + const ipfs = { + _options: { + libp2p: { + dht: { + enabled: false + } + } + } + } const config = ipnsRouting(ipfs) expect(config.stores).to.have.lengthOf(1) @@ -563,8 +570,11 @@ describe('name', function () { }) it('should use the pubsub datastore if enabled', function (done) { + const dht = {} + const ipfs = { libp2p: { + dht, pubsub: {} }, _peerInfo: { @@ -582,8 +592,8 @@ describe('name', function () { const config = ipnsRouting(ipfs) expect(config.stores).to.have.lengthOf(2) - expect(config.stores[0] instanceof PubsubDatastore).to.eql(true) - expect(config.stores[1] instanceof OfflineDatastore).to.eql(true) + expect(config.stores.some(s => s instanceof PubsubDatastore)).to.eql(true) + expect(config.stores).to.include(dht) done() }) @@ -617,5 +627,16 @@ describe('name', function () { done() }) + + it('should use the dht by default', function (done) { + const dht = {} + const ipfs = { libp2p: { dht } } + const config = ipnsRouting(ipfs) + + expect(config.stores).to.have.lengthOf(1) + expect(config.stores[0]).to.eql(dht) + + done() + }) }) }) diff --git a/test/core/ping.spec.js b/test/core/ping.spec.js index 6d04792013..149f98246c 100644 --- a/test/core/ping.spec.js +++ b/test/core/ping.spec.js @@ -194,8 +194,7 @@ describe('ping', function () { }) }) - // TODO: unskip when DHT enabled in 0.36 - describe.skip('DHT enabled', function () { + describe('DHT enabled', function () { // Our bootstrap process will run 3 IPFS daemons where // A ----> B ----> C // Allowing us to test the ping command using the DHT peer routing diff --git a/test/http-api/inject/dht.js b/test/http-api/inject/dht.js index c57deaecd0..455a4bb8b1 100644 --- a/test/http-api/inject/dht.js +++ b/test/http-api/inject/dht.js @@ -8,8 +8,7 @@ const expect = chai.expect chai.use(dirtyChai) module.exports = (http) => { - // TODO: unskip when DHT is enabled in 0.36 - describe.skip('/dht', () => { + describe('/dht', () => { let api before(() => { diff --git a/test/http-api/interface.js b/test/http-api/interface.js index 43c6ff6a12..b5fe189bb8 100644 --- a/test/http-api/interface.js +++ b/test/http-api/interface.js @@ -48,11 +48,7 @@ describe('interface-ipfs-core over ipfs-http-client tests', () => { } } } - }), { - skip: { - reason: 'TODO: unskip when DHT is enabled in 0.36' - } - }) + })) tests.filesRegular(defaultCommonFactory)