Skip to content

Commit

Permalink
don't start the ipfs node in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
wanderer committed May 25, 2017
1 parent 600f990 commit ee2ec06
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 21 deletions.
4 changes: 2 additions & 2 deletions exoInterface.js
Original file line number Diff line number Diff line change
Expand Up @@ -157,8 +157,8 @@ module.exports = class ExoInterface extends EventEmitter {
* @param {Message} message - the message
*/
async send (portRef, message) {
if (!this.ports.isValid(portRef)) {
throw new Error('invalid port')
if (!this.ports.isBound(portRef)) {
throw new Error('cannot send message with an unbound port')
}

// set the port that the message came from
Expand Down
3 changes: 2 additions & 1 deletion port.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@ module.exports = class Port {
* @property {Interger} ticks - the last know number of ticks the
* corrisponding container is at
*/
constructor () {
constructor (name) {
this._queue = []
this.ticks = 0
this.name = name
}

/**
Expand Down
14 changes: 8 additions & 6 deletions portManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ module.exports = class PortManager {
}

_bindRef (portRef, name) {
const port = new Port()
const port = new Port(name)
this._portMap.set(portRef, port)
}

Expand Down Expand Up @@ -98,19 +98,20 @@ module.exports = class PortManager {
/**
* deletes a port given its name
* @param {String} name
* @returns {boolean} whether or not the port was deleted
*/
delete (name) {
const port = this.ports[name]
delete this.ports[name]
this._portMap.delete(port)
return this._portMap.delete(port)
}

/**
* check if a port object is still valid
* @param {Object} port
* @return {Boolean}
*/
isValid (port) {
isBound (port) {
return this._portMap.has(port)
}

Expand Down Expand Up @@ -140,12 +141,13 @@ module.exports = class PortManager {
/**
* creates a new Port given the container type
* @param {String} type
* @param {*} data - the data to populate the initail state with
* @returns {Object} the newly created port
*/
create (type) {
create (type, data) {
const Container = this.hypervisor._containerTypes[type]
return this._createPortObject(type, {
'/': Container.createState()
'/': Container.createState(data)
})
}

Expand Down Expand Up @@ -184,7 +186,7 @@ module.exports = class PortManager {
* @returns {Promise}
*/
async getNextMessage (ports = [...this._portMap]) {
if (this._portMap.size) {
if (ports.length) {
// find the oldest message
const ticks = ports.map(([name, port]) => {
return port.size ? port.ticks : this.exoInterface.ticks
Expand Down
16 changes: 4 additions & 12 deletions tests/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ const tape = require('tape')
const IPFS = require('ipfs')
const Hypervisor = require('../')

const node = new IPFS()
const node = new IPFS({
start: false
})

class BaseContainer {
constructor (kernel) {
Expand All @@ -17,17 +19,7 @@ class BaseContainer {
}
}

node.on('error', err => {
console.log(err)
})

node.on('start', () => {
tape.onFinish(() => {
node.stop(() => {
process.exit()
})
})

node.on('ready', () => {
tape('basic', async t => {
t.plan(2)
let message
Expand Down

0 comments on commit ee2ec06

Please sign in to comment.