diff --git a/lib/common.js b/lib/common.js index 66fd8ee0..61e6e262 100644 --- a/lib/common.js +++ b/lib/common.js @@ -541,6 +541,7 @@ exports.history = function history(opts) { } function History(opts) { + var self = this opts = opts || {} this._total = 0 @@ -548,9 +549,10 @@ function History(opts) { this._map = {} if (opts.prune) { - this._prunehist = [] this._prune_interval = setInterval( - this.prune.bind(this), + function() { + self.prune(Date.now()) + }, opts.interval || 100 ) if (this._prune_interval.unref) { @@ -582,7 +584,6 @@ History.prototype.place = function place(timelimit) { var i = this._list.length var s = 0 var e = i - //var c = 'u' if (0 === this._list.length) { return 0 @@ -590,31 +591,22 @@ History.prototype.place = function place(timelimit) { do { i = Math.floor((s + e) / 2) - //i = Math.ceil((s+e)/2) - //console.log('S ',i,s,e) if (timelimit > this._list[i].timelimit) { s = i + 1 i = s - //c = 's' } else if (timelimit < this._list[i].timelimit) { e = i - //i = e - //c = 'e' } else { i++ break } - - //console.log('E ',i,s,e,s x.split('/').pop()) - delegate.did = - (delegate.did ? delegate.did + '/' : '') + (didnid() + '~' + loc) + (delegate.did ? delegate.did + '/' : '') + didnid() var strdesc delegate.toString = function toString() { @@ -1297,6 +1290,7 @@ intern.execute_action = function( data.id = data.meta.id data.result = [] data.timelimit = Date.now() + data.meta.timeout + private$.history.add(data) if (opts.$.legacy.meta) { @@ -1449,6 +1443,10 @@ intern.handle_inward_break = function( intern.make_actmsg = function(origmsg) { var actmsg = Object.assign({}, origmsg) + if (actmsg.id$) { + delete actmsg.id$ + } + if (actmsg.caller$) { delete actmsg.caller$ } @@ -1456,12 +1454,12 @@ intern.make_actmsg = function(origmsg) { if (actmsg.meta$) { delete actmsg.meta$ } - + // backwards compatibility for Seneca 3.x transports if (origmsg.transport$) { actmsg.transport$ = origmsg.transport$ } - + return actmsg } diff --git a/test/actions.test.js b/test/actions.test.js index 28955580..05d30a37 100644 --- a/test/actions.test.js +++ b/test/actions.test.js @@ -42,7 +42,7 @@ describe('actions', function() { }) it('cmd_close', function(fin) { - var si = Seneca({ log: 'silent' }) + var si = Seneca().test(fin) var log = [] si.on('close', function() { diff --git a/test/prior.test.js b/test/prior.test.js index 69d26283..fcf82119 100644 --- a/test/prior.test.js +++ b/test/prior.test.js @@ -14,14 +14,26 @@ var expect = Code.expect var testopts = { log: 'test' } describe('prior', function() { - lab.beforeEach(function(done) { - process.removeAllListeners('SIGHUP') - process.removeAllListeners('SIGTERM') - process.removeAllListeners('SIGINT') - process.removeAllListeners('SIGBREAK') - done() - }) + it('happy', function(fin) { + Seneca() + .test(fin) + + .add('a:1', function a1(msg, reply) { + reply({x:msg.x}) + }) + + .add('a:1', function a1p(msg, reply) { + msg.x = msg.x + 1 + this.prior(msg, reply) + }) + + .act('a:1,x:2', function(ignore, out) { + expect(out.x).equal(3) + fin() + }) + }) + it('add-general-to-specific', function(done) { Seneca(testopts) .error(done) diff --git a/test/transport.test.js b/test/transport.test.js index 9ec92472..34445380 100644 --- a/test/transport.test.js +++ b/test/transport.test.js @@ -43,13 +43,18 @@ describe('transport', function() { // TODO: test top level qaz:* : def and undef other pats it('happy-nextgen', test_opts, function(fin) { - var s0 = Seneca({ id$: 's0', legacy: { transport: false } }).test(fin) - var c0 = Seneca({ id$: 'c0', timeout: 22222*tmx, legacy: { transport: false } }).test(fin) + var s0 = Seneca({ id$: 's0', legacy: { transport: false } }) + .test(fin) + var c0 = Seneca({ id$: 'c0', timeout: 22222*tmx, legacy: { transport: false } }) + .test(fin) s0 .add('a:1', function a1(msg, reply, meta) { reply({ x: msg.x }) }) + .add('b:1', function a1(msg, reply, meta) { + reply([1,2,3]) + }) .listen(62010) .ready(function() { c0.client(62010) @@ -61,7 +66,11 @@ describe('transport', function() { expect(meta.pattern).equals('') expect(meta.trace[0].desc[0]).equals('a:1') - s0.close(c0.close.bind(c0, fin)) + c0.act('b:1', function(ignore, out, meta) { + expect(out).equals([1,2,3]) + + s0.close(c0.close.bind(c0, fin)) + }) }) }) })