aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorDan Finlay <dan@danfinlay.com>2016-11-29 04:43:44 +0800
committerDan Finlay <dan@danfinlay.com>2016-11-29 08:13:03 +0800
commit80e76b45ee67900b5a60da1ddcd8b310f1e92413 (patch)
tree4eff8a2a7718e25afe8958198e3880e22530fdbb /test
parentb8991195829474691f17db3a7a6c9c081f9a95c9 (diff)
downloadtangerine-wallet-browser-80e76b45ee67900b5a60da1ddcd8b310f1e92413.tar
tangerine-wallet-browser-80e76b45ee67900b5a60da1ddcd8b310f1e92413.tar.gz
tangerine-wallet-browser-80e76b45ee67900b5a60da1ddcd8b310f1e92413.tar.bz2
tangerine-wallet-browser-80e76b45ee67900b5a60da1ddcd8b310f1e92413.tar.lz
tangerine-wallet-browser-80e76b45ee67900b5a60da1ddcd8b310f1e92413.tar.xz
tangerine-wallet-browser-80e76b45ee67900b5a60da1ddcd8b310f1e92413.tar.zst
tangerine-wallet-browser-80e76b45ee67900b5a60da1ddcd8b310f1e92413.zip
Denodeify most of KeyringController
Mostly Fixes #893 A couple methods cache callbacks, and will require a larger refactor to fully denodeify. Specifically, our methods involving web3 requests to sign a tx, sign a message, and approve or cancel either of those. I think we should postpone those until the TxManager refactor, since it will likely handle this response caching itself.
Diffstat (limited to 'test')
-rw-r--r--test/integration/lib/keyring-controller-test.js11
-rw-r--r--test/unit/keyring-controller-test.js28
-rw-r--r--test/unit/keyrings/hd-test.js2
3 files changed, 28 insertions, 13 deletions
diff --git a/test/integration/lib/keyring-controller-test.js b/test/integration/lib/keyring-controller-test.js
index 678744834..ae5ecc578 100644
--- a/test/integration/lib/keyring-controller-test.js
+++ b/test/integration/lib/keyring-controller-test.js
@@ -38,8 +38,8 @@ QUnit.test('keyringController:isInitialized', function (assert) {
QUnit.test('keyringController:submitPassword', function (assert) {
var done = assert.async()
- this.keyringController.submitPassword(PASSWORD, (err, state) => {
- assert.notOk(err)
+ this.keyringController.submitPassword(PASSWORD)
+ .then((state) => {
assert.ok(state.identities[FIRST_ADDRESS])
done()
})
@@ -49,9 +49,14 @@ QUnit.test('keyringController:setLocked', function (assert) {
var done = assert.async()
var self = this
- this.keyringController.setLocked(function(err) {
+ this.keyringController.setLocked()
+ .then(function() {
assert.notOk(self.keyringController.password, 'password should be deallocated')
assert.deepEqual(self.keyringController.keyrings, [], 'keyrings should be deallocated')
done()
})
+ .catch((reason) => {
+ assert.ifError(reason)
+ done()
+ })
})
diff --git a/test/unit/keyring-controller-test.js b/test/unit/keyring-controller-test.js
index 056e465ca..69a57ef52 100644
--- a/test/unit/keyring-controller-test.js
+++ b/test/unit/keyring-controller-test.js
@@ -32,8 +32,8 @@ describe('KeyringController', function() {
// Browser crypto is tested in the integration test suite.
keyringController.encryptor = mockEncryptor
- keyringController.createNewVaultAndKeychain(password, function (err, newState) {
- assert.ifError(err)
+ keyringController.createNewVaultAndKeychain(password)
+ .then(function (newState) {
state = newState
done()
})
@@ -50,12 +50,16 @@ describe('KeyringController', function() {
it('should set a vault on the configManager', function(done) {
keyringController.configManager.setVault(null)
assert(!keyringController.configManager.getVault(), 'no previous vault')
- keyringController.createNewVaultAndKeychain(password, (err, state) => {
- assert.ifError(err)
+ keyringController.createNewVaultAndKeychain(password)
+ .then(() => {
const vault = keyringController.configManager.getVault()
assert(vault, 'vault created')
done()
})
+ .catch((reason) => {
+ assert.ifError(reason)
+ done()
+ })
})
})
@@ -124,13 +128,17 @@ describe('KeyringController', function() {
const account = addresses[0]
var nick = 'Test nickname'
keyringController.identities[ethUtil.addHexPrefix(account)] = {}
- keyringController.saveAccountLabel(account, nick, (err, label) => {
- assert.ifError(err)
+ keyringController.saveAccountLabel(account, nick)
+ .then((label) => {
assert.equal(label, nick)
const persisted = keyringController.configManager.nicknameForWallet(account)
assert.equal(persisted, nick)
done()
})
+ .catch((reason) => {
+ assert.ifError(reason)
+ done()
+ })
})
this.timeout(10000)
@@ -138,8 +146,8 @@ describe('KeyringController', function() {
const account = addresses[0]
var nick = 'Test nickname'
keyringController.configManager.setNicknameForWallet(account, nick)
- keyringController.createNewVaultAndRestore(password, seedWords, (err, state) => {
- assert.ifError(err)
+ keyringController.createNewVaultAndRestore(password, seedWords)
+ .then((state) => {
const identity = keyringController.identities['0x' + account]
assert.equal(identity.name, nick)
@@ -147,6 +155,10 @@ describe('KeyringController', function() {
assert(accounts)
done()
})
+ .catch((reason) => {
+ assert.ifError(reason)
+ done()
+ })
})
})
diff --git a/test/unit/keyrings/hd-test.js b/test/unit/keyrings/hd-test.js
index 2d9e0ffd9..dfc0ec908 100644
--- a/test/unit/keyrings/hd-test.js
+++ b/test/unit/keyrings/hd-test.js
@@ -57,13 +57,11 @@ describe('hd-keyring', function() {
describe('#deserialize a private key', function() {
it('serializes what it deserializes', function(done) {
- console.log('deserializing ' + sampleMnemonic)
keyring.deserialize({
mnemonic: sampleMnemonic,
numberOfAccounts: 1
})
.then(() => {
- console.dir(keyring)
assert.equal(keyring.wallets.length, 1, 'restores two accounts')
return keyring.addAccounts(1)
}).then(() => {