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

Commit

Permalink
fix: ci tests
Browse files Browse the repository at this point in the history
  • Loading branch information
vasco-santos committed Jan 30, 2019
1 parent 37140a2 commit f2e5a4d
Show file tree
Hide file tree
Showing 38 changed files with 439 additions and 232 deletions.
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@
"form-data": "^2.3.3",
"hat": "0.0.3",
"interface-ipfs-core": "~0.96.0",
"ipfsd-ctl": "~0.40.1",
"ipfsd-ctl": "~0.40.2",
"ncp": "^2.0.0",
"qs": "^6.5.2",
"rimraf": "^2.6.2",
Expand Down Expand Up @@ -128,7 +128,7 @@
"joi": "^14.3.0",
"joi-browser": "^13.4.0",
"joi-multiaddr": "^4.0.0",
"libp2p": "~0.24.1",
"libp2p": "~0.24.3",
"libp2p-bootstrap": "~0.9.3",
"libp2p-crypto": "~0.16.0",
"libp2p-kad-dht": "~0.14.4",
Expand All @@ -140,7 +140,7 @@
"libp2p-tcp": "~0.13.0",
"libp2p-webrtc-star": "~0.15.5",
"libp2p-websocket-star-multi": "~0.4.0",
"libp2p-websockets": "~0.12.0",
"libp2p-websockets": "~0.12.2",
"lodash": "^4.17.11",
"mafmt": "^6.0.2",
"mime-types": "^2.1.21",
Expand Down
13 changes: 5 additions & 8 deletions src/cli/commands/dht/find-peer.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,12 @@ module.exports = {

builder: {},

handler (argv) {
argv.ipfs.dht.findPeer(argv.peerID, (err, result) => {
if (err) {
throw err
}

const addresses = result.multiaddrs.toArray().map((ma) => ma.toString())
handler ({ ipfs, peerID, resolve }) {
resolve((async () => {
const peers = await ipfs.dht.findPeer(peerID)
const addresses = peers.multiaddrs.toArray().map((ma) => ma.toString())

print(addresses)
})
})())
}
}
11 changes: 5 additions & 6 deletions src/cli/commands/dht/find-providers.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,17 @@ module.exports = {
},

handler (argv) {
const { ipfs, key, resolve } = argv
const opts = {
maxNumProviders: argv['num-providers']
}

argv.ipfs.dht.findProvs(argv.key, opts, (err, result) => {
if (err) {
throw err
}
resolve((async () => {
const provs = await ipfs.dht.findProvs(key, opts)

result.forEach((element) => {
provs.forEach((element) => {
print(element.id.toB58String())
})
})
})())
}
}
12 changes: 5 additions & 7 deletions src/cli/commands/dht/get.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,11 @@ module.exports = {

builder: {},

handler (argv) {
argv.ipfs.dht.get(argv.key, (err, result) => {
if (err) {
throw err
}
handler ({ ipfs, key, resolve }) {
resolve((async () => {
const value = await ipfs.dht.get(key)

print(result)
})
print(value)
})())
}
}
12 changes: 6 additions & 6 deletions src/cli/commands/dht/provide.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ module.exports = {
}
},

handler (argv) {
argv.ipfs.dht.provide(argv.key, (err, result) => {
if (err) {
throw err
}
})
handler ({ ipfs, key, resolve }) {
// TODO add recursive option

resolve((async () => {
await ipfs.dht.provide(key)
})())
}
}
10 changes: 4 additions & 6 deletions src/cli/commands/dht/put.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,9 @@ module.exports = {

builder: {},

handler (argv) {
argv.ipfs.dht.put(argv.key, argv.value, (err) => {
if (err) {
throw err
}
})
handler ({ ipfs, key, value, resolve }) {
resolve((async () => {
await ipfs.dht.put(key, value)
})())
}
}
10 changes: 4 additions & 6 deletions src/cli/commands/dht/query.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,13 @@ module.exports = {

builder: {},

handler (argv) {
argv.ipfs.dht.query(argv.peerID, (err, result) => {
if (err) {
throw err
}
handler ({ ipfs, peerID, resolve }) {
resolve((async () => {
const result = await ipfs.dht.query(peerID)

result.forEach((peerID) => {
print(peerID.id.toB58String())
})
})
})())
}
}
42 changes: 21 additions & 21 deletions src/core/components/libp2p.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,37 +47,37 @@ module.exports = function libp2p (self, config) {

function defaultBundle ({ datastore, peerInfo, peerBook, options, config }) {
const libp2pDefaults = {
datastore: opts.datastore,
peerInfo: opts.peerInfo,
peerBook: opts.peerBook,
datastore,
peerInfo,
peerBook,
config: {
peerDiscovery: {
mdns: {
enabled: get(opts.options, 'config.Discovery.MDNS.Enabled',
get(opts.config, 'Discovery.MDNS.Enabled', true))
enabled: get(options, 'config.Discovery.MDNS.Enabled',
get(config, 'Discovery.MDNS.Enabled', true))
},
webRTCStar: {
enabled: get(opts.options, 'config.Discovery.webRTCStar.Enabled',
get(opts.config, 'Discovery.webRTCStar.Enabled', true))
enabled: get(options, 'config.Discovery.webRTCStar.Enabled',
get(config, 'Discovery.webRTCStar.Enabled', true))
},
bootstrap: {
list: get(opts.options, 'config.Bootstrap',
get(opts.config, 'Bootstrap', []))
list: get(options, 'config.Bootstrap',
get(config, 'Bootstrap', []))
}
},
relay: {
enabled: get(opts.options, 'relay.enabled',
get(opts.config, 'relay.enabled', false)),
enabled: get(options, 'relay.enabled',
get(config, 'relay.enabled', false)),
hop: {
enabled: get(opts.options, 'relay.hop.enabled',
get(opts.config, 'relay.hop.enabled', false)),
active: get(opts.options, 'relay.hop.active',
get(opts.config, 'relay.hop.active', false))
enabled: get(options, 'relay.hop.enabled',
get(config, 'relay.hop.enabled', false)),
active: get(options, 'relay.hop.active',
get(config, 'relay.hop.active', false))
}
},
dht: {
kBucketSize: get(opts.options, 'dht.kBucketSize', 20),
enabledDiscovery: get(opts.options, 'dht.enabledDiscovery', true),
kBucketSize: get(options, 'dht.kBucketSize', 20),
enabledDiscovery: get(options, 'dht.enabledDiscovery', true),
validators: {
ipns: ipnsUtils.validator
},
Expand All @@ -86,12 +86,12 @@ function defaultBundle ({ datastore, peerInfo, peerBook, options, config }) {
}
},
EXPERIMENTAL: {
dht: true,
pubsub: get(opts.options, 'EXPERIMENTAL.pubsub', false)
dht: !(get(options, 'local', false)),
pubsub: get(options, 'EXPERIMENTAL.pubsub', false)
}
},
connectionManager: get(opts.options, 'connectionManager',
get(opts.config, 'connectionManager', {}))
connectionManager: get(options, 'connectionManager',
get(config, 'connectionManager', {}))
}

const libp2pOptions = defaultsDeep(get(options, 'libp2p', {}), libp2pDefaults)
Expand Down
10 changes: 5 additions & 5 deletions src/core/components/pin-set.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ const protobuf = require('protons')
const fnv1a = require('fnv1a')
const varint = require('varint')
const { DAGNode, DAGLink } = require('ipld-dag-pb')
const some = require('async/some')
const eachOf = require('async/eachOf')
const someSeries = require('async/someSeries')
const eachOfSeries = require('async/eachOfSeries')

const pbSchema = require('./pin.proto')

Expand Down Expand Up @@ -69,7 +69,7 @@ exports = module.exports = function (dag) {
return searchChildren(root, callback)

function searchChildren (root, cb) {
some(root.links, ({ cid }, done) => {
someSeries(root.links, ({ cid }, done) => {
const bs58Link = toB58String(cid)

if (bs58Link === childhash) {
Expand Down Expand Up @@ -174,7 +174,7 @@ exports = module.exports = function (dag) {
return bins
}, {})

eachOf(bins, (bin, idx, eachCb) => {
eachOfSeries(bins, (bin, idx, eachCb) => {
storePins(
bin,
depth + 1,
Expand Down Expand Up @@ -233,7 +233,7 @@ exports = module.exports = function (dag) {
return callback(err)
}

eachOf(node.links, (link, idx, eachCb) => {
eachOfSeries(node.links, (link, idx, eachCb) => {
if (idx < pbh.header.fanout) {
// the first pbh.header.fanout links are fanout bins
// if a fanout bin is not 'empty', dig into and walk its DAGLinks
Expand Down
5 changes: 2 additions & 3 deletions src/core/components/start.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,8 @@ module.exports = (self) => {
ipnsStores.push(pubsubDs)
}

// DHT should be added as routing if we are not running with offline flag
// TODO: Need to change this logic once DHT is enabled by default, for now fallback to Offline datastore
if (get(self._options, 'EXPERIMENTAL.dht', false) && !self._options.offline) {
// DHT should be added as routing if we are not running with local flag
if (!self._options.offline) {
ipnsStores.push(self.libp2p.dht)
} else {
const offlineDatastore = new OfflineDatastore(self._repo)
Expand Down
10 changes: 9 additions & 1 deletion test/cli/dht.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,15 @@ const ipfsExec = require('../utils/ipfs-exec')
const daemonOpts = {
exec: `./src/cli/bin.js`,
config: {
Bootstrap: []
Bootstrap: [],
Discovery: {
MDNS: {
Enabled: false
},
webRTCStar: {
Enabled: false
}
}
},
initOptions: { bits: 512 }
}
Expand Down
13 changes: 12 additions & 1 deletion test/cli/name-pubsub.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,18 @@ const spawnDaemon = (callback) => {
df.spawn({
exec: `./src/cli/bin.js`,
args: ['--enable-namesys-pubsub'],
initOptions: { bits: 512 }
initOptions: { bits: 512 },
config: {
Bootstrap: [],
Discovery: {
MDNS: {
Enabled: false
},
webRTCStar: {
Enabled: false
}
}
}
}, callback)
}

Expand Down
14 changes: 11 additions & 3 deletions test/cli/name.js
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ describe('name', () => {
})
})

describe.skip('using dht', () => {
describe('using dht', () => {
const passPhrase = hat()
const pass = '--pass ' + passPhrase
const name = 'test-key-' + hat()
Expand All @@ -199,9 +199,17 @@ describe('name', () => {
df.spawn({
exec: `./src/cli/bin.js`,
config: {
Bootstrap: []
Bootstrap: [],
Discovery: {
MDNS: {
Enabled: false
},
webRTCStar: {
Enabled: false
}
}
},
args: ['--pass', passPhrase, '--enable-dht-experiment'],
args: ['--pass', passPhrase],
initOptions: { bits: 512 }
}, (err, _ipfsd) => {
expect(err).to.not.exist()
Expand Down
4 changes: 3 additions & 1 deletion test/core/dht.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@ describe('dht', () => {
factory.spawn({
exec: IPFS,
initOptions: { bits: 512 },
config: { Bootstrap: [] }
config: {
Bootstrap: []
}
}, (err, _ipfsd) => {
expect(err).to.not.exist()
ipfsd = _ipfsd
Expand Down
4 changes: 2 additions & 2 deletions test/core/files-sharding.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ describe('files directory (sharding tests)', () => {
})

it('should be able to add dir without sharding', function (done) {
this.timeout(40 * 1000)
this.timeout(70 * 1000)

pull(
pull.values(createTestFiles()),
Expand Down Expand Up @@ -114,7 +114,7 @@ describe('files directory (sharding tests)', () => {
})

it('should be able to add dir with sharding', function (done) {
this.timeout(40 * 1000)
this.timeout(80 * 1000)

pull(
pull.values(createTestFiles()),
Expand Down
Loading

0 comments on commit f2e5a4d

Please sign in to comment.