Skip to content
This repository was archived by the owner on Mar 10, 2020. It is now read-only.

Commit 3e7c72e

Browse files
committed
feat(swarm): modularise swarm
BREAKING CHANGE: Consumers of this test suite now have fine grained control over what tests are run. Tests can now be skipped and "onlyed" (run only specific tests). This can be done on a test, command and sub-system level. See the updated usage guide for instructions: https://github.com/ipfs/interface-ipfs-core/blob/master/README.md#usage. This means that tests skips depending on implementation (e.g. go/js), environment (e.g. node/browser) or platform (e.g. macOS/linux/windows) that were previously present in this suite have been removed. Consumers of this library should add their own skips based on the implementation that's being tested and the environment/platform that the tests are running on. The following other breaking changes have been made: 1. The common object passed to test suites has changed. It must now be a function that returns a common object (same shape and functions as before). 2. The `ipfs.ls` tests (not MFS `ipfs.files.ls`) is now a root level suite. You'll need to import it and use like `tests.ls(createCommon)` to have those tests run. 3. The `generic` suite (an alias to `miscellaneous`) has been removed. See #290 for more details. License: MIT Signed-off-by: Alan Shaw <alan@tableflip.io>
1 parent 02985ae commit 3e7c72e

File tree

8 files changed

+427
-307
lines changed

8 files changed

+427
-307
lines changed

js/src/pubsub/subscribe.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -308,7 +308,7 @@ module.exports = (createCommon, options) => {
308308
})
309309
})
310310

311-
it('should receive multiple messages', function (done) {
311+
it('should receive multiple messages', (done) => {
312312
const inbox1 = []
313313
const inbox2 = []
314314
const outbox = ['hello', 'world', 'this', 'is', 'pubsub']

js/src/swarm.js

Lines changed: 0 additions & 306 deletions
This file was deleted.

js/src/swarm/addrs.js

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
/* eslint-env mocha */
2+
'use strict'
3+
4+
const chai = require('chai')
5+
const dirtyChai = require('dirty-chai')
6+
const { spawnNodes } = require('../utils/spawn')
7+
const { getDescribe, getIt } = require('../utils/mocha')
8+
9+
const expect = chai.expect
10+
chai.use(dirtyChai)
11+
12+
module.exports = (createCommon, options) => {
13+
const describe = getDescribe(options)
14+
const it = getIt(options)
15+
const common = createCommon()
16+
17+
describe('.swarm.addrs', function () {
18+
this.timeout(80 * 1000)
19+
20+
let ipfs
21+
22+
before(function (done) {
23+
// CI takes longer to instantiate the daemon, so we need to increase the
24+
// timeout for the before step
25+
this.timeout(100 * 1000)
26+
27+
common.setup((err, factory) => {
28+
expect(err).to.not.exist()
29+
30+
spawnNodes(2, factory, (err, nodes) => {
31+
expect(err).to.not.exist()
32+
ipfs = nodes[0]
33+
done()
34+
})
35+
})
36+
})
37+
38+
after((done) => common.teardown(done))
39+
40+
it('should get a list of node addresses', (done) => {
41+
ipfs.swarm.addrs((err, multiaddrs) => {
42+
expect(err).to.not.exist()
43+
expect(multiaddrs).to.not.be.empty()
44+
expect(multiaddrs).to.be.an('array')
45+
expect(multiaddrs[0].constructor.name).to.be.eql('PeerInfo')
46+
done()
47+
})
48+
})
49+
50+
it('should get a list of node addresses (promised)', () => {
51+
return ipfs.swarm.addrs().then((multiaddrs) => {
52+
expect(multiaddrs).to.have.length.above(0)
53+
})
54+
})
55+
})
56+
}

0 commit comments

Comments
 (0)