1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-12-23 09:52:26 +01:00

Delete localhost state from incoming tx controller (#9569)

This commit is contained in:
Erik Marks 2020-10-13 06:18:24 -07:00 committed by GitHub
parent f9e0c64abe
commit 4ce04b5cb9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 63 additions and 0 deletions

View File

@ -11,6 +11,7 @@ const version = 48
* 4. Delete CachedBalancesController.cachedBalances
* 5. Convert transactions metamaskNetworkId to decimal if they are hex
* 6. Convert address book keys from decimal to hex
* 7. Delete localhost key in IncomingTransactionsController
*/
export default {
version,
@ -104,6 +105,11 @@ function transformState (state = {}) {
}
})
// 7. Delete localhost key in IncomingTransactionsController
delete state.IncomingTransactionsController
?.incomingTxLastFetchedBlocksByNetwork
?.localhost
return state
}

View File

@ -518,4 +518,61 @@ describe('migration #48', function () {
foo: 'bar',
})
})
it('should delete localhost key in IncomingTransactionsController', async function () {
const oldStorage = {
meta: {},
data: {
IncomingTransactionsController: {
incomingTxLastFetchedBlocksByNetwork: {
fizz: 'buzz',
localhost: {},
},
bar: 'baz',
},
foo: 'bar',
},
}
const newStorage = await migration48.migrate(oldStorage)
assert.deepEqual(newStorage.data, {
...expectedPreferencesState,
IncomingTransactionsController: {
incomingTxLastFetchedBlocksByNetwork: {
fizz: 'buzz',
},
bar: 'baz',
},
foo: 'bar',
})
})
it('should not modify IncomingTransactionsController state if affected key is missing', async function () {
const oldStorage = {
meta: {},
data: {
IncomingTransactionsController: {
incomingTxLastFetchedBlocksByNetwork: {
fizz: 'buzz',
rpc: {},
},
bar: 'baz',
},
foo: 'bar',
},
}
const newStorage = await migration48.migrate(oldStorage)
assert.deepEqual(newStorage.data, {
...expectedPreferencesState,
IncomingTransactionsController: {
incomingTxLastFetchedBlocksByNetwork: {
fizz: 'buzz',
rpc: {},
},
bar: 'baz',
},
foo: 'bar',
})
})
})