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

Commit e859a81

Browse files
committed
fix: ci tests
1 parent 37af8ca commit e859a81

36 files changed

+408
-141
lines changed

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@
7272
"form-data": "^2.3.3",
7373
"hat": "0.0.3",
7474
"interface-ipfs-core": "~0.96.0",
75-
"ipfsd-ctl": "~0.40.1",
75+
"ipfsd-ctl": "~0.40.2",
7676
"ncp": "^2.0.0",
7777
"qs": "^6.5.2",
7878
"rimraf": "^2.6.2",
@@ -128,7 +128,7 @@
128128
"joi": "^14.3.0",
129129
"joi-browser": "^13.4.0",
130130
"joi-multiaddr": "^4.0.0",
131-
"libp2p": "~0.24.1",
131+
"libp2p": "~0.24.3",
132132
"libp2p-bootstrap": "~0.9.3",
133133
"libp2p-crypto": "~0.16.0",
134134
"libp2p-kad-dht": "~0.14.4",
@@ -140,7 +140,7 @@
140140
"libp2p-tcp": "~0.13.0",
141141
"libp2p-webrtc-star": "~0.15.5",
142142
"libp2p-websocket-star-multi": "~0.4.0",
143-
"libp2p-websockets": "~0.12.0",
143+
"libp2p-websockets": "~0.12.2",
144144
"lodash": "^4.17.11",
145145
"mafmt": "^6.0.2",
146146
"mime-types": "^2.1.21",

