move errors around. assert.

This commit is contained in:
Christopher Jeffrey 2016-04-29 17:45:13 -07:00
parent 06171c5779
commit d89bd13f09
No known key found for this signature in database
GPG Key ID: 8962AB9DE6666BBD
17 changed files with 249 additions and 232 deletions

View File

@ -374,10 +374,9 @@ Block.prototype._verify = function _verify(ret) {
// Count legacy sigops (do not count scripthash or witness)
sigops += tx.getLegacySigops();
if (sigops * scale > constants.block.MAX_SIGOPS_COST) {
return callback(new VerifyError(block,
'invalid',
'bad-blk-sigops',
100));
ret.reason = 'bad-blk-sigops';
ret.score = 100;
return false;
}
}

View File

@ -13,7 +13,7 @@ var constants = bcoin.protocol.constants;
var network = bcoin.protocol.network;
var utils = require('./utils');
var assert = utils.assert;
var VerifyError = utils.VerifyError;
var VerifyError = bcoin.errors.VerifyError;
/**
* Represents a blockchain.

View File

@ -58,6 +58,9 @@ try {
* @property {Function} protocol.network - See {@link module:network}.
* @property {Function} protocol.framer - {@link Framer} constructor.
* @property {Function} protocol.parser - {@link Parser} constructor.
* @property {Object} errors
* @property {Function} errors.VerifyError - {@link VerifyError} constructor.
* @property {Function} errors.ScriptError - {@link ScriptError} constructor.
* @property {Function} profiler - {@link module:profiler}.
* @property {Function} ldb - See {@link module:ldb}.
* @property {Function} script - {@link Script} constructor.
@ -187,6 +190,7 @@ function Environment(options) {
this.uri = require('./uri');
this.protocol = require('./protocol')(this);
this.errors = require('./errors')(this);
this.profiler = require('./profiler')(this);
this.ldb = require('./ldb')(this);
this.timedata = require('./timedata')(this);
@ -199,11 +203,8 @@ function Environment(options) {
this.coins = require('./coins')(this);
this.coinview = require('./coinview')(this);
this.tx = require('./tx')(this);
this.transaction = this.tx;
this.mtx = require('./mtx')(this);
this.mutabletransaction = this.mtx;
this.txdb = require('./txdb')(this);
this.transactiondb = this.txdb;
this.abstractblock = require('./abstractblock')(this);
this.compactblock = require('./compactblock')(this);
this.block = require('./block')(this);

117
lib/bcoin/errors.js Normal file
View File

@ -0,0 +1,117 @@
/*!
* errors.js - error objects for bcoin
* Copyright (c) 2014-2015, Fedor Indutny (MIT License)
* Copyright (c) 2014-2016, Christopher Jeffrey (MIT License).
* https://github.com/indutny/bcoin
*/
module.exports = function(bcoin) {
var utils = bcoin.utils;
var constants = bcoin.protocol.constants;
/**
* An error thrown during verification. Can be either
* a mempool transaction validation error or a blockchain
* block verification error. Ultimately used to send
* `reject` packets to peers.
* @global
* @constructor
* @extends Error
* @param {Block|TX} object
* @param {String} code - Reject packet ccode.
* @param {String} reason - Reject packet reason.
* @param {Number} score - Ban score increase
* (can be -1 for no reject packet).
* @property {String} code
* @property {Buffer} hash
* @property {Number} height (will be the coinbase height if not present).
* @property {Number} score
* @property {String} message
*/
function VerifyError(object, code, reason, score) {
Error.call(this);
if (Error.captureStackTrace)
Error.captureStackTrace(this, VerifyError);
this.type = 'VerifyError';
this.hash = object.hash();
this.height = object.height;
if (object.getCoinbaseHeight && this.height === -1)
this.height = object.getCoinbaseHeight();
this.code = code;
this.reason = score === -1 ? null : reason;
this.score = score;
this.message = 'Verification failure: '
+ reason
+ ' (code=' + code
+ ', score=' + score
+ ', height=' + this.height
+ ', hash=' + utils.revHex(this.hash.toString('hex')) + ')';
}
utils.inherits(VerifyError, Error);
/**
* An error thrown from the scripting system,
* potentially pertaining to Script execution.
* @global
* @constructor
* @extends Error
* @param {String} code - Error code.
* @param {(Number|String)?} op - Opcode.
* @param {Number?} ip - Instruction pointer.
* @property {String} message - Error message.
* @property {String} code - Original code passed in.
* @property {String?} op - Symbolic opcode.
* @property {Number?} ip - Instruction pointer.
*/
function ScriptError(code, op, ip) {
Error.call(this);
if (Error.captureStackTrace)
Error.captureStackTrace(this, ScriptError);
this.type = 'ScriptError';
this.code = code;
if (typeof op !== 'string') {
if (Buffer.isBuffer(op))
op = 'PUSHDATA[' + op.length + ']';
if (op || ip != null) {
code += ' (';
if (op) {
op = constants.opcodesByVal[op] || op;
code += 'op=' + op;
if (ip != null)
code += ', ';
}
if (ip != null)
code += 'ip=' + ip;
code += ')';
}
this.message = code;
this.op = op || '';
this.ip = ip != null ? ip : -1;
} else {
this.message = op;
this.op = '';
this.ip = -1;
}
}
utils.inherits(ScriptError, Error);
return {
VerifyError: VerifyError,
ScriptError: ScriptError
};
};

