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

Commit

Permalink
feat(swarm): modularise swarm
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
alanshaw committed Jun 8, 2018
1 parent 02985ae commit 3e7c72e
Show file tree
Hide file tree
Showing 8 changed files with 427 additions and 307 deletions.
2 changes: 1 addition & 1 deletion js/src/pubsub/subscribe.js
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ module.exports = (createCommon, options) => {
})
})

it('should receive multiple messages', function (done) {
it('should receive multiple messages', (done) => {
const inbox1 = []
const inbox2 = []
const outbox = ['hello', 'world', 'this', 'is', 'pubsub']
Expand Down
306 changes: 0 additions & 306 deletions js/src/swarm.js

This file was deleted.

56 changes: 56 additions & 0 deletions js/src/swarm/addrs.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
/* eslint-env mocha */
'use strict'

const chai = require('chai')
const dirtyChai = require('dirty-chai')
const { spawnNodes } = require('../utils/spawn')
const { getDescribe, getIt } = require('../utils/mocha')

const expect = chai.expect
chai.use(dirtyChai)

module.exports = (createCommon, options) => {
const describe = getDescribe(options)
const it = getIt(options)
const common = createCommon()

describe('.swarm.addrs', function () {
this.timeout(80 * 1000)

let ipfs

before(function (done) {
// CI takes longer to instantiate the daemon, so we need to increase the
// timeout for the before step
this.timeout(100 * 1000)

common.setup((err, factory) => {
expect(err).to.not.exist()

spawnNodes(2, factory, (err, nodes) => {
expect(err).to.not.exist()
ipfs = nodes[0]
done()
})
})
})

after((done) => common.teardown(done))

it('should get a list of node addresses', (done) => {
ipfs.swarm.addrs((err, multiaddrs) => {
expect(err).to.not.exist()
expect(multiaddrs).to.not.be.empty()
expect(multiaddrs).to.be.an('array')
expect(multiaddrs[0].constructor.name).to.be.eql('PeerInfo')
done()
})
})

it('should get a list of node addresses (promised)', () => {
return ipfs.swarm.addrs().then((multiaddrs) => {
expect(multiaddrs).to.have.length.above(0)
})
})
})
}
Loading

0 comments on commit 3e7c72e

Please sign in to comment.