mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-11-22 09:57:02 +01:00
Add additional migration test
This commit is contained in:
parent
2ab34760b0
commit
e95c937569
@ -89,7 +89,7 @@ module.exports = class MetamaskController {
|
||||
setLocked: nodeify(keyringController.setLocked).bind(keyringController),
|
||||
submitPassword: (password, cb) => {
|
||||
this.migrateOldVaultIfAny(password)
|
||||
.then(keyringController.submitPassword.bind(keyringController))
|
||||
.then(keyringController.submitPassword.bind(keyringController, password))
|
||||
.then((newState) => { cb(null, newState) })
|
||||
.catch((reason) => { cb(reason) })
|
||||
},
|
||||
@ -452,7 +452,7 @@ module.exports = class MetamaskController {
|
||||
return this.idStoreMigrator.migratedVaultForPassword(password)
|
||||
.then(this.restoreOldVaultAccounts.bind(this))
|
||||
.then(this.restoreOldLostAccounts.bind(this))
|
||||
.then(keyringController.persistAllKeyrings.bind(keyringController))
|
||||
.then(keyringController.persistAllKeyrings.bind(keyringController, password))
|
||||
.then(() => password)
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,7 @@
|
||||
var KeyringController = require('../../../app/scripts/keyring-controller')
|
||||
var ConfigManager = require('../../../app/scripts/lib/config-manager')
|
||||
var IdStoreMigrator = require('../../../app/scripts/lib/idStore-migrator')
|
||||
var SimpleKeyring = require('../../../app/scripts/keyrings/simple')
|
||||
var normalize = require('../../../app/scripts/lib/sig-util').normalize
|
||||
|
||||
var oldStyleVault = require('../mocks/oldVault.json')
|
||||
var badStyleVault = require('../mocks/badVault.json')
|
||||
@ -68,7 +69,23 @@ QUnit.test('migrator:migratedVaultForPassword', function (assert) {
|
||||
assert.equal(lostAccounts.length, 1, 'one lost account')
|
||||
assert.equal(lostAccounts[0].address, '0xe15D894BeCB0354c501AE69429B05143679F39e0'.toLowerCase())
|
||||
assert.ok(lostAccounts[0].privateKey, 'private key exported')
|
||||
|
||||
var lostAccount = lostAccounts[0]
|
||||
var privateKey = lostAccount.privateKey
|
||||
|
||||
var simple = new SimpleKeyring()
|
||||
simple.deserialize([privateKey])
|
||||
.then(() => {
|
||||
return simple.getAccounts()
|
||||
})
|
||||
.then((accounts) => {
|
||||
assert.equal(normalize(accounts[0]), lostAccount.address, 'recovered address.')
|
||||
done()
|
||||
})
|
||||
.catch((reason) => {
|
||||
assert.ifError(reason)
|
||||
done(reason)
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
|
1
test/integration/mocks/badVault2.json
Normal file
1
test/integration/mocks/badVault2.json
Normal file
@ -0,0 +1 @@
|
||||
{"meta":{"version":4},"data":{"fiatCurrency":"USD","isConfirmed":true,"TOSHash":"a4f4e23f823a7ac51783e7ffba7914a911b09acdb97263296b7e14b527f80c5b","noticesList":[{"read":true,"date":"Fri Dec 16 2016","title":"Ending Morden Support","body":"Due to [recent events](https://blog.ethereum.org/2016/11/20/from-morden-to-ropsten/), MetaMask is now deprecating support for the Morden Test Network.\n\nUsers will still be able to access Morden through a locally hosted node, but we will no longer be providing hosted access to this network through [Infura](http://infura.io/).\n\nPlease use the new Ropsten Network as your new default test network.\n\nYou can fund your Ropsten account using the buy button on your account page.\n\nBest wishes!\nThe MetaMask Team\n\n","id":0}],"conversionRate":7.07341909,"conversionDate":1482539284,"wallet":"{\"encSeed\":{\"encStr\":\"LZsdN8lJzYkUe1UpmAalnERdgkBFt25gWDdK8kfQUwMAk/27XR+dc+8n5swgoF5qgwhc9LBgliEGNDs1Q/lnuld3aQLabkOeAW4BHS1vS7FxqKrzDS3iyzSuQO6wDQmGno/buuknVgDsKiyjW22hpt7vtVVWA+ZL1P3x6M0+AxGJjeGVrG+E8Q==\",\"nonce\":\"T6O9BmwmTj214XUK3KF0s3iCKo3OlrUD\"},\"ksData\":{\"m/44'/60'/0'/0\":{\"info\":{\"curve\":\"secp256k1\",\"purpose\":\"sign\"},\"encHdPathPriv\":{\"encStr\":\"GNNfZevCMlgMVh9y21y1UwrC9qcmH6XYq7v+9UoqbHnzPQJFlxidN5+x/Sldo72a6+5zJpQkkdZ+Q0lePrzvXfuSd3D/RO7WKFIKo9nAQI5+JWwz4INuCmVcmqCv2J4BTLGjrG8fp5pDJ62Bn0XHqkJo3gx3fpvs3cS66+ZKwg==\",\"nonce\":\"HRTlGj44khQs2veYHEF/GqTI1t0yYvyd\"},\"hdIndex\":3,\"encPrivKeys\":{\"e15d894becb0354c501ae69429b05143679f39e0\":{\"key\":\"ZAeZL9VcRUtiiO4VXOQKBFg787PR5R3iymjUeU5vpDRIqOXbjWN6N4ZNR8YpSXl+\",\"nonce\":\"xLsADagS8uqDYae6cImyhxF7o1kBDbPe\"},\"87658c15aefe7448008a28513a11b6b130ef4cd0\":{\"key\":\"ku0mm5s1agRJNAMYIJO0qeoDe+FqcbqdQI6azXF3GL1OLo6uMlt6I4qS+eeravFi\",\"nonce\":\"xdGfSUPKtkW8ge0SWIbbpahs/NyEMzn5\"},\"aa25854c0379e53c957ac9382e720c577fa31fd5\":{\"key\":\"NjpYC9FbiC95CTx/1kwgOHk5LSN9vl4RULEBbvwfVOjqSH8WixNoP3R6I/QyNIs2\",\"nonce\":\"M/HWpXXA9QvuZxEykkGQPJKKdz33ovQr\"}},\"addresses\":[\"e15d894becb0354c501ae69429b05143679f39e0\",\"87658c15aefe7448008a28513a11b6b130ef4cd0\",\"aa25854c0379e53c957ac9382e720c577fa31fd5\"]}},\"encHdRootPriv\":{\"encStr\":\"f+3prUOzl+95aNAV+ad6lZdsYZz120ZsL67ucjj3tiMXf/CC4X8XB9N2QguhoMy6fW+fATUsTdJe8+CbAAyb79V9HY0Pitzq9Yw/g1g0/Ii2JzsdGBriuMsPdwZSVqz+rvQFw/6Qms1xjW6cqa8S7kM2WA5l8RB1Ck6r5zaqbA==\",\"nonce\":\"oGahxNFekVxH9sg6PUCCHIByvo4WFSqm\"},\"salt\":\"N7xYoEA53yhSweOsEphku1UKkIEuZtX2MwLBhVM6RR8=\",\"version\":2}","config":{"provider":{"type":"testnet"},"selectedAccount":"0xe15d894becb0354c501ae69429b05143679f39e0"},"isDisclaimerConfirmed":true,"walletNicknames":{"0xac39b311dceb2a4b2f5d8461c1cdaf756f4f7ae9":"Account 1","0xd7c0cd9e7d2701c710d64fc492c7086679bdf7b4":"Account 2","0x1acfb961c5a8268eac8e09d6241a26cbeff42241":"Account 3"},"lostAccounts":["0xe15d894becb0354c501ae69429b05143679f39e0","0x87658c15aefe7448008a28513a11b6b130ef4cd0","0xaa25854c0379e53c957ac9382e720c577fa31fd5"]}}
|
Loading…
Reference in New Issue
Block a user