View File

@ -15,7 +15,7 @@ var utils = require('./utils');
var assert = utils.assert;
var BufferWriter = require('./writer');
var BufferReader = require('./reader');
var VerifyError = utils.VerifyError;
var VerifyError = bcoin.errors.VerifyError;
var pad32 = utils.pad32;
var DUMMY = new Buffer([0]);

View File

@ -12,6 +12,7 @@ var utils = require('./utils');
var assert = utils.assert;
var network = bcoin.protocol.network;
var constants = bcoin.protocol.constants;
var VerifyError = bcoin.errors.VerifyError;
/**
* A pool of peers for handling all network activity.

View File

@ -17,6 +17,7 @@ var opcodes = constants.opcodes;
var STACK_TRUE = new Buffer([1]);
var STACK_FALSE = new Buffer([]);
var STACK_NEGATE = new Buffer([0x81]);
var ScriptError = bcoin.errors.ScriptError;
/**
* Refers to the witness field of segregated witness transactions.
@ -4297,62 +4298,8 @@ Script.isScript = function isScript(obj) {
&& typeof obj.getSubscript === 'function';
};
/**
* An error thrown from the scripting system,
* potentially pertaining to Script execution.
* @global
* @constructor
* @extends Error
* @param {String} code - Error code.
* @param {(Number|String)?} op - Opcode.
* @param {Number?} ip - Instruction pointer.
* @property {String} message - Error message.
* @property {String} code - Original code passed in.
* @property {String?} op - Symbolic opcode.
* @property {Number?} ip - Instruction pointer.
*/
function ScriptError(code, op, ip) {
Error.call(this);
if (Error.captureStackTrace)
Error.captureStackTrace(this, ScriptError);
this.type = 'ScriptError';
this.code = code;
if (typeof op !== 'string') {
if (Buffer.isBuffer(op))
op = 'PUSHDATA[' + op.length + ']';
if (op || ip != null) {
code += ' (';
if (op) {
op = constants.opcodesByVal[op] || op;
code += 'op=' + op;
if (ip != null)
code += ', ';
}
if (ip != null)
code += 'ip=' + ip;
code += ')';
}
this.message = code;
this.op = op || '';
this.ip = ip != null ? ip : -1;
} else {
this.message = op;
this.op = '';
this.ip = -1;
}
}
utils.inherits(ScriptError, Error);
Script.witness = Witness;
Script.stack = Stack;
Script.error = ScriptError;
return Script;
};

View File

