lint: consistent return values.

This commit is contained in:
Christopher Jeffrey 2017-07-30 17:23:43 -07:00
parent 5e73e51177
commit 5eb6620431
No known key found for this signature in database
GPG Key ID: 8962AB9DE6666BBD
31 changed files with 262 additions and 150 deletions

View File

@ -8,7 +8,7 @@
"ecmaVersion": 8 "ecmaVersion": 8
}, },
"rules": { "rules": {
"consistent-return": "off", "consistent-return": "error",
"func-name-matching": "off", "func-name-matching": "off",
"indent": ["error", 2, { "indent": ["error", 2, {
"SwitchCase": 1, "SwitchCase": 1,

163
bin/cli
View File

@ -25,7 +25,7 @@ function CLI() {
CLI.prototype.log = function log(json) { CLI.prototype.log = function log(json) {
if (typeof json === 'string') if (typeof json === 'string')
return console.log.apply(console, arguments); 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() { CLI.prototype.getInfo = async function getInfo() {
@ -491,81 +491,113 @@ CLI.prototype.handleWallet = async function handleWallet() {
switch (this.argv.shift()) { switch (this.argv.shift()) {
case 'listen': case 'listen':
return await this.listenWallet(); await this.listenWallet();
break;
case 'get': case 'get':
return await this.getWallet(); await this.getWallet();
break;
case 'master': case 'master':
return await this.getMaster(); await this.getMaster();
break;
case 'shared': case 'shared':
if (this.argv[0] === 'add') { if (this.argv[0] === 'add') {
this.argv.shift(); this.argv.shift();
return await this.addSharedKey(); await this.addSharedKey();
break;
} }
if (this.argv[0] === 'remove') { if (this.argv[0] === 'remove') {
this.argv.shift(); this.argv.shift();
return await this.removeSharedKey(); await this.removeSharedKey();
break;
} }
if (this.argv[0] === 'list') if (this.argv[0] === 'list')
this.argv.shift(); this.argv.shift();
return await this.getSharedKeys(); await this.getSharedKeys();
break;
case 'balance': case 'balance':
return await this.getBalance(); await this.getBalance();
break;
case 'history': case 'history':
return await this.getWalletHistory(); await this.getWalletHistory();
break;
case 'pending': case 'pending':
return await this.getWalletPending(); await this.getWalletPending();
break;
case 'coins': case 'coins':
return await this.getWalletCoins(); await this.getWalletCoins();
break;
case 'account': case 'account':
if (this.argv[0] === 'list') { if (this.argv[0] === 'list') {
this.argv.shift(); this.argv.shift();
return await this.getAccounts(); await this.getAccounts();
break;
} }
if (this.argv[0] === 'create') { if (this.argv[0] === 'create') {
this.argv.shift(); this.argv.shift();
return await this.createAccount(); await this.createAccount();
break;
} }
if (this.argv[0] === 'get') if (this.argv[0] === 'get')
this.argv.shift(); this.argv.shift();
return await this.getAccount(); await this.getAccount();
break;
case 'address': case 'address':
return await this.createAddress(); await this.createAddress();
break;
case 'change': case 'change':
return await this.createChange(); await this.createChange();
break;
case 'nested': case 'nested':
return await this.createNested(); await this.createNested();
break;
case 'retoken': case 'retoken':
return await this.retoken(); await this.retoken();
break;
case 'sign': case 'sign':
return await this.signTX(); await this.signTX();
break;
case 'mktx': case 'mktx':
return await this.createTX(); await this.createTX();
break;
case 'send': case 'send':
return await this.sendTX(); await this.sendTX();
break;
case 'zap': case 'zap':
return await this.zapWallet(); await this.zapWallet();
break;
case 'tx': case 'tx':
return await this.getDetails(); await this.getDetails();
break;
case 'blocks': case 'blocks':
return await this.getWalletBlocks(); await this.getWalletBlocks();
break;
case 'block': case 'block':
return await this.getWalletBlock(); await this.getWalletBlock();
break;
case 'view': case 'view':
return await this.viewTX(); await this.viewTX();
break;
case 'import': case 'import':
return await this.importKey(); await this.importKey();
break;
case 'watch': case 'watch':
return await this.importAddress(); await this.importAddress();
break;
case 'key': case 'key':
return await this.getKey(); await this.getKey();
break;
case 'dump': case 'dump':
return await this.getWIF(); await this.getWIF();
break;
case 'lock': case 'lock':
return await this.lock(); await this.lock();
break;
case 'unlock': case 'unlock':
return await this.unlock(); await this.unlock();
break;
case 'resend': case 'resend':
return await this.resendWallet(); await this.resendWallet();
break;
default: default:
this.log('Unrecognized command.'); this.log('Unrecognized command.');
this.log('Commands:'); this.log('Commands:');
@ -603,7 +635,7 @@ CLI.prototype.handleWallet = async function handleWallet() {
this.log('Other Options:'); this.log('Other Options:');
this.log(' --passphrase [passphrase]: For signing and account creation.'); this.log(' --passphrase [passphrase]: For signing and account creation.');
this.log(' --account [account-name]: Account name.'); this.log(' --account [account-name]: Account name.');
return; break;
} }
}; };
@ -616,31 +648,44 @@ CLI.prototype.handleNode = async function handleNode() {
switch (this.argv.shift()) { switch (this.argv.shift()) {
case 'info': case 'info':
return await this.getInfo(); await this.getInfo();
break;
case 'wallets': case 'wallets':
return await this.getWallets(); await this.getWallets();
break;
case 'mkwallet': case 'mkwallet':
return await this.createWallet(); await this.createWallet();
break;
case 'broadcast': case 'broadcast':
return await this.broadcast(); await this.broadcast();
break;
case 'mempool': case 'mempool':
return await this.getMempool(); await this.getMempool();
break;
case 'tx': case 'tx':
return await this.getTX(); await this.getTX();
break;
case 'coin': case 'coin':
return await this.getCoin(); await this.getCoin();
break;
case 'block': case 'block':
return await this.getBlock(); await this.getBlock();
break;
case 'rescan': case 'rescan':
return await this.rescan(); await this.rescan();
break;
case 'reset': case 'reset':
return await this.reset(); await this.reset();
break;
case 'resend': case 'resend':
return await this.resend(); await this.resend();
break;
case 'backup': case 'backup':
return await this.backup(); await this.backup();
break;
case 'rpc': case 'rpc':
return await this.rpc(); await this.rpc();
break;
default: default:
this.log('Unrecognized command.'); this.log('Unrecognized command.');
this.log('Commands:'); this.log('Commands:');
@ -657,7 +702,7 @@ CLI.prototype.handleNode = async function handleNode() {
this.log(' $ resend: Resend pending transactions.'); this.log(' $ resend: Resend pending transactions.');
this.log(' $ backup [path]: Backup the wallet db.'); this.log(' $ backup [path]: Backup the wallet db.');
this.log(' $ rpc [command] [args]: Execute RPC command.'); this.log(' $ rpc [command] [args]: Execute RPC command.');
return; break;
} }
}; };
@ -668,29 +713,33 @@ CLI.prototype.open = async function open() {
this.argv.shift(); this.argv.shift();
if (this.argv[0] === 'create') { if (this.argv[0] === 'create') {
this.argv[0] = 'mkwallet'; this.argv[0] = 'mkwallet';
return await this.handleNode(); await this.handleNode();
break;
} }
return await this.handleWallet(); await this.handleWallet();
break;
default: default:
return await this.handleNode(); await this.handleNode();
break;
} }
}; };
CLI.prototype.destroy = function destroy() { CLI.prototype.destroy = function destroy() {
if (this.wallet) if (this.wallet)
this.wallet.client.destroy(); this.wallet.client.destroy();
if (this.client) if (this.client)
this.client.destroy(); this.client.destroy();
return Promise.resolve(); return Promise.resolve();
}; };
async function main() { (async () => {
const cli = new CLI(); const cli = new CLI();
await cli.open(); await cli.open();
await cli.destroy(); await cli.destroy();
} process.exit(0);
})().catch((err) => {
main().then(process.exit).catch((err) => { console.error(err.stack);
console.error(err.stack + ''); process.exit(1);
return process.exit(1);
}); });

View File

@ -151,7 +151,7 @@ PaymentDetails.prototype.getData = function getData(enc) {
try { try {
data = JSON.parse(data); data = JSON.parse(data);
} catch (e) { } catch (e) {
return; return null;
} }
return data; return data;
} }

View File

@ -953,8 +953,10 @@ Chain.prototype.setBestChain = async function setBestChain(entry, block, prev, f
// In spv-mode, we reset the // In spv-mode, we reset the
// chain and redownload the blocks. // chain and redownload the blocks.
if (this.options.spv) if (this.options.spv) {
return await this.reorganizeSPV(entry); await this.reorganizeSPV(entry);
return;
}
await this.reorganize(entry); await this.reorganize(entry);
} }
@ -1138,8 +1140,10 @@ Chain.prototype._replay = async function _replay(block, silent) {
if (!(await entry.isMainChain())) if (!(await entry.isMainChain()))
throw new Error('Cannot reset on alternate chain.'); throw new Error('Cannot reset on alternate chain.');
if (entry.isGenesis()) if (entry.isGenesis()) {
return await this._reset(entry.hash, silent); await this._reset(entry.hash, silent);
return;
}
await this._reset(entry.prevBlock, silent); await this._reset(entry.prevBlock, silent);
}; };

View File

@ -523,10 +523,8 @@ function pow10(exp) {
return 10000000; return 10000000;
case 8: case 8:
return 100000000; return 100000000;
default:
assert(false, 'Exponent is too large.');
break;
} }
throw new Error('Exponent is too large.');
} }
function modSafe(mod) { function modSafe(mod) {
@ -549,10 +547,8 @@ function modSafe(mod) {
return 4740991; return 4740991;
case 100000000: case 100000000:
return 54740991; return 54740991;
default:
assert(false, 'Exponent is too large.');
break;
} }
throw new Error('Exponent is too large.');
} }
function divSafe(div) { function divSafe(div) {
@ -575,10 +571,8 @@ function divSafe(div) {
return 900719925; return 900719925;
case 100000000: case 100000000:
return 90071992; return 90071992;
default:
assert(false, 'Exponent is too large.');
break;
} }
throw new Error('Exponent is too large.');
} }
/* /*

View File

@ -46,6 +46,8 @@ DB.prototype.batch = function batch(ops, options, callback) {
} }
this.level.batch(ops, options, callback); this.level.batch(ops, options, callback);
return undefined;
}; };
DB.prototype.iterator = function iterator(options) { DB.prototype.iterator = function iterator(options) {
@ -142,8 +144,10 @@ Iterator.prototype.seek = function seek(key) {
}; };
Iterator.prototype.end = function end(callback) { Iterator.prototype.end = function end(callback) {
if (this._end) if (this._end) {
return callback(new Error('end() already called on iterator.')); callback(new Error('end() already called on iterator.'));
return;
}
this._end = true; this._end = true;
this.iter.end(callback); this.iter.end(callback);
}; };

View File

@ -227,7 +227,7 @@ MemDB.prototype.batch = function _batch(ops, options, callback) {
if (ops) { if (ops) {
batch.ops = ops; batch.ops = ops;
batch.write(callback); batch.write(callback);
return; return undefined;
} }
return batch; return batch;
@ -339,7 +339,7 @@ Batch.prototype.del = function del(key) {
Batch.prototype.write = function write(callback) { Batch.prototype.write = function write(callback) {
if (this.written) { if (this.written) {
setImmediate(() => callback(new Error('Already written.'))); setImmediate(() => callback(new Error('Already written.')));
return; return this;
} }
for (const op of this.ops) { for (const op of this.ops) {
@ -352,7 +352,7 @@ Batch.prototype.write = function write(callback) {
break; break;
default: default:
setImmediate(() => callback(new Error('Bad op.'))); setImmediate(() => callback(new Error('Bad op.')));
return; return this;
} }
} }

View File

@ -218,19 +218,27 @@ HTTPBase.prototype.basicAuth = function basicAuth(options) {
return async (req, res) => { return async (req, res) => {
const hdr = req.headers['authorization']; const hdr = req.headers['authorization'];
if (!hdr) if (!hdr) {
return fail(res); fail(res);
return;
}
if (hdr.length > 1000) if (hdr.length > 1000) {
return fail(res); fail(res);
return;
}
const parts = hdr.split(' '); const parts = hdr.split(' ');
if (parts.length !== 2) if (parts.length !== 2) {
return fail(res); fail(res);
return;
}
if (parts[0] !== 'Basic') if (parts[0] !== 'Basic') {
return fail(res); fail(res);
return;
}
const auth = Buffer.from(parts[1], 'base64').toString('utf8'); const auth = Buffer.from(parts[1], 'base64').toString('utf8');
const items = auth.split(':'); const items = auth.split(':');
@ -239,24 +247,32 @@ HTTPBase.prototype.basicAuth = function basicAuth(options) {
const password = items.join(':'); const password = items.join(':');
if (user) { if (user) {
if (username.length > 255) if (username.length > 255) {
return fail(res); fail(res);
return;
}
const raw = Buffer.from(username, 'utf8'); const raw = Buffer.from(username, 'utf8');
const hash = digest.hash256(raw); const hash = digest.hash256(raw);
if (!ccmp(hash, user)) if (!ccmp(hash, user)) {
return fail(res); fail(res);
return;
}
} }
if (password.length > 255) if (password.length > 255) {
return fail(res); fail(res);
return;
}
const raw = Buffer.from(password, 'utf8'); const raw = Buffer.from(password, 'utf8');
const hash = digest.hash256(raw); const hash = digest.hash256(raw);
if (!ccmp(hash, pass)) if (!ccmp(hash, pass)) {
return fail(res); fail(res);
return;
}
req.username = username; req.username = username;
}; };

View File

@ -2213,7 +2213,7 @@ Pool.prototype.handleBlock = async function handleBlock(peer, packet) {
return; return;
} }
return await this.addBlock(peer, packet.block, flags); await this.addBlock(peer, packet.block, flags);
}; };
/** /**

View File

@ -662,7 +662,7 @@ Proxy.prototype.resume = function resume() {
Proxy.prototype.destroy = function destroy() { Proxy.prototype.destroy = function destroy() {
if (!this.socket) if (!this.socket)
return; return;
return this.socket.destroy(); this.socket.destroy();
}; };
/* /*

View File

@ -394,8 +394,10 @@ Logger.prototype.error = function error(...args) {
const err = args[0]; const err = args[0];
if (err instanceof Error) if (err instanceof Error) {
return this.logError(Logger.levels.ERROR, null, err); this.logError(Logger.levels.ERROR, null, err);
return;
}
this.log(Logger.levels.ERROR, null, args); this.log(Logger.levels.ERROR, null, args);
}; };
@ -412,8 +414,10 @@ Logger.prototype.warning = function warning(...args) {
const err = args[0]; const err = args[0];
if (err instanceof Error) if (err instanceof Error) {
return this.logError(Logger.levels.WARNING, null, err); this.logError(Logger.levels.WARNING, null, err);
return;
}
this.log(Logger.levels.WARNING, null, args); this.log(Logger.levels.WARNING, null, args);
}; };
@ -430,8 +434,10 @@ Logger.prototype.info = function info(...args) {
const err = args[0]; const err = args[0];
if (err instanceof Error) if (err instanceof Error) {
return this.logError(Logger.levels.INFO, null, err); this.logError(Logger.levels.INFO, null, err);
return;
}
this.log(Logger.levels.INFO, null, args); this.log(Logger.levels.INFO, null, args);
}; };
@ -448,8 +454,10 @@ Logger.prototype.debug = function debug(...args) {
const err = args[0]; const err = args[0];
if (err instanceof Error) if (err instanceof Error) {
return this.logError(Logger.levels.DEBUG, null, err); this.logError(Logger.levels.DEBUG, null, err);
return;
}
this.log(Logger.levels.DEBUG, null, args); this.log(Logger.levels.DEBUG, null, args);
}; };
@ -466,8 +474,10 @@ Logger.prototype.spam = function spam(...args) {
const err = args[0]; const err = args[0];
if (err instanceof Error) if (err instanceof Error) {
return this.logError(Logger.levels.SPAM, null, err); this.logError(Logger.levels.SPAM, null, err);
return;
}
this.log(Logger.levels.SPAM, null, args); this.log(Logger.levels.SPAM, null, args);
}; };
@ -521,7 +531,7 @@ Logger.prototype.writeConsole = function writeConsole(level, module, args) {
assert(name, 'Invalid log level.'); assert(name, 'Invalid log level.');
if (!this.console) if (!this.console)
return; return false;
if (!process.stdout) { if (!process.stdout) {
let msg = `[${name}] `; let msg = `[${name}] `;
@ -537,13 +547,17 @@ Logger.prototype.writeConsole = function writeConsole(level, module, args) {
msg += util.format(args, false); msg += util.format(args, false);
return level === Logger.levels.ERROR if (level === Logger.levels.ERROR) {
? console.error(msg) console.error(msg);
: console.log(msg); return true;
}
console.log(msg);
return true;
} }
let msg; let msg;
if (this.colors) { if (this.colors) {
const color = Logger.styles[level]; const color = Logger.styles[level];
assert(color); assert(color);
@ -707,8 +721,10 @@ LoggerContext.prototype.error = function error(...args) {
const err = args[0]; const err = args[0];
if (err instanceof Error) if (err instanceof Error) {
return this.logError(Logger.levels.ERROR, err); this.logError(Logger.levels.ERROR, err);
return;
}
this.log(Logger.levels.ERROR, args); this.log(Logger.levels.ERROR, args);
}; };
@ -725,8 +741,10 @@ LoggerContext.prototype.warning = function warning(...args) {
const err = args[0]; const err = args[0];
if (err instanceof Error) if (err instanceof Error) {
return this.logError(Logger.levels.WARNING, err); this.logError(Logger.levels.WARNING, err);
return;
}
this.log(Logger.levels.WARNING, args); this.log(Logger.levels.WARNING, args);
}; };
@ -743,8 +761,10 @@ LoggerContext.prototype.info = function info(...args) {
const err = args[0]; const err = args[0];
if (err instanceof Error) if (err instanceof Error) {
return this.logError(Logger.levels.INFO, err); this.logError(Logger.levels.INFO, err);
return;
}
this.log(Logger.levels.INFO, args); this.log(Logger.levels.INFO, args);
}; };
@ -761,8 +781,10 @@ LoggerContext.prototype.debug = function debug(...args) {
const err = args[0]; const err = args[0];
if (err instanceof Error) if (err instanceof Error) {
return this.logError(Logger.levels.DEBUG, err); this.logError(Logger.levels.DEBUG, err);
return;
}
this.log(Logger.levels.DEBUG, args); this.log(Logger.levels.DEBUG, args);
}; };
@ -779,8 +801,10 @@ LoggerContext.prototype.spam = function spam(...args) {
const err = args[0]; const err = args[0];
if (err instanceof Error) if (err instanceof Error) {
return this.logError(Logger.levels.SPAM, err); this.logError(Logger.levels.SPAM, err);
return;
}
this.log(Logger.levels.SPAM, args); this.log(Logger.levels.SPAM, args);
}; };

View File

@ -431,7 +431,7 @@ TX.prototype.signatureHash = function signatureHash(index, prev, value, type, ve
if (version === 1) if (version === 1)
return this.signatureHashV1(index, prev, value, type); 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()) if (this.isCoinbase())
return; return;
if (!pool) if (!pool) {
return this.check(view, flags); 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(input, 'Input does not exist.');
assert(coin, 'No coin passed.'); assert(coin, 'No coin passed.');
if (!pool) if (!pool) {
return this.checkInput(index, coin, flags); this.checkInput(index, coin, flags);
return;
}
return await pool.checkInput(this, index, coin, flags); await pool.checkInput(this, index, coin, flags);
}; };
/** /**

View File

@ -199,7 +199,7 @@ Network.get = function get(type) {
if (typeof type === 'string') if (typeof type === 'string')
return Network.create(type); return Network.create(type);
assert(false, 'Unknown network.'); throw new Error('Unknown network.');
}; };
/** /**

View File

@ -396,7 +396,7 @@ Opcode.from = function from(data) {
if (BN.isBN(data)) if (BN.isBN(data))
return Opcode.fromNumber(data); return Opcode.fromNumber(data);
assert(false, 'Bad data for opcode.'); throw new Error('Bad data for opcode.');
}; };
/** /**

View File

@ -154,7 +154,7 @@ ScriptNum.prototype.toString = function toString(base) {
return str; return str;
} }
assert(false, `Base ${base} not supported.`); throw new Error(`Base ${base} not supported.`);
}; };
ScriptNum.prototype.toJSON = function toJSON() { ScriptNum.prototype.toJSON = function toJSON() {
@ -237,7 +237,7 @@ ScriptNum.prototype.fromString = function fromString(str, base) {
return this; return this;
} }
assert(false, `Base ${base} not supported.`); throw new Error(`Base ${base} not supported.`);
}; };
ScriptNum.fromString = function fromString(str, base) { ScriptNum.fromString = function fromString(str, base) {

View File

@ -484,7 +484,7 @@ IP.getType = function getType(raw) {
if (IP.isOnion(raw)) if (IP.isOnion(raw))
return IP.types.ONION; return IP.types.ONION;
assert(false, 'Unknown type.'); throw new Error('Unknown type.');
}; };
/** /**

View File

@ -369,7 +369,8 @@ StaticWriter.prototype.writeString = function writeString(value, enc) {
StaticWriter.prototype.writeHash = function writeHash(value) { StaticWriter.prototype.writeHash = function writeHash(value) {
if (typeof value !== 'string') { if (typeof value !== 'string') {
assert(value.length === 32); assert(value.length === 32);
return this.writeBytes(value); this.writeBytes(value);
return;
} }
assert(value.length === 64); assert(value.length === 64);
this.data.write(value, this.written, 'hex'); this.data.write(value, this.written, 'hex');

View File

@ -551,7 +551,7 @@ util.pad8 = function pad8(num) {
return num; return num;
} }
assert(false); throw new Error('Number too big.');
}; };
/** /**
@ -590,7 +590,7 @@ util.pad32 = function pad32(num) {
return num; return num;
} }
assert(false); throw new Error('Number too big.');
}; };
/** /**
@ -613,7 +613,7 @@ util.hex8 = function hex8(num) {
return num; return num;
} }
assert(false); throw new Error('Number too big.');
}; };
/** /**
@ -648,7 +648,7 @@ util.hex32 = function hex32(num) {
return num; return num;
} }
assert(false); throw new Error('Number too big.');
}; };
/** /**

View File

@ -466,7 +466,8 @@ BufferWriter.prototype.writeString = function writeString(value, enc) {
BufferWriter.prototype.writeHash = function writeHash(value) { BufferWriter.prototype.writeHash = function writeHash(value) {
if (typeof value !== 'string') { if (typeof value !== 'string') {
assert(value.length === 32); assert(value.length === 32);
return this.writeBytes(value); this.writeBytes(value);
return;
} }
assert(value.length === 64); assert(value.length === 64);
this.writeString(value, 'hex'); this.writeString(value, 'hex');

View File

@ -519,7 +519,7 @@ Account.prototype.derivePath = function derivePath(path, master) {
return null; return null;
} }
default: { default: {
assert(false, 'Bad key type.'); throw new Error('Bad key type.');
} }
} }
}; };

View File

@ -100,7 +100,8 @@ WalletClient.prototype._open = async function _open() {
block = parseBlock(entry, txs); block = parseBlock(entry, txs);
} catch (e) { } catch (e) {
this.emit('error', e); this.emit('error', e);
return cb(); cb();
return;
} }
this.fire('block rescan', block.entry, block.txs).then(cb, cb); this.fire('block rescan', block.entry, block.txs).then(cb, cb);

View File

@ -197,7 +197,7 @@ async function reserializeUndo() {
function write(data, str, off) { function write(data, str, off) {
if (Buffer.isBuffer(str)) if (Buffer.isBuffer(str))
return str.copy(data, off); return str.copy(data, off);
data.write(str, off, 'hex'); return data.write(str, off, 'hex');
} }
function pair(prefix, hash) { function pair(prefix, hash) {

View File

@ -541,7 +541,7 @@ function entryToRaw(entry, main) {
function write(data, str, off) { function write(data, str, off) {
if (Buffer.isBuffer(str)) if (Buffer.isBuffer(str))
return str.copy(data, off); return str.copy(data, off);
data.write(str, off, 'hex'); return data.write(str, off, 'hex');
} }
function pair(prefix, hash) { function pair(prefix, hash) {

View File

@ -4,6 +4,8 @@
* https://github.com/bcoin-org/bcoin * https://github.com/bcoin-org/bcoin
*/ */
/* eslint-disable */
'use strict'; 'use strict';
const assert = require('assert'); const assert = require('assert');

