aboutsummaryrefslogtreecommitdiffstats
path: root/test/unit
diff options
context:
space:
mode:
authorDan Miller <danjm.com@gmail.com>2018-10-26 12:42:59 +0800
committerDan Miller <danjm.com@gmail.com>2018-12-04 11:36:05 +0800
commit9b9a2cc2e00618167d5fac8103e928fc16153b2d (patch)
treee17a0495531b3ea51167321809af877158a05ef7 /test/unit
parent3162a2747c0e54f729405caaef777519e4ded4dc (diff)
downloadtangerine-wallet-browser-9b9a2cc2e00618167d5fac8103e928fc16153b2d.tar
tangerine-wallet-browser-9b9a2cc2e00618167d5fac8103e928fc16153b2d.tar.gz
tangerine-wallet-browser-9b9a2cc2e00618167d5fac8103e928fc16153b2d.tar.bz2
tangerine-wallet-browser-9b9a2cc2e00618167d5fac8103e928fc16153b2d.tar.lz
tangerine-wallet-browser-9b9a2cc2e00618167d5fac8103e928fc16153b2d.tar.xz
tangerine-wallet-browser-9b9a2cc2e00618167d5fac8103e928fc16153b2d.tar.zst
tangerine-wallet-browser-9b9a2cc2e00618167d5fac8103e928fc16153b2d.zip
Adds createSpeedUpTransaction to txController
Diffstat (limited to 'test/unit')
-rw-r--r--test/unit/app/controllers/transactions/tx-controller-test.js67
1 files changed, 67 insertions, 0 deletions
diff --git a/test/unit/app/controllers/transactions/tx-controller-test.js b/test/unit/app/controllers/transactions/tx-controller-test.js
index 2fe4c47d1..6889f9bb2 100644
--- a/test/unit/app/controllers/transactions/tx-controller-test.js
+++ b/test/unit/app/controllers/transactions/tx-controller-test.js
@@ -5,6 +5,9 @@ const EthTx = require('ethereumjs-tx')
const ObservableStore = require('obs-store')
const sinon = require('sinon')
const TransactionController = require('../../../../../app/scripts/controllers/transactions')
+const {
+ TRANSACTION_TYPE_RETRY,
+} = require('../../../../../app/scripts/controllers/transactions/enums')
const { createTestProviderTools, getTestAccounts } = require('../../../../stub/provider')
const noop = () => true
@@ -392,6 +395,70 @@ describe('Transaction Controller', function () {
})
+ describe('#createSpeedUpTransaction', () => {
+ let addTxSpy
+ let approveTransactionSpy
+ let txParams
+ let expectedTxParams
+
+ beforeEach(() => {
+ addTxSpy = sinon.spy(txController, 'addTx')
+ approveTransactionSpy = sinon.spy(txController, 'approveTransaction')
+
+ txParams = {
+ nonce: '0x00',
+ from: '0xB09d8505E1F4EF1CeA089D47094f5DD3464083d4',
+ to: '0xB09d8505E1F4EF1CeA089D47094f5DD3464083d4',
+ gas: '0x5209',
+ gasPrice: '0xa',
+ }
+ txController.txStateManager._saveTxList([
+ { id: 1, status: 'submitted', metamaskNetworkId: currentNetworkId, txParams, history: [] },
+ ])
+
+ expectedTxParams = Object.assign({}, txParams, { gasPrice: '0xb'})
+ })
+
+ afterEach(() => {
+ addTxSpy.restore()
+ approveTransactionSpy.restore()
+ })
+
+ it('should call this.addTx and this.approveTransaction with the expected args', async () => {
+ await txController.createSpeedUpTransaction(1)
+ assert.equal(addTxSpy.callCount, 1)
+
+ const addTxArgs = addTxSpy.getCall(0).args[0]
+ assert.deepEqual(addTxArgs.txParams, expectedTxParams)
+
+ const { lastGasPrice, type } = addTxArgs
+ assert.deepEqual({ lastGasPrice, type }, {
+ lastGasPrice: '0xa',
+ type: TRANSACTION_TYPE_RETRY,
+ })
+ })
+
+ it('should call this.approveTransaction with the id of the returned tx', async () => {
+ const result = await txController.createSpeedUpTransaction(1)
+ assert.equal(approveTransactionSpy.callCount, 1)
+
+ const approveTransactionArg = approveTransactionSpy.getCall(0).args[0]
+ assert.equal(result.id, approveTransactionArg)
+ })
+
+ it('should return the expected txMeta', async () => {
+ const result = await txController.createSpeedUpTransaction(1)
+
+ assert.deepEqual(result.txParams, expectedTxParams)
+
+ const { lastGasPrice, type } = result
+ assert.deepEqual({ lastGasPrice, type }, {
+ lastGasPrice: '0xa',
+ type: TRANSACTION_TYPE_RETRY,
+ })
+ })
+ })
+
describe('#publishTransaction', function () {
let hash, txMeta
beforeEach(function () {