diff --git a/src/core/config.js b/src/core/config.js index 422b92fef9..1d40e862c5 100644 --- a/src/core/config.js +++ b/src/core/config.js @@ -55,8 +55,8 @@ const configSchema = s({ Addresses: optional(s({ Delegates: optional(s(['multiaddr'])), Swarm: optional(s(['multiaddr'])), - API: 'multiaddr?', - Gateway: 'multiaddr' + API: optional(union([s('multiaddr'), s(['multiaddr'])])), + Gateway: optional(union([s('multiaddr'), s(['multiaddr'])])) })), Discovery: optional(s({ MDNS: optional(s({ @@ -67,7 +67,13 @@ const configSchema = s({ Enabled: 'boolean?' })) })), - Bootstrap: optional(s(['multiaddr-ipfs'])) + Bootstrap: optional(s(['multiaddr-ipfs'])), + Swarm: optional(s({ + ConnMgr: optional(s({ + LowWater: 'number?', + HighWater: 'number?' + })) + })) })), ipld: 'object?', libp2p: optional(union(['function', 'object'])) // libp2p validates this diff --git a/test/core/config.spec.js b/test/core/config.spec.js index 65abe05e5b..8f2e643e1c 100644 --- a/test/core/config.spec.js +++ b/test/core/config.spec.js @@ -123,11 +123,17 @@ describe('config', () => { { config: { Addresses: { Swarm: undefined } } }, { config: { Addresses: { API: '/ip4/127.0.0.1/tcp/5002' } } }, + { config: { Addresses: { API: ['/ip4/127.0.0.1/tcp/5002', '/ip4/127.0.0.1/tcp/5003'] } } }, { config: { Addresses: { API: undefined } } }, { config: { Addresses: { Gateway: '/ip4/127.0.0.1/tcp/9090' } } }, + { config: { Addresses: { Gateway: ['/ip4/127.0.0.1/tcp/9090', '/ip4/127.0.0.1/tcp/9091'] } } }, { config: { Addresses: { Gateway: undefined } } }, + { config: { Addresses: { Delegates: ['/dns4/node0.preload.ipfs.io/tcp/443/https'] } } }, + { config: { Addresses: { Delegates: [] } } }, + { config: { Addresses: { Delegates: undefined } } }, + { config: { Addresses: undefined } }, { config: { Discovery: { MDNS: { Enabled: true } } } }, @@ -144,9 +150,10 @@ describe('config', () => { { config: { Bootstrap: ['/ip4/104.236.176.52/tcp/4001/ipfs/QmSoLnSGccFuZQJzRadHn95W2CrSFmZuTdDWP8HXaHca9z'] } }, { config: { Bootstrap: [] } }, - { config: { Addresses: { Delegates: ['/dns4/node0.preload.ipfs.io/tcp/443/https'] } } }, - { config: { Addresses: { Delegates: [] } } }, - { config: { Addresses: { Delegates: undefined } } }, + { config: { Swarm: { ConnMgr: { LowWater: 200, HighWater: 500 } } } }, + { config: { Swarm: { ConnMgr: { LowWater: undefined, HighWater: undefined } } } }, + { config: { Swarm: { ConnMgr: undefined } } }, + { config: { Swarm: undefined } }, { config: undefined } ] @@ -173,6 +180,11 @@ describe('config', () => { { config: { Bootstrap: ['/ip4/0.0.0.0/tcp/4002'] } }, { config: { Bootstrap: 138 } }, + { config: { Swarm: { ConnMgr: { LowWater: 200, HighWater: {} } } } }, + { config: { Swarm: { ConnMgr: { LowWater: {}, HighWater: 500 } } } }, + { config: { Swarm: { ConnMgr: 138 } } }, + { config: { Swarm: 138 } }, + { config: 138 } ]