|
|
@ -238,4 +238,47 @@ describe('TransactionStateManger', function () { |
|
|
|
assert.equal(txStateManager.getFilteredTxList(filterParams).length, 5, `getFilteredTxList - ${JSON.stringify(filterParams)}`) |
|
|
|
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) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
}) |
|
|
|
}) |
|
|
|
}) |