aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorBruno Barbieri <brunobar79@gmail.com>2018-02-01 02:29:30 +0800
committerBruno Barbieri <brunobar79@gmail.com>2018-02-01 02:29:30 +0800
commita70eda36515ee8dc7f0b58bf561dd14c92e70596 (patch)
tree06f5f112c62b1bf522ad9fed188ac264bf88fcd5 /test
parentc1b7cfe91d803c0085afe59d058f2422a0e8dc30 (diff)
downloadtangerine-wallet-browser-a70eda36515ee8dc7f0b58bf561dd14c92e70596.tar.gz
tangerine-wallet-browser-a70eda36515ee8dc7f0b58bf561dd14c92e70596.tar.zst
tangerine-wallet-browser-a70eda36515ee8dc7f0b58bf561dd14c92e70596.zip
add test for wipeTransactions
Diffstat (limited to 'test')
-rw-r--r--test/unit/tx-state-manager-test.js49
1 files changed, 49 insertions, 0 deletions
diff --git a/test/unit/tx-state-manager-test.js b/test/unit/tx-state-manager-test.js
index 464e50ee4..3d9641453 100644
--- a/test/unit/tx-state-manager-test.js
+++ b/test/unit/tx-state-manager-test.js
@@ -238,4 +238,53 @@ describe('TransactionStateManger', function () {
assert.equal(txStateManager.getFilteredTxList(filterParams).length, 5, `getFilteredTxList - ${JSON.stringify(filterParams)}`)
})
})
+
+ describe('#wipeTransactions', function () {
+
+ const specificAddress = '0xaa';
+
+ it('should remove only the transactions from a specific address', function () {
+
+ const txMetas = [
+ { id: 0, status: 'unapproved', txParams: { from: specificAddress, to: '0xbb' }, metamaskNetworkId: currentNetworkId },
+ { id: 1, status: 'confirmed', txParams: { from: '0xbb', to: specificAddress }, metamaskNetworkId: currentNetworkId },
+ { id: 2, status: 'confirmed', txParams: { from: '0xcc', 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: '0xbb' }, metamaskNetworkId: currentNetworkId },
+ { id: 1, status: 'confirmed', txParams: { from: specificAddress, to: specificAddress }, metamaskNetworkId: otherNetworkId },
+ { id: 2, status: 'confirmed', txParams: { from: specificAddress, to: specificAddress }, 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)
+
+ console.log('NETWORK TX LIST: ', txStateManager.getTxList());
+ console.log('FULL TX LIST: ', txStateManager.getFullTxList());
+
+ assert.equal(txsFromCurrentNetworkAndAddress.length, 0);
+ assert.equal(txFromOtherNetworks.length, 2);
+
+
+ })
+ })
}) \ No newline at end of file