src/cli/commands/dht/find-peer.js

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,12 @@ module.exports = {
99

1010
builder: {},
1111

12-
handler (argv) {
13-
argv.ipfs.dht.findPeer(argv.peerID, (err, result) => {
14-
if (err) {
15-
throw err
16-
}
17-
18-
const addresses = result.multiaddrs.toArray().map((ma) => ma.toString())
12+
handler ({ ipfs, peerID, resolve }) {
13+
resolve((async () => {
14+
const peers = await ipfs.dht.findPeer(peerID)
15+
const addresses = peers.multiaddrs.toArray().map((ma) => ma.toString())
1916

2017
print(addresses)
21-
})
18+
})())
2219
}
2320
}

src/cli/commands/dht/find-providers.js

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,18 +16,17 @@ module.exports = {
1616
},
1717

1818
handler (argv) {
19+
const { ipfs, key, resolve } = argv
1920
const opts = {
2021
maxNumProviders: argv['num-providers']
2122
}
2223

23-
argv.ipfs.dht.findProvs(argv.key, opts, (err, result) => {
24-
if (err) {
25-
throw err
26-
}
24+
resolve((async () => {
25+
const provs = await ipfs.dht.findProvs(key, opts)
2726

28-
result.forEach((element) => {
27+
provs.forEach((element) => {
2928
print(element.id.toB58String())
3029
})
31-
})
30+
})())
3231
}
3332
}

src/cli/commands/dht/get.js

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,11 @@ module.exports = {
99

1010
builder: {},
1111

12-
handler (argv) {
13-
argv.ipfs.dht.get(argv.key, (err, result) => {
14-
if (err) {
15-
throw err
16-
}
12+
handler ({ ipfs, key, resolve }) {
13+
resolve((async () => {
14+
const value = await ipfs.dht.get(key)
1715

18-
print(result)
19-
})
16+
print(value)
17+
})())
2018
}
2119
}

src/cli/commands/dht/provide.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,11 @@ module.exports = {
1313
}
1414
},
1515

16-
handler (argv) {
17-
argv.ipfs.dht.provide(argv.key, (err, result) => {
18-
if (err) {
19-
throw err
20-
}
21-
})
16+
handler ({ ipfs, key, resolve }) {
17+
// TODO add recursive option
18+
19+
resolve((async () => {
20+
await ipfs.dht.provide(key)
21+
})())
2222
}
2323
}

src/cli/commands/dht/put.js

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,9 @@ module.exports = {
77

88
builder: {},
99

10-
handler (argv) {
11-
argv.ipfs.dht.put(argv.key, argv.value, (err) => {
12-
if (err) {
13-
throw err
14-
}
15-
})
10+
handler ({ ipfs, key, value, resolve }) {
11+
resolve((async () => {
12+
await ipfs.dht.put(key, value)
13+
})())
1614
}
1715
}

src/cli/commands/dht/query.js

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,13 @@ module.exports = {
99

1010
builder: {},
1111

12-
handler (argv) {
13-
argv.ipfs.dht.query(argv.peerID, (err, result) => {
14-
if (err) {
15-
throw err
16-
}
12+
handler ({ ipfs, peerID, resolve }) {
13+
resolve((async () => {
14+
const result = await ipfs.dht.query(peerID)
1715

1816
result.forEach((peerID) => {
1917
print(peerID.id.toB58String())
2018
})
21-
})
19+
})())
2220
}
2321
}

src/core/components/libp2p.js

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -47,37 +47,37 @@ module.exports = function libp2p (self, config) {
4747

4848
function defaultBundle ({ datastore, peerInfo, peerBook, options, config }) {
4949
const libp2pDefaults = {
50-
datastore: opts.datastore,
51-
peerInfo: opts.peerInfo,
52-
peerBook: opts.peerBook,
50+
datastore,
51+
peerInfo,
52+
peerBook,
5353
config: {
5454
peerDiscovery: {
5555
mdns: {
56-
enabled: get(opts.options, 'config.Discovery.MDNS.Enabled',
57-
get(opts.config, 'Discovery.MDNS.Enabled', true))
56+
enabled: get(options, 'config.Discovery.MDNS.Enabled',
57+
get(config, 'Discovery.MDNS.Enabled', true))
5858
},
5959
webRTCStar: {
60-
enabled: get(opts.options, 'config.Discovery.webRTCStar.Enabled',
61-
get(opts.config, 'Discovery.webRTCStar.Enabled', true))
60+
enabled: get(options, 'config.Discovery.webRTCStar.Enabled',
61+
get(config, 'Discovery.webRTCStar.Enabled', true))
6262
},
6363
bootstrap: {
64-
list: get(opts.options, 'config.Bootstrap',
65-
get(opts.config, 'Bootstrap', []))
64+
list: get(options, 'config.Bootstrap',
65+
get(config, 'Bootstrap', []))
6666
}
6767
},
6868
relay: {
69-
enabled: get(opts.options, 'relay.enabled',
70-
get(opts.config, 'relay.enabled', false)),
69+
enabled: get(options, 'relay.enabled',
70+
get(config, 'relay.enabled', false)),
7171
hop: {
72-
enabled: get(opts.options, 'relay.hop.enabled',
73-
get(opts.config, 'relay.hop.enabled', false)),
74-
active: get(opts.options, 'relay.hop.active',
75-
get(opts.config, 'relay.hop.active', false))
72+
enabled: get(options, 'relay.hop.enabled',
73+
get(config, 'relay.hop.enabled', false)),
74+
active: get(options, 'relay.hop.active',
75+
get(config, 'relay.hop.active', false))
7676
}
7777
},
7878
dht: {
79-
kBucketSize: get(opts.options, 'dht.kBucketSize', 20),
80-
enabledDiscovery: get(opts.options, 'dht.enabledDiscovery', true),
79+
kBucketSize: get(options, 'dht.kBucketSize', 20),
80+
enabledDiscovery: get(options, 'dht.enabledDiscovery', true),
8181
validators: {
8282
ipns: ipnsUtils.validator
8383
},
@@ -86,12 +86,12 @@ function defaultBundle ({ datastore, peerInfo, peerBook, options, config }) {
8686
}
8787
},
8888
EXPERIMENTAL: {
89-
dht: true,
90-
pubsub: get(opts.options, 'EXPERIMENTAL.pubsub', false)
89+
dht: !(get(options, 'local', false)),
90+
pubsub: get(options, 'EXPERIMENTAL.pubsub', false)
9191
}
9292
},
93-
connectionManager: get(opts.options, 'connectionManager',
94-
get(opts.config, 'connectionManager', {}))
93+
connectionManager: get(options, 'connectionManager',
94+
get(config, 'connectionManager', {}))
9595
}
9696

9797
const libp2pOptions = defaultsDeep(get(options, 'libp2p', {}), libp2pDefaults)

src/core/components/pin-set.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ const protobuf = require('protons')
66
const fnv1a = require('fnv1a')
77
const varint = require('varint')
88
const { DAGNode, DAGLink } = require('ipld-dag-pb')
9-
const some = require('async/some')
10-
const eachOf = require('async/eachOf')
9+
const someSeries = require('async/someSeries')
10+
const eachOfSeries = require('async/eachOfSeries')
1111

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

@@ -69,7 +69,7 @@ exports = module.exports = function (dag) {
6969
return searchChildren(root, callback)
7070

7171
function searchChildren (root, cb) {
72-
some(root.links, ({ cid }, done) => {
72+
someSeries(root.links, ({ cid }, done) => {
7373
const bs58Link = toB58String(cid)
7474

7575
if (bs58Link === childhash) {
@@ -174,7 +174,7 @@ exports = module.exports = function (dag) {
174174
return bins
175175
}, {})
176176

177-
eachOf(bins, (bin, idx, eachCb) => {
177+
eachOfSeries(bins, (bin, idx, eachCb) => {
178178
storePins(
179179
bin,
180180
depth + 1,
@@ -233,7 +233,7 @@ exports = module.exports = function (dag) {
233233
return callback(err)
234234
}
235235

236-
eachOf(node.links, (link, idx, eachCb) => {
236+
eachOfSeries(node.links, (link, idx, eachCb) => {
237237
if (idx < pbh.header.fanout) {
238238
// the first pbh.header.fanout links are fanout bins
239239
// if a fanout bin is not 'empty', dig into and walk its DAGLinks

src/core/components/start.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,8 @@ module.exports = (self) => {
6767
ipnsStores.push(pubsubDs)
6868
}
6969

70-
// DHT should be added as routing if we are not running with offline flag
71-
// TODO: Need to change this logic once DHT is enabled by default, for now fallback to Offline datastore
72-
if (get(self._options, 'EXPERIMENTAL.dht', false) && !self._options.offline) {
70+
// DHT should be added as routing if we are not running with local flag
71+
if (!self._options.offline) {
7372
ipnsStores.push(self.libp2p.dht)
7473
} else {
7574
const offlineDatastore = new OfflineDatastore(self._repo)

test/cli/dht.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,15 @@ const ipfsExec = require('../utils/ipfs-exec')
1818
const daemonOpts = {
1919
exec: `./src/cli/bin.js`,
2020
config: {
21-
Bootstrap: []
21+
Bootstrap: [],
22+
Discovery: {
23+
MDNS: {
24+
Enabled: false
25+
},
26+
webRTCStar: {
27+
Enabled: false
28+
}
29+
}
2230
},
2331
initOptions: { bits: 512 }
2432
}

test/cli/name-pubsub.js

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,18 @@ const spawnDaemon = (callback) => {
2121
df.spawn({
2222
exec: `./src/cli/bin.js`,
2323
args: ['--enable-namesys-pubsub'],
24-
initOptions: { bits: 512 }
24+
initOptions: { bits: 512 },
25+
config: {
26+
Bootstrap: [],
27+
Discovery: {
28+
MDNS: {
29+
Enabled: false
30+
},
31+
webRTCStar: {
32+
Enabled: false
33+
}
34+
}
35+
}
2536
}, callback)
2637
}
2738

test/cli/name.js

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ describe('name', () => {
181181
})
182182
})
183183

184-
describe.skip('using dht', () => {
184+
describe('using dht', () => {
185185
const passPhrase = hat()
186186
const pass = '--pass ' + passPhrase
187187
const name = 'test-key-' + hat()
@@ -199,9 +199,17 @@ describe('name', () => {
199199
df.spawn({
200200
exec: `./src/cli/bin.js`,
201201
config: {
202-
Bootstrap: []
202+
Bootstrap: [],
203+
Discovery: {
204+
MDNS: {
205+
Enabled: false
206+
},
207+
webRTCStar: {
208+
Enabled: false
209+
}
210+
}
203211
},
204-
args: ['--pass', passPhrase, '--enable-dht-experiment'],
212+
args: ['--pass', passPhrase],
205213
initOptions: { bits: 512 }
206214
}, (err, _ipfsd) => {
207215
expect(err).to.not.exist()

test/core/dht.spec.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,9 @@ describe('dht', () => {
2121
factory.spawn({
2222
exec: IPFS,
2323
initOptions: { bits: 512 },
24-
config: { Bootstrap: [] }
24+
config: {
25+
Bootstrap: []
26+
}
2527
}, (err, _ipfsd) => {
2628
expect(err).to.not.exist()
2729
ipfsd = _ipfsd

test/core/files-sharding.spec.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ describe('files directory (sharding tests)', () => {
6262
})
6363

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

6767
pull(
6868
pull.values(createTestFiles()),
@@ -114,7 +114,7 @@ describe('files directory (sharding tests)', () => {
114114
})
115115

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

119119
pull(
120120
pull.values(createTestFiles()),

0 commit comments

Comments
 (0)