View File

@ -4,6 +4,8 @@
* https://github.com/bcoin-org/bcoin * https://github.com/bcoin-org/bcoin
*/ */
/* eslint-disable */
'use strict'; 'use strict';
const assert = require('assert'); const assert = require('assert');

View File

@ -4,6 +4,8 @@
* https://github.com/bcoin-org/bcoin * https://github.com/bcoin-org/bcoin
*/ */
/* eslint-disable */
'use strict'; 'use strict';
const assert = require('assert'); const assert = require('assert');

View File

@ -4,6 +4,8 @@
* https://github.com/bcoin-org/bcoin * https://github.com/bcoin-org/bcoin
*/ */
/* eslint-disable */
'use strict'; 'use strict';
/** /**

View File

@ -4,6 +4,8 @@
* https://github.com/bcoin-org/bcoin * https://github.com/bcoin-org/bcoin
*/ */
/* eslint-disable */
'use strict'; 'use strict';
const assert = require('assert'); const assert = require('assert');

View File

@ -4,6 +4,8 @@
* https://github.com/bcoin-org/bcoin * https://github.com/bcoin-org/bcoin
*/ */
/* eslint-disable */
'use strict'; 'use strict';
const assert = require('assert'); const assert = require('assert');

View File

@ -121,7 +121,7 @@ async function indexTips() {
function write(data, str, off) { function write(data, str, off) {
if (Buffer.isBuffer(str)) if (Buffer.isBuffer(str))
return str.copy(data, off); return str.copy(data, off);
data.write(str, off, 'hex'); return data.write(str, off, 'hex');
} }
function pair(prefix, hash) { function pair(prefix, hash) {

View File

@ -1,6 +1,5 @@
'use strict'; 'use strict';
const assert = require('assert');
const util = require('../lib/utils/util'); const util = require('../lib/utils/util');
const Script = require('../lib/script/script'); const Script = require('../lib/script/script');
const Stack = require('../lib/script/stack'); const Stack = require('../lib/script/stack');
@ -173,7 +172,7 @@ function randomRedeem() {
case 4: case 4:
return randomProgram(); return randomProgram();
} }
assert(false); throw new Error();
} }
function randomScript() { function randomScript() {
@ -193,7 +192,7 @@ function randomScript() {
case 6: case 6:
return randomProgram(); return randomProgram();
} }
assert(false); throw new Error();
} }
function randomPubkeyContext() { function randomPubkeyContext() {
@ -269,7 +268,7 @@ function randomContext() {
case 5: case 5:
return randomWitnessNestedContext(); return randomWitnessNestedContext();
} }
assert(false); throw new Error();
} }
function fuzzSimple(flags) { function fuzzSimple(flags) {
@ -434,11 +433,14 @@ function main() {
switch (process.argv[2]) { switch (process.argv[2]) {
case 'simple': case 'simple':
return fuzzSimple(flags); fuzzSimple(flags);
break;
case 'verify': case 'verify':
return fuzzVerify(flags); fuzzVerify(flags);
break;
case 'less': case 'less':
return fuzzLess(flags); fuzzLess(flags);
break;
default: default:
util.log('Please select a mode:'); util.log('Please select a mode:');
util.log('simple, verify, less'); util.log('simple, verify, less');