http: better events.

This commit is contained in:
Christopher Jeffrey 2016-08-22 19:08:39 -07:00
parent c7ab83993c
commit 3cac0a96d2
No known key found for this signature in database
GPG Key ID: 8962AB9DE6666BBD
2 changed files with 9 additions and 15 deletions

View File

@ -1214,15 +1214,8 @@ function ClientSocket(server, socket) {
this.filter = {};
this.filterCount = 0;
this.node = this.server.node;
this.network = this.server.network;
this.chain = this.server.chain;
this.mempool = this.server.mempool;
this.pool = this.server.pool;
this.fees = this.server.fees;
this.miner = this.server.miner;
this.wallet = this.server.wallet;
this.walletdb = this.server.walletdb;
this.logger = this.server.logger;
this.events = [];
@ -1248,7 +1241,7 @@ ClientSocket.prototype._init = function _init() {
else
ack = self.socket.ack(packet.id);
emit.apply(self, [event, args, ack]);
emit.call(self, event, args, ack);
return result;
};

View File

@ -195,9 +195,10 @@ describe('Chain', function() {
assert.ifError(err);
chain.add(block, function(err) {
assert.ifError(err);
chain.db.getCoin(block.txs[1].hash('hex'), 1, function(err, coin) {
var tx = block.txs[1];
var output = bcoin.coin.fromTX(tx, 1);
chain.db.getCoin(tx.hash('hex'), 1, function(err, coin) {
assert.ifError(err);
var output = bcoin.coin.fromTX(block.txs[1], 1);
assert.deepEqual(coin.toRaw(), output.toRaw());
cb();
});
@ -228,15 +229,15 @@ describe('Chain', function() {
});
it('should rescan for transactions', function(cb) {
var txs = [];
var total = 0;
walletdb.getAddressHashes(function(err, hashes) {
assert.ifError(err);
chain.db.scan(null, hashes, function(block, tx, next) {
txs = txs.concat(tx);
chain.db.scan(null, hashes, function(block, txs, next) {
total += txs.length;
next();
}, function(err) {
assert.ifError(err);
assert.equal(txs.length, 25);
assert.equal(total, 25);
cb();
});
});
@ -244,6 +245,6 @@ describe('Chain', function() {
it('should cleanup', function(cb) {
constants.tx.COINBASE_MATURITY = 100;
cb();
node.close(cb);
});
});