From dbc48c3992b9592ae6984c0dc402f06ad60d7814 Mon Sep 17 00:00:00 2001 From: Thomas Huang Date: Mon, 12 Jun 2017 17:42:54 -0700 Subject: [PATCH 1/3] Make test Async --- test/unit/tx-controller-test.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/test/unit/tx-controller-test.js b/test/unit/tx-controller-test.js index 3954300a8..f05ae479b 100644 --- a/test/unit/tx-controller-test.js +++ b/test/unit/tx-controller-test.js @@ -311,12 +311,13 @@ describe('Transaction Controller', function () { }) describe('#sign replay-protected tx', function () { - it('prepares a tx with the chainId set', function () { + it('prepares a tx with the chainId set', function (done) { txController.addTx({ id: '1', status: 'unapproved', metamaskNetworkId: currentNetworkId, txParams: {} }, noop) txController.signTransaction('1', (err, rawTx) => { if (err) return assert.fail('it should not fail') const ethTx = new EthTx(ethUtil.toBuffer(rawTx)) assert.equal(ethTx.getChainId(), currentNetworkId) + done() }) }) }) From ae7c296669ad5c81e85071de071e2b0f2b1d4463 Mon Sep 17 00:00:00 2001 From: Thomas Huang Date: Mon, 12 Jun 2017 17:44:11 -0700 Subject: [PATCH 2/3] Fix networkState in chain id --- app/scripts/controllers/transactions.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/scripts/controllers/transactions.js b/app/scripts/controllers/transactions.js index faccf1ab1..d4603aafa 100644 --- a/app/scripts/controllers/transactions.js +++ b/app/scripts/controllers/transactions.js @@ -212,7 +212,7 @@ module.exports = class TransactionController extends EventEmitter { getChainId () { const networkState = this.networkStore.getState() - const getChainId = parseInt(networkState.network) + const getChainId = parseInt(networkState) if (Number.isNaN(getChainId)) { return 0 } else { From c0f07844af434666ae1e511e90e36ca493e8bb91 Mon Sep 17 00:00:00 2001 From: Thomas Huang Date: Mon, 12 Jun 2017 17:52:37 -0700 Subject: [PATCH 3/3] Finish async when failing async test --- test/unit/tx-controller-test.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/unit/tx-controller-test.js b/test/unit/tx-controller-test.js index f05ae479b..f0d8a706e 100644 --- a/test/unit/tx-controller-test.js +++ b/test/unit/tx-controller-test.js @@ -314,7 +314,7 @@ describe('Transaction Controller', function () { it('prepares a tx with the chainId set', function (done) { txController.addTx({ id: '1', status: 'unapproved', metamaskNetworkId: currentNetworkId, txParams: {} }, noop) txController.signTransaction('1', (err, rawTx) => { - if (err) return assert.fail('it should not fail') + if (err) return done('it should not fail') const ethTx = new EthTx(ethUtil.toBuffer(rawTx)) assert.equal(ethTx.getChainId(), currentNetworkId) done()