@ -11,6 +11,7 @@
var utils = exports;
var assert = require('assert');
var bn = require('bn.js');
var util = require('util');
var crypto, hash;
@ -550,32 +551,21 @@ utils.revHex = function revHex(s) {
return r;
};
function assert(val, msg) {
if (!val)
throw new Error(msg || 'Assertion failed');
}
/**
* Shallow merge between multiple objects.
* @param {Object} target
* @param {...Object} args
* @returns {Object} target
*/
assert.fatal = function fatal(l, r, msg) {
if (!val) {
if (!msg)
msg = 'Assertion failed (fatal exception)';
msg = new Error(msg);
console.error(msg.stack + '');
if (process.exit)
process.exit(1);
else
throw msg;
}
};
assert.equal = function assertEqual(l, r, msg) {
if (l != r)
throw new Error(msg || ('Assertion failed: ' + l + ' != ' + r));
};
assert.noError = function noError(err) {
if (err)
throw err;
utils.merge = function merge(target) {
var args = Array.prototype.slice.call(arguments, 1);
args.forEach(function(obj) {
Object.keys(obj).forEach(function(key) {
target[key] = obj[key];
});
});
return target;
};
/**
@ -585,7 +575,35 @@ assert.noError = function noError(err) {
* @param {String?} msg - Optional error message.
*/
utils.assert = assert;
utils.assert = function assert(value, message) {
return assert.ok(value, message);
};
utils.merge(utils.assert, assert);
utils.assert.fatal = function fatal(value, message) {
var err;
if (!value) {
if (!message)
message = 'Assertion failed (fatal exception)';
err = new assert.AssertionError({
message: message,
actual: value,
expected: true,
operator: '==',
stackStartFunction: fatal
});
if (process.exit) {
console.error(err.stack + '');
process.exit(1);
} else {
throw err;
}
}
};
/**
* Convert satoshis to a BTC string. Note that
@ -1026,23 +1044,6 @@ utils.error = function error() {
process.stderr.write(msg);
};
/**
* Shallow merge between multiple objects.
* @param {Object} target
* @param {...Object} args
* @returns {Object} target
*/
utils.merge = function merge(target) {
var args = Array.prototype.slice.call(arguments, 1);
args.forEach(function(obj) {
Object.keys(obj).forEach(function(key) {
target[key] = obj[key];
});
});
return target;
};
/**
* Sort public keys lexicographically.
* @param {Buffer[]} keys
@ -2781,52 +2782,3 @@ utils.binarySearch = function binarySearch(items, key, insert, compare) {
return start - 1;
};
/**
* An error thrown during verification. Can be either
* a mempool transaction validation error or a blockchain
* block verification error. Ultimately used to send
* `reject` packets to peers.
* @global
* @constructor
* @extends Error
* @param {Block|TX} object
* @param {String} code - Reject packet ccode.
* @param {String} reason - Reject packet reason.
* @param {Number} score - Ban score increase
* (can be -1 for no reject packet).
* @property {String} code
* @property {Buffer} hash
* @property {Number} height (will be the coinbase height if not present).
* @property {Number} score
* @property {String} message
*/
function VerifyError(object, code, reason, score) {
Error.call(this);
if (Error.captureStackTrace)
Error.captureStackTrace(this, VerifyError);
this.type = 'VerifyError';
this.hash = object.hash();
this.height = object.height;
if (object.getCoinbaseHeight && this.height === -1)
this.height = object.getCoinbaseHeight();
this.code = code;
this.reason = score === -1 ? null : reason;
this.score = score;
this.message = 'Verification failure: '
+ reason
+ ' (code=' + code
+ ', score=' + score
+ ', height=' + this.height
+ ', hash=' + utils.revHex(this.hash.toString('hex')) + ')';
}
utils.inherits(VerifyError, Error);
utils.VerifyError = VerifyError;

View File

@ -1,6 +1,6 @@
var assert = require('assert');
var bn = require('bn.js');
var bcoin = require('../')();
var assert = require('assert');
describe('Block', function() {
var parser = bcoin.protocol.parser;

View File

@ -1,5 +1,5 @@
var assert = require('assert');
var bcoin = require('../')();
var assert = require('assert');
describe('Bloom', function() {
it('should do proper murmur3', function() {

View File

@ -4,7 +4,7 @@ var bcoin = require('../')({ network: 'regtest', db: 'memory' });
process.env.BCOIN_NETWORK = 'main';
var constants = bcoin.protocol.constants;
var utils = bcoin.utils;
var assert = utils.assert;
var assert = require('assert');
var opcodes = constants.opcodes;
constants.tx.COINBASE_MATURITY = 0;
@ -32,7 +32,7 @@ describe('Chain', function() {
miner.createBlock(function(err, attempt) {
if (realTip)
chain.tip = realTip;
assert.noError(err);
assert.ifError(err);
if (tx) {
var redeemer = bcoin.mtx();
redeemer.addOutput({
@ -63,7 +63,7 @@ describe('Chain', function() {
it('should mine a block', function(cb) {
miner.mineBlock(function(err, block) {
assert.noError(err);
assert.ifError(err);
assert(block);
cb();
});
@ -72,29 +72,29 @@ describe('Chain', function() {
it('should mine competing chains', function(cb) {
utils.forRangeSerial(0, 10, function(i, next) {
mineBlock(ch1, cb1, function(err, chain1) {
assert.noError(err);
assert.ifError(err);
cb1 = chain1.txs[0];
mineBlock(ch2, cb2, function(err, chain2) {
assert.noError(err);
assert.ifError(err);
cb2 = chain2.txs[0];
deleteCoins(chain1.txs);
chain.add(chain1, function(err) {
assert.noError(err);
assert.ifError(err);
deleteCoins(chain2.txs);
chain.add(chain2, function(err) {
assert.noError(err);
assert.ifError(err);
assert(chain.tip.hash === chain1.hash('hex'));
competingTip = chain2.hash('hex');
chain.db.get(chain1.hash('hex'), function(err, entry1) {
assert.noError(err);
assert.ifError(err);
chain.db.get(chain2.hash('hex'), function(err, entry2) {
assert.noError(err);
assert.ifError(err);
assert(entry1);
assert(entry2);
ch1 = entry1;
ch2 = entry2;
chain.db.isMainChain(chain2.hash('hex'), function(err, result) {
assert.noError(err);
assert.ifError(err);
assert(!result);
next();
});
@ -110,12 +110,12 @@ describe('Chain', function() {
it('should handle a reorg', function(cb) {
oldTip = chain.tip;
chain.db.get(competingTip, function(err, entry) {
assert.noError(err);
assert.ifError(err);
assert(entry);
assert(chain.height === entry.height);
chain.tip = entry;
miner.mineBlock(function(err, reorg) {
assert.noError(err);
assert.ifError(err);
assert(reorg);
chain.tip = oldTip;
var forked = false;
@ -124,7 +124,7 @@ describe('Chain', function() {
});
deleteCoins(reorg.txs);
chain.add(reorg, function(err) {
assert.noError(err);
assert.ifError(err);
assert(forked);
assert(chain.tip.hash === reorg.hash('hex'));
assert(chain.tip.chainwork.cmp(oldTip.chainwork) > 0);
@ -136,7 +136,7 @@ describe('Chain', function() {
it('should check main chain', function(cb) {
chain.db.isMainChain(oldTip, function(err, result) {
assert.noError(err);
assert.ifError(err);
assert(!result);
cb();
});
@ -144,16 +144,16 @@ describe('Chain', function() {
it('should mine a block after a reorg', function(cb) {
mineBlock(null, cb2, function(err, block) {
assert.noError(err);
assert.ifError(err);
deleteCoins(block.txs);
chain.add(block, function(err) {
assert.noError(err);
assert.ifError(err);
chain.db.get(block.hash('hex'), function(err, entry) {
assert.noError(err);
assert.ifError(err);
assert(entry);
assert(chain.tip.hash === entry.hash);
chain.db.isMainChain(entry.hash, function(err, result) {
assert.noError(err);
assert.ifError(err);
assert(result);
cb();
});
@ -164,7 +164,7 @@ describe('Chain', function() {
it('should fail to mine a block with coins on a side chain', function(cb) {
mineBlock(null, cb1, function(err, block) {
assert.noError(err);
assert.ifError(err);
deleteCoins(block.txs);
chain.add(block, function(err) {
assert(err);

View File

@ -2,7 +2,7 @@ var bn = require('bn.js');
var bcoin = require('../')({ db: 'memory' });
var constants = bcoin.protocol.constants;
var utils = bcoin.utils;
var assert = utils.assert;
var assert = require('assert');
var opcodes = constants.opcodes;
describe('Mempool', function() {
@ -84,31 +84,31 @@ describe('Mempool', function() {
fake.hint = 'fake';
mempool.addTX(fake, function(err) {
assert.noError(err);
assert.ifError(err);
mempool.addTX(t4, function(err) {
assert.noError(err);
assert.ifError(err);
mempool.getBalance(function(err, balance) {
assert.noError(err);
assert.ifError(err);
assert.equal(balance.total.toString(10), '0');
mempool.addTX(t1, function(err) {
assert.noError(err);
assert.ifError(err);
mempool.getBalance(function(err, balance) {
assert.noError(err);
assert.ifError(err);
assert.equal(balance.total.toString(10), '60000');
mempool.addTX(t2, function(err) {
assert.noError(err);
assert.ifError(err);
mempool.getBalance(function(err, balance) {
assert.noError(err);
assert.ifError(err);
assert.equal(balance.total.toString(10), '50000');
mempool.addTX(t3, function(err) {
assert.noError(err);
assert.ifError(err);
mempool.getBalance(function(err, balance) {
assert.noError(err);
assert.ifError(err);
assert.equal(balance.total.toString(10), '22000');
mempool.addTX(f1, function(err) {
assert.noError(err);
assert.ifError(err);
mempool.getBalance(function(err, balance) {
assert.noError(err);
assert.ifError(err);
assert.equal(balance.total.toString(10), '20000');
mempool.getHistory(function(err, txs) {
assert(txs.some(function(tx) {

View File

@ -1,5 +1,5 @@
var assert = require('assert');
var bcoin = require('../')();
var assert = require('assert');
var constants = bcoin.protocol.constants;
var network = bcoin.protocol.network;
var utils = bcoin.utils;

View File

@ -1,5 +1,5 @@
var assert = require('assert');
var bcoin = require('../')();
var assert = require('assert');
var Script = bcoin.script;
var Stack = bcoin.script.stack;
var utils = bcoin.utils;
@ -340,7 +340,7 @@ describe('Script', function() {
assert.equal(err.code, expected);
return;
}
utils.assert.noError(err);
utils.assert.ifError(err);
assert(res);
});
});

View File

@ -1,6 +1,6 @@
var assert = require('assert');
var bn = require('bn.js');
var bcoin = require('../')();
var assert = require('assert');
var utils = bcoin.utils;
var constants = bcoin.protocol.constants;
var opcodes = bcoin.protocol.constants.opcodes;

View File

@ -1,6 +1,6 @@
var assert = require('assert');
var bn = require('bn.js');
var bcoin = require('../')();
var assert = require('assert');
var utils = bcoin.utils;
describe('Utils', function() {

View File

@ -2,7 +2,7 @@ var bn = require('bn.js');
var bcoin = require('../')({ db: process.env.BCOIN_TEST_DB || 'memory' });
var constants = bcoin.protocol.constants;
var utils = bcoin.utils;
var assert = utils.assert;
var assert = require('assert');
var dummyInput = {
prevout: {
@ -52,7 +52,7 @@ describe('Wallet', function() {
flags |= bcoin.protocol.constants.flags.VERIFY_WITNESS;
wdb.create({ witness: witness }, function(err, w) {
assert.noError(err);
assert.ifError(err);
if (witness)
assert(bcoin.address.parse(w.getAddress()).type === 'witnesspubkeyhash');
@ -139,9 +139,9 @@ describe('Wallet', function() {
var dw, di;
it('should have TX pool and be serializable', function(cb) {
wdb.create({}, function(err, w) {
assert.noError(err);
assert.ifError(err);
wdb.create({}, function(err, f) {
assert.noError(err);
assert.ifError(err);
dw = w;
// Coinbase
@ -188,30 +188,30 @@ describe('Wallet', function() {
// Fake TX should temporarly change output
wdb.addTX(fake, function(err) {
assert.noError(err);
assert.ifError(err);
wdb.addTX(t4, function(err) {
assert.noError(err);
assert.ifError(err);
w.getBalance(function(err, balance) {
assert.noError(err);
assert.ifError(err);
assert.equal(balance.total.toString(10), '22500');
wdb.addTX(t1, function(err) {
w.getBalance(function(err, balance) {
assert.noError(err);
assert.ifError(err);
assert.equal(balance.total.toString(10), '73000');
wdb.addTX(t2, function(err) {
assert.noError(err);
assert.ifError(err);
w.getBalance(function(err, balance) {
assert.noError(err);
assert.ifError(err);
assert.equal(balance.total.toString(10), '47000');
wdb.addTX(t3, function(err) {
assert.noError(err);
assert.ifError(err);
w.getBalance(function(err, balance) {
assert.noError(err);
assert.ifError(err);
assert.equal(balance.total.toString(10), '22000');
wdb.addTX(f1, function(err) {
assert.noError(err);
assert.ifError(err);
w.getBalance(function(err, balance) {
assert.noError(err);
assert.ifError(err);
assert.equal(balance.total.toString(10), '11000');
w.getHistory(function(err, txs) {
assert(txs.some(function(tx) {
@ -244,9 +244,9 @@ describe('Wallet', function() {
var t1 = bcoin.mtx().addOutput(dw, 5000);
t1.addInput(di);
wdb.addTX(t1, function(err) {
assert.noError(err);
assert.ifError(err);
dw.getBalance(function(err, balance) {
assert.noError(err);
assert.ifError(err);
assert.equal(balance.total.toString(10), '11000');
cb();
});
@ -255,9 +255,9 @@ describe('Wallet', function() {
it('should fill tx with inputs', function(cb) {
wdb.create({}, function(err, w1) {
assert.noError(err);
assert.ifError(err);
wdb.create({}, function(err, w2) {
assert.noError(err);
assert.ifError(err);
// Coinbase
var t1 = bcoin.mtx()
@ -270,12 +270,12 @@ describe('Wallet', function() {
// Fake TX should temporarly change output
wdb.addTX(t1, function(err) {
assert.noError(err);
assert.ifError(err);
// Create new transaction
var t2 = bcoin.mtx().addOutput(w2, 5460);
w1.fill(t2, function(err) {
assert.noError(err);
assert.ifError(err);
w1.sign(t2);
assert(t2.verify());
@ -300,11 +300,11 @@ describe('Wallet', function() {
it('should sign multiple inputs using different keys', function(cb) {
wdb.create({}, function(err, w1) {
assert.noError(err);
assert.ifError(err);
wdb.create({}, function(err, w2) {
assert.noError(err);
assert.ifError(err);
wdb.create({}, function(err, to) {
assert.noError(err);
assert.ifError(err);
// Coinbase
var t1 = bcoin.mtx()
@ -327,9 +327,9 @@ describe('Wallet', function() {
// Fake TX should temporarly change output
wdb.addTX(t1, function(err) {
assert.noError(err);
assert.ifError(err);
wdb.addTX(t2, function(err) {
assert.noError(err);
assert.ifError(err);
// Create our tx with an output
var tx = bcoin.mtx();
@ -339,9 +339,9 @@ describe('Wallet', function() {
var total = cost.add(new bn(constants.tx.MIN_FEE));
w1.getCoins(function(err, coins1) {
assert.noError(err);
assert.ifError(err);
w2.getCoins(function(err, coins2) {
assert.noError(err);
assert.ifError(err);
// Add dummy output (for `left`) to calculate maximum TX size
tx.addOutput(w1, new bn(0));
@ -405,13 +405,13 @@ describe('Wallet', function() {
};
wdb.create(utils.merge({}, options), function(err, w1) {
assert.noError(err);
assert.ifError(err);
wdb.create(utils.merge({}, options), function(err, w2) {
assert.noError(err);
assert.ifError(err);
wdb.create(utils.merge({}, options), function(err, w3) {
assert.noError(err);
assert.ifError(err);
wdb.create({}, function(err, receive) {
assert.noError(err);
assert.ifError(err);
w1.addKey(w2);
w1.addKey(w3);
@ -458,11 +458,11 @@ describe('Wallet', function() {
assert.equal(w1.receiveDepth, 1);
wdb.addTX(utx, function(err) {
assert.noError(err);
assert.ifError(err);
wdb.addTX(utx, function(err) {
assert.noError(err);
assert.ifError(err);
wdb.addTX(utx, function(err) {
assert.noError(err);
assert.ifError(err);
assert.equal(w1.receiveDepth, 2);
assert.equal(w1.changeDepth, 1);
@ -478,7 +478,7 @@ describe('Wallet', function() {
send.addOutput({ address: receive.getAddress(), value: 5460 });
assert(!send.verify(null, true, flags));
w1.fill(send, { m: w1.m, n: w1.n }, function(err) {
assert.noError(err);
assert.ifError(err);
w1.sign(send);
@ -499,11 +499,11 @@ describe('Wallet', function() {
send.height = 1;
wdb.addTX(send, function(err) {
assert.noError(err);
assert.ifError(err);
wdb.addTX(send, function(err) {
assert.noError(err);
assert.ifError(err);
wdb.addTX(send, function(err) {
assert.noError(err);
assert.ifError(err);
assert.equal(w1.receiveDepth, 2);
assert.equal(w1.changeDepth, 2);
@ -557,7 +557,7 @@ describe('Wallet', function() {
it('should have gratuitous dump', function(cb) {
bcoin.walletdb().dump(function(err, records) {
assert.noError(err);
assert.ifError(err);
// console.log(records);
setTimeout(cb, 200);
});