fix: improve config defaults (#409)

This removes defaults from superstruct and instead uses
mergeOptions to deeply set the defaults on configuration.
This ensures that defaults are properly set.

This is a step toward removing superstruct altogether, #406,
but it is still being used for basic type validation.
This commit is contained in:
Jacob Heun
2019-08-21 16:44:30 +02:00
committed by GitHub
parent b3deb356f1
commit 3eef695bc0
4 changed files with 64 additions and 50 deletions

View File

@ -125,6 +125,15 @@ describe('configuration', () => {
interval: 1000,
enabled: true
}
},
dht: {
enabled: false
},
relay: {
enabled: true
},
pubsub: {
enabled: true
}
}
}
@ -292,6 +301,14 @@ describe('configuration', () => {
}
},
dht: {
kBucketSize: 20,
enabled: false,
randomWalk: {
enabled: false,
queriesPerPeriod: 1,
interval: 300000,
timeout: 10000
},
selectors,
validators
}

View File

@ -376,7 +376,7 @@ describe('.pubsub', () => {
constructor (node, config) {
expect(config).to.be.eql({
enabled: true,
selfEmit: false,
emitSelf: false,
signMessages: false,
strictSigning: false
}).mark()
@ -390,7 +390,7 @@ describe('.pubsub', () => {
config: {
pubsub: {
enabled: true,
selfEmit: false,
emitSelf: false,
signMessages: false,
strictSigning: false
}
@ -408,7 +408,7 @@ describe('.pubsub', () => {
constructor (node, config) {
expect(config).to.be.eql({
enabled: true,
selfEmit: true,
emitSelf: true,
signMessages: true,
strictSigning: true
}).mark()
@ -422,7 +422,7 @@ describe('.pubsub', () => {
config: {
pubsub: {
enabled: true,
selfEmit: true,
emitSelf: true,
signMessages: true,
strictSigning: true
}