aboutsummaryrefslogtreecommitdiffstats
path: root/test/unit
diff options
context:
space:
mode:
authorFrankie <frankie.diamond@gmail.com>2018-02-01 03:57:38 +0800
committerGitHub <noreply@github.com>2018-02-01 03:57:38 +0800
commit201e0579a57d4638c8c61e99c63b7c26821a0f2a (patch)
tree275bc04ea86f48b2c5f9109c69c7b21b93c744bf /test/unit
parent7e144680134e1bf87727f5dd048e846996e8367a (diff)
parentf16535619692dd7f1c24bcc07875d60804d50ee2 (diff)
downloadtangerine-wallet-browser-201e0579a57d4638c8c61e99c63b7c26821a0f2a.tar
tangerine-wallet-browser-201e0579a57d4638c8c61e99c63b7c26821a0f2a.tar.gz
tangerine-wallet-browser-201e0579a57d4638c8c61e99c63b7c26821a0f2a.tar.bz2
tangerine-wallet-browser-201e0579a57d4638c8c61e99c63b7c26821a0f2a.tar.lz
tangerine-wallet-browser-201e0579a57d4638c8c61e99c63b7c26821a0f2a.tar.xz
tangerine-wallet-browser-201e0579a57d4638c8c61e99c63b7c26821a0f2a.tar.zst
tangerine-wallet-browser-201e0579a57d4638c8c61e99c63b7c26821a0f2a.zip
Merge branch 'master' into localStorage-clean-up
Diffstat (limited to 'test/unit')
-rw-r--r--test/unit/tx-state-manager-test.js43
1 files changed, 43 insertions, 0 deletions
diff --git a/test/unit/tx-state-manager-test.js b/test/unit/tx-state-manager-test.js
index 464e50ee4..02dc52967 100644
--- a/test/unit/tx-state-manager-test.js
+++ b/test/unit/tx-state-manager-test.js
@@ -238,4 +238,47 @@ describe('TransactionStateManger', function () {
assert.equal(txStateManager.getFilteredTxList(filterParams).length, 5, `getFilteredTxList - ${JSON.stringify(filterParams)}`)
})
})
+
+ describe('#wipeTransactions', function () {
+
+ const specificAddress = '0xaa'
+ const otherAddress = '0xbb'
+
+ it('should remove only the transactions from a specific address', function () {
+
+ const txMetas = [
+ { id: 0, status: 'unapproved', txParams: { from: specificAddress, to: otherAddress }, metamaskNetworkId: currentNetworkId },
+ { id: 1, status: 'confirmed', txParams: { from: otherAddress, to: specificAddress }, metamaskNetworkId: currentNetworkId },
+ { id: 2, status: 'confirmed', txParams: { from: otherAddress, to: specificAddress }, metamaskNetworkId: currentNetworkId },
+ ]
+ txMetas.forEach((txMeta) => txStateManager.addTx(txMeta, noop))
+
+ txStateManager.wipeTransactions(specificAddress)
+
+ const transactionsFromCurrentAddress = txStateManager.getTxList().filter((txMeta) => txMeta.txParams.from === specificAddress)
+ const transactionsFromOtherAddresses = txStateManager.getTxList().filter((txMeta) => txMeta.txParams.from !== specificAddress)
+
+ assert.equal(transactionsFromCurrentAddress.length, 0)
+ assert.equal(transactionsFromOtherAddresses.length, 2)
+ })
+
+ it('should not remove the transactions from other networks', function () {
+ const txMetas = [
+ { id: 0, status: 'unapproved', txParams: { from: specificAddress, to: otherAddress }, metamaskNetworkId: currentNetworkId },
+ { id: 1, status: 'confirmed', txParams: { from: specificAddress, to: otherAddress }, metamaskNetworkId: otherNetworkId },
+ { id: 2, status: 'confirmed', txParams: { from: specificAddress, to: otherAddress }, metamaskNetworkId: otherNetworkId },
+ ]
+
+ txMetas.forEach((txMeta) => txStateManager.addTx(txMeta, noop))
+
+ txStateManager.wipeTransactions(specificAddress)
+
+ const txsFromCurrentNetworkAndAddress = txStateManager.getTxList().filter((txMeta) => txMeta.txParams.from === specificAddress)
+ const txFromOtherNetworks = txStateManager.getFullTxList().filter((txMeta) => txMeta.metamaskNetworkId === otherNetworkId)
+
+ assert.equal(txsFromCurrentNetworkAndAddress.length, 0)
+ assert.equal(txFromOtherNetworks.length, 2)
+
+ })
+ })
}) \ No newline at end of file