it('should return state unaltered if the providerConfig already has an id',async()=>{
constoldData={
other:'data',
NetworkController:{
networkConfigurations:{
id1:{
foo:'bar',
},
},
providerConfig:{
id:'test',
},
},
};
constoldStorage={
meta:{
version: 88,
},
data: oldData,
};
constnewStorage=awaitmigrate(oldStorage);
expect(newStorage.data).toStrictEqual(oldData);
});
it('should return state unaltered if there is no network config with the same rpcUrl and the providerConfig',async()=>{
constoldData={
other:'data',
NetworkController:{
networkConfigurations:{
id1:{
foo:'bar',
rpcUrl:'http://foo.bar',
},
},
providerConfig:{
rpcUrl:'http://baz.buzz',
},
},
};
constoldStorage={
meta:{
version: 88,
},
data: oldData,
};
constnewStorage=awaitmigrate(oldStorage);
expect(newStorage.data).toStrictEqual(oldData);
});
it('should update the provider config to have the id of a network config with the same rpcUrl',async()=>{
constoldData={
other:'data',
NetworkController:{
networkConfigurations:{
id1:{
foo:'bar',
rpcUrl:'http://foo.bar',
id:'test',
},
},
providerConfig:{
rpcUrl:'http://foo.bar',
},
},
};
constoldStorage={
meta:{
version: 88,
},
data: oldData,
};
constnewStorage=awaitmigrate(oldStorage);
expect(newStorage.data).toStrictEqual({
other:'data',
NetworkController:{
networkConfigurations:{
id1:{
foo:'bar',
rpcUrl:'http://foo.bar',
id:'test',
},
},
providerConfig:{
rpcUrl:'http://foo.bar',
id:'test',
},
},
});
});
it('should update the provider config to have the id of a network config with the same rpcUrl, even if there are other networks with the same chainId',async()=>{