aboutsummaryrefslogtreecommitdiffstats
path: root/test/unit
diff options
context:
space:
mode:
authorkumavis <aaron@kumavis.me>2018-05-25 13:41:09 +0800
committerkumavis <aaron@kumavis.me>2018-05-25 13:41:09 +0800
commitafdefc58e99a14b26911fc5badcf983629b33179 (patch)
tree4122e72706ae1a1dafdc93dc40b23562e94496bb /test/unit
parent630e2300f4c2377bf14931964cfe9542910292db (diff)
downloadtangerine-wallet-browser-afdefc58e99a14b26911fc5badcf983629b33179.tar
tangerine-wallet-browser-afdefc58e99a14b26911fc5badcf983629b33179.tar.gz
tangerine-wallet-browser-afdefc58e99a14b26911fc5badcf983629b33179.tar.bz2
tangerine-wallet-browser-afdefc58e99a14b26911fc5badcf983629b33179.tar.lz
tangerine-wallet-browser-afdefc58e99a14b26911fc5badcf983629b33179.tar.xz
tangerine-wallet-browser-afdefc58e99a14b26911fc5badcf983629b33179.tar.zst
tangerine-wallet-browser-afdefc58e99a14b26911fc5badcf983629b33179.zip
test - unit - tx-controller-test - add history object to txMeta when using internal calls
Diffstat (limited to 'test/unit')
-rw-r--r--test/unit/app/controllers/transactions/tx-controller-test.js60
1 files changed, 29 insertions, 31 deletions
diff --git a/test/unit/app/controllers/transactions/tx-controller-test.js b/test/unit/app/controllers/transactions/tx-controller-test.js
index 1f32a0f37..c450ed3ed 100644
--- a/test/unit/app/controllers/transactions/tx-controller-test.js
+++ b/test/unit/app/controllers/transactions/tx-controller-test.js
@@ -53,9 +53,9 @@ describe('Transaction Controller', function () {
describe('#getUnapprovedTxCount', function () {
it('should return the number of unapproved txs', function () {
txController.txStateManager._saveTxList([
- { id: 1, status: 'unapproved', metamaskNetworkId: currentNetworkId, txParams: {} },
- { id: 2, status: 'unapproved', metamaskNetworkId: currentNetworkId, txParams: {} },
- { id: 3, status: 'unapproved', metamaskNetworkId: currentNetworkId, txParams: {} },
+ { id: 1, status: 'unapproved', metamaskNetworkId: currentNetworkId, txParams: {}, history: [] },
+ { id: 2, status: 'unapproved', metamaskNetworkId: currentNetworkId, txParams: {}, history: [] },
+ { id: 3, status: 'unapproved', metamaskNetworkId: currentNetworkId, txParams: {}, history: [] },
])
const unapprovedTxCount = txController.getUnapprovedTxCount()
assert.equal(unapprovedTxCount, 3, 'should be 3')
@@ -65,9 +65,9 @@ describe('Transaction Controller', function () {
describe('#getPendingTxCount', function () {
it('should return the number of pending txs', function () {
txController.txStateManager._saveTxList([
- { id: 1, status: 'submitted', metamaskNetworkId: currentNetworkId, txParams: {} },
- { id: 2, status: 'submitted', metamaskNetworkId: currentNetworkId, txParams: {} },
- { id: 3, status: 'submitted', metamaskNetworkId: currentNetworkId, txParams: {} },
+ { id: 1, status: 'submitted', metamaskNetworkId: currentNetworkId, txParams: {}, history: [] },
+ { id: 2, status: 'submitted', metamaskNetworkId: currentNetworkId, txParams: {}, history: [] },
+ { id: 3, status: 'submitted', metamaskNetworkId: currentNetworkId, txParams: {}, history: [] },
])
const pendingTxCount = txController.getPendingTxCount()
assert.equal(pendingTxCount, 3, 'should be 3')
@@ -83,15 +83,15 @@ describe('Transaction Controller', function () {
'to': '0xc684832530fcbddae4b4230a47e991ddcec2831d',
}
txController.txStateManager._saveTxList([
- {id: 0, status: 'confirmed', metamaskNetworkId: currentNetworkId, txParams},
- {id: 1, status: 'confirmed', metamaskNetworkId: currentNetworkId, txParams},
- {id: 2, status: 'confirmed', metamaskNetworkId: currentNetworkId, txParams},
- {id: 3, status: 'unapproved', metamaskNetworkId: currentNetworkId, txParams},
- {id: 4, status: 'rejected', metamaskNetworkId: currentNetworkId, txParams},
- {id: 5, status: 'approved', metamaskNetworkId: currentNetworkId, txParams},
- {id: 6, status: 'signed', metamaskNetworkId: currentNetworkId, txParams},
- {id: 7, status: 'submitted', metamaskNetworkId: currentNetworkId, txParams},
- {id: 8, status: 'failed', metamaskNetworkId: currentNetworkId, txParams},
+ {id: 0, status: 'confirmed', metamaskNetworkId: currentNetworkId, txParams, history: [] },
+ {id: 1, status: 'confirmed', metamaskNetworkId: currentNetworkId, txParams, history: [] },
+ {id: 2, status: 'confirmed', metamaskNetworkId: currentNetworkId, txParams, history: [] },
+ {id: 3, status: 'unapproved', metamaskNetworkId: currentNetworkId, txParams, history: [] },
+ {id: 4, status: 'rejected', metamaskNetworkId: currentNetworkId, txParams, history: [] },
+ {id: 5, status: 'approved', metamaskNetworkId: currentNetworkId, txParams, history: [] },
+ {id: 6, status: 'signed', metamaskNetworkId: currentNetworkId, txParams, history: [] },
+ {id: 7, status: 'submitted', metamaskNetworkId: currentNetworkId, txParams, history: [] },
+ {id: 8, status: 'failed', metamaskNetworkId: currentNetworkId, txParams, history: [] },
])
})
@@ -188,24 +188,22 @@ describe('Transaction Controller', function () {
})
describe('#addTxGasDefaults', function () {
- it('should add the tx defaults if their are none', function (done) {
+ it('should add the tx defaults if their are none', async () => {
const txMeta = {
- 'txParams': {
- 'from': '0xc684832530fcbddae4b4230a47e991ddcec2831d',
- 'to': '0xc684832530fcbddae4b4230a47e991ddcec2831d',
+ txParams: {
+ from: '0xc684832530fcbddae4b4230a47e991ddcec2831d',
+ to: '0xc684832530fcbddae4b4230a47e991ddcec2831d',
},
+ history: [],
}
- providerResultStub.eth_gasPrice = '4a817c800'
- providerResultStub.eth_getBlockByNumber = { gasLimit: '47b784' }
- providerResultStub.eth_estimateGas = '5209'
- txController.addTxGasDefaults(txMeta)
- .then((txMetaWithDefaults) => {
- assert(txMetaWithDefaults.txParams.value, '0x0', 'should have added 0x0 as the value')
- assert(txMetaWithDefaults.txParams.gasPrice, 'should have added the gas price')
- assert(txMetaWithDefaults.txParams.gas, 'should have added the gas field')
- done()
- })
- .catch(done)
+ providerResultStub.eth_gasPrice = '4a817c800'
+ providerResultStub.eth_getBlockByNumber = { gasLimit: '47b784' }
+ providerResultStub.eth_estimateGas = '5209'
+
+ const txMetaWithDefaults = await txController.addTxGasDefaults(txMeta)
+ assert(txMetaWithDefaults.txParams.value, '0x0', 'should have added 0x0 as the value')
+ assert(txMetaWithDefaults.txParams.gasPrice, 'should have added the gas price')
+ assert(txMetaWithDefaults.txParams.gas, 'should have added the gas field')
})
})
@@ -378,7 +376,7 @@ describe('Transaction Controller', function () {
data: '0x0',
}
txController.txStateManager._saveTxList([
- { id: 1, status: 'submitted', metamaskNetworkId: currentNetworkId, txParams },
+ { id: 1, status: 'submitted', metamaskNetworkId: currentNetworkId, txParams, history: [] },
])
txController.retryTransaction(1)
.then((txMeta) => {