From 6ba8eb9951f565d846de81ef4ff3db86125ef7c3 Mon Sep 17 00:00:00 2001 From: Christopher Jeffrey Date: Mon, 31 Jul 2017 00:34:42 -0700 Subject: [PATCH] eslint: more style rules. --- .eslintrc.json | 52 ++++++++++++++++++++-- bench/coins.js | 12 +++-- bin/cli | 2 +- examples/tx.js | 8 ++-- lib/bcoin.js | 2 + lib/crypto/scrypt.js | 2 + lib/db/lowlevelup.js | 4 +- lib/net/bip150.js | 2 +- lib/net/parser.js | 2 + lib/net/tcp.js | 2 + lib/net/upnp.js | 2 +- lib/protocol/networks.js | 14 +++--- lib/script/common.js | 8 ++-- lib/script/script.js | 13 ++++-- lib/script/stack.js | 7 ++- lib/script/witness.js | 3 +- lib/utils/co.js | 4 +- lib/utils/ip.js | 2 + lib/utils/pem.js | 12 +++-- lib/utils/writer.js | 92 +++++++++++++++++++++++++++++---------- lib/wallet/rpc.js | 2 +- lib/wallet/wallet.js | 3 +- lib/workers/packets.js | 1 - lib/workers/workerpool.js | 2 + migrate/walletdb2to3.js | 3 +- package.json | 2 +- scripts/fuzz.js | 7 ++- test/aes-test.js | 32 +++++++++----- test/bech32-test.js | 4 +- test/bip150-test.js | 1 + test/bip151-test.js | 1 + test/bip70-test.js | 5 ++- test/block-test.js | 33 ++++++++------ test/bloom-test.js | 1 + test/chachapoly-test.js | 7 ++- test/chain-test.js | 1 + test/coins-test.js | 1 + test/gcs-test.js | 1 + test/hd-test.js | 4 +- test/http-test.js | 19 +++++--- test/key-address-test.js | 7 ++- test/mempool-test.js | 16 ++++--- test/mnemonic-test.js | 1 + test/node-test.js | 16 ++++--- test/protocol-test.js | 1 + test/script-test.js | 1 + test/scrypt-test.js | 1 + test/siphash-test.js | 1 + test/tx-test.js | 9 ++-- test/util/node-context.js | 4 +- test/utils-test.js | 4 +- test/wallet-test.js | 13 +++--- 52 files changed, 320 insertions(+), 129 deletions(-) diff --git a/.eslintrc.json b/.eslintrc.json index ab7949c5..b1789709 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -8,7 +8,22 @@ "ecmaVersion": 8 }, "rules": { + "array-bracket-spacing": ["error", "never"], + "arrow-parens": ["error", "as-needed", { + "requireForBlockBody": true + }], + "arrow-spacing": "error", + "block-spacing": ["error", "always"], + "brace-style": ["error", "1tbs"], + "camelcase": ["error", { + "properties": "never" + }], + "comma-dangle": ["error", "never"], "consistent-return": "error", + "eol-last": ["error", "always"], + "eqeqeq": ["error", "always", { + "null": "ignore" + }], "func-name-matching": "off", "indent": ["error", 2, { "SwitchCase": 1, @@ -19,15 +34,36 @@ }], "handle-callback-err": "off", "linebreak-style": ["error", "unix"], + "max-len": ["error", { + "code": 80, + "ignorePattern": "function \\w+\\(", + "ignoreUrls": true + }], + "max-statements-per-line": ["error", { + "max": 1 + }], + "new-cap": ["error", { + "newIsCap": true, + "capIsNew": false + }], + "new-parens": "error", "no-buffer-constructor": "error", "no-console": "off", - "no-cond-assign": "off", "no-extra-semi": "off", "no-fallthrough": "off", "no-func-assign": "off", + "no-implicit-coercion": "off", + "no-multi-assign": "error", + "no-multiple-empty-lines": ["error", { + "max": 1 + }], + "no-nested-ternary": "error", "no-param-reassign": "off", + "no-return-assign": "error", + "no-return-await": "off", "no-shadow-restricted-names": "error", "no-tabs": "error", + "no-trailing-spaces": "error", "no-unused-vars": ["error", { "vars": "all", "args": "none", @@ -37,17 +73,25 @@ "functions": false, "classes": false }], - "no-unreachable": "off", "no-useless-escape": "off", - "no-unsafe-finally": "off", "no-var": "error", + "nonblock-statement-body-position": ["error", "below"], + "padded-blocks": ["error", "never"], + "prefer-arrow-callback": "error", "prefer-const": ["error", { "destructuring": "all", "ignoreReadBeforeAssign": true }], + "prefer-template": "off", "quotes": ["error", "single"], "semi": ["error", "always"], + "spaced-comment": ["error", "always", { + "exceptions": ["!"] + }], + "space-before-blocks": "error", "strict": "error", - "valid-jsdoc": "error" + "unicode-bom": ["error", "never"], + "valid-jsdoc": "error", + "wrap-iife": ["error", "inside"] } } diff --git a/bench/coins.js b/bench/coins.js index 074cfc1a..87028b2e 100644 --- a/bench/coins.js +++ b/bench/coins.js @@ -12,25 +12,29 @@ const raw = coins.toRaw(); { const end = bench('serialize'); - for (let i = 0; i < 10000; i++) { + + for (let i = 0; i < 10000; i++) coins.toRaw(); - } + end(10000); } { const end = bench('parse'); - for (let i = 0; i < 10000; i++) { + + for (let i = 0; i < 10000; i++) Coins.fromRaw(raw); - } + end(10000); } { const end = bench('get'); + for (let i = 0; i < 10000; i++) { for (let j = 0; j < coins.outputs.length; j++) coins.get(j); } + end(10000 * coins.outputs.length); } diff --git a/bin/cli b/bin/cli index 5d033b74..332ffccf 100755 --- a/bin/cli +++ b/bin/cli @@ -633,7 +633,7 @@ CLI.prototype.handleWallet = async function handleWallet() { this.log(' $ unlock [passphrase] [timeout?]: Unlock wallet.'); this.log(' $ resend: Resend pending transactions.'); this.log('Other Options:'); - this.log(' --passphrase [passphrase]: For signing and account creation.'); + this.log(' --passphrase [passphrase]: For signing & account creation.'); this.log(' --account [account-name]: Account name.'); break; } diff --git a/examples/tx.js b/examples/tx.js index 5058d028..c88effe3 100644 --- a/examples/tx.js +++ b/examples/tx.js @@ -1,5 +1,7 @@ 'use strict'; +/* eslint new-cap: "off" */ + const bcoin = require('bcoin'); const assert = require('assert'); @@ -39,9 +41,9 @@ const assert = require('assert'); value: 10000 }); - // Now that we've created the output, we can do some coin selection (the output - // must be added first so we know how much money is needed and also so we can - // accurately estimate the size for fee calculation). + // Now that we've created the output, we can do some coin selection (the + // output must be added first so we know how much money is needed and also so + // we can accurately estimate the size for fee calculation). // Select coins from our array and add inputs. // Calculate fee and add a change output. diff --git a/lib/bcoin.js b/lib/bcoin.js index cb221862..1a94b8ae 100644 --- a/lib/bcoin.js +++ b/lib/bcoin.js @@ -5,6 +5,8 @@ * https://github.com/bcoin-org/bcoin */ +/* eslint prefer-arrow-callback: "off" */ + 'use strict'; /** diff --git a/lib/crypto/scrypt.js b/lib/crypto/scrypt.js index 638e609e..b07dedc6 100644 --- a/lib/crypto/scrypt.js +++ b/lib/crypto/scrypt.js @@ -31,6 +31,8 @@ * SUCH DAMAGE. */ +/* eslint camelcase: "off" */ + 'use strict'; /** diff --git a/lib/db/lowlevelup.js b/lib/db/lowlevelup.js index d1f2fd93..806d4c20 100644 --- a/lib/db/lowlevelup.js +++ b/lib/db/lowlevelup.js @@ -58,8 +58,8 @@ function LowlevelUp(backend, location, options) { */ LowlevelUp.prototype.init = function init() { - const backend = this.backend; - let db = new backend(this.location); + const Backend = this.backend; + let db = new Backend(this.location); let binding = db; // Stay as close to the metal as possible. diff --git a/lib/net/bip150.js b/lib/net/bip150.js index 001842ce..36206165 100644 --- a/lib/net/bip150.js +++ b/lib/net/bip150.js @@ -343,7 +343,7 @@ BIP150.prototype.destroy = function destroy() { * @returns {Job} */ -BIP150.prototype.cleanup = function cleanup(err) { +BIP150.prototype.cleanup = function cleanup() { const job = this.job; assert(!this.completed, 'Already completed.'); diff --git a/lib/net/parser.js b/lib/net/parser.js index a1801f31..96535d58 100644 --- a/lib/net/parser.js +++ b/lib/net/parser.js @@ -5,6 +5,8 @@ * https://github.com/bcoin-org/bcoin */ +/* eslint nonblock-statement-body-position: "off" */ + 'use strict'; const assert = require('assert'); diff --git a/lib/net/tcp.js b/lib/net/tcp.js index 7a2512ea..6c112654 100644 --- a/lib/net/tcp.js +++ b/lib/net/tcp.js @@ -4,6 +4,8 @@ * https://github.com/bcoin-org/bcoin */ +/* eslint prefer-arrow-callback: "off" */ + 'use strict'; const EventEmitter = require('events'); diff --git a/lib/net/upnp.js b/lib/net/upnp.js index 57a2274a..84b60fbc 100644 --- a/lib/net/upnp.js +++ b/lib/net/upnp.js @@ -491,7 +491,7 @@ XMLElement.fromRaw = function fromRaw(xml) { let decl = false; while (xml.length > 0) { - let m = null; + let m; m = /^<\?xml[^<>]*\?>/i.exec(xml); if (m) { diff --git a/lib/protocol/networks.js b/lib/protocol/networks.js index 93f64b35..28d9f16f 100644 --- a/lib/protocol/networks.js +++ b/lib/protocol/networks.js @@ -127,7 +127,8 @@ main.genesis = { version: 1, hash: '6fe28c0ab6f1b372c1a6a246ae63f74f931e8365e15a089c68d6190000000000', prevBlock: '0000000000000000000000000000000000000000000000000000000000000000', - merkleRoot: '3ba3edfd7a7b12b27ac72c3e67768f617fc81bc3888a51323a9fb8aa4b1e5e4a', + merkleRoot: + '3ba3edfd7a7b12b27ac72c3e67768f617fc81bc3888a51323a9fb8aa4b1e5e4a', time: 1231006505, bits: 486604799, nonce: 2083236893, @@ -519,7 +520,8 @@ testnet.genesis = { version: 1, hash: '43497fd7f826957108f4a30fd9cec3aeba79972084e90ead01ea330900000000', prevBlock: '0000000000000000000000000000000000000000000000000000000000000000', - merkleRoot: '3ba3edfd7a7b12b27ac72c3e67768f617fc81bc3888a51323a9fb8aa4b1e5e4a', + merkleRoot: + '3ba3edfd7a7b12b27ac72c3e67768f617fc81bc3888a51323a9fb8aa4b1e5e4a', time: 1296688602, bits: 486604799, nonce: 414098458, @@ -679,7 +681,8 @@ regtest.genesis = { version: 1, hash: '06226e46111a0b59caaf126043eb5bbf28c34f3a5e332a1fc7b2b73cf188910f', prevBlock: '0000000000000000000000000000000000000000000000000000000000000000', - merkleRoot: '3ba3edfd7a7b12b27ac72c3e67768f617fc81bc3888a51323a9fb8aa4b1e5e4a', + merkleRoot: + '3ba3edfd7a7b12b27ac72c3e67768f617fc81bc3888a51323a9fb8aa4b1e5e4a', time: 1296688602, bits: 545259519, nonce: 2, @@ -731,7 +734,7 @@ regtest.bip30 = {}; regtest.activationThreshold = 108; // 75% for testchains -regtest.minerWindow = 144; // Faster than normal for regtest (144 instead of 2016) +regtest.minerWindow = 144; // Faster than normal for regtest regtest.deployments = { csv: { @@ -840,7 +843,8 @@ simnet.genesis = { version: 1, hash: 'f67ad7695d9b662a72ff3d8edbbb2de0bfa67b13974bb9910d116d5cbd863e68', prevBlock: '0000000000000000000000000000000000000000000000000000000000000000', - merkleRoot: '3ba3edfd7a7b12b27ac72c3e67768f617fc81bc3888a51323a9fb8aa4b1e5e4a', + merkleRoot: + '3ba3edfd7a7b12b27ac72c3e67768f617fc81bc3888a51323a9fb8aa4b1e5e4a', time: 1401292357, bits: 545259519, nonce: 2, diff --git a/lib/script/common.js b/lib/script/common.js index 227f0dae..d6021113 100644 --- a/lib/script/common.js +++ b/lib/script/common.js @@ -451,13 +451,15 @@ exports.isCompressedEncoding = function isCompressedEncoding(key) { exports.isSignatureEncoding = function isSignatureEncoding(sig) { assert(Buffer.isBuffer(sig)); - // Format: 0x30 [total-length] 0x02 [R-length] [R] 0x02 [S-length] [S] [sighash] + // Format: + // 0x30 [total-length] 0x02 [R-length] [R] 0x02 [S-length] [S] [sighash] // * total-length: 1-byte length descriptor of everything that follows, // excluding the sighash byte. // * R-length: 1-byte length descriptor of the R value that follows. // * R: arbitrary-length big-endian encoded R value. It must use the shortest // possible encoding for a positive integers (which means no null bytes at - // the start, except a single one when the next byte has its highest bit set). + // the start, except a single one when the next byte has its highest bit + // set). // * S-length: 1-byte length descriptor of the S value that follows. // * S: arbitrary-length big-endian encoded S value. The same rules apply. // * sighash: 1-byte value indicating what data is hashed (not part of the DER @@ -750,7 +752,7 @@ exports.num = function num(value, minimal, size) { * assert.deepEqual(Script.array(0), Buffer.alloc(0)); * assert.deepEqual(Script.array(0xffee), Buffer.from('eeff00', 'hex')); * assert.deepEqual(Script.array(new BN(0xffee)), Buffer.from('eeff00', 'hex')); - * assert.deepEqual(Script.array(new BN(0x1e).ineg()), Buffer.from('9e', 'hex')); + * assert.deepEqual(Script.array(new BN(0x1e).neg()), Buffer.from('9e', 'hex')); * @param {Number|BN} value * @returns {Buffer} */ diff --git a/lib/script/script.js b/lib/script/script.js index 265b60dc..3bdec829 100644 --- a/lib/script/script.js +++ b/lib/script/script.js @@ -126,7 +126,8 @@ Script.prototype.__defineGetter__('length', function() { */ Script.prototype.__defineSetter__('length', function(length) { - return this.code.length = length; + this.code.length = length; + return length; }); /** @@ -1174,7 +1175,13 @@ Script.prototype.execute = function execute(stack, flags, tx, index, value, vers if (sig.length > 0) { const type = sig[sig.length - 1]; - const hash = tx.signatureHash(index, subscript, value, type, version); + const hash = tx.signatureHash( + index, + subscript, + value, + type, + version + ); if (checksig(hash, sig, key)) { isig++; @@ -1277,7 +1284,7 @@ Script.num = function num(value, minimal, size) { * assert.deepEqual(Script.array(0), Buffer.alloc(0)); * assert.deepEqual(Script.array(0xffee), Buffer.from('eeff00', 'hex')); * assert.deepEqual(Script.array(new BN(0xffee)), Buffer.from('eeff00', 'hex')); - * assert.deepEqual(Script.array(new BN(0x1e).ineg()), Buffer.from('9e', 'hex')); + * assert.deepEqual(Script.array(new BN(0x1e).neg()), Buffer.from('9e', 'hex')); * @param {Number|BN} value * @returns {Buffer} */ diff --git a/lib/script/stack.js b/lib/script/stack.js index 753353de..22f6a87d 100644 --- a/lib/script/stack.js +++ b/lib/script/stack.js @@ -47,7 +47,8 @@ Stack.prototype.__defineGetter__('length', function() { */ Stack.prototype.__defineSetter__('length', function(length) { - return this.items.length = length; + this.items.length = length; + return length; }); /** @@ -250,7 +251,9 @@ Stack.prototype.set = function set(i, value) { if (i < 0) i = this.items.length + i; - return this.items[i] = value; + this.items[i] = value; + + return value; }; /** diff --git a/lib/script/witness.js b/lib/script/witness.js index 86f632e7..41cb4bd6 100644 --- a/lib/script/witness.js +++ b/lib/script/witness.js @@ -66,7 +66,8 @@ Witness.prototype.__defineGetter__('length', function() { */ Witness.prototype.__defineSetter__('length', function(length) { - return this.items.length = length; + this.items.length = length; + return length; }); /** diff --git a/lib/utils/co.js b/lib/utils/co.js index 8d22657b..20b24e1d 100644 --- a/lib/utils/co.js +++ b/lib/utils/co.js @@ -104,7 +104,7 @@ function isPromise(obj) { */ function wait() { - return new Promise((resolve) => setImmediate(resolve)); + return new Promise(resolve => setImmediate(resolve)); }; /** @@ -114,7 +114,7 @@ function wait() { */ function timeout(time) { - return new Promise((resolve) => setTimeout(resolve, time)); + return new Promise(resolve => setTimeout(resolve, time)); } /** diff --git a/lib/utils/ip.js b/lib/utils/ip.js index 6ca0f751..37bcab97 100644 --- a/lib/utils/ip.js +++ b/lib/utils/ip.js @@ -9,6 +9,8 @@ * Copyright (c) 2012, Fedor Indutny (MIT License). */ +/* eslint no-unreachable: "off" */ + 'use strict'; const assert = require('assert'); diff --git a/lib/utils/pem.js b/lib/utils/pem.js index 72218529..2d68372e 100644 --- a/lib/utils/pem.js +++ b/lib/utils/pem.js @@ -29,13 +29,15 @@ PEM.parse = function parse(pem) { while (pem.length) { let m; - if (m = /^-----BEGIN ([^\-]+)-----/.exec(pem)) { + m = /^-----BEGIN ([^\-]+)-----/.exec(pem); + if (m) { pem = pem.substring(m[0].length); tag = m[1]; continue; } - if (m = /^-----END ([^\-]+)-----/.exec(pem)) { + m = /^-----END ([^\-]+)-----/.exec(pem); + if (m) { pem = pem.substring(m[0].length); assert(tag === m[1], 'Tag mismatch.'); @@ -55,13 +57,15 @@ PEM.parse = function parse(pem) { continue; } - if (m = /^[a-zA-Z0-9\+=\/]+/.exec(pem)) { + m = /^[a-zA-Z0-9\+=\/]+/.exec(pem); + if (m) { pem = pem.substring(m[0].length); chunk += m[0]; continue; } - if (m = /^\s+/.exec(pem)) { + m = /^\s+/.exec(pem); + if (m) { pem = pem.substring(m[0].length); continue; } diff --git a/lib/utils/writer.js b/lib/utils/writer.js index fe37a500..40fa4bb3 100644 --- a/lib/utils/writer.js +++ b/lib/utils/writer.js @@ -75,29 +75,75 @@ BufferWriter.prototype.render = function render(keep) { for (const op of this.ops) { switch (op.type) { - case SEEK: off += op.value; break; - case UI8: off = data.writeUInt8(op.value, off, true); break; - case UI16: off = data.writeUInt16LE(op.value, off, true); break; - case UI16BE: off = data.writeUInt16BE(op.value, off, true); break; - case UI32: off = data.writeUInt32LE(op.value, off, true); break; - case UI32BE: off = data.writeUInt32BE(op.value, off, true); break; - case UI64: off = encoding.writeU64(data, op.value, off); break; - case UI64BE: off = encoding.writeU64BE(data, op.value, off); break; - case I8: off = data.writeInt8(op.value, off, true); break; - case I16: off = data.writeInt16LE(op.value, off, true); break; - case I16BE: off = data.writeInt16BE(op.value, off, true); break; - case I32: off = data.writeInt32LE(op.value, off, true); break; - case I32BE: off = data.writeInt32BE(op.value, off, true); break; - case I64: off = encoding.write64(data, op.value, off); break; - case I64BE: off = encoding.write64BE(data, op.value, off); break; - case FL: off = data.writeFloatLE(op.value, off, true); break; - case FLBE: off = data.writeFloatBE(op.value, off, true); break; - case DBL: off = data.writeDoubleLE(op.value, off, true); break; - case DBLBE: off = data.writeDoubleBE(op.value, off, true); break; - case VARINT: off = encoding.writeVarint(data, op.value, off); break; - case VARINT2: off = encoding.writeVarint2(data, op.value, off); break; - case BYTES: off += op.value.copy(data, off); break; - case STR: off += data.write(op.value, off, op.enc); break; + case SEEK: + off += op.value; + break; + case UI8: + off = data.writeUInt8(op.value, off, true); + break; + case UI16: + off = data.writeUInt16LE(op.value, off, true); + break; + case UI16BE: + off = data.writeUInt16BE(op.value, off, true); + break; + case UI32: + off = data.writeUInt32LE(op.value, off, true); + break; + case UI32BE: + off = data.writeUInt32BE(op.value, off, true); + break; + case UI64: + off = encoding.writeU64(data, op.value, off); + break; + case UI64BE: + off = encoding.writeU64BE(data, op.value, off); + break; + case I8: + off = data.writeInt8(op.value, off, true); + break; + case I16: + off = data.writeInt16LE(op.value, off, true); + break; + case I16BE: + off = data.writeInt16BE(op.value, off, true); + break; + case I32: + off = data.writeInt32LE(op.value, off, true); + break; + case I32BE: + off = data.writeInt32BE(op.value, off, true); + break; + case I64: + off = encoding.write64(data, op.value, off); + break; + case I64BE: + off = encoding.write64BE(data, op.value, off); + break; + case FL: + off = data.writeFloatLE(op.value, off, true); + break; + case FLBE: + off = data.writeFloatBE(op.value, off, true); + break; + case DBL: + off = data.writeDoubleLE(op.value, off, true); + break; + case DBLBE: + off = data.writeDoubleBE(op.value, off, true); + break; + case VARINT: + off = encoding.writeVarint(data, op.value, off); + break; + case VARINT2: + off = encoding.writeVarint2(data, op.value, off); + break; + case BYTES: + off += op.value.copy(data, off); + break; + case STR: + off += data.write(op.value, off, op.enc); + break; case CHECKSUM: off += digest.hash256(data.slice(0, off)).copy(data, off, 0, 4); break; diff --git a/lib/wallet/rpc.js b/lib/wallet/rpc.js index 7ba9310b..08eb99f2 100644 --- a/lib/wallet/rpc.js +++ b/lib/wallet/rpc.js @@ -889,7 +889,7 @@ RPC.prototype._listReceived = async function _listReceived(minconf, empty, watch account: path.name, amount: 0, confirmations: -1, - label: '', + label: '' }); } diff --git a/lib/wallet/wallet.js b/lib/wallet/wallet.js index 4e5ccc4e..13a9541e 100644 --- a/lib/wallet/wallet.js +++ b/lib/wallet/wallet.js @@ -1546,7 +1546,8 @@ Wallet.prototype.createTX = async function createTX(options, force) { // Consensus sanity checks. assert(mtx.isSane(), 'TX failed sanity check.'); - assert(mtx.verifyInputs(this.db.state.height + 1), 'TX failed context check.'); + assert(mtx.verifyInputs(this.db.state.height + 1), + 'TX failed context check.'); const total = await this.template(mtx); diff --git a/lib/workers/packets.js b/lib/workers/packets.js index 99f29d3c..b8a96117 100644 --- a/lib/workers/packets.js +++ b/lib/workers/packets.js @@ -694,7 +694,6 @@ SignInputResultPacket.fromRaw = function fromRaw(data) { return packet; }; - /** * ECVerifyPacket * @constructor diff --git a/lib/workers/workerpool.js b/lib/workers/workerpool.js index 697f7074..a269b402 100644 --- a/lib/workers/workerpool.js +++ b/lib/workers/workerpool.js @@ -5,6 +5,8 @@ * https://github.com/bcoin-org/bcoin */ +/* eslint no-nested-ternary: "off" */ + 'use strict'; const assert = require('assert'); diff --git a/migrate/walletdb2to3.js b/migrate/walletdb2to3.js index b9f06c03..e8e9b09a 100644 --- a/migrate/walletdb2to3.js +++ b/migrate/walletdb2to3.js @@ -8,6 +8,7 @@ const Path = require('../lib/wallet/path'); const MasterKey = require('../lib/wallet/masterkey'); const Account = require('../lib/wallet/account'); const Wallet = require('../lib/wallet/wallet'); +const KeyRing = require('../lib/primitives/keyring'); const BufferReader = require('../lib/utils/reader'); const BufferWriter = require('../lib/utils/writer'); const layout = walletdb.layout; @@ -85,7 +86,7 @@ async function updatePathMap() { continue; } const ring = keyFromRaw(path.data); - path.data = new bcoin.keyring(ring).toRaw(); + path.data = new KeyRing(ring).toRaw(); } batch.put(layout.P(key, hash), path.toRaw()); } diff --git a/package.json b/package.json index f134187f..b212fa81 100644 --- a/package.json +++ b/package.json @@ -60,7 +60,7 @@ "scripts": { "clean": "rm -f {browser/,}{bcoin.js,bcoin-worker.js}", "docs": "jsdoc -c jsdoc.json", - "lint": "eslint lib/ test/ migrate/ examples/ bench/ scripts/*.js bin/cli bin/node bin/spvnode || exit 0", + "lint": "eslint lib/ test/ migrate/ examples/ bench/ scripts/*.js bin/{cli,node,spvnode,wallet} || exit 0", "lint-file": "eslint", "test": "mocha --reporter spec test/*-test.js", "test-browser": "BCOIN_NO_NATIVE=1 BCOIN_NO_SECP256K1=1 mocha --reporter spec test/*-test.js", diff --git a/scripts/fuzz.js b/scripts/fuzz.js index 6a4ce540..a31e3363 100644 --- a/scripts/fuzz.js +++ b/scripts/fuzz.js @@ -10,7 +10,8 @@ const Outpoint = require('../lib/primitives/outpoint'); const TX = require('../lib/primitives/tx'); const random = require('../lib/crypto/random'); -const MANDATORY = Script.flags.MANDATORY_VERIFY_FLAGS | Script.flags.VERIFY_WITNESS; +const MANDATORY = Script.flags.MANDATORY_VERIFY_FLAGS + | Script.flags.VERIFY_WITNESS; const STANDARD = Script.flags.STANDARD_VERIFY_FLAGS; function randomOutpoint() { @@ -429,7 +430,9 @@ function fuzzLess(flags) { } function main() { - const flags = process.argv.indexOf('--standard') !== -1 ? STANDARD : MANDATORY; + const flags = process.argv.indexOf('--standard') !== -1 + ? STANDARD + : MANDATORY; switch (process.argv[2]) { case 'simple': diff --git a/test/aes-test.js b/test/aes-test.js index 828089d2..fbea6ac4 100644 --- a/test/aes-test.js +++ b/test/aes-test.js @@ -1,4 +1,5 @@ /* eslint-env mocha */ +/* eslint prefer-arrow-callback: "off" */ 'use strict'; @@ -6,11 +7,12 @@ const assert = require('assert'); const digest = require('../lib/crypto/digest'); const aes = require('../lib/crypto/aes'); const pbkdf2 = require('../lib/crypto/pbkdf2'); -const nativeCrypto = require('crypto'); +const ncrypto = require('crypto'); describe('AES', function() { function pbkdf2key(passphrase, iterations, dkLen, ivLen, alg) { - const key = pbkdf2.derive(passphrase, '', iterations, dkLen + ivLen, 'sha512'); + const key = pbkdf2.derive( + passphrase, '', iterations, dkLen + ivLen, 'sha512'); return { key: key.slice(0, dkLen), iv: key.slice(dkLen, dkLen + ivLen) @@ -18,7 +20,7 @@ describe('AES', function() { } function nencrypt(data, passphrase) { - assert(nativeCrypto, 'No crypto module available.'); + assert(ncrypto, 'No crypto module available.'); assert(passphrase, 'No passphrase.'); if (typeof data === 'string') @@ -28,7 +30,7 @@ describe('AES', function() { passphrase = Buffer.from(passphrase, 'utf8'); const key = pbkdf2key(passphrase, 2048, 32, 16); - const cipher = nativeCrypto.createCipheriv('aes-256-cbc', key.key, key.iv); + const cipher = ncrypto.createCipheriv('aes-256-cbc', key.key, key.iv); return Buffer.concat([ cipher.update(data), @@ -37,7 +39,7 @@ describe('AES', function() { } function ndecrypt(data, passphrase) { - assert(nativeCrypto, 'No crypto module available.'); + assert(ncrypto, 'No crypto module available.'); assert(passphrase, 'No passphrase.'); if (typeof data === 'string') @@ -47,7 +49,7 @@ describe('AES', function() { passphrase = Buffer.from(passphrase, 'utf8'); const key = pbkdf2key(passphrase, 2048, 32, 16); - const decipher = nativeCrypto.createDecipheriv('aes-256-cbc', key.key, key.iv); + const decipher = ncrypto.createDecipheriv('aes-256-cbc', key.key, key.iv); return Buffer.concat([ decipher.update(data), @@ -56,7 +58,7 @@ describe('AES', function() { } function bencrypt(data, passphrase) { - assert(nativeCrypto, 'No crypto module available.'); + assert(ncrypto, 'No crypto module available.'); assert(passphrase, 'No passphrase.'); if (typeof data === 'string') @@ -70,7 +72,7 @@ describe('AES', function() { } function bdecrypt(data, passphrase) { - assert(nativeCrypto, 'No crypto module available.'); + assert(ncrypto, 'No crypto module available.'); assert(passphrase, 'No passphrase.'); if (typeof data === 'string') @@ -84,7 +86,7 @@ describe('AES', function() { } function encrypt(data, passphrase) { - assert(nativeCrypto, 'No crypto module available.'); + assert(ncrypto, 'No crypto module available.'); assert(passphrase, 'No passphrase.'); if (typeof data === 'string') @@ -99,7 +101,7 @@ describe('AES', function() { } function decrypt(data, passphrase) { - assert(nativeCrypto, 'No crypto module available.'); + assert(ncrypto, 'No crypto module available.'); assert(passphrase, 'No passphrase.'); if (typeof data === 'string') @@ -133,11 +135,17 @@ describe('AES', function() { }); it('should encrypt and decrypt a hash with uneven blocks', () => { - const hash = Buffer.concat([digest.sha256(Buffer.alloc(0)), Buffer.from([1,2,3])]); + const hash = Buffer.concat([ + digest.sha256(Buffer.alloc(0)), + Buffer.from([1,2,3])]); + const enchash = encrypt(hash, 'foo'); const dechash = decrypt(enchash, 'foo'); - const hash2 = Buffer.concat([digest.sha256(Buffer.alloc(0)), Buffer.from([1,2,3])]); + const hash2 = Buffer.concat([ + digest.sha256(Buffer.alloc(0)), + Buffer.from([1,2,3])]); + const enchash2 = nencrypt(hash2, 'foo'); const dechash2 = ndecrypt(enchash2, 'foo'); diff --git a/test/bech32-test.js b/test/bech32-test.js index 520deeb3..c1553105 100644 --- a/test/bech32-test.js +++ b/test/bech32-test.js @@ -22,6 +22,8 @@ // THE SOFTWARE. /* eslint-env mocha */ +/* eslint max-len: "off" */ +/* eslint prefer-arrow-callback: "off" */ 'use strict'; @@ -97,7 +99,7 @@ describe('Bech32', function() { 'BC1QR508D6QEJXTDG4Y5R3ZARVARYV98GJ9P', 'tb1qrp33g0q5c5txsp9arysrx4k6zdkfs4nce4xj0gdcccefvpysxf3q0sL5k7', 'tb1pw508d6qejxtdg4y5r3zarqfsj6c3', - 'tb1qrp33g0q5c5txsp9arysrx4k6zdkfs4nce4xj0gdcccefvpysxf3pjxtptv', + 'tb1qrp33g0q5c5txsp9arysrx4k6zdkfs4nce4xj0gdcccefvpysxf3pjxtptv' ]; function fromAddress(hrp, addr) { diff --git a/test/bip150-test.js b/test/bip150-test.js index 6122f60a..d6107e4e 100644 --- a/test/bip150-test.js +++ b/test/bip150-test.js @@ -1,4 +1,5 @@ /* eslint-env mocha */ +/* eslint prefer-arrow-callback: "off" */ 'use strict'; diff --git a/test/bip151-test.js b/test/bip151-test.js index 7af51e93..9d09b588 100644 --- a/test/bip151-test.js +++ b/test/bip151-test.js @@ -1,4 +1,5 @@ /* eslint-env mocha */ +/* eslint prefer-arrow-callback: "off" */ 'use strict'; diff --git a/test/bip70-test.js b/test/bip70-test.js index 4d29c450..70a8201a 100644 --- a/test/bip70-test.js +++ b/test/bip70-test.js @@ -1,4 +1,5 @@ /* eslint-env mocha */ +/* eslint prefer-arrow-callback: "off" */ 'use strict'; @@ -39,7 +40,9 @@ describe('BIP70', function() { assert(request.verify()); } - x509.verifyTime = function() { return true; }; + x509.verifyTime = function() { + return true; + }; it('should parse and verify a payment request', () => { testRequest(tests.valid); diff --git a/test/block-test.js b/test/block-test.js index 9745d8fe..f56c141a 100644 --- a/test/block-test.js +++ b/test/block-test.js @@ -1,4 +1,6 @@ /* eslint-env mocha */ +/* eslint max-len: "off" */ +/* eslint prefer-arrow-callback: "off" */ 'use strict'; @@ -16,6 +18,9 @@ const encoding = require('../lib/utils/encoding'); const bip152 = require('../lib/net/bip152'); const BufferReader = require('../lib/utils/reader'); const fs = require('../lib/utils/fs'); +const CompactBlock = bip152.CompactBlock; +const TXRequest = bip152.TXRequest; +const TXResponse = bip152.TXResponse; const block300025 = require('./data/block300025.json'); const cmpct2block = fs.readFileSync(`${__dirname}/data/cmpct2.bin`); @@ -285,8 +290,8 @@ describe('Block', function() { it('should handle compact block', () => { const block = Block.fromRaw(cmpct1[1], 'hex'); - const cblock1 = bip152.CompactBlock.fromRaw(cmpct1[0], 'hex'); - const cblock2 = bip152.CompactBlock.fromBlock(block, false, cblock1.keyNonce); + const cblock1 = CompactBlock.fromRaw(cmpct1[0], 'hex'); + const cblock2 = CompactBlock.fromBlock(block, false, cblock1.keyNonce); const map = new Map(); assert(cblock1.init()); @@ -318,8 +323,8 @@ describe('Block', function() { it('should handle half-full compact block', () => { const block = Block.fromRaw(cmpct1[1], 'hex'); - const cblock1 = bip152.CompactBlock.fromRaw(cmpct1[0], 'hex'); - const cblock2 = bip152.CompactBlock.fromBlock(block, false, cblock1.keyNonce); + const cblock1 = CompactBlock.fromRaw(cmpct1[0], 'hex'); + const cblock2 = CompactBlock.fromBlock(block, false, cblock1.keyNonce); const map = new Map(); assert(cblock1.init()); @@ -345,12 +350,12 @@ describe('Block', function() { assert.equal(req.hash, cblock1.hash('hex')); assert.deepEqual(req.indexes, [5, 6, 7, 8, 9]); - req = bip152.TXRequest.fromRaw(req.toRaw()); + req = TXRequest.fromRaw(req.toRaw()); assert.equal(req.hash, cblock1.hash('hex')); assert.deepEqual(req.indexes, [5, 6, 7, 8, 9]); - let res = bip152.TXResponse.fromBlock(block, req); - res = bip152.TXResponse.fromRaw(res.toRaw()); + let res = TXResponse.fromBlock(block, req); + res = TXResponse.fromRaw(res.toRaw()); result = cblock1.fillMissing(res); assert(result); @@ -365,8 +370,8 @@ describe('Block', function() { it('should handle compact block', () => { const block = Block.fromRaw(cmpct2block); - const cblock1 = bip152.CompactBlock.fromRaw(cmpct2, 'hex'); - const cblock2 = bip152.CompactBlock.fromBlock(block, false, cblock1.keyNonce); + const cblock1 = CompactBlock.fromRaw(cmpct2, 'hex'); + const cblock2 = CompactBlock.fromBlock(block, false, cblock1.keyNonce); const map = new Map(); assert(cblock1.init()); @@ -396,8 +401,8 @@ describe('Block', function() { it('should handle half-full compact block', () => { const block = Block.fromRaw(cmpct2block); - const cblock1 = bip152.CompactBlock.fromRaw(cmpct2, 'hex'); - const cblock2 = bip152.CompactBlock.fromBlock(block, false, cblock1.keyNonce); + const cblock1 = CompactBlock.fromRaw(cmpct2, 'hex'); + const cblock2 = CompactBlock.fromBlock(block, false, cblock1.keyNonce); const map = new Map(); assert(cblock1.init()); @@ -420,11 +425,11 @@ describe('Block', function() { let req = cblock1.toRequest(); assert.equal(req.hash, cblock1.hash('hex')); - req = bip152.TXRequest.fromRaw(req.toRaw()); + req = TXRequest.fromRaw(req.toRaw()); assert.equal(req.hash, cblock1.hash('hex')); - let res = bip152.TXResponse.fromBlock(block, req); - res = bip152.TXResponse.fromRaw(res.toRaw()); + let res = TXResponse.fromBlock(block, req); + res = TXResponse.fromRaw(res.toRaw()); result = cblock1.fillMissing(res); assert(result); diff --git a/test/bloom-test.js b/test/bloom-test.js index 7bbe8262..02660802 100644 --- a/test/bloom-test.js +++ b/test/bloom-test.js @@ -1,4 +1,5 @@ /* eslint-env mocha */ +/* eslint prefer-arrow-callback: "off" */ 'use strict'; diff --git a/test/chachapoly-test.js b/test/chachapoly-test.js index 7c1783cb..ec1f7bb9 100644 --- a/test/chachapoly-test.js +++ b/test/chachapoly-test.js @@ -1,4 +1,5 @@ /* eslint-env mocha */ +/* eslint prefer-arrow-callback: "off" */ 'use strict'; @@ -96,7 +97,8 @@ describe('ChaCha20 / Poly1305 / AEAD', function() { + '0000000000000000000000000000000000000000000000000000000000000000', ciphertext: '' + '76b8e0ada0f13d90405d6ae55386bd28bdd219b8a08ded1aa836efcc8b77' - + '0dc7da41597c5157488d7724e03fb8d84a376a43b8f41518a11cc387b669b2ee6586', + + '0dc7da41597c5157488d7724e03fb8d84a376a43b8f41518a11cc387b669' + + 'b2ee6586', counter: 0 }); }); @@ -175,7 +177,8 @@ describe('ChaCha20 / Poly1305 / AEAD', function() { }); it('should perform poly1305', () => { - let key = '85d6be7857556d337f4452fe42d506a80103808afb0db2fd4abff6af4149f51b'; + let key = '85d6be7857556d337f4452fe42d506a' + + '80103808afb0db2fd4abff6af4149f51b'; let msg = 'Cryptographic Forum Research Group'; let tag = 'a8061dc1305136c6c22b8baf0c0127a9'; diff --git a/test/chain-test.js b/test/chain-test.js index 648eeea7..1f24b6d2 100644 --- a/test/chain-test.js +++ b/test/chain-test.js @@ -1,4 +1,5 @@ /* eslint-env mocha */ +/* eslint prefer-arrow-callback: "off" */ 'use strict'; diff --git a/test/coins-test.js b/test/coins-test.js index 91073e52..ae312006 100644 --- a/test/coins-test.js +++ b/test/coins-test.js @@ -1,4 +1,5 @@ /* eslint-env mocha */ +/* eslint prefer-arrow-callback: "off" */ 'use strict'; diff --git a/test/gcs-test.js b/test/gcs-test.js index 5de93c52..1ffa78d7 100644 --- a/test/gcs-test.js +++ b/test/gcs-test.js @@ -1,4 +1,5 @@ /* eslint-env mocha */ +/* eslint prefer-arrow-callback: "off" */ 'use strict'; diff --git a/test/hd-test.js b/test/hd-test.js index 4202370a..21596e41 100644 --- a/test/hd-test.js +++ b/test/hd-test.js @@ -1,4 +1,5 @@ /* eslint-env mocha */ +/* eslint prefer-arrow-callback: "off" */ 'use strict'; @@ -23,7 +24,8 @@ describe('HD', function() { let master, child1, child2, child3, child4, child5, child6; it('should create a pbkdf2 seed', () => { - const seed = pbkdf2.derive(vectors.phrase, 'mnemonicfoo', 2048, 64, 'sha512'); + const seed = pbkdf2.derive( + vectors.phrase, 'mnemonicfoo', 2048, 64, 'sha512'); assert.equal(seed.toString('hex'), vectors.seed); }); diff --git a/test/http-test.js b/test/http-test.js index 160d7dc7..b6b1d025 100644 --- a/test/http-test.js +++ b/test/http-test.js @@ -1,4 +1,5 @@ /* eslint-env mocha */ +/* eslint prefer-arrow-callback: "off" */ 'use strict'; @@ -184,15 +185,17 @@ describe('HTTP', function() { it('should get a block template', async () => { const json = await wallet.client.rpc.execute('getblocktemplate', []); assert.deepStrictEqual(json, { - capabilities: [ 'proposal' ], - mutable: [ 'time', 'transactions', 'prevblock' ], + capabilities: ['proposal'], + mutable: ['time', 'transactions', 'prevblock'], version: 536870912, rules: [], vbavailable: {}, vbrequired: 0, height: 1, - previousblockhash: '0f9188f13cb7b2c71f2a335e3a4fc328bf5beb436012afca590b1a11466e2206', - target: '7fffff0000000000000000000000000000000000000000000000000000000000', + previousblockhash: + '0f9188f13cb7b2c71f2a335e3a4fc328bf5beb436012afca590b1a11466e2206', + target: + '7fffff0000000000000000000000000000000000000000000000000000000000', bits: '207fffff', noncerange: '00000000ffffffff', curtime: json.curtime, @@ -201,7 +204,9 @@ describe('HTTP', function() { expires: json.expires, sigoplimit: 20000, sizelimit: 1000000, - longpollid: '0f9188f13cb7b2c71f2a335e3a4fc328bf5beb436012afca590b1a11466e22060000000000', + longpollid: + '0f9188f13cb7b2c71f2a335e3a4fc328bf5beb436012afca590b1a11466e2206' + + '0000000000', submitold: false, coinbaseaux: { flags: '6d696e65642062792062636f696e' }, coinbasevalue: 5000000000, @@ -221,7 +226,9 @@ describe('HTTP', function() { }); it('should validate an address', async () => { - const json = await wallet.client.rpc.execute('validateaddress', [addr.toString()]); + const json = await wallet.client.rpc.execute('validateaddress', [ + addr.toString() + ]); assert.deepStrictEqual(json, { isvalid: true, address: addr.toString(), diff --git a/test/key-address-test.js b/test/key-address-test.js index d1c23655..c238bc41 100644 --- a/test/key-address-test.js +++ b/test/key-address-test.js @@ -1,4 +1,5 @@ /* eslint-env mocha */ +/* eslint prefer-arrow-callback: "off" */ 'use strict'; @@ -6,8 +7,10 @@ const assert = require('assert'); const keyring = require('../lib/primitives/keyring'); describe('Keyring Address', function() { - const ukey = keyring.fromSecret('5KYZdUEo39z3FPrtuX2QbbwGnNP5zTd7yyr2SC1j299sBCnWjss'); - const ckey = keyring.fromSecret('L4rK1yDtCWekvXuE6oXD9jCYfFNV2cWRpVuPLBcCU2z8TrisoyY1'); + const ukey = keyring.fromSecret( + '5KYZdUEo39z3FPrtuX2QbbwGnNP5zTd7yyr2SC1j299sBCnWjss'); + const ckey = keyring.fromSecret( + 'L4rK1yDtCWekvXuE6oXD9jCYfFNV2cWRpVuPLBcCU2z8TrisoyY1'); it('check uncompressed public key', () => { assert.equal( diff --git a/test/mempool-test.js b/test/mempool-test.js index db1fd93b..f73a77b8 100644 --- a/test/mempool-test.js +++ b/test/mempool-test.js @@ -1,4 +1,5 @@ /* eslint-env mocha */ +/* eslint prefer-arrow-callback: "off" */ 'use strict'; @@ -62,7 +63,8 @@ describe('Mempool', function() { const prev = Script.fromPubkey(kp.publicKey); t1.addCoin(dummy(prev)); - const sig = t1.signature(0, prev, 70000, kp.privateKey, Script.hashType.ALL, 0); + const sig = t1.signature( + 0, prev, 70000, kp.privateKey, Script.hashType.ALL, 0); t1.inputs[0].script = new Script([sig]); // balance: 51000 @@ -166,7 +168,8 @@ describe('Mempool', function() { chain.tip.height = 200; - const sig = tx.signature(0, prev, 70000, kp.privateKey, Script.hashType.ALL, 0); + const sig = tx.signature( + 0, prev, 70000, kp.privateKey, Script.hashType.ALL, 0); tx.inputs[0].script = new Script([sig]); tx = tx.toTX(); @@ -190,7 +193,8 @@ describe('Mempool', function() { tx.setLocktime(200); chain.tip.height = 200 - 1; - const sig = tx.signature(0, prev, 70000, kp.privateKey, Script.hashType.ALL, 0); + const sig = tx.signature( + 0, prev, 70000, kp.privateKey, Script.hashType.ALL, 0); tx.inputs[0].script = new Script([sig]); tx = tx.toTX(); @@ -223,7 +227,8 @@ describe('Mempool', function() { const prevs = Script.fromPubkeyhash(kp.getKeyHash()); - const sig = tx.signature(0, prevs, 70000, kp.privateKey, Script.hashType.ALL, 1); + const sig = tx.signature( + 0, prevs, 70000, kp.privateKey, Script.hashType.ALL, 1); sig[sig.length - 1] = 0; tx.inputs[0].witness = new Witness([sig, kp.publicKey]); @@ -253,7 +258,8 @@ describe('Mempool', function() { tx.addCoin(dummy(prev, prevHash)); - const sig = tx.signature(0, prev, 70000, kp.privateKey, Script.hashType.ALL, 0); + const sig = tx.signature( + 0, prev, 70000, kp.privateKey, Script.hashType.ALL, 0); tx.inputs[0].script = new Script([sig]); tx.inputs[0].witness.push(Buffer.alloc(0)); tx = tx.toTX(); diff --git a/test/mnemonic-test.js b/test/mnemonic-test.js index 20a6d26d..276c0bc7 100644 --- a/test/mnemonic-test.js +++ b/test/mnemonic-test.js @@ -1,4 +1,5 @@ /* eslint-env mocha */ +/* eslint prefer-arrow-callback: "off" */ 'use strict'; diff --git a/test/node-test.js b/test/node-test.js index d44ce2ba..440e7f07 100644 --- a/test/node-test.js +++ b/test/node-test.js @@ -1,4 +1,5 @@ /* eslint-env mocha */ +/* eslint prefer-arrow-callback: "off" */ 'use strict'; @@ -183,7 +184,7 @@ describe('Node', function() { assert(chain.tip === tip); }); - it('should fail to mine a block with coins on an alternate chain', async () => { + it('should fail to mine block with coins on an alternate chain', async () => { const block = await mineBlock(null, cb1); const tip = chain.tip; let err; @@ -467,15 +468,16 @@ describe('Node', function() { assert.deepStrictEqual(json, { result: { - capabilities: [ 'proposal' ], - mutable: [ 'time', 'transactions', 'prevblock' ], + capabilities: ['proposal'], + mutable: ['time', 'transactions', 'prevblock'], version: 536870912, - rules: [ 'csv', '!segwit', 'testdummy' ], + rules: ['csv', '!segwit', 'testdummy'], vbavailable: {}, vbrequired: 0, height: 437, previousblockhash: node.chain.tip.rhash(), - target: '7fffff0000000000000000000000000000000000000000000000000000000000', + target: + '7fffff0000000000000000000000000000000000000000000000000000000000', bits: '207fffff', noncerange: '00000000ffffffff', curtime: json.result.curtime, @@ -490,7 +492,9 @@ describe('Node', function() { coinbaseaux: { flags: '6d696e65642062792062636f696e' }, coinbasevalue: 1250000000, coinbasetxn: undefined, - default_witness_commitment: '6a24aa21a9ede2f61c3f71d1defd3fa999dfa36953755c690689799962b48bebd836974e8cf9', + default_witness_commitment: + '6a24aa21a9ede2f61c3f71d1defd3fa999dfa36953755c690689799962' + + 'b48bebd836974e8cf9', transactions: [] }, error: null, diff --git a/test/protocol-test.js b/test/protocol-test.js index 0e7db3c6..2be4f56f 100644 --- a/test/protocol-test.js +++ b/test/protocol-test.js @@ -1,4 +1,5 @@ /* eslint-env mocha */ +/* eslint prefer-arrow-callback: "off" */ 'use strict'; diff --git a/test/script-test.js b/test/script-test.js index 802d9a83..b5eb3a3a 100644 --- a/test/script-test.js +++ b/test/script-test.js @@ -1,4 +1,5 @@ /* eslint-env mocha */ +/* eslint prefer-arrow-callback: "off" */ 'use strict'; diff --git a/test/scrypt-test.js b/test/scrypt-test.js index 5685bf07..6ec18002 100644 --- a/test/scrypt-test.js +++ b/test/scrypt-test.js @@ -1,4 +1,5 @@ /* eslint-env mocha */ +/* eslint prefer-arrow-callback: "off" */ 'use strict'; diff --git a/test/siphash-test.js b/test/siphash-test.js index 64f5316d..a0b23a6e 100644 --- a/test/siphash-test.js +++ b/test/siphash-test.js @@ -1,4 +1,5 @@ /* eslint-env mocha */ +/* eslint prefer-arrow-callback: "off" */ 'use strict'; diff --git a/test/tx-test.js b/test/tx-test.js index 4e900206..60fe8966 100644 --- a/test/tx-test.js +++ b/test/tx-test.js @@ -1,4 +1,5 @@ /* eslint-env mocha */ +/* eslint prefer-arrow-callback: "off" */ 'use strict'; @@ -270,7 +271,7 @@ describe('TX', function() { if (valid) { if (comments.indexOf('Coinbase') === 0) { - it(`should handle valid coinbase ${suffix}: ${comments}`, () => { + it(`should handle valid tx test ${suffix}: ${comments}`, () => { clearCache(tx, noCache); assert.ok(tx.isSane()); }); @@ -282,7 +283,7 @@ describe('TX', function() { }); } else { if (comments === 'Duplicate inputs') { - it(`should handle duplicate input test ${suffix}: ${comments}`, () => { + it(`should handle invalid tx test ${suffix}: ${comments}`, () => { clearCache(tx, noCache); assert.ok(tx.verify(view, flags)); assert.ok(!tx.isSane()); @@ -290,7 +291,7 @@ describe('TX', function() { return; } if (comments === 'Negative output') { - it(`should handle invalid tx (negative) ${suffix}: ${comments}`, () => { + it(`should handle invalid tx test ${suffix}: ${comments}`, () => { clearCache(tx, noCache); assert.ok(tx.verify(view, flags)); assert.ok(!tx.isSane()); @@ -298,7 +299,7 @@ describe('TX', function() { return; } if (comments.indexOf('Coinbase') === 0) { - it(`should handle invalid coinbase ${suffix}: ${comments}`, () => { + it(`should handle invalid tx test ${suffix}: ${comments}`, () => { clearCache(tx, noCache); assert.ok(!tx.isSane()); }); diff --git a/test/util/node-context.js b/test/util/node-context.js index 57d7a5df..0912e144 100644 --- a/test/util/node-context.js +++ b/test/util/node-context.js @@ -17,7 +17,7 @@ function NodeContext(network, size) { this.init(); }; -NodeContext.prototype.init = function() { +NodeContext.prototype.init = function init() { let i, port, last, node; for (i = 0; i < this.size; i++) { @@ -46,7 +46,7 @@ NodeContext.prototype.init = function() { ] }); - node.on('error', function(err) { + node.on('error', (err) => { node.logger.error(err); }); diff --git a/test/utils-test.js b/test/utils-test.js index 9738ee64..5d10959e 100644 --- a/test/utils-test.js +++ b/test/utils-test.js @@ -1,4 +1,5 @@ /* eslint-env mocha */ +/* eslint prefer-arrow-callback: "off" */ 'use strict'; @@ -254,7 +255,8 @@ describe('Utils', function() { let info = 'f0f1f2f3f4f5f6f7f8f9'; let len = 42; - let prkE = '077709362c2e32df0ddc3f0dc47bba6390b6c73bb50f9c3122ec844ad7c2b3e5'; + let prkE = '077709362c2e32df0ddc3f0dc47bba6390b6c73bb50f9c3122ec8' + + '44ad7c2b3e5'; let okmE = '3cb25f25faacd57a90434f64d0362f2a2d2d0a90cf1' + 'a5a4c5db02d56ecc4c5bf34007208d5b887185865'; diff --git a/test/wallet-test.js b/test/wallet-test.js index 0cd5ff15..233aec05 100644 --- a/test/wallet-test.js +++ b/test/wallet-test.js @@ -1,4 +1,5 @@ /* eslint-env mocha */ +/* eslint prefer-arrow-callback: "off" */ 'use strict'; @@ -127,15 +128,15 @@ describe('Wallet', function() { assert(tx.verify(flags)); } - it('should sign/verify pubkeyhash tx', async () => { + it('should sign/verify p2pkh tx', async () => { await testP2PKH(false, false); }); - it('should sign/verify witnesspubkeyhash tx', async () => { + it('should sign/verify p2wpkh tx', async () => { await testP2PKH(true, false); }); - it('should sign/verify witnesspubkeyhash tx with bullshit nesting', async () => { + it('should sign/verify p2wpkh tx w/ nested bullshit', async () => { await testP2PKH(true, true); }); @@ -730,15 +731,15 @@ describe('Wallet', function() { assert.equal(send.getFee(view), 10000); } - it('should verify 2-of-3 scripthash tx', async () => { + it('should verify 2-of-3 p2sh tx', async () => { await testMultisig(false, false); }); - it('should verify 2-of-3 witnessscripthash tx', async () => { + it('should verify 2-of-3 p2wsh tx', async () => { await testMultisig(true, false); }); - it('should verify 2-of-3 witnessscripthash tx with bullshit nesting', async () => { + it('should verify 2-of-3 p2wsh tx w/ nested bullshit', async () => { await testMultisig(true, true); });