From e118cc7958f907583bbd41a3af1802b06c2c5753 Mon Sep 17 00:00:00 2001 From: Alex Browne Date: Wed, 30 May 2018 17:28:46 -0700 Subject: [PATCH 1/3] Include signature by default in FakeTransaction.hash --- fake.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/fake.js b/fake.js index 36be1f8..63758d7 100644 --- a/fake.js +++ b/fake.js @@ -59,6 +59,9 @@ module.exports = class FakeTransaction extends Transaction { * @return {Buffer} */ hash (includeSignature) { + if (includeSignature === null || includeSignature === undefined) { + includeSignature = true + } if (includeSignature) { // include a fake signature using the from address as a private key let fakeKey = Buffer.concat([this._from, this._from.slice(0, 12)]) From 5f0a610849de09f922f8ccee5af1aae4bec36e51 Mon Sep 17 00:00:00 2001 From: Alex Browne Date: Wed, 30 May 2018 18:01:56 -0700 Subject: [PATCH 2/3] Update FakeTransaction.hash tests --- test/fake.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/fake.js b/test/fake.js index 196a6d2..b41cd7a 100644 --- a/test/fake.js +++ b/test/fake.js @@ -16,8 +16,8 @@ tape('[FakeTransaction]: Basic functions', function (t) { var modifiedFromFieldTxData = Object.assign({}, baseTxData, { from: '0x2222222222222222222222222222222222222222' }) var baseTx = new FakeTransaction(baseTxData) var modifiedFromFieldTx = new FakeTransaction(modifiedFromFieldTxData) - var baseTxHash = utils.bufferToHex(baseTx.hash(true)) - var modifiedFromFieldTxHash = utils.bufferToHex(modifiedFromFieldTx.hash(true)) + var baseTxHash = utils.bufferToHex(baseTx.hash()) + var modifiedFromFieldTxHash = utils.bufferToHex(modifiedFromFieldTx.hash()) st.notEqual(baseTxHash, modifiedFromFieldTxHash, 'FakeTransactions with different `from` addresses but otherwise identical data should have different hashes') }) }) From b2eedb069160e948fdf320564e3cbbbd8534a743 Mon Sep 17 00:00:00 2001 From: Leonid Logvinov Date: Sat, 2 Jun 2018 09:29:29 -0700 Subject: [PATCH 3/3] Use ES6 default parameters for includeSignature --- fake.js | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/fake.js b/fake.js index 63758d7..b3fca2b 100644 --- a/fake.js +++ b/fake.js @@ -58,10 +58,7 @@ module.exports = class FakeTransaction extends Transaction { * @param {Boolean} [includeSignature=true] whether or not to inculde the signature * @return {Buffer} */ - hash (includeSignature) { - if (includeSignature === null || includeSignature === undefined) { - includeSignature = true - } + hash (includeSignature = true) { if (includeSignature) { // include a fake signature using the from address as a private key let fakeKey = Buffer.concat([this._from, this._from.slice(0, 12)])