aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorfrankiebee <frankie.diamond@gmail.com>2017-07-12 03:18:44 +0800
committerfrankiebee <frankie.diamond@gmail.com>2017-07-12 03:18:44 +0800
commita670e54973ed1bae20455507a4b3c44e231ba822 (patch)
tree00300ea3362b7b48be26d6547f89ed4c5bfac597 /test
parentc121ac21ec3bed0381e36de7ead1b583a3da148c (diff)
parentf5de16c91174fbbf208e5aef8f542d3bbbb3cb93 (diff)
downloadtangerine-wallet-browser-a670e54973ed1bae20455507a4b3c44e231ba822.tar.gz
tangerine-wallet-browser-a670e54973ed1bae20455507a4b3c44e231ba822.tar.zst
tangerine-wallet-browser-a670e54973ed1bae20455507a4b3c44e231ba822.zip
Merge branch 'nonce-tracker' of https://github.com/MetaMask/metamask-plugin into nonce-tracker
Diffstat (limited to 'test')
-rw-r--r--test/unit/tx-controller-test.js49
1 files changed, 43 insertions, 6 deletions
diff --git a/test/unit/tx-controller-test.js b/test/unit/tx-controller-test.js
index 8ce6a5a65..a5af13915 100644
--- a/test/unit/tx-controller-test.js
+++ b/test/unit/tx-controller-test.js
@@ -18,9 +18,10 @@ describe('Transaction Controller', function () {
txController = new TransactionController({
networkStore: new ObservableStore(currentNetworkId),
txHistoryLimit: 10,
- blockTracker: { getCurrentBlock: noop, on: noop },
+ blockTracker: { getCurrentBlock: noop, on: noop, once: noop },
provider: { sendAsync: noop },
ethQuery: new EthQuery({ sendAsync: noop }),
+ ethStore: { getState: noop },
signTransaction: (ethTx) => new Promise((resolve) => {
ethTx.sign(privKey)
resolve()
@@ -269,7 +270,7 @@ describe('Transaction Controller', function () {
})
- it('does not overwrite set values', function (done) {
+ it('does not overwrite set values', function () {
this.timeout(15000)
const wrongValue = '0x05'
@@ -288,9 +289,7 @@ describe('Transaction Controller', function () {
const pubStub = sinon.stub(txController.txProviderUtils, 'publishTransaction')
.callsArgWithAsync(1, null, originalValue)
- txController.approveTransaction(txMeta.id).then((err) => {
- assert.ifError(err, 'should not error')
-
+ return txController.approveTransaction(txMeta.id).then(() => {
const result = txController.getTx(txMeta.id)
const params = result.txParams
@@ -302,7 +301,6 @@ describe('Transaction Controller', function () {
priceStub.restore()
signStub.restore()
pubStub.restore()
- done()
})
})
})
@@ -318,4 +316,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()
+ })
+ })
+ })
})
+