mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-11-22 09:57:02 +01:00
a7a086537b
The "last fetched" state for the `PhishingController` has been deleted to force an immediate full update of the phishing configuration state. We're doing this because the state was cleared in v10.34.2 because the format of that state had changed. This has been implemented in migration 92. The previous migration 92 has been renamed to 93 because it won't be included until a future release. We need the migrations to remain sequential, and this will save us from having to resolve a complex conflict when releasing this.
79 lines
1.8 KiB
TypeScript
79 lines
1.8 KiB
TypeScript
import { cloneDeep } from 'lodash';
|
|
import { migrate, version } from './092';
|
|
|
|
const PREVIOUS_VERSION = version - 1;
|
|
|
|
describe('migration #92', () => {
|
|
it('should update the version metadata', async () => {
|
|
const oldStorage = {
|
|
meta: {
|
|
version: PREVIOUS_VERSION,
|
|
},
|
|
data: {},
|
|
};
|
|
|
|
const newStorage = await migrate(oldStorage);
|
|
expect(newStorage.meta).toStrictEqual({
|
|
version,
|
|
});
|
|
});
|
|
|
|
it('should return state unaltered if there is no phishing controller state', async () => {
|
|
const oldData = {
|
|
other: 'data',
|
|
};
|
|
const oldStorage = {
|
|
meta: {
|
|
version: PREVIOUS_VERSION,
|
|
},
|
|
data: oldData,
|
|
};
|
|
|
|
const newStorage = await migrate(cloneDeep(oldStorage));
|
|
expect(newStorage.data).toStrictEqual(oldData);
|
|
});
|
|
|
|
it('should return state unaltered if there is no phishing controller last fetched state', async () => {
|
|
const oldData = {
|
|
other: 'data',
|
|
PhishingController: {
|
|
whitelist: [],
|
|
},
|
|
};
|
|
const oldStorage = {
|
|
meta: {
|
|
version: PREVIOUS_VERSION,
|
|
},
|
|
data: oldData,
|
|
};
|
|
|
|
const newStorage = await migrate(cloneDeep(oldStorage));
|
|
expect(newStorage.data).toStrictEqual(oldData);
|
|
});
|
|
|
|
it('should remove both last fetched properties from phishing controller state', async () => {
|
|
const oldData = {
|
|
other: 'data',
|
|
PhishingController: {
|
|
whitelist: [],
|
|
hotlistLastFetched: 0,
|
|
stalelistLastFetched: 0,
|
|
},
|
|
};
|
|
const oldStorage = {
|
|
meta: {
|
|
version: PREVIOUS_VERSION,
|
|
},
|
|
data: oldData,
|
|
};
|
|
|
|
const newStorage = await migrate(oldStorage);
|
|
expect(newStorage.data).toStrictEqual({
|
|
other: 'data',
|
|
PhishingController: {
|
|
whitelist: [],
|
|
},
|
|
});
|
|
});
|
|
});
|