aboutsummaryrefslogtreecommitdiffstats
path: root/test/unit/keyrings/hd-test.js
diff options
context:
space:
mode:
authorDan Finlay <dan@danfinlay.com>2017-02-22 06:25:47 +0800
committerDan Finlay <dan@danfinlay.com>2017-02-22 06:25:47 +0800
commit0584988688a471698e9b3ad05cb0597f0270ea9e (patch)
treebdcbb009636dcdea67abcc28238023dd8bf7e882 /test/unit/keyrings/hd-test.js
parent29f07238f443007a03c968349af4d3fca7e10522 (diff)
downloadtangerine-wallet-browser-0584988688a471698e9b3ad05cb0597f0270ea9e.tar.gz
tangerine-wallet-browser-0584988688a471698e9b3ad05cb0597f0270ea9e.tar.zst
tangerine-wallet-browser-0584988688a471698e9b3ad05cb0597f0270ea9e.zip
Move sigUtil and keyrings to external modules
These external modules now have their own test coverage and build enforcement. This allowed me to somewhat more easily add good tests around our personalSign strategy (held now in [eth-sig-util](https://github.com/flyswatter/eth-sig-util), and allow each of the keyrings to import that, etc.
Diffstat (limited to 'test/unit/keyrings/hd-test.js')
-rw-r--r--test/unit/keyrings/hd-test.js127
1 files changed, 0 insertions, 127 deletions
diff --git a/test/unit/keyrings/hd-test.js b/test/unit/keyrings/hd-test.js
deleted file mode 100644
index dfc0ec908..000000000
--- a/test/unit/keyrings/hd-test.js
+++ /dev/null
@@ -1,127 +0,0 @@
-const assert = require('assert')
-const extend = require('xtend')
-const HdKeyring = require('../../../app/scripts/keyrings/hd')
-
-// Sample account:
-const privKeyHex = 'b8a9c05beeedb25df85f8d641538cbffedf67216048de9c678ee26260eb91952'
-
-const sampleMnemonic = 'finish oppose decorate face calm tragic certain desk hour urge dinosaur mango'
-const firstAcct = '1c96099350f13d558464ec79b9be4445aa0ef579'
-const secondAcct = '1b00aed43a693f3a957f9feb5cc08afa031e37a0'
-
-describe('hd-keyring', function() {
-
- let keyring
- beforeEach(function() {
- keyring = new HdKeyring()
- })
-
- describe('constructor', function(done) {
- keyring = new HdKeyring({
- mnemonic: sampleMnemonic,
- numberOfAccounts: 2,
- })
-
- const accounts = keyring.getAccounts()
- .then((accounts) => {
- assert.equal(accounts[0], firstAcct)
- assert.equal(accounts[1], secondAcct)
- done()
- })
- })
-
- describe('Keyring.type', function() {
- it('is a class property that returns the type string.', function() {
- const type = HdKeyring.type
- assert.equal(typeof type, 'string')
- })
- })
-
- describe('#type', function() {
- it('returns the correct value', function() {
- const type = keyring.type
- const correct = HdKeyring.type
- assert.equal(type, correct)
- })
- })
-
- describe('#serialize empty wallets.', function() {
- it('serializes a new mnemonic', function() {
- keyring.serialize()
- .then((output) => {
- assert.equal(output.numberOfAccounts, 0)
- assert.equal(output.mnemonic, null)
- })
- })
- })
-
- describe('#deserialize a private key', function() {
- it('serializes what it deserializes', function(done) {
- keyring.deserialize({
- mnemonic: sampleMnemonic,
- numberOfAccounts: 1
- })
- .then(() => {
- assert.equal(keyring.wallets.length, 1, 'restores two accounts')
- return keyring.addAccounts(1)
- }).then(() => {
- return keyring.getAccounts()
- }).then((accounts) => {
- assert.equal(accounts[0], firstAcct)
- assert.equal(accounts[1], secondAcct)
- assert.equal(accounts.length, 2)
-
- return keyring.serialize()
- }).then((serialized) => {
- assert.equal(serialized.mnemonic, sampleMnemonic)
- done()
- })
- })
- })
-
- describe('#addAccounts', function() {
- describe('with no arguments', function() {
- it('creates a single wallet', function(done) {
- keyring.addAccounts()
- .then(() => {
- assert.equal(keyring.wallets.length, 1)
- done()
- })
- })
- })
-
- describe('with a numeric argument', function() {
- it('creates that number of wallets', function(done) {
- keyring.addAccounts(3)
- .then(() => {
- assert.equal(keyring.wallets.length, 3)
- done()
- })
- })
- })
- })
-
- describe('#getAccounts', function() {
- it('calls getAddress on each wallet', function(done) {
-
- // Push a mock wallet
- const desiredOutput = 'foo'
- keyring.wallets.push({
- getAddress() {
- return {
- toString() {
- return desiredOutput
- }
- }
- }
- })
-
- const output = keyring.getAccounts()
- .then((output) => {
- assert.equal(output[0], desiredOutput)
- assert.equal(output.length, 1)
- done()
- })
- })
- })
-})