mirror of
https://github.com/fluencelabs/js-libp2p
synced 2025-04-25 02:22:14 +00:00
fix: dht config (#359)
This commit is contained in:
parent
51cc993876
commit
f3801f0e6c
@ -48,27 +48,16 @@ const configSchema = s({
|
||||
enabled: true
|
||||
}),
|
||||
// DHT config
|
||||
dht: s({
|
||||
kBucketSize: 'number',
|
||||
enabled: 'boolean?',
|
||||
validators: 'object?',
|
||||
selectors: 'object?',
|
||||
randomWalk: optional(s({
|
||||
enabled: 'boolean?',
|
||||
queriesPerPeriod: 'number?',
|
||||
interval: 'number?',
|
||||
timeout: 'number?'
|
||||
}, {
|
||||
// random walk defaults
|
||||
enabled: false, // disabled waiting for https://github.com/libp2p/js-libp2p-kad-dht/issues/86
|
||||
queriesPerPeriod: 1,
|
||||
interval: 30000,
|
||||
timeout: 10000
|
||||
}))
|
||||
}, {
|
||||
dht: s('object?', {
|
||||
// DHT defaults
|
||||
enabled: false,
|
||||
kBucketSize: 20
|
||||
kBucketSize: 20,
|
||||
randomWalk: {
|
||||
enabled: false, // disabled waiting for https://github.com/libp2p/js-libp2p-kad-dht/issues/86
|
||||
queriesPerPeriod: 1,
|
||||
interval: 300e3,
|
||||
timeout: 10e3
|
||||
}
|
||||
}),
|
||||
// Experimental config
|
||||
EXPERIMENTAL: s({
|
||||
@ -77,11 +66,7 @@ const configSchema = s({
|
||||
// Experimental defaults
|
||||
pubsub: false
|
||||
})
|
||||
}, {
|
||||
relay: {},
|
||||
dht: {},
|
||||
EXPERIMENTAL: {}
|
||||
})
|
||||
}, {})
|
||||
|
||||
const optionsSchema = s({
|
||||
switch: 'object?',
|
||||
|
@ -91,7 +91,7 @@ describe('configuration', () => {
|
||||
randomWalk: {
|
||||
enabled: false,
|
||||
queriesPerPeriod: 1,
|
||||
interval: 30000,
|
||||
interval: 300000,
|
||||
timeout: 10000
|
||||
}
|
||||
},
|
||||
@ -153,7 +153,7 @@ describe('configuration', () => {
|
||||
randomWalk: {
|
||||
enabled: false,
|
||||
queriesPerPeriod: 1,
|
||||
interval: 30000,
|
||||
interval: 300000,
|
||||
timeout: 10000
|
||||
}
|
||||
},
|
||||
@ -242,7 +242,7 @@ describe('configuration', () => {
|
||||
expect(() => validateConfig(options)).to.throw()
|
||||
})
|
||||
|
||||
it('should add defaults, validators and selectors for dht', () => {
|
||||
it('should be able to add validators and selectors for dht', () => {
|
||||
const selectors = {}
|
||||
const validators = {}
|
||||
|
||||
@ -283,14 +283,6 @@ describe('configuration', () => {
|
||||
}
|
||||
},
|
||||
dht: {
|
||||
kBucketSize: 20,
|
||||
enabled: false,
|
||||
randomWalk: {
|
||||
enabled: false,
|
||||
queriesPerPeriod: 1,
|
||||
interval: 30000,
|
||||
timeout: 10000
|
||||
},
|
||||
selectors,
|
||||
validators
|
||||
}
|
||||
@ -298,4 +290,43 @@ describe('configuration', () => {
|
||||
}
|
||||
expect(validateConfig(options)).to.deep.equal(expected)
|
||||
})
|
||||
|
||||
it('should support new properties for the dht config', () => {
|
||||
const options = {
|
||||
peerInfo,
|
||||
modules: {
|
||||
transport: [WS],
|
||||
dht: DHT
|
||||
},
|
||||
config: {
|
||||
dht: {
|
||||
kBucketSize: 20,
|
||||
enabled: false,
|
||||
myNewDHTConfigProperty: true,
|
||||
randomWalk: {
|
||||
enabled: false,
|
||||
queriesPerPeriod: 1,
|
||||
interval: 300000,
|
||||
timeout: 10000
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const expected = {
|
||||
kBucketSize: 20,
|
||||
enabled: false,
|
||||
myNewDHTConfigProperty: true,
|
||||
randomWalk: {
|
||||
enabled: false,
|
||||
queriesPerPeriod: 1,
|
||||
interval: 300000,
|
||||
timeout: 10000
|
||||
}
|
||||
}
|
||||
|
||||
const actual = validateConfig(options).config.dht
|
||||
|
||||
expect(actual).to.deep.equal(expected)
|
||||
})
|
||||
})
|
||||
|
Loading…
x
Reference in New Issue
Block a user