aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorDan Finlay <flyswatter@users.noreply.github.com>2017-07-07 01:03:06 +0800
committerGitHub <noreply@github.com>2017-07-07 01:03:06 +0800
commit33c2b864db8d92a1c7904b1c1e4bbc3ad5d73e31 (patch)
treeb08ba5ad7da8d772530687d096f2f184b0dd0d91 /test
parent8201ae1b53f7be60cf61351905e3dba21f2f39f8 (diff)
parentb87d10ab1dff539c4cb32ab32ccc1069598fb11b (diff)
downloadtangerine-wallet-browser-33c2b864db8d92a1c7904b1c1e4bbc3ad5d73e31.tar.gz
tangerine-wallet-browser-33c2b864db8d92a1c7904b1c1e4bbc3ad5d73e31.tar.zst
tangerine-wallet-browser-33c2b864db8d92a1c7904b1c1e4bbc3ad5d73e31.zip
Merge pull request #1747 from MetaMask/FailingTestForFailingLowBalanceTx
Fail txs on retry if balance is insufficient
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 0d35cd62c..01a498820 100644
--- a/test/unit/tx-controller-test.js
+++ b/test/unit/tx-controller-test.js
@@ -19,6 +19,7 @@ describe('Transaction Controller', function () {
txController = new TransactionController({
networkStore: new ObservableStore(currentNetworkId),
txHistoryLimit: 10,
+ ethStore: { getState: noop },
provider: { _blockTracker: new EventEmitter()},
blockTracker: new EventEmitter(),
ethQuery: new EthQuery(new EventEmitter()),
@@ -322,4 +323,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()
+ })
+ })
+ })
})
+