diff options
author | frankiebee <frankie.diamond@gmail.com> | 2017-08-22 02:35:22 +0800 |
---|---|---|
committer | frankiebee <frankie.diamond@gmail.com> | 2017-08-22 02:35:22 +0800 |
commit | fbba3a1ac8575b910e8a2a684748d617eec19414 (patch) | |
tree | c2940c33345d128a2888fc4441b8342e6b778d65 /test/unit/tx-state-manager-test.js | |
parent | 7ea83b6bae34dcf652d85474fe1d82893d592d55 (diff) | |
parent | 9203b4edf9df8b616877c57970fb01a7fb87924b (diff) | |
download | tangerine-wallet-browser-fbba3a1ac8575b910e8a2a684748d617eec19414.tar tangerine-wallet-browser-fbba3a1ac8575b910e8a2a684748d617eec19414.tar.gz tangerine-wallet-browser-fbba3a1ac8575b910e8a2a684748d617eec19414.tar.bz2 tangerine-wallet-browser-fbba3a1ac8575b910e8a2a684748d617eec19414.tar.lz tangerine-wallet-browser-fbba3a1ac8575b910e8a2a684748d617eec19414.tar.xz tangerine-wallet-browser-fbba3a1ac8575b910e8a2a684748d617eec19414.tar.zst tangerine-wallet-browser-fbba3a1ac8575b910e8a2a684748d617eec19414.zip |
Merge branch 'master' into transactionControllerRefractorPt3
Diffstat (limited to 'test/unit/tx-state-manager-test.js')
-rw-r--r-- | test/unit/tx-state-manager-test.js | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/test/unit/tx-state-manager-test.js b/test/unit/tx-state-manager-test.js index 0b35465d6..998bbe152 100644 --- a/test/unit/tx-state-manager-test.js +++ b/test/unit/tx-state-manager-test.js @@ -150,7 +150,7 @@ describe('TransactionStateManger', function () { assert.equal(result.hash, 'foo') }) - it('updates gas price', function () { + it('updates gas price and adds history items', function () { const originalGasPrice = '0x01' const desiredGasPrice = '0x02' @@ -166,10 +166,21 @@ describe('TransactionStateManger', function () { const updatedMeta = clone(txMeta) txStateManager.addTx(txMeta) - updatedMeta.txParams.gasPrice = desiredGasPrice - txStateManager.updateTx(updatedMeta) - let result = txStateManager.getTx('1') + const updatedTx = txController.getTx('1') + // verify tx was initialized correctly + assert.equal(updatedTx.history.length, 1, 'one history item (initial)') + assert.equal(Array.isArray(updatedTx.history[0]), false, 'first history item is initial state') + assert.deepEqual(updatedTx.history[0], txStateHistoryHelper.snapshotFromTxMeta(updatedTx), 'first history item is initial state') + // modify value and updateTx + updatedTx.txParams.gasPrice = desiredGasPrice + txController.updateTx(updatedTx) + // check updated value + const result = txController.getTx('1') assert.equal(result.txParams.gasPrice, desiredGasPrice, 'gas price updated') + // validate history was updated + assert.equal(result.history.length, 2, 'two history items (initial + diff)') + const expectedEntry = { op: 'replace', path: '/txParams/gasPrice', value: desiredGasPrice } + assert.deepEqual(result.history[1], [expectedEntry], 'two history items (initial + diff)') }) }) |