From 875c35de2ae83186cae6bda11814b2cf86b93b15 Mon Sep 17 00:00:00 2001 From: Chris Kleeschulte Date: Thu, 10 Sep 2015 13:18:39 -0400 Subject: [PATCH] Added a full stack integration-style regtest for the bus - The test exercises subscribe and calls unsubscribe. --- integration/regtest-node.js | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/integration/regtest-node.js b/integration/regtest-node.js index dff7a4df..932b1483 100644 --- a/integration/regtest-node.js +++ b/integration/regtest-node.js @@ -219,4 +219,23 @@ describe('Node Functionality', function() { node.services.bitcoind.isMainChain(invalidatedBlockHash).should.equal(false); setImmediate(done); }); + + describe('Bus Functionality', function() { + it('subscribes and unsubscribes to an event on the bus', function(done) { + var bus = node.openBus(); + var block; + bus.subscribe('db/block'); + bus.on('block', function(data) { + bus.unsubscribe('db/block'); + data.should.be.equal(block); + done(); + }); + client.generate(1, function(err, response) { + if (err) { + throw err; + } + block = response.result[0]; + }); + }); + }); });