aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDan Finlay <dan@danfinlay.com>2017-07-06 13:36:52 +0800
committerDan Finlay <dan@danfinlay.com>2017-07-06 13:36:52 +0800
commita915dfdeaa51c80c599b15f4e1ec14c90ac00fbf (patch)
tree4db2c556198024948977cdd785110080a4ee1b9b
parent8aab5d965b2095683baaf35bf1de6450de981800 (diff)
downloadtangerine-wallet-browser-a915dfdeaa51c80c599b15f4e1ec14c90ac00fbf.tar
tangerine-wallet-browser-a915dfdeaa51c80c599b15f4e1ec14c90ac00fbf.tar.gz
tangerine-wallet-browser-a915dfdeaa51c80c599b15f4e1ec14c90ac00fbf.tar.bz2
tangerine-wallet-browser-a915dfdeaa51c80c599b15f4e1ec14c90ac00fbf.tar.lz
tangerine-wallet-browser-a915dfdeaa51c80c599b15f4e1ec14c90ac00fbf.tar.xz
tangerine-wallet-browser-a915dfdeaa51c80c599b15f4e1ec14c90ac00fbf.tar.zst
tangerine-wallet-browser-a915dfdeaa51c80c599b15f4e1ec14c90ac00fbf.zip
Add failing test for retrying an over-spending tx
-rw-r--r--test/unit/tx-controller-test.js37
1 files changed, 37 insertions, 0 deletions
diff --git a/test/unit/tx-controller-test.js b/test/unit/tx-controller-test.js
index 0d35cd62c..b5df7f970 100644
--- a/test/unit/tx-controller-test.js
+++ b/test/unit/tx-controller-test.js
@@ -322,4 +322,41 @@ describe('Transaction Controller', function () {
})
})
})
+
+ describe('#_resubmitTx with a too-low balance', function () {
+ const from = '0xda0da0'
+ const txMeta = {
+ id: 1,
+ status: 'submitted'
+ txParams: {
+ from,
+ nonce: '0x1'
+ },
+ }
+
+ const lowBalance = '0x0'
+ const fakeStoreState = {}
+ fakeStoreState[from] = {
+ balance: lowBalance,
+ nonce: '0x0',
+ }
+
+ // Stubbing out current account state:
+ const getStateStub = sinon.stub(txController.ethStore, 'getState')
+ .returns(fakeStoreState)
+
+ // Adding the fake tx:
+ txController.addTx(txMeta, noop)
+
+ it('should fail the transaction', function (done) {
+ txController._resubmitTx(txMeta, function (err) {
+ assert.ifError('should not throw an error')
+ const updatedMeta = txController.getTx(txMeta.id)
+ assert.notEqual(updatedMeta.status, txMeta.status, 'status changed.')
+ assert.notEqual(updatedMeta.status, 'failed', 'tx set to failed.')
+ })
+ })
+ })
+
})
+