feat: auto dial discovered peers (#349)

This commit is contained in:
Jacob Heun
2019-04-11 12:44:58 +02:00
committed by GitHub
parent 8b627797e2
commit 01aa44724e
12 changed files with 430 additions and 153 deletions

View File

@ -58,6 +58,56 @@ describe('configuration', () => {
}).to.throw('ERROR_EMPTY')
})
it('should add defaults to config', () => {
const options = {
peerInfo,
modules: {
transport: [ WS ],
peerDiscovery: [ Bootstrap ],
dht: DHT
}
}
const expected = {
peerInfo,
connectionManager: {
minPeers: 25
},
modules: {
transport: [ WS ],
peerDiscovery: [ Bootstrap ],
dht: DHT
},
config: {
peerDiscovery: {
autoDial: true
},
EXPERIMENTAL: {
pubsub: false
},
dht: {
kBucketSize: 20,
enabled: false,
randomWalk: {
enabled: false,
queriesPerPeriod: 1,
interval: 30000,
timeout: 10000
}
},
relay: {
enabled: true,
hop: {
active: false,
enabled: false
}
}
}
}
expect(validateConfig(options)).to.deep.equal(expected)
})
it('should add defaults to missing items', () => {
const options = {
peerInfo,
@ -78,6 +128,9 @@ describe('configuration', () => {
const expected = {
peerInfo,
connectionManager: {
minPeers: 25
},
modules: {
transport: [ WS ],
peerDiscovery: [ Bootstrap ],
@ -85,6 +138,7 @@ describe('configuration', () => {
},
config: {
peerDiscovery: {
autoDial: true,
bootstrap: {
interval: 1000,
enabled: true
@ -180,6 +234,9 @@ describe('configuration', () => {
}
const expected = {
peerInfo,
connectionManager: {
minPeers: 25
},
modules: {
transport: [WS],
dht: DHT
@ -188,6 +245,9 @@ describe('configuration', () => {
EXPERIMENTAL: {
pubsub: false
},
peerDiscovery: {
autoDial: true
},
relay: {
enabled: true,
hop: {