aboutsummaryrefslogtreecommitdiffstats
path: root/test/unit/tx-controller-test.js
diff options
context:
space:
mode:
authorfrankiebee <frankie.diamond@gmail.com>2017-08-05 02:40:22 +0800
committerfrankiebee <frankie.diamond@gmail.com>2017-08-05 02:40:22 +0800
commit54739cb798b70e14d7774d9e92745188afca5461 (patch)
tree56ede904f92967cc3a88dfbafb497984b89b891b /test/unit/tx-controller-test.js
parent4ac0b972025ddd55a9a42b4a15db0a5f207f4078 (diff)
downloadtangerine-wallet-browser-54739cb798b70e14d7774d9e92745188afca5461.tar.gz
tangerine-wallet-browser-54739cb798b70e14d7774d9e92745188afca5461.tar.zst
tangerine-wallet-browser-54739cb798b70e14d7774d9e92745188afca5461.zip
test for pending tx watcher
Diffstat (limited to 'test/unit/tx-controller-test.js')
-rw-r--r--test/unit/tx-controller-test.js49
1 files changed, 3 insertions, 46 deletions
diff --git a/test/unit/tx-controller-test.js b/test/unit/tx-controller-test.js
index f290088a1..e54dc9719 100644
--- a/test/unit/tx-controller-test.js
+++ b/test/unit/tx-controller-test.js
@@ -27,7 +27,8 @@ describe('Transaction Controller', function () {
}),
})
txController.nonceTracker.getNonceLock = () => Promise.resolve({ nextNonce: 0, releaseLock: noop })
- txController.query = new Proxy({}, {
+ txController.txProviderUtils = new TxProvideUtils(txController.provider)
+ txController.query = txController.txProviderUtils.query = new Proxy({}, {
get: (queryStubResult, key) => {
if (key === 'stubResult') {
return function (method, ...args) {
@@ -39,7 +40,7 @@ describe('Transaction Controller', function () {
}
},
})
- txController.txProviderUtils = new TxProvideUtils(txController.query)
+
})
describe('#newUnapprovedTransaction', function () {
@@ -76,7 +77,6 @@ describe('Transaction Controller', function () {
it('should resolve when finished and status is submitted and resolve with the hash', function (done) {
txController.once('newUnaprovedTx', (txMetaFromEmit) => {
setTimeout(() => {
- console.log('HELLLO')
txController.setTxHash(txMetaFromEmit.id, '0x0')
txController.setTxStatusSubmitted(txMetaFromEmit.id)
}, 10)
@@ -93,7 +93,6 @@ describe('Transaction Controller', function () {
it('should reject when finished and status is rejected', function (done) {
txController.once('newUnaprovedTx', (txMetaFromEmit) => {
setTimeout(() => {
- console.log('HELLLO')
txController.setTxStatusRejected(txMetaFromEmit.id)
}, 10)
})
@@ -429,46 +428,4 @@ describe('Transaction Controller', function () {
}).catch(done)
})
})
-
- 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)
- .then(() => {
- const updatedMeta = txController.getTx(txMeta.id)
- assert.notEqual(updatedMeta.status, txMeta.status, 'status changed.')
- assert.equal(updatedMeta.status, 'failed', 'tx set to failed.')
- done()
- })
- .catch((err) => {
- assert.ifError(err, 'should not throw an error')
- done(err)
- })
- })
- })
}) \ No newline at end of file