diff --git a/npm-shrinkwrap.json b/npm-shrinkwrap.json index 281b4e28..a7dd78c2 100644 --- a/npm-shrinkwrap.json +++ b/npm-shrinkwrap.json @@ -1,8 +1,8 @@ { "name": "ripple-rest", "version": "1.8.0-rc1", - "npm-shrinkwrap-version": "5.3.0", - "node-version": "v0.12.2", + "npm-shrinkwrap-version": "5.4.0", + "node-version": "v0.12.3", "dependencies": { "async": { "version": "0.9.0", diff --git a/package.json b/package.json index aa0eb4cd..80d8fbf2 100644 --- a/package.json +++ b/package.json @@ -46,6 +46,7 @@ "devDependencies": { "assert-diff": "^0.0.4", "coveralls": "^2.10.0", + "eventemitter2": "^0.4.14", "istanbul": "^0.2.10", "mocha": "^2.1.0", "npm-shrinkwrap": "^5.3", diff --git a/test/balances-test.js b/test/balances-test.js index d2f910b3..4f2db5ff 100644 --- a/test/balances-test.js +++ b/test/balances-test.js @@ -440,11 +440,11 @@ suite('get balances', function() { conn.send(fixtures.accountNotFoundResponse(message)); }); - /* TODO: uncommenting this breaks *other* test cases self.wss.once('request_account_lines', function(message, conn) { - assert(false, 'Should not request account lines'); + assert.strictEqual(message.command, 'account_lines'); + assert.strictEqual(message.account, addresses.VALID); + conn.send(fixtures.accountNotFoundResponse(message)); }); - */ self.app .get(requestPath(addresses.VALID)) diff --git a/test/payments-test.js b/test/payments-test.js index 31c62f0d..fecf5f0b 100644 --- a/test/payments-test.js +++ b/test/payments-test.js @@ -831,7 +831,8 @@ suite('post payments', function() { conn.send(fixtures.accountInfoResponse(message)); }); - self.wss.once('request_submit', function(message, conn) { + // "on" instead of "once" because ripple-lib resubmits + self.wss.on('request_submit', function(message, conn) { assert.strictEqual(message.command, 'submit'); conn.send(fixtures.rippledSubmitErrorResponse(message, { @@ -969,7 +970,7 @@ suite('post payments', function() { conn.send(fixtures.rippledSubcribeResponse(message)); }); - self.wss.once('request_account_info', function(message, conn) { + self.wss.on('request_account_info', function(message, conn) { assert.strictEqual(message.command, 'account_info'); assert.strictEqual(message.account, addresses.VALID); conn.send(fixtures.accountInfoResponse(message)); @@ -1007,7 +1008,7 @@ suite('post payments', function() { conn.send(fixtures.rippledSubcribeResponse(message)); }); - self.wss.once('request_account_info', function(message, conn) { + self.wss.on('request_account_info', function(message, conn) { assert.strictEqual(message.command, 'account_info'); assert.strictEqual(message.account, addresses.VALID); conn.send(fixtures.accountInfoResponse(message)); diff --git a/test/testutils.js b/test/testutils.js index 73e9cdc1..bef95ba8 100644 --- a/test/testutils.js +++ b/test/testutils.js @@ -14,6 +14,7 @@ var api = require('../server/api'); var apiFactory = require('../server/apifactory'); var version = require('../server/version'); var PRNGMock = require('./prngmock'); +var EventEmitter2 = require('eventemitter2').EventEmitter2; var LEDGER_OFFSET = 3; @@ -58,6 +59,24 @@ function setup(done) { self.db = api.db; self.wss = new WSS({port: 5995}); + _.assign(self.wss, EventEmitter2.prototype); + + self.wss.onAny(function() { + if (self.wss.listeners(this.event).length === 0) { + throw new Error('Should not ' + this.event.replace(/_/g, ' ')); + } + }); + + self.wss.on('listening', function() {}); + self.wss.on('headers', function() {}); + self.wss.on('connection/', function() {}); + self.wss.on('request_subscribe', function(message) { + // always allow subscribing to account notifications + if (self.wss.listeners('request_subscribe').length <= 1) { + assert(message.accounts && message.accounts.length === 1); + assert(message.streams === undefined); + } + }); self.wss.once('connection', function(conn) { conn.on('message', function(message) {