Skip to content
This repository was archived by the owner on Feb 12, 2024. It is now read-only.

Commit 656c375

Browse files
author
Alan Shaw
committed
fix: tests
License: MIT Signed-off-by: Alan Shaw <[email protected]>
1 parent ea14bbc commit 656c375

File tree

2 files changed

+27
-5
lines changed

2 files changed

+27
-5
lines changed

src/core/ipns/routing/config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ module.exports = (ipfs) => {
2222
}
2323

2424
// DHT should not be added as routing if we are offline or it is disabled
25-
if (get(ipfs._options, 'offline') || !get(ipfs._options, 'libp2p.dht.enabled', false)) {
25+
if (get(ipfs._options, 'offline') || !get(ipfs._options, 'libp2p.dht.enabled', true)) {
2626
const offlineDatastore = new OfflineDatastore(ipfs._repo)
2727
ipnsStores.push(offlineDatastore)
2828
} else {

test/core/name.js

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -537,8 +537,16 @@ describe('name', function () {
537537
})
538538

539539
describe('ipns.routing', function () {
540-
it('should use only the offline datastore by default', function (done) {
541-
const ipfs = {}
540+
it('should use offline datastore if DHT is disabled', function (done) {
541+
const ipfs = {
542+
_options: {
543+
libp2p: {
544+
dht: {
545+
enabled: false
546+
}
547+
}
548+
}
549+
}
542550
const config = ipnsRouting(ipfs)
543551

544552
expect(config.stores).to.have.lengthOf(1)
@@ -562,8 +570,11 @@ describe('name', function () {
562570
})
563571

564572
it('should use the pubsub datastore if enabled', function (done) {
573+
const dht = {}
574+
565575
const ipfs = {
566576
libp2p: {
577+
dht,
567578
pubsub: {}
568579
},
569580
_peerInfo: {
@@ -581,8 +592,8 @@ describe('name', function () {
581592
const config = ipnsRouting(ipfs)
582593

583594
expect(config.stores).to.have.lengthOf(2)
584-
expect(config.stores[0] instanceof PubsubDatastore).to.eql(true)
585-
expect(config.stores[1] instanceof OfflineDatastore).to.eql(true)
595+
expect(config.stores.some(s => s instanceof PubsubDatastore)).to.eql(true)
596+
expect(config.stores).to.include(dht)
586597

587598
done()
588599
})
@@ -616,5 +627,16 @@ describe('name', function () {
616627

617628
done()
618629
})
630+
631+
it('should use the dht by default', function (done) {
632+
const dht = {}
633+
const ipfs = { libp2p: { dht } }
634+
const config = ipnsRouting(ipfs)
635+
636+
expect(config.stores).to.have.lengthOf(1)
637+
expect(config.stores[0]).to.eql(dht)
638+
639+
done()
640+
})
619641
})
620642
})

0 commit comments

Comments
 (0)