Merge pull request #1601 from MetaMask/ChainIdErrorTest

Chain id error test
feature/default_network_editable
Frankie 8 years ago committed by GitHub
commit eccb8b8f80
  1. 2
      app/scripts/controllers/transactions.js
  2. 5
      test/unit/tx-controller-test.js

@ -212,7 +212,7 @@ module.exports = class TransactionController extends EventEmitter {
getChainId () { getChainId () {
const networkState = this.networkStore.getState() const networkState = this.networkStore.getState()
const getChainId = parseInt(networkState.network) const getChainId = parseInt(networkState)
if (Number.isNaN(getChainId)) { if (Number.isNaN(getChainId)) {
return 0 return 0
} else { } else {

@ -311,12 +311,13 @@ describe('Transaction Controller', function () {
}) })
describe('#sign replay-protected tx', 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.addTx({ id: '1', status: 'unapproved', metamaskNetworkId: currentNetworkId, txParams: {} }, noop)
txController.signTransaction('1', (err, rawTx) => { 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)) const ethTx = new EthTx(ethUtil.toBuffer(rawTx))
assert.equal(ethTx.getChainId(), currentNetworkId) assert.equal(ethTx.getChainId(), currentNetworkId)
done()
}) })
}) })
}) })

Loading…
Cancel
Save