diff --git a/.eslintrc.json b/.eslintrc.json index 4b45ace9..ab7949c5 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -8,7 +8,7 @@ "ecmaVersion": 8 }, "rules": { - "consistent-return": "off", + "consistent-return": "error", "func-name-matching": "off", "indent": ["error", 2, { "SwitchCase": 1, diff --git a/bin/cli b/bin/cli index 661b46c0..5d033b74 100755 --- a/bin/cli +++ b/bin/cli @@ -25,7 +25,7 @@ function CLI() { CLI.prototype.log = function log(json) { if (typeof json === 'string') return console.log.apply(console, arguments); - console.log(JSON.stringify(json, null, 2)); + return console.log(JSON.stringify(json, null, 2)); }; CLI.prototype.getInfo = async function getInfo() { @@ -491,81 +491,113 @@ CLI.prototype.handleWallet = async function handleWallet() { switch (this.argv.shift()) { case 'listen': - return await this.listenWallet(); + await this.listenWallet(); + break; case 'get': - return await this.getWallet(); + await this.getWallet(); + break; case 'master': - return await this.getMaster(); + await this.getMaster(); + break; case 'shared': if (this.argv[0] === 'add') { this.argv.shift(); - return await this.addSharedKey(); + await this.addSharedKey(); + break; } if (this.argv[0] === 'remove') { this.argv.shift(); - return await this.removeSharedKey(); + await this.removeSharedKey(); + break; } if (this.argv[0] === 'list') this.argv.shift(); - return await this.getSharedKeys(); + await this.getSharedKeys(); + break; case 'balance': - return await this.getBalance(); + await this.getBalance(); + break; case 'history': - return await this.getWalletHistory(); + await this.getWalletHistory(); + break; case 'pending': - return await this.getWalletPending(); + await this.getWalletPending(); + break; case 'coins': - return await this.getWalletCoins(); + await this.getWalletCoins(); + break; case 'account': if (this.argv[0] === 'list') { this.argv.shift(); - return await this.getAccounts(); + await this.getAccounts(); + break; } if (this.argv[0] === 'create') { this.argv.shift(); - return await this.createAccount(); + await this.createAccount(); + break; } if (this.argv[0] === 'get') this.argv.shift(); - return await this.getAccount(); + await this.getAccount(); + break; case 'address': - return await this.createAddress(); + await this.createAddress(); + break; case 'change': - return await this.createChange(); + await this.createChange(); + break; case 'nested': - return await this.createNested(); + await this.createNested(); + break; case 'retoken': - return await this.retoken(); + await this.retoken(); + break; case 'sign': - return await this.signTX(); + await this.signTX(); + break; case 'mktx': - return await this.createTX(); + await this.createTX(); + break; case 'send': - return await this.sendTX(); + await this.sendTX(); + break; case 'zap': - return await this.zapWallet(); + await this.zapWallet(); + break; case 'tx': - return await this.getDetails(); + await this.getDetails(); + break; case 'blocks': - return await this.getWalletBlocks(); + await this.getWalletBlocks(); + break; case 'block': - return await this.getWalletBlock(); + await this.getWalletBlock(); + break; case 'view': - return await this.viewTX(); + await this.viewTX(); + break; case 'import': - return await this.importKey(); + await this.importKey(); + break; case 'watch': - return await this.importAddress(); + await this.importAddress(); + break; case 'key': - return await this.getKey(); + await this.getKey(); + break; case 'dump': - return await this.getWIF(); + await this.getWIF(); + break; case 'lock': - return await this.lock(); + await this.lock(); + break; case 'unlock': - return await this.unlock(); + await this.unlock(); + break; case 'resend': - return await this.resendWallet(); + await this.resendWallet(); + break; default: this.log('Unrecognized command.'); this.log('Commands:'); @@ -603,7 +635,7 @@ CLI.prototype.handleWallet = async function handleWallet() { this.log('Other Options:'); this.log(' --passphrase [passphrase]: For signing and account creation.'); this.log(' --account [account-name]: Account name.'); - return; + break; } }; @@ -616,31 +648,44 @@ CLI.prototype.handleNode = async function handleNode() { switch (this.argv.shift()) { case 'info': - return await this.getInfo(); + await this.getInfo(); + break; case 'wallets': - return await this.getWallets(); + await this.getWallets(); + break; case 'mkwallet': - return await this.createWallet(); + await this.createWallet(); + break; case 'broadcast': - return await this.broadcast(); + await this.broadcast(); + break; case 'mempool': - return await this.getMempool(); + await this.getMempool(); + break; case 'tx': - return await this.getTX(); + await this.getTX(); + break; case 'coin': - return await this.getCoin(); + await this.getCoin(); + break; case 'block': - return await this.getBlock(); + await this.getBlock(); + break; case 'rescan': - return await this.rescan(); + await this.rescan(); + break; case 'reset': - return await this.reset(); + await this.reset(); + break; case 'resend': - return await this.resend(); + await this.resend(); + break; case 'backup': - return await this.backup(); + await this.backup(); + break; case 'rpc': - return await this.rpc(); + await this.rpc(); + break; default: this.log('Unrecognized command.'); this.log('Commands:'); @@ -657,7 +702,7 @@ CLI.prototype.handleNode = async function handleNode() { this.log(' $ resend: Resend pending transactions.'); this.log(' $ backup [path]: Backup the wallet db.'); this.log(' $ rpc [command] [args]: Execute RPC command.'); - return; + break; } }; @@ -668,29 +713,33 @@ CLI.prototype.open = async function open() { this.argv.shift(); if (this.argv[0] === 'create') { this.argv[0] = 'mkwallet'; - return await this.handleNode(); + await this.handleNode(); + break; } - return await this.handleWallet(); + await this.handleWallet(); + break; default: - return await this.handleNode(); + await this.handleNode(); + break; } }; CLI.prototype.destroy = function destroy() { if (this.wallet) this.wallet.client.destroy(); + if (this.client) this.client.destroy(); + return Promise.resolve(); }; -async function main() { +(async () => { const cli = new CLI(); await cli.open(); await cli.destroy(); -} - -main().then(process.exit).catch((err) => { - console.error(err.stack + ''); - return process.exit(1); + process.exit(0); +})().catch((err) => { + console.error(err.stack); + process.exit(1); }); diff --git a/lib/bip70/paymentdetails.js b/lib/bip70/paymentdetails.js index 10107e34..c665e423 100644 --- a/lib/bip70/paymentdetails.js +++ b/lib/bip70/paymentdetails.js @@ -151,7 +151,7 @@ PaymentDetails.prototype.getData = function getData(enc) { try { data = JSON.parse(data); } catch (e) { - return; + return null; } return data; } diff --git a/lib/blockchain/chain.js b/lib/blockchain/chain.js index 0ad2dc3d..91e0e3a9 100644 --- a/lib/blockchain/chain.js +++ b/lib/blockchain/chain.js @@ -953,8 +953,10 @@ Chain.prototype.setBestChain = async function setBestChain(entry, block, prev, f // In spv-mode, we reset the // chain and redownload the blocks. - if (this.options.spv) - return await this.reorganizeSPV(entry); + if (this.options.spv) { + await this.reorganizeSPV(entry); + return; + } await this.reorganize(entry); } @@ -1138,8 +1140,10 @@ Chain.prototype._replay = async function _replay(block, silent) { if (!(await entry.isMainChain())) throw new Error('Cannot reset on alternate chain.'); - if (entry.isGenesis()) - return await this._reset(entry.hash, silent); + if (entry.isGenesis()) { + await this._reset(entry.hash, silent); + return; + } await this._reset(entry.prevBlock, silent); }; diff --git a/lib/btc/amount.js b/lib/btc/amount.js index 49fa3e5b..a64e1e67 100644 --- a/lib/btc/amount.js +++ b/lib/btc/amount.js @@ -523,10 +523,8 @@ function pow10(exp) { return 10000000; case 8: return 100000000; - default: - assert(false, 'Exponent is too large.'); - break; } + throw new Error('Exponent is too large.'); } function modSafe(mod) { @@ -549,10 +547,8 @@ function modSafe(mod) { return 4740991; case 100000000: return 54740991; - default: - assert(false, 'Exponent is too large.'); - break; } + throw new Error('Exponent is too large.'); } function divSafe(div) { @@ -575,10 +571,8 @@ function divSafe(div) { return 900719925; case 100000000: return 90071992; - default: - assert(false, 'Exponent is too large.'); - break; } + throw new Error('Exponent is too large.'); } /* diff --git a/lib/db/level.js b/lib/db/level.js index a3010317..b033acd8 100644 --- a/lib/db/level.js +++ b/lib/db/level.js @@ -46,6 +46,8 @@ DB.prototype.batch = function batch(ops, options, callback) { } this.level.batch(ops, options, callback); + + return undefined; }; DB.prototype.iterator = function iterator(options) { @@ -142,8 +144,10 @@ Iterator.prototype.seek = function seek(key) { }; Iterator.prototype.end = function end(callback) { - if (this._end) - return callback(new Error('end() already called on iterator.')); + if (this._end) { + callback(new Error('end() already called on iterator.')); + return; + } this._end = true; this.iter.end(callback); }; diff --git a/lib/db/memdb.js b/lib/db/memdb.js index 0c8a36b6..8c277eac 100644 --- a/lib/db/memdb.js +++ b/lib/db/memdb.js @@ -227,7 +227,7 @@ MemDB.prototype.batch = function _batch(ops, options, callback) { if (ops) { batch.ops = ops; batch.write(callback); - return; + return undefined; } return batch; @@ -339,7 +339,7 @@ Batch.prototype.del = function del(key) { Batch.prototype.write = function write(callback) { if (this.written) { setImmediate(() => callback(new Error('Already written.'))); - return; + return this; } for (const op of this.ops) { @@ -352,7 +352,7 @@ Batch.prototype.write = function write(callback) { break; default: setImmediate(() => callback(new Error('Bad op.'))); - return; + return this; } } diff --git a/lib/http/base.js b/lib/http/base.js index 011eae98..355aa435 100644 --- a/lib/http/base.js +++ b/lib/http/base.js @@ -218,19 +218,27 @@ HTTPBase.prototype.basicAuth = function basicAuth(options) { return async (req, res) => { const hdr = req.headers['authorization']; - if (!hdr) - return fail(res); + if (!hdr) { + fail(res); + return; + } - if (hdr.length > 1000) - return fail(res); + if (hdr.length > 1000) { + fail(res); + return; + } const parts = hdr.split(' '); - if (parts.length !== 2) - return fail(res); + if (parts.length !== 2) { + fail(res); + return; + } - if (parts[0] !== 'Basic') - return fail(res); + if (parts[0] !== 'Basic') { + fail(res); + return; + } const auth = Buffer.from(parts[1], 'base64').toString('utf8'); const items = auth.split(':'); @@ -239,24 +247,32 @@ HTTPBase.prototype.basicAuth = function basicAuth(options) { const password = items.join(':'); if (user) { - if (username.length > 255) - return fail(res); + if (username.length > 255) { + fail(res); + return; + } const raw = Buffer.from(username, 'utf8'); const hash = digest.hash256(raw); - if (!ccmp(hash, user)) - return fail(res); + if (!ccmp(hash, user)) { + fail(res); + return; + } } - if (password.length > 255) - return fail(res); + if (password.length > 255) { + fail(res); + return; + } const raw = Buffer.from(password, 'utf8'); const hash = digest.hash256(raw); - if (!ccmp(hash, pass)) - return fail(res); + if (!ccmp(hash, pass)) { + fail(res); + return; + } req.username = username; }; diff --git a/lib/net/pool.js b/lib/net/pool.js index 7e258135..3db7ba69 100644 --- a/lib/net/pool.js +++ b/lib/net/pool.js @@ -2213,7 +2213,7 @@ Pool.prototype.handleBlock = async function handleBlock(peer, packet) { return; } - return await this.addBlock(peer, packet.block, flags); + await this.addBlock(peer, packet.block, flags); }; /** diff --git a/lib/net/socks.js b/lib/net/socks.js index f6380029..2a21b5c7 100644 --- a/lib/net/socks.js +++ b/lib/net/socks.js @@ -662,7 +662,7 @@ Proxy.prototype.resume = function resume() { Proxy.prototype.destroy = function destroy() { if (!this.socket) return; - return this.socket.destroy(); + this.socket.destroy(); }; /* diff --git a/lib/node/logger.js b/lib/node/logger.js index a0692ed3..747c8b24 100644 --- a/lib/node/logger.js +++ b/lib/node/logger.js @@ -394,8 +394,10 @@ Logger.prototype.error = function error(...args) { const err = args[0]; - if (err instanceof Error) - return this.logError(Logger.levels.ERROR, null, err); + if (err instanceof Error) { + this.logError(Logger.levels.ERROR, null, err); + return; + } this.log(Logger.levels.ERROR, null, args); }; @@ -412,8 +414,10 @@ Logger.prototype.warning = function warning(...args) { const err = args[0]; - if (err instanceof Error) - return this.logError(Logger.levels.WARNING, null, err); + if (err instanceof Error) { + this.logError(Logger.levels.WARNING, null, err); + return; + } this.log(Logger.levels.WARNING, null, args); }; @@ -430,8 +434,10 @@ Logger.prototype.info = function info(...args) { const err = args[0]; - if (err instanceof Error) - return this.logError(Logger.levels.INFO, null, err); + if (err instanceof Error) { + this.logError(Logger.levels.INFO, null, err); + return; + } this.log(Logger.levels.INFO, null, args); }; @@ -448,8 +454,10 @@ Logger.prototype.debug = function debug(...args) { const err = args[0]; - if (err instanceof Error) - return this.logError(Logger.levels.DEBUG, null, err); + if (err instanceof Error) { + this.logError(Logger.levels.DEBUG, null, err); + return; + } this.log(Logger.levels.DEBUG, null, args); }; @@ -466,8 +474,10 @@ Logger.prototype.spam = function spam(...args) { const err = args[0]; - if (err instanceof Error) - return this.logError(Logger.levels.SPAM, null, err); + if (err instanceof Error) { + this.logError(Logger.levels.SPAM, null, err); + return; + } this.log(Logger.levels.SPAM, null, args); }; @@ -521,7 +531,7 @@ Logger.prototype.writeConsole = function writeConsole(level, module, args) { assert(name, 'Invalid log level.'); if (!this.console) - return; + return false; if (!process.stdout) { let msg = `[${name}] `; @@ -537,13 +547,17 @@ Logger.prototype.writeConsole = function writeConsole(level, module, args) { msg += util.format(args, false); - return level === Logger.levels.ERROR - ? console.error(msg) - : console.log(msg); + if (level === Logger.levels.ERROR) { + console.error(msg); + return true; + } + + console.log(msg); + + return true; } let msg; - if (this.colors) { const color = Logger.styles[level]; assert(color); @@ -707,8 +721,10 @@ LoggerContext.prototype.error = function error(...args) { const err = args[0]; - if (err instanceof Error) - return this.logError(Logger.levels.ERROR, err); + if (err instanceof Error) { + this.logError(Logger.levels.ERROR, err); + return; + } this.log(Logger.levels.ERROR, args); }; @@ -725,8 +741,10 @@ LoggerContext.prototype.warning = function warning(...args) { const err = args[0]; - if (err instanceof Error) - return this.logError(Logger.levels.WARNING, err); + if (err instanceof Error) { + this.logError(Logger.levels.WARNING, err); + return; + } this.log(Logger.levels.WARNING, args); }; @@ -743,8 +761,10 @@ LoggerContext.prototype.info = function info(...args) { const err = args[0]; - if (err instanceof Error) - return this.logError(Logger.levels.INFO, err); + if (err instanceof Error) { + this.logError(Logger.levels.INFO, err); + return; + } this.log(Logger.levels.INFO, args); }; @@ -761,8 +781,10 @@ LoggerContext.prototype.debug = function debug(...args) { const err = args[0]; - if (err instanceof Error) - return this.logError(Logger.levels.DEBUG, err); + if (err instanceof Error) { + this.logError(Logger.levels.DEBUG, err); + return; + } this.log(Logger.levels.DEBUG, args); }; @@ -779,8 +801,10 @@ LoggerContext.prototype.spam = function spam(...args) { const err = args[0]; - if (err instanceof Error) - return this.logError(Logger.levels.SPAM, err); + if (err instanceof Error) { + this.logError(Logger.levels.SPAM, err); + return; + } this.log(Logger.levels.SPAM, args); }; diff --git a/lib/primitives/tx.js b/lib/primitives/tx.js index 5f175d08..188899a0 100644 --- a/lib/primitives/tx.js +++ b/lib/primitives/tx.js @@ -431,7 +431,7 @@ TX.prototype.signatureHash = function signatureHash(index, prev, value, type, ve if (version === 1) return this.signatureHashV1(index, prev, value, type); - assert(false, 'Unknown sighash version.'); + throw new Error('Unknown sighash version.'); }; /** @@ -811,10 +811,12 @@ TX.prototype.checkAsync = async function checkAsync(view, flags, pool) { if (this.isCoinbase()) return; - if (!pool) - return this.check(view, flags); + if (!pool) { + this.check(view, flags); + return; + } - return await pool.check(this, view, flags); + await pool.check(this, view, flags); }; /** @@ -833,10 +835,12 @@ TX.prototype.checkInputAsync = async function checkInputAsync(index, coin, flags assert(input, 'Input does not exist.'); assert(coin, 'No coin passed.'); - if (!pool) - return this.checkInput(index, coin, flags); + if (!pool) { + this.checkInput(index, coin, flags); + return; + } - return await pool.checkInput(this, index, coin, flags); + await pool.checkInput(this, index, coin, flags); }; /** diff --git a/lib/protocol/network.js b/lib/protocol/network.js index fd973947..16d2144a 100644 --- a/lib/protocol/network.js +++ b/lib/protocol/network.js @@ -199,7 +199,7 @@ Network.get = function get(type) { if (typeof type === 'string') return Network.create(type); - assert(false, 'Unknown network.'); + throw new Error('Unknown network.'); }; /** diff --git a/lib/script/opcode.js b/lib/script/opcode.js index 8eae5dc5..ed4a9881 100644 --- a/lib/script/opcode.js +++ b/lib/script/opcode.js @@ -396,7 +396,7 @@ Opcode.from = function from(data) { if (BN.isBN(data)) return Opcode.fromNumber(data); - assert(false, 'Bad data for opcode.'); + throw new Error('Bad data for opcode.'); }; /** diff --git a/lib/script/scriptnum.js b/lib/script/scriptnum.js index 94c4f347..2498d4cc 100644 --- a/lib/script/scriptnum.js +++ b/lib/script/scriptnum.js @@ -154,7 +154,7 @@ ScriptNum.prototype.toString = function toString(base) { return str; } - assert(false, `Base ${base} not supported.`); + throw new Error(`Base ${base} not supported.`); }; ScriptNum.prototype.toJSON = function toJSON() { @@ -237,7 +237,7 @@ ScriptNum.prototype.fromString = function fromString(str, base) { return this; } - assert(false, `Base ${base} not supported.`); + throw new Error(`Base ${base} not supported.`); }; ScriptNum.fromString = function fromString(str, base) { diff --git a/lib/utils/ip.js b/lib/utils/ip.js index 59b124f4..6ca0f751 100644 --- a/lib/utils/ip.js +++ b/lib/utils/ip.js @@ -484,7 +484,7 @@ IP.getType = function getType(raw) { if (IP.isOnion(raw)) return IP.types.ONION; - assert(false, 'Unknown type.'); + throw new Error('Unknown type.'); }; /** diff --git a/lib/utils/staticwriter.js b/lib/utils/staticwriter.js index 2cd37156..83377a5e 100644 --- a/lib/utils/staticwriter.js +++ b/lib/utils/staticwriter.js @@ -369,7 +369,8 @@ StaticWriter.prototype.writeString = function writeString(value, enc) { StaticWriter.prototype.writeHash = function writeHash(value) { if (typeof value !== 'string') { assert(value.length === 32); - return this.writeBytes(value); + this.writeBytes(value); + return; } assert(value.length === 64); this.data.write(value, this.written, 'hex'); diff --git a/lib/utils/util.js b/lib/utils/util.js index bc6f5b4a..19e2cac5 100644 --- a/lib/utils/util.js +++ b/lib/utils/util.js @@ -551,7 +551,7 @@ util.pad8 = function pad8(num) { return num; } - assert(false); + throw new Error('Number too big.'); }; /** @@ -590,7 +590,7 @@ util.pad32 = function pad32(num) { return num; } - assert(false); + throw new Error('Number too big.'); }; /** @@ -613,7 +613,7 @@ util.hex8 = function hex8(num) { return num; } - assert(false); + throw new Error('Number too big.'); }; /** @@ -648,7 +648,7 @@ util.hex32 = function hex32(num) { return num; } - assert(false); + throw new Error('Number too big.'); }; /** diff --git a/lib/utils/writer.js b/lib/utils/writer.js index e8d9c0f6..fe37a500 100644 --- a/lib/utils/writer.js +++ b/lib/utils/writer.js @@ -466,7 +466,8 @@ BufferWriter.prototype.writeString = function writeString(value, enc) { BufferWriter.prototype.writeHash = function writeHash(value) { if (typeof value !== 'string') { assert(value.length === 32); - return this.writeBytes(value); + this.writeBytes(value); + return; } assert(value.length === 64); this.writeString(value, 'hex'); diff --git a/lib/wallet/account.js b/lib/wallet/account.js index 82b54fab..70e492c4 100644 --- a/lib/wallet/account.js +++ b/lib/wallet/account.js @@ -519,7 +519,7 @@ Account.prototype.derivePath = function derivePath(path, master) { return null; } default: { - assert(false, 'Bad key type.'); + throw new Error('Bad key type.'); } } }; diff --git a/lib/wallet/client.js b/lib/wallet/client.js index 38256902..04c74c54 100644 --- a/lib/wallet/client.js +++ b/lib/wallet/client.js @@ -100,7 +100,8 @@ WalletClient.prototype._open = async function _open() { block = parseBlock(entry, txs); } catch (e) { this.emit('error', e); - return cb(); + cb(); + return; } this.fire('block rescan', block.entry, block.txs).then(cb, cb); diff --git a/migrate/chaindb1to2.js b/migrate/chaindb1to2.js index 2f1e1560..57babdd7 100644 --- a/migrate/chaindb1to2.js +++ b/migrate/chaindb1to2.js @@ -197,7 +197,7 @@ async function reserializeUndo() { function write(data, str, off) { if (Buffer.isBuffer(str)) return str.copy(data, off); - data.write(str, off, 'hex'); + return data.write(str, off, 'hex'); } function pair(prefix, hash) { diff --git a/migrate/chaindb2to3.js b/migrate/chaindb2to3.js index 9e830b74..98164e23 100644 --- a/migrate/chaindb2to3.js +++ b/migrate/chaindb2to3.js @@ -541,7 +541,7 @@ function entryToRaw(entry, main) { function write(data, str, off) { if (Buffer.isBuffer(str)) return str.copy(data, off); - data.write(str, off, 'hex'); + return data.write(str, off, 'hex'); } function pair(prefix, hash) { diff --git a/migrate/coins-old.js b/migrate/coins-old.js index a5b436c9..5d8cb713 100644 --- a/migrate/coins-old.js +++ b/migrate/coins-old.js @@ -4,6 +4,8 @@ * https://github.com/bcoin-org/bcoin */ +/* eslint-disable */ + 'use strict'; const assert = require('assert'); diff --git a/migrate/coins/coins.js b/migrate/coins/coins.js index c4c74c72..edacce24 100644 --- a/migrate/coins/coins.js +++ b/migrate/coins/coins.js @@ -4,6 +4,8 @@ * https://github.com/bcoin-org/bcoin */ +/* eslint-disable */ + 'use strict'; const assert = require('assert'); diff --git a/migrate/coins/coinview.js b/migrate/coins/coinview.js index 659fe93b..6f70250b 100644 --- a/migrate/coins/coinview.js +++ b/migrate/coins/coinview.js @@ -4,6 +4,8 @@ * https://github.com/bcoin-org/bcoin */ +/* eslint-disable */ + 'use strict'; const assert = require('assert'); diff --git a/migrate/coins/compress.js b/migrate/coins/compress.js index d890455a..455780c1 100644 --- a/migrate/coins/compress.js +++ b/migrate/coins/compress.js @@ -4,6 +4,8 @@ * https://github.com/bcoin-org/bcoin */ +/* eslint-disable */ + 'use strict'; /** diff --git a/migrate/coins/undocoins.js b/migrate/coins/undocoins.js index b1e6e607..0e9acedd 100644 --- a/migrate/coins/undocoins.js +++ b/migrate/coins/undocoins.js @@ -4,6 +4,8 @@ * https://github.com/bcoin-org/bcoin */ +/* eslint-disable */ + 'use strict'; const assert = require('assert'); diff --git a/migrate/coinview-old.js b/migrate/coinview-old.js index e9880d0b..4d363921 100644 --- a/migrate/coinview-old.js +++ b/migrate/coinview-old.js @@ -4,6 +4,8 @@ * https://github.com/bcoin-org/bcoin */ +/* eslint-disable */ + 'use strict'; const assert = require('assert'); diff --git a/migrate/ensure-tip-index.js b/migrate/ensure-tip-index.js index 2fa074ee..200322dc 100644 --- a/migrate/ensure-tip-index.js +++ b/migrate/ensure-tip-index.js @@ -121,7 +121,7 @@ async function indexTips() { function write(data, str, off) { if (Buffer.isBuffer(str)) return str.copy(data, off); - data.write(str, off, 'hex'); + return data.write(str, off, 'hex'); } function pair(prefix, hash) { diff --git a/scripts/fuzz.js b/scripts/fuzz.js index 2a3b3288..6a4ce540 100644 --- a/scripts/fuzz.js +++ b/scripts/fuzz.js @@ -1,6 +1,5 @@ 'use strict'; -const assert = require('assert'); const util = require('../lib/utils/util'); const Script = require('../lib/script/script'); const Stack = require('../lib/script/stack'); @@ -173,7 +172,7 @@ function randomRedeem() { case 4: return randomProgram(); } - assert(false); + throw new Error(); } function randomScript() { @@ -193,7 +192,7 @@ function randomScript() { case 6: return randomProgram(); } - assert(false); + throw new Error(); } function randomPubkeyContext() { @@ -269,7 +268,7 @@ function randomContext() { case 5: return randomWitnessNestedContext(); } - assert(false); + throw new Error(); } function fuzzSimple(flags) { @@ -434,11 +433,14 @@ function main() { switch (process.argv[2]) { case 'simple': - return fuzzSimple(flags); + fuzzSimple(flags); + break; case 'verify': - return fuzzVerify(flags); + fuzzVerify(flags); + break; case 'less': - return fuzzLess(flags); + fuzzLess(flags); + break; default: util.log('Please select a mode:'); util.log('simple, verify, less');