aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorkumavis <kumavis@users.noreply.github.com>2017-07-08 05:21:43 +0800
committerGitHub <noreply@github.com>2017-07-08 05:21:43 +0800
commitd228f46254783885e9762a2f96ecb9c3077c5fb3 (patch)
treeb0e0fde9f209c3728f7a1e36d3c4417ea7a3852d /test
parent51ff6d74e884b599f78b5454b33f2bc1a046f0b2 (diff)
parent678cfd21755bab430d28a8f0d0fb44a81ecefade (diff)
downloadtangerine-wallet-browser-d228f46254783885e9762a2f96ecb9c3077c5fb3.tar
tangerine-wallet-browser-d228f46254783885e9762a2f96ecb9c3077c5fb3.tar.gz
tangerine-wallet-browser-d228f46254783885e9762a2f96ecb9c3077c5fb3.tar.bz2
tangerine-wallet-browser-d228f46254783885e9762a2f96ecb9c3077c5fb3.tar.lz
tangerine-wallet-browser-d228f46254783885e9762a2f96ecb9c3077c5fb3.tar.xz
tangerine-wallet-browser-d228f46254783885e9762a2f96ecb9c3077c5fb3.tar.zst
tangerine-wallet-browser-d228f46254783885e9762a2f96ecb9c3077c5fb3.zip
Merge branch 'master' into nonce-tracker
Diffstat (limited to 'test')
-rw-r--r--test/unit/tx-controller-test.js40
1 files changed, 40 insertions, 0 deletions
diff --git a/test/unit/tx-controller-test.js b/test/unit/tx-controller-test.js
index 8ce6a5a65..c9eff5d01 100644
--- a/test/unit/tx-controller-test.js
+++ b/test/unit/tx-controller-test.js
@@ -21,6 +21,7 @@ describe('Transaction Controller', function () {
blockTracker: { getCurrentBlock: noop, on: noop },
provider: { sendAsync: noop },
ethQuery: new EthQuery({ sendAsync: noop }),
+ ethStore: { getState: noop },
signTransaction: (ethTx) => new Promise((resolve) => {
ethTx.sign(privKey)
resolve()
@@ -318,4 +319,43 @@ describe('Transaction Controller', function () {
})
})
})
+
+ describe('#_resubmitTx with a too-low balance', function () {
+ it('should fail the transaction', function (done) {
+ const from = '0xda0da0'
+ const txMeta = {
+ id: 1,
+ status: 'submitted',
+ metamaskNetworkId: currentNetworkId,
+ txParams: {
+ from,
+ nonce: '0x1',
+ value: '0xfffff',
+ },
+ }
+
+ const lowBalance = '0x0'
+ const fakeStoreState = { accounts: {} }
+ fakeStoreState.accounts[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(clone(txMeta))
+
+ txController._resubmitTx(txMeta, function (err) {
+ assert.ifError(err, 'should not throw an error')
+ const updatedMeta = txController.getTx(txMeta.id)
+ assert.notEqual(updatedMeta.status, txMeta.status, 'status changed.')
+ assert.equal(updatedMeta.status, 'failed', 'tx set to failed.')
+ done()
+ })
+ })
+ })
})
+