]> git.immae.eu Git - perso/Immae/Projets/Cryptomonnaies/BIP39.git/blob - tests/spec/tests.js
Merge pull request #216 from Coinomi/ethereum-like
[perso/Immae/Projets/Cryptomonnaies/BIP39.git] / tests / spec / tests.js
1 // Usage:
2 // cd /path/to/repo/tests
3 // jasmine spec/tests.js
4 //
5 // Dependencies:
6 // nodejs
7 // selenium
8 // jasmine
9 // see https://developer.mozilla.org/en-US/docs/Mozilla/Firefox/Headless_mode#Automated_testing_with_headless_mode
10
11 // USER SPECIFIED OPTIONS
12 var browser = process.env.BROWSER; //"firefox"; // or "chrome"
13 if (!browser) {
14 console.log("Browser can be set via environment variable, eg");
15 console.log("BROWSER=firefox jasmine spec/tests.js");
16 console.log("Options for BROWSER are firefox chrome");
17 console.log("Using default browser: chrome");
18 browser = "chrome";
19 }
20 else {
21 console.log("Using browser: " + browser);
22 }
23
24 // Globals
25
26 var webdriver = require('selenium-webdriver');
27 var By = webdriver.By;
28 var Key = webdriver.Key;
29 var until = webdriver.until;
30 var newDriver = null;
31 var driver = null;
32 // Delays in ms
33 var generateDelay = 1500;
34 var feedbackDelay = 500;
35 var entropyFeedbackDelay = 500;
36 var bip38delay = 15000;
37
38 // url uses file:// scheme
39 var path = require('path')
40 var parentDir = path.resolve(process.cwd(), '..', 'src', 'index.html');
41 var url = "file://" + parentDir;
42 if (browser == "firefox") {
43 // TODO loading local html in firefox is broken
44 console.log("Loading local html in firefox is broken, see https://stackoverflow.com/q/46367054");
45 console.log("You must run a server in this case, ie do this:");
46 console.log("$ cd /path/to/bip39/src");
47 console.log("$ python -m http.server");
48 url = "http://localhost:8000";
49 }
50
51 // Variables dependent on specific browser selection
52
53 if (browser == "firefox") {
54 var firefox = require('selenium-webdriver/firefox');
55 var binary = new firefox.Binary(firefox.Channel.NIGHTLY);
56 binary.addArguments("-headless");
57 newDriver = function() {
58 return new webdriver.Builder()
59 .forBrowser('firefox')
60 .setFirefoxOptions(new firefox.Options().setBinary(binary))
61 .build();
62 }
63 }
64 else if (browser == "chrome") {
65 var chrome = require('selenium-webdriver/chrome');
66 newDriver = function() {
67 return new webdriver.Builder()
68 .forBrowser('chrome')
69 .setChromeOptions(new chrome.Options().addArguments("headless"))
70 .build();
71 }
72 }
73
74 // Helper functions
75
76 function testNetwork(done, params) {
77 var phrase = params.phrase || 'abandon abandon ability';
78 driver.findElement(By.css('.phrase'))
79 .sendKeys(phrase);
80 selectNetwork(params.selectText);
81 driver.sleep(generateDelay).then(function() {
82 getFirstAddress(function(address) {
83 expect(address).toBe(params.firstAddress);
84 done();
85 });
86 });
87 }
88
89 function getFirstRowValue(handler, selector) {
90 driver.findElements(By.css(selector))
91 .then(function(els) {
92 els[0].getText()
93 .then(handler);
94 })
95 }
96
97 function getFirstAddress(handler) {
98 getFirstRowValue(handler, ".address");
99 }
100
101 function getFirstPath(handler) {
102 getFirstRowValue(handler, ".index");
103 }
104
105 function testColumnValuesAreInvisible(done, columnClassName) {
106 var selector = "." + columnClassName + " span";
107 driver.findElements(By.css(selector))
108 .then(function(els) {
109 els[0].getAttribute("class")
110 .then(function(classes) {
111 expect(classes).toContain("invisible");
112 done();
113 });
114 })
115 }
116
117 function testRowsAreInCorrectOrder(done) {
118 driver.findElements(By.css('.index'))
119 .then(function(els) {
120 var testRowAtIndex = function(i) {
121 if (i >= els.length) {
122 done();
123 }
124 else {
125 els[i].getText()
126 .then(function(actualPath) {
127 var noHardened = actualPath.replace(/'/g, "");
128 var pathBits = noHardened.split("/")
129 var lastBit = pathBits[pathBits.length-1];
130 var actualIndex = parseInt(lastBit);
131 expect(actualIndex).toBe(i);
132 testRowAtIndex(i+1);
133 });
134 }
135 }
136 testRowAtIndex(0);
137 });
138 }
139
140 function selectNetwork(name) {
141 driver.executeScript(function() {
142 var selectText = arguments[0];
143 $(".network option[selected]").removeAttr("selected");
144 $(".network option").filter(function(i,e) {
145 return $(e).html() == selectText;
146 }).prop("selected", true);
147 $(".network").trigger("change");
148 }, name);
149 }
150
151 function testEntropyType(done, entropyText, entropyTypeUnsafe) {
152 // entropy type is compiled into regexp so needs escaping
153 // see https://stackoverflow.com/a/2593661
154 var entropyType = (entropyTypeUnsafe+'').replace(/[.?*+^$[\]\\(){}|-]/g, "\\$&");
155 driver.findElement(By.css('.use-entropy'))
156 .click();
157 driver.findElement(By.css('.entropy'))
158 .sendKeys(entropyText);
159 driver.sleep(generateDelay).then(function() {
160 driver.findElement(By.css('.entropy-container'))
161 .getText()
162 .then(function(text) {
163 var re = new RegExp("Entropy Type\\s+" + entropyType);
164 expect(text).toMatch(re);
165 done();
166 });
167 });
168 }
169
170 function testEntropyBits(done, entropyText, entropyBits) {
171 driver.findElement(By.css('.use-entropy'))
172 .click();
173 driver.findElement(By.css('.entropy'))
174 .sendKeys(entropyText);
175 driver.sleep(generateDelay).then(function() {
176 driver.findElement(By.css('.entropy-container'))
177 .getText()
178 .then(function(text) {
179 var re = new RegExp("Total Bits\\s+" + entropyBits);
180 expect(text).toMatch(re);
181 done();
182 });
183 });
184 }
185
186 function testEntropyFeedback(done, entropyDetail) {
187 // entropy type is compiled into regexp so needs escaping
188 // see https://stackoverflow.com/a/2593661
189 if ("type" in entropyDetail) {
190 entropyDetail.type = (entropyDetail.type+'').replace(/[.?*+^$[\]\\(){}|-]/g, "\\$&");
191 }
192 driver.findElement(By.css('.use-entropy'))
193 .click();
194 driver.findElement(By.css('.entropy'))
195 .sendKeys(entropyDetail.entropy);
196 driver.sleep(entropyFeedbackDelay).then(function() {
197 driver.findElement(By.css('.entropy-container'))
198 .getText()
199 .then(function(text) {
200 driver.findElement(By.css('.phrase'))
201 .getAttribute("value")
202 .then(function(phrase) {
203 if ("filtered" in entropyDetail) {
204 var key = "Filtered Entropy";
205 var value = entropyDetail.filtered;
206 var reText = key + "\\s+" + value;
207 var re = new RegExp(reText);
208 expect(text).toMatch(re);
209 }
210 if ("type" in entropyDetail) {
211 var key = "Entropy Type";
212 var value = entropyDetail.type;
213 var reText = key + "\\s+" + value;
214 var re = new RegExp(reText);
215 expect(text).toMatch(re);
216 }
217 if ("events" in entropyDetail) {
218 var key = "Event Count";
219 var value = entropyDetail.events;
220 var reText = key + "\\s+" + value;
221 var re = new RegExp(reText);
222 expect(text).toMatch(re);
223 }
224 if ("bits" in entropyDetail) {
225 var key = "Total Bits";
226 var value = entropyDetail.bits;
227 var reText = key + "\\s+" + value;
228 var re = new RegExp(reText);
229 expect(text).toMatch(re);
230 }
231 if ("bitsPerEvent" in entropyDetail) {
232 var key = "Bits Per Event";
233 var value = entropyDetail.bitsPerEvent;
234 var reText = key + "\\s+" + value;
235 var re = new RegExp(reText);
236 expect(text).toMatch(re);
237 }
238 if ("words" in entropyDetail) {
239 var actualWords = phrase.split(/\s+/)
240 .filter(function(w) { return w.length > 0 })
241 .length;
242 expect(actualWords).toBe(entropyDetail.words);
243 }
244 if ("strength" in entropyDetail) {
245 var key = "Time To Crack";
246 var value = entropyDetail.strength;
247 var reText = key + "\\s+" + value;
248 var re = new RegExp(reText);
249 expect(text).toMatch(re);
250 }
251 done();
252 });
253 });
254 });
255 }
256
257 function testClientSelect(done, params) {
258 // set mnemonic and select bip32 tab
259 driver.findElement(By.css('#bip32-tab a'))
260 .click()
261 driver.findElement(By.css('.phrase'))
262 .sendKeys("abandon abandon ability");
263 driver.sleep(generateDelay).then(function() {
264 // BITCOIN CORE
265 // set bip32 client to bitcoin core
266 driver.executeScript(function() {
267 $("#bip32-client").val(arguments[0]).trigger("change");
268 }, params.selectValue);
269 driver.sleep(generateDelay).then(function() {
270 // check the derivation path is correct
271 driver.findElement(By.css("#bip32-path"))
272 .getAttribute("value")
273 .then(function(path) {
274 expect(path).toBe(params.bip32path);
275 // check hardened addresses is selected
276 driver.findElement(By.css(".hardened-addresses"))
277 .getAttribute("checked")
278 .then(function(isChecked) {
279 expect(isChecked).toBe(params.useHardenedAddresses);
280 // check input is readonly
281 driver.findElement(By.css("#bip32-path"))
282 .getAttribute("readonly")
283 .then(function(isReadonly) {
284 expect(isReadonly).toBe("true");
285 done();
286 });
287 });
288 });
289 });
290 });
291 }
292
293 // Tests
294
295 describe('BIP39 Tool Tests', function() {
296
297 beforeEach(function(done) {
298 driver = newDriver();
299 driver.get(url).then(done);
300 });
301
302 // Close the website after each test is run (so that it is opened fresh each time)
303 afterEach(function(done) {
304 driver.quit().then(done);
305 });
306
307 // BEGIN TESTS
308
309 // Page initially loads with blank phrase
310 it('Should load the page', function(done) {
311 driver.findElement(By.css('.phrase'))
312 .getAttribute('value').then(function(value) {
313 expect(value).toBe('');
314 done();
315 });
316 });
317
318 // Page has text
319 it('Should have text on the page', function(done) {
320 driver.findElement(By.css('body'))
321 .getText()
322 .then(function(text) {
323 var textToFind = "You can enter an existing BIP39 mnemonic";
324 expect(text).toContain(textToFind);
325 done();
326 });
327 });
328
329 // Entering mnemonic generates addresses
330 it('Should have a list of addresses', function(done) {
331 driver.findElement(By.css('.phrase'))
332 .sendKeys('abandon abandon ability');
333 driver.sleep(generateDelay).then(function() {
334 driver.findElements(By.css('.address'))
335 .then(function(els) {
336 expect(els.length).toBe(20);
337 done();
338 })
339 });
340 });
341
342 // Generate button generates random mnemonic
343 it('Should be able to generate a random mnemonic', function(done) {
344 // initial phrase is blank
345 driver.findElement(By.css('.phrase'))
346 .getAttribute("value")
347 .then(function(phrase) {
348 expect(phrase.length).toBe(0);
349 // press generate
350 driver.findElement(By.css('.generate')).click();
351 driver.sleep(generateDelay).then(function() {
352 // new phrase is not blank
353 driver.findElement(By.css('.phrase'))
354 .getAttribute("value")
355 .then(function(phrase) {
356 expect(phrase.length).toBeGreaterThan(0);
357 done();
358 });
359 });
360 });
361 });
362
363 // Mnemonic length can be customized
364 it('Should allow custom length mnemonics', function(done) {
365 // set strength to 6
366 driver.executeScript(function() {
367 $(".strength option[selected]").removeAttr("selected");
368 $(".strength option[value=6]").prop("selected", true);
369 });
370 driver.findElement(By.css('.generate')).click();
371 driver.sleep(generateDelay).then(function() {
372 driver.findElement(By.css('.phrase'))
373 .getAttribute("value")
374 .then(function(phrase) {
375 var words = phrase.split(" ");
376 expect(words.length).toBe(6);
377 done();
378 });
379 });
380 });
381
382 // Passphrase can be set
383 it('Allows a passphrase to be set', function(done) {
384 driver.findElement(By.css('.phrase'))
385 .sendKeys('abandon abandon ability');
386 driver.findElement(By.css('.passphrase'))
387 .sendKeys('secure_passphrase');
388 driver.sleep(generateDelay).then(function() {
389 getFirstAddress(function(address) {
390 expect(address).toBe("15pJzUWPGzR7avffV9nY5by4PSgSKG9rba");
391 done();
392 })
393 });
394 });
395
396 // Network can be set to networks other than bitcoin
397 it('Allows selection of bitcoin testnet', function(done) {
398 var params = {
399 selectText: "BTC - Bitcoin Testnet",
400 firstAddress: "mucaU5iiDaJDb69BHLeDv8JFfGiyg2nJKi",
401 };
402 testNetwork(done, params);
403 });
404 it('Allows selection of litecoin', function(done) {
405 var params = {
406 selectText: "LTC - Litecoin",
407 firstAddress: "LQ4XU8RX2ULPmPq9FcUHdVmPVchP9nwXdn",
408 };
409 testNetwork(done, params);
410 });
411 it('Allows selection of ripple', function(done) {
412 var params = {
413 selectText: "XRP - Ripple",
414 firstAddress: "rLTFnqbmCVPGx6VfaygdtuKWJgcN4v1zRS",
415 phrase: "ill clump only blind unit burden thing track silver cloth review awake useful craft whale all satisfy else trophy sunset walk vanish hope valve",
416 };
417 testNetwork(done, params);
418 });
419 it('Allows selection of dogecoin', function(done) {
420 var params = {
421 selectText: "DOGE - Dogecoin",
422 firstAddress: "DPQH2AtuzkVSG6ovjKk4jbUmZ6iXLpgbJA",
423 };
424 testNetwork(done, params);
425 });
426 it('Allows selection of denarius', function(done) {
427 var params = {
428 selectText: "DNR - Denarius",
429 firstAddress: "DFdFMVUMzU9xX88EywXvAGwjiwpxyh9vKb",
430 };
431 testNetwork(done, params);
432 });
433 it('Allows selection of shadowcash', function(done) {
434 var params = {
435 selectText: "SDC - ShadowCash",
436 firstAddress: "SiSZtfYAXEFvMm3XM8hmtkGDyViRwErtCG",
437 };
438 testNetwork(done, params);
439 });
440 it('Allows selection of shadowcash testnet', function(done) {
441 var params = {
442 selectText: "SDC - ShadowCash Testnet",
443 firstAddress: "tM2EDpVKaTiEg2NZg3yKg8eqjLr55BErHe",
444 };
445 testNetwork(done, params);
446 });
447 it('Allows selection of viacoin', function(done) {
448 var params = {
449 selectText: "VIA - Viacoin",
450 firstAddress: "Vq9Eq4N5SQnjqZvxtxzo7hZPW5XnyJsmXT",
451 };
452 testNetwork(done, params);
453 });
454 it('Allows selection of viacoin testnet', function(done) {
455 var params = {
456 selectText: "VIA - Viacoin Testnet",
457 firstAddress: "tM2EDpVKaTiEg2NZg3yKg8eqjLr55BErHe",
458 };
459 testNetwork(done, params);
460 });
461 it('Allows selection of jumbucks', function(done) {
462 var params = {
463 selectText: "JBS - Jumbucks",
464 firstAddress: "JLEXccwDXADK4RxBPkRez7mqsHVoJBEUew",
465 };
466 testNetwork(done, params);
467 });
468 it('Allows selection of clam', function(done) {
469 var params = {
470 selectText: "CLAM - Clams",
471 firstAddress: "xCp4sakjVx4pUAZ6cBCtuin8Ddb6U1sk9y",
472 };
473 testNetwork(done, params);
474 });
475 it('Allows selection of crown', function(done) {
476 var params = {
477 selectText: "CRW - Crown",
478 firstAddress: "18pWSwSUAQdiwMHUfFZB1fM2xue9X1FqE5",
479 };
480 testNetwork(done, params);
481 });
482 it('Allows selection of dash', function(done) {
483 var params = {
484 selectText: "DASH - Dash",
485 firstAddress: "XdbhtMuGsPSkE6bPdNTHoFSszQKmK4S5LT",
486 };
487 testNetwork(done, params);
488 });
489 it('Allows selection of dash testnet', function(done) {
490 var params = {
491 selectText: "DASH - Dash Testnet",
492 firstAddress: "yaR52EN4oojdJfBgzWJTymC4uuCLPT29Gw",
493 };
494 testNetwork(done, params);
495 });
496 it('Allows selection of game', function(done) {
497 var params = {
498 selectText: "GAME - GameCredits",
499 firstAddress: "GSMY9bAp36cMR4zyT4uGVS7GFjpdXbao5Q",
500 };
501 testNetwork(done, params);
502 });
503 it('Allows selection of komodo', function(done) {
504 var params = {
505 selectText: "KMD - Komodo",
506 firstAddress: "RMPPzJwAjPVZZAwJvXivHJGGjdCx6WBD2t",
507 };
508 testNetwork(done, params);
509 });
510 it('Allows selection of namecoin', function(done) {
511 var params = {
512 selectText: "NMC - Namecoin",
513 firstAddress: "Mw2vK2Bvex1yYtYF6sfbEg2YGoUc98YUD2",
514 };
515 testNetwork(done, params);
516 });
517 it('Allows selection of onixcoin', function(done) {
518 var params = {
519 selectText: "ONX - Onixcoin",
520 firstAddress: "XGwMqddeKjT3ddgX73QokjVbCL3aK6Yxfk",
521 };
522 testNetwork(done, params);
523 });
524 it('Allows selection of peercoin', function(done) {
525 var params = {
526 selectText: "PPC - Peercoin",
527 firstAddress: "PVAiioTaK2eDHSEo3tppT9AVdBYqxRTBAm",
528 };
529 testNetwork(done, params);
530 });
531 it('Allows selection of ethereum', function(done) {
532 var params = {
533 selectText: "ETH - Ethereum",
534 firstAddress: "0xe5815d5902Ad612d49283DEdEc02100Bd44C2772",
535 };
536 testNetwork(done, params);
537 // TODO test private key and public key
538 });
539 it('Allows selection of slimcoin', function(done) {
540 var params = {
541 selectText: "SLM - Slimcoin",
542 firstAddress: "SNzPi1CafHFm3WWjRo43aMgiaEEj3ogjww",
543 };
544 testNetwork(done, params);
545 });
546 it('Allows selection of slimcoin testnet', function(done) {
547 var params = {
548 selectText: "SLM - Slimcoin Testnet",
549 firstAddress: "n3nMgWufTek5QQAr6uwMhg5xbzj8xqc4Dq",
550 };
551 testNetwork(done, params);
552 });
553 it('Allows selection of bitcoin cash', function(done) {
554 var params = {
555 selectText: "BCH - Bitcoin Cash",
556 firstAddress: "bitcoincash:qzlquk7w4hkudxypl4fgv8x279r754dkvur7jpcsps",
557 };
558 testNetwork(done, params);
559 });
560 it('Allows selection of myriadcoin', function(done) {
561 var params = {
562 selectText: "XMY - Myriadcoin",
563 firstAddress: "MJEswvRR46wh9BoiVj9DzKYMBkCramhoBV",
564 };
565 testNetwork(done, params);
566 });
567 it('Allows selection of pivx', function(done) {
568 var params = {
569 selectText: "PIVX - PIVX",
570 firstAddress: "DBxgT7faCuno7jmtKuu6KWCiwqsVPqh1tS",
571 };
572 testNetwork(done, params);
573 });
574 it('Allows selection of pivx testnet', function(done) {
575 var params = {
576 selectText: "PIVX - PIVX Testnet",
577 firstAddress: "yB5U384n6dGkVE3by5y9VdvHHPwPg68fQj",
578 };
579 testNetwork(done, params);
580 });
581 it('Allows selection of maza', function(done) {
582 var params = {
583 selectText: "MAZA - Maza",
584 firstAddress: "MGW4Bmi2NEm4PxSjgeFwhP9vg18JHoRnfw",
585 };
586 testNetwork(done, params);
587 });
588 it('Allows selection of fujicoin', function(done) {
589 var params = {
590 selectText: "FJC - Fujicoin",
591 firstAddress: "FgiaLpG7C99DyR4WnPxXedRVHXSfKzUDhF",
592 };
593 testNetwork(done, params);
594 });
595 it('Allows selection of nubits', function(done) {
596 var params = {
597 selectText: "USNBT - NuBits",
598 firstAddress: "BLxkabXuZSJSdesLD7KxZdqovd4YwyBTU6",
599 };
600 testNetwork(done, params);
601 });
602 it('Allows selection of bitcoin gold', function(done) {
603 var params = {
604 selectText: "BTG - Bitcoin Gold",
605 firstAddress: "GdDqug4WUsn5syNbSTHatNn4XnuwZtzedx",
606 };
607 testNetwork(done, params);
608 });
609 it('Allows selection of monacoin', function(done) {
610 var params = {
611 selectText: "MONA - Monacoin",
612 firstAddress: "MKMiMr7MyjDKjJbCBzgF6u4ByqTS4NkRB1",
613 };
614 testNetwork(done, params);
615 });
616 it('Allows selection of AXE', function(done) {
617 var params = {
618 selectText: "AXE - Axe",
619 firstAddress: "PScwtLUyPiGrqtKXrHF37DGETLXLZdw4up",
620 };
621 testNetwork(done, params);
622 });
623 it('Allows selection of BlackCoin', function(done) {
624 var params = {
625 selectText: "BLK - BlackCoin",
626 firstAddress: "B5MznAKwj7uQ42vDz3w4onhBXPcqhTwJ9z",
627 };
628 testNetwork(done, params);
629 });
630 it('Allows selection of Neblio', function(done) {
631 var params = {
632 selectText: "NEBL - Neblio",
633 firstAddress: "NefkeEEvhusbHMmTRrxx7H9wFnUXd8qQsE",
634 };
635 testNetwork(done, params);
636 });
637 it('Allows selection of Beetlecoin', function(done) {
638 var params = {
639 selectText: "BEET - Beetlecoin",
640 firstAddress: "BVmtbEsGrjpknprmpHFq26z4kYHJUFHE71",
641 };
642 testNetwork(done, params);
643 });
644 it('Allows selection of Adcoin', function(done) {
645 var params = {
646 selectText: "ACC - Adcoin",
647 firstAddress: "AcEDM6V5sF4kFHC76MJjjfProtS5Sw2qcd",
648 };
649 testNetwork(done, params);
650 });
651 it('Allows selection of Asiacoin', function(done) {
652 var params = {
653 selectText: "AC - Asiacoin",
654 firstAddress: "ALupuEEz7kJjQTAvmtcBMBVuEjPa7GqZzE",
655 };
656 testNetwork(done, params);
657 });
658 it('Allows selection of Auroracoin', function(done) {
659 var params = {
660 selectText: "AUR - Auroracoin",
661 firstAddress: "ANuraS6F4Jpi413FEnavjYkKYJJRHkgYCm",
662 };
663 testNetwork(done, params);
664 });
665 it('Allows selection of Bata', function(done) {
666 var params = {
667 selectText: "BTA - Bata",
668 firstAddress: "BGxBdNeYPtF3GCuTtZBPQdFxCkdBYSF3fj",
669 };
670 testNetwork(done, params);
671 });
672 it('Allows selection of Belacoin', function(done) {
673 var params = {
674 selectText: "BELA - Belacoin",
675 firstAddress: "BEeetqpNffdzeknSpNmQp5KAFh2KK1Qx7S",
676 };
677 testNetwork(done, params);
678 });
679 it('Allows selection of Bitcoin Atom', function(done) {
680 var params = {
681 selectText: "BCA - Bitcoin Atom",
682 firstAddress: "AMy6qMbJeC4zsGRL6iWszmeCdQH65fgfih",
683 };
684 testNetwork(done, params);
685 });
686 it('Allows selection of Bitcoinplus', function(done) {
687 var params = {
688 selectText: "XBC - Bitcoinplus",
689 firstAddress: "B7FSynZoDbEwTCSgsXq9nJ5ue8owYLVL8r",
690 };
691 testNetwork(done, params);
692 });
693 it('Allows selection of Bitcoin Private', function(done) {
694 var params = {
695 selectText: "BTCP - Bitcoin Private",
696 firstAddress: "b1M3PbiXXyN6Hdivdw5rJv5VKpLjPzhm4jM",
697 };
698 testNetwork(done, params);
699 });
700 it('Allows selection of Bitcoinz', function(done) {
701 var params = {
702 selectText: "BTCZ - Bitcoinz",
703 firstAddress: "t1X2YQoxs8cYRo2oaBYgVEwW5QNjCC59NYc",
704 };
705 testNetwork(done, params);
706 });
707 it('Allows selection of Bitcore', function(done) {
708 var params = {
709 selectText: "BTX - Bitcore",
710 firstAddress: "1Dg18EtqhReS11e9h8khkLjWGLHVjPM2AB",
711 };
712 testNetwork(done, params);
713 });
714 it('Allows selection of Bitsend', function(done) {
715 var params = {
716 selectText: "BSD - Bitsend",
717 firstAddress: "iBPk7LYjDun3EPk7CRR8UUmnPoceVc1bp2",
718 };
719 testNetwork(done, params);
720 });
721 it('Allows selection of Britcoin', function(done) {
722 var params = {
723 selectText: "BRIT - Britcoin",
724 firstAddress: "B6Aue4J2XLs1f1dtD4H1SHYFfh4XrmEbrw",
725 };
726 testNetwork(done, params);
727 });
728 it('Allows selection of Canadaecoin', function(done) {
729 var params = {
730 selectText: "CDN - Canadaecoin",
731 firstAddress: "CanAyCfd5Rj2CQVfaoAmvDUZunPM5W1AEQ",
732 };
733 testNetwork(done, params);
734 });
735 it('Allows selection of Cannacoin', function(done) {
736 var params = {
737 selectText: "CCN - Cannacoin",
738 firstAddress: "CYjW8xWB43g6krLJTmmrPk1PonoQX7h9Qd",
739 };
740 testNetwork(done, params);
741 });
742 it('Allows selection of Clubcoin', function(done) {
743 var params = {
744 selectText: "CLUB - Clubcoin",
745 firstAddress: "CHMDEXN4sihpSVX4GyAa2hZ62shnby7uyN",
746 };
747 testNetwork(done, params);
748 });
749 it('Allows selection of Compcoin', function(done) {
750 var params = {
751 selectText: "CMP - Compcoin",
752 firstAddress: "CLshtw3zhxkseBJS46UF12v3AFy9Dx7JVv",
753 };
754 testNetwork(done, params);
755 });
756 it('Allows selection of Crave', function(done) {
757 var params = {
758 selectText: "CRAVE - Crave",
759 firstAddress: "VCYJeti6uKMNBFKCL7eP96UwuFWYHM7c85",
760 };
761 testNetwork(done, params);
762 });
763 it('Allows selection of Defcoin', function(done) {
764 var params = {
765 selectText: "DFC - Defcoin",
766 firstAddress: "D8swcgyaaFUrXZU3ATwbgy16buCpWqbG1M",
767 };
768 testNetwork(done, params);
769 });
770 it('Allows selection of Diamond', function(done) {
771 var params = {
772 selectText: "DMD - Diamond",
773 firstAddress: "dJnrVbLL9UPjdaVRz2C8VpqHZknqAqjLek",
774 };
775 testNetwork(done, params);
776 });
777 it('Allows selection of Digibyte', function(done) {
778 var params = {
779 selectText: "DGB - Digibyte",
780 firstAddress: "D85Rp9jwLtMdmP6wGjTiqHBdVQLST3YCEq",
781 };
782 testNetwork(done, params);
783 });
784 it('Allows selection of Digitalcoin', function(done) {
785 var params = {
786 selectText: "DGC - Digitalcoin",
787 firstAddress: "DKw4UGKEAZWweDNEbBFNQx4EM8x1mpUdia",
788 };
789 testNetwork(done, params);
790 });
791 it('Allows selection of Ecoin', function(done) {
792 var params = {
793 selectText: "ECN - Ecoin",
794 firstAddress: "e6WFPLG5gcXyF7cESFteH1hE2XSmowW5yB",
795 };
796 testNetwork(done, params);
797 });
798 it('Allows selection of Edrcoin', function(done) {
799 var params = {
800 selectText: "EDRC - Edrcoin",
801 firstAddress: "eh1nUJsvgKPFv6ebMBfcwJ299GMCpjeZUG",
802 };
803 testNetwork(done, params);
804 });
805 it('Allows selection of Egulden', function(done) {
806 var params = {
807 selectText: "EFL - Egulden",
808 firstAddress: "Lg66yt55R7edRM58cDhKzXik2kFme3viX7",
809 };
810 testNetwork(done, params);
811 });
812 it('Allows selection of Einsteinium', function(done) {
813 var params = {
814 selectText: "EMC2 - Einsteinium",
815 firstAddress: "EVAABm9hXKHk2MpVMbwNakRubFnNha5m8m",
816 };
817 testNetwork(done, params);
818 });
819 it('Allows selection of Europecoin', function(done) {
820 var params = {
821 selectText: "ERC - Europecoin",
822 firstAddress: "ESA2YwPYntAoaPrE8Fm5qkKRtkcwLcwD6R",
823 };
824 testNetwork(done, params);
825 });
826 it('Allows selection of Exclusivecoin', function(done) {
827 var params = {
828 selectText: "EXCL - Exclusivecoin",
829 firstAddress: "EbUa6m8UZW6nTxsYZD2FsDjkadKbp5M6JT",
830 };
831 testNetwork(done, params);
832 });
833 it('Allows selection of Feathercoin', function(done) {
834 var params = {
835 selectText: "FTC - Feathercoin",
836 firstAddress: "6gDdjAMoSgQaW8UhqK3oboHs6ftGAroKkM",
837 };
838 testNetwork(done, params);
839 });
840 it('Allows selection of Firstcoin', function(done) {
841 var params = {
842 selectText: "FRST - Firstcoin",
843 firstAddress: "FJN9GzfMm7Q8R4DJwK1H9F6A1GTghvFiMJ",
844 };
845 testNetwork(done, params);
846 });
847 it('Allows selection of Flashcoin', function(done) {
848 var params = {
849 selectText: "FLASH - Flashcoin",
850 firstAddress: "UWfpf5LfMmLxZYooEb2EyvWhZ8NG7EZDRt",
851 };
852 testNetwork(done, params);
853 });
854 it('Allows selection of GCRCoin', function(done) {
855 var params = {
856 selectText: "GCR - GCRCoin",
857 firstAddress: "GJjF5cLwyXLacpuvXAVksxGxKvHDjx58d6",
858 };
859 testNetwork(done, params);
860 });
861 it('Allows selection of Gobyte', function(done) {
862 var params = {
863 selectText: "GBX - Gobyte",
864 firstAddress: "GS813Ys2brkmvSUw1rUqGPm2HqQVDHJRyA",
865 };
866 testNetwork(done, params);
867 });
868 it('Allows selection of Gridcoin', function(done) {
869 var params = {
870 selectText: "GRC - Gridcoin",
871 firstAddress: "SGrWbBPvobgqKRF8td1Kdc9vbRY7MJ78Y9",
872 };
873 testNetwork(done, params);
874 });
875 it('Allows selection of Gulden', function(done) {
876 var params = {
877 selectText: "NLG - Gulden",
878 firstAddress: "GcDP7cNEc33MPPdTFNJ8pZc6VMZJ2CbKxY",
879 };
880 testNetwork(done, params);
881 });
882 it('Allows selection of Helleniccoin', function(done) {
883 var params = {
884 selectText: "HNC - Helleniccoin",
885 firstAddress: "LbHEKe5H72zp9G1fuWNiiNePTUfJb88915",
886 };
887 testNetwork(done, params);
888 });
889 it('Allows selection of Hempcoin', function(done) {
890 var params = {
891 selectText: "THC - Hempcoin",
892 firstAddress: "H8sdWbZyJV4gyXyHtLXDaNnAuUDhK5mfTV",
893 };
894 testNetwork(done, params);
895 });
896 it('Allows selection of Insane', function(done) {
897 var params = {
898 selectText: "INSN - Insane",
899 firstAddress: "iMPqEJMiXWuxC9U2NVinCCMr4t72h58EWx",
900 };
901 testNetwork(done, params);
902 });
903 it('Allows selection of Iop', function(done) {
904 var params = {
905 selectText: "IOP - Iop",
906 firstAddress: "pGKQmcaPf95Ur5o6oHK4qdiZ52p1yaTvq1",
907 };
908 testNetwork(done, params);
909 });
910 it('Allows selection of Ixcoin', function(done) {
911 var params = {
912 selectText: "IXC - Ixcoin",
913 firstAddress: "xgE9bTZ6YypT3E6ByzkTt31Hq68E9BqywH",
914 };
915 testNetwork(done, params);
916 });
917 it('Allows selection of Kobocoin', function(done) {
918 var params = {
919 selectText: "KOBO - Kobocoin",
920 firstAddress: "FTVoNJETXDAM8x7MnmdE8RwWndSr9PQWhy",
921 };
922 testNetwork(done, params);
923 });
924 it('Allows selection of Landcoin', function(done) {
925 var params = {
926 selectText: "LDCN - Landcoin",
927 firstAddress: "LLvLwNjG1aJcn1RS4W4GJUbv8fNaRATG7c",
928 };
929 testNetwork(done, params);
930 });
931 it('Allows selection of Library Credits', function(done) {
932 var params = {
933 selectText: "LBC - Library Credits",
934 firstAddress: "bQJEQrHDJyHdqycB32uysh1SWn8Ln8LMdg",
935 };
936 testNetwork(done, params);
937 });
938 it('Allows selection of Linx', function(done) {
939 var params = {
940 selectText: "LINX - Linx",
941 firstAddress: "XGWQ3cb3LGUB3VnHmj6xYSMgnokNbf6dyk",
942 };
943 testNetwork(done, params);
944 });
945 it('Allows selection of Litecoincash', function(done) {
946 var params = {
947 selectText: "LCC - Litecoincash",
948 firstAddress: "Ce5n7fjUuQPLutJ4W5nCCfQLKdKLE1mv9A",
949 };
950 testNetwork(done, params);
951 });
952 it('Allows selection of Lynx', function(done) {
953 var params = {
954 selectText: "LYNX - Lynx",
955 firstAddress: "KUeY3ZdZkg96p4W98pj1JjygCFU1XqWdw3",
956 };
957 testNetwork(done, params);
958 });
959 it('Allows selection of Minexcoin', function(done) {
960 var params = {
961 selectText: "MNX - Minexcoin",
962 firstAddress: "XC1VnyJVfiMDwWgFtAHDp41cgY3AHk3dJT",
963 };
964 testNetwork(done, params);
965 });
966 it('Allows selection of Navcoin', function(done) {
967 var params = {
968 selectText: "NAV - Navcoin",
969 firstAddress: "NTQVTPK3NWSQLKoffkiQw99T8PifkF1Y2U",
970 };
971 testNetwork(done, params);
972 });
973 it('Allows selection of Neoscoin', function(done) {
974 var params = {
975 selectText: "NEOS - Neoscoin",
976 firstAddress: "NgATz6QbQNXvayHQ4CpZayugb9HeaPDdby",
977 };
978 testNetwork(done, params);
979 });
980 it('Allows selection of Neurocoin', function(done) {
981 var params = {
982 selectText: "NRO - Neurocoin",
983 firstAddress: "NVdYErQ3mFpDuF5DquW9WMiT7sLc8ufFTn",
984 };
985 testNetwork(done, params);
986 });
987 it('Allows selection of Newyorkc', function(done) {
988 var params = {
989 selectText: "NYC - Newyorkc",
990 firstAddress: "RSVMfyH1fKfy3puADJEhut2vfkRyon6imm",
991 };
992 testNetwork(done, params);
993 });
994 it('Allows selection of Novacoin', function(done) {
995 var params = {
996 selectText: "NVC - Novacoin",
997 firstAddress: "4JRvUmxcKCJmaMXZyvRoSS1cmG2XvnZfHN",
998 };
999 testNetwork(done, params);
1000 });
1001 it('Allows selection of Nushares', function(done) {
1002 var params = {
1003 selectText: "NSR - Nushares",
1004 firstAddress: "SecjXzU3c7EecdT7EbC4vvmbdtBBokWh6J",
1005 };
1006 testNetwork(done, params);
1007 });
1008 it('Allows selection of Okcash', function(done) {
1009 var params = {
1010 selectText: "OK - Okcash",
1011 firstAddress: "PV4Qp1TUYuGv4TqVtLZtqvrsWWRycfx1Yi",
1012 };
1013 testNetwork(done, params);
1014 });
1015 it('Allows selection of Omnicore', function(done) {
1016 var params = {
1017 selectText: "OMNI - Omnicore",
1018 firstAddress: "1Q1t3gonjCT3rW38TsTsCvgSc3hh7zBGbi",
1019 };
1020 testNetwork(done, params);
1021 });
1022 it('Allows selection of Pesobit', function(done) {
1023 var params = {
1024 selectText: "PSB - Pesobit",
1025 firstAddress: "PDePsF7ALyXP7JaywokdYiRTDtKa14MAr1",
1026 };
1027 testNetwork(done, params);
1028 });
1029 it('Allows selection of Pinkcoin', function(done) {
1030 var params = {
1031 selectText: "PINK - Pinkcoin",
1032 firstAddress: "2TgjYQffjbzUHJghNaVbdsjHbRwruC3yzC",
1033 };
1034 testNetwork(done, params);
1035 });
1036 it('Allows selection of POSWcoin', function(done) {
1037 var params = {
1038 selectText: "POSW - POSWcoin",
1039 firstAddress: "PNxewmZoPnGBvoEbH6hgQZCK1igDiBCdgC",
1040 };
1041 testNetwork(done, params);
1042 });
1043 it('Allows selection of Potcoin', function(done) {
1044 var params = {
1045 selectText: "POT - Potcoin",
1046 firstAddress: "PEo7Vg2ctXgpP4vuLPeY9aGJtZotyrmiHc",
1047 };
1048 testNetwork(done, params);
1049 });
1050 it('Allows selection of Putincoin', function(done) {
1051 var params = {
1052 selectText: "PUT - Putincoin",
1053 firstAddress: "PViWnfr2uFtovd6e7joM49C94CsGSnqJis",
1054 };
1055 testNetwork(done, params);
1056 });
1057 it('Allows selection of Reddcoin', function(done) {
1058 var params = {
1059 selectText: "RDD - Reddcoin",
1060 firstAddress: "RtgRvXMBng1y51ftteveFqwNfyRG18HpxQ",
1061 };
1062 testNetwork(done, params);
1063 });
1064 it('Allows selection of RevolutionVR', function(done) {
1065 var params = {
1066 selectText: "RVR - RevolutionVR",
1067 firstAddress: "VXeeoP2jkzZnMFxtc66ZBZK1NHN5QJnnjL",
1068 };
1069 testNetwork(done, params);
1070 });
1071 it('Allows selection of Rubycoin', function(done) {
1072 var params = {
1073 selectText: "RBY - Rubycoin",
1074 firstAddress: "RV76JDtjTs11JdMDRToYn6CHecMRPLnKS6",
1075 };
1076 testNetwork(done, params);
1077 });
1078 it('Allows selection of Smileycoin', function(done) {
1079 var params = {
1080 selectText: "SMLY - Smileycoin",
1081 firstAddress: "BEZVnEBCAyFByrgKpwAgYgtvP4rKAd9Sj2",
1082 };
1083 testNetwork(done, params);
1084 });
1085 it('Allows selection of Solarcoin', function(done) {
1086 var params = {
1087 selectText: "SLR - Solarcoin",
1088 firstAddress: "8LZ13HbnjtaMJWSvvVFNTLf71zFfDrhwLu",
1089 };
1090 testNetwork(done, params);
1091 });
1092 it('Allows selection of Stratis', function(done) {
1093 var params = {
1094 selectText: "STRAT - Stratis",
1095 firstAddress: "ScfJnq3QDhKgDMEds6sqUE1ot6ShfhmXXq",
1096 };
1097 testNetwork(done, params);
1098 });
1099 it('Allows selection of Stratis Test', function(done) {
1100 var params = {
1101 selectText: "TSTRAT - Stratis Testnet",
1102 firstAddress: "TRLWm3dye4FRrDWouwYUSUZP96xb76mBE3",
1103 };
1104 testNetwork(done, params);
1105 });
1106 it('Allows selection of Syscoin', function(done) {
1107 var params = {
1108 selectText: "SYS - Syscoin",
1109 firstAddress: "SZwJi42Pst3VAMomyK5DG4157WM5ofRmSj",
1110 };
1111 testNetwork(done, params);
1112 });
1113 it('Allows selection of Toa', function(done) {
1114 var params = {
1115 selectText: "TOA - Toa",
1116 firstAddress: "TSe1QAnUwQzUfbBusDzRJ9URttrRGKoNKF",
1117 };
1118 testNetwork(done, params);
1119 });
1120 it('Allows selection of Ultimatesecurecash', function(done) {
1121 var params = {
1122 selectText: "USC - Ultimatesecurecash",
1123 firstAddress: "UPyLAZU2Che5fiy7Ed8xVJFmXAUhitA4ug",
1124 };
1125 testNetwork(done, params);
1126 });
1127 it('Allows selection of Unobtanium', function(done) {
1128 var params = {
1129 selectText: "UNO - Unobtanium",
1130 firstAddress: "uUBMPVMXrR6qhqornJqKTWgr8L69vihSL9",
1131 };
1132 testNetwork(done, params);
1133 });
1134 it('Allows selection of Vcash', function(done) {
1135 var params = {
1136 selectText: "XVC - Vcash",
1137 firstAddress: "VuL53MSY6KjvAjKSeRkh3NDnKykacDVeps",
1138 };
1139 testNetwork(done, params);
1140 });
1141 it('Allows selection of Verge', function(done) {
1142 var params = {
1143 selectText: "XVG - Verge",
1144 firstAddress: "DCrVuGkMjLJpTGgwAgv9AcMdeb1nkWbjZA",
1145 };
1146 testNetwork(done, params);
1147 });
1148 it('Allows selection of Vertcoin', function(done) {
1149 var params = {
1150 selectText: "VTC - Vertcoin",
1151 firstAddress: "Vf6koGuiWdXQfx8tNqxoNeEDxh4xh5cxsG",
1152 };
1153 testNetwork(done, params);
1154 });
1155 it('Allows selection of Vivo', function(done) {
1156 var params = {
1157 selectText: "VIVO - Vivo",
1158 firstAddress: "VFmBwuXXGhJe7MarQG2GfzHMFebRHgfSpB",
1159 };
1160 testNetwork(done, params);
1161 });
1162 it('Allows selection of Vpncoin', function(done) {
1163 var params = {
1164 selectText: "VASH - Vpncoin",
1165 firstAddress: "VoEmH1qXC4TsSgBAStR21QYetwnFqbqCx9",
1166 };
1167 testNetwork(done, params);
1168 });
1169 it('Allows selection of Whitecoin', function(done) {
1170 var params = {
1171 selectText: "XWC - Whitecoin",
1172 firstAddress: "WcSwCAUqrSgeSYbsaS3SSWWhsx8KRYTFDR",
1173 };
1174 testNetwork(done, params);
1175 });
1176 it('Allows selection of Wincoin', function(done) {
1177 var params = {
1178 selectText: "WC - Wincoin",
1179 firstAddress: "WaDVCESMGgyKgNESdn3u43NnwmGSkZED3Z",
1180 };
1181 testNetwork(done, params);
1182 });
1183 it('Allows selection of Zcoin', function(done) {
1184 var params = {
1185 selectText: "XZC - Zcoin",
1186 firstAddress: "a6VcMdP4XgAA9Tr7xNszmPG5FZpfRf17Cq",
1187 };
1188 testNetwork(done, params);
1189 });
1190 it('Allows selection of Zcash', function(done) {
1191 var params = {
1192 selectText: "ZEC - Zcash",
1193 firstAddress: "t1Sz8AneMcVuzUg3tPJ8et5AS5LFJ7K2EF9",
1194 };
1195 testNetwork(done, params);
1196 });
1197 it('Allows selection of Zclassic', function(done) {
1198 var params = {
1199 selectText: "ZCL - Zclassic",
1200 firstAddress: "t1TBMxTvVJRybUbMLGWq8H4A8F4VUL7czEc",
1201 };
1202 testNetwork(done, params);
1203 });
1204 it('Allows selection of Zencash', function(done) {
1205 var params = {
1206 selectText: "ZEN - Zencash",
1207 firstAddress: "znWh9XASyW2dZq5tck84wFjiwuqVysi7q3p",
1208 };
1209 testNetwork(done, params);
1210 });
1211 it('Allows selection of Energi', function(done) {
1212 var params = {
1213 selectText: "NRG - Energi",
1214 firstAddress: "EejRy4t4nidzhGGzkJUgFP3z4HYBjhTsRt",
1215 };
1216 testNetwork(done, params);
1217 });
1218 it('Allows selection of Ethereum Classic', function(done) {
1219 var params = {
1220 selectText: "ETC - Ethereum Classic",
1221 firstAddress: "0x3c05e5556693808367afB62eF3b63e35d6eD249A",
1222 };
1223 testNetwork(done, params);
1224 });
1225 it('Allows selection of Pirl', function(done) {
1226 var params = {
1227 selectText: "PIRL - Pirl",
1228 firstAddress: "0xe77FC0723dA122B5025CA79193c28563eB47e776",
1229 };
1230 testNetwork(done, params);
1231 });
1232 it('Allows selection of MIX', function(done) {
1233 var params = {
1234 selectText: "MIX - MIX",
1235 firstAddress: "0x98BC5e63aeb6A4e82d72850d20710F07E29A29F1",
1236 };
1237 testNetwork(done, params);
1238 });
1239 it('Allows selection of Musicoin', function(done) {
1240 var params = {
1241 selectText: "MUSIC - Musicoin",
1242 firstAddress: "0xDc060e4A0b0313ea83Cf6B3A39B9db2D29004897",
1243 };
1244 testNetwork(done, params);
1245 });
1246 it('Allows selection of Poa', function(done) {
1247 var params = {
1248 selectText: "POA - Poa",
1249 firstAddress: "0x53aF28d754e106210C3d0467Dd581eaf7e3C5e60",
1250 };
1251 testNetwork(done, params);
1252 });
1253 it('Allows selection of Expanse', function(done) {
1254 var params = {
1255 selectText: "EXP - Expanse",
1256 firstAddress: "0xf57FeAbf26582b6E3E666559d3B1Cc6fB2b2c5F6",
1257 };
1258 testNetwork(done, params);
1259 });
1260 it('Allows selection of Callisto', function(done) {
1261 var params = {
1262 selectText: "CLO - Callisto",
1263 firstAddress: "0x4f9364F7420B317266C51Dc8eB979717D4dE3f4E",
1264 };
1265 testNetwork(done, params);
1266 });
1267
1268
1269 // BIP39 seed is set from phrase
1270 it('Sets the bip39 seed from the prhase', function(done) {
1271 driver.findElement(By.css('.phrase'))
1272 .sendKeys('abandon abandon ability');
1273 driver.sleep(generateDelay).then(function() {
1274 driver.findElement(By.css('.seed'))
1275 .getAttribute("value")
1276 .then(function(seed) {
1277 expect(seed).toBe("20da140d3dd1df8713cefcc4d54ce0e445b4151027a1ab567b832f6da5fcc5afc1c3a3f199ab78b8e0ab4652efd7f414ac2c9a3b81bceb879a70f377aa0a58f3");
1278 done();
1279 })
1280 });
1281 });
1282
1283 // BIP32 root key is set from phrase
1284 it('Sets the bip39 root key from the prhase', function(done) {
1285 driver.findElement(By.css('.phrase'))
1286 .sendKeys('abandon abandon ability');
1287 driver.sleep(generateDelay).then(function() {
1288 driver.findElement(By.css('.root-key'))
1289 .getAttribute("value")
1290 .then(function(seed) {
1291 expect(seed).toBe("xprv9s21ZrQH143K2jkGDCeTLgRewT9F2pH5JZs2zDmmjXes34geVnFiuNa8KTvY5WoYvdn4Ag6oYRoB6cXtc43NgJAEqDXf51xPm6fhiMCKwpi");
1292 done();
1293 })
1294 });
1295 });
1296
1297 // Tabs show correct addresses when changed
1298 it('Shows the correct address when tab is changed', function(done) {
1299 driver.findElement(By.css('.phrase'))
1300 .sendKeys('abandon abandon ability');
1301 driver.sleep(generateDelay).then(function() {
1302 driver.findElement(By.css('#bip32-tab a'))
1303 .click();
1304 driver.sleep(generateDelay).then(function() {
1305 getFirstAddress(function(address) {
1306 expect(address).toBe("17uQ7s2izWPwBmEVFikTmZUjbBKWYdJchz");
1307 done();
1308 });
1309 });
1310 });
1311 });
1312
1313 // BIP44 derivation path is shown
1314 it('Shows the derivation path for bip44 tab', function(done) {
1315 driver.findElement(By.css('.phrase'))
1316 .sendKeys('abandon abandon ability');
1317 driver.sleep(generateDelay).then(function() {
1318 driver.findElement(By.css('#bip44 .path'))
1319 .getAttribute("value")
1320 .then(function(path) {
1321 expect(path).toBe("m/44'/0'/0'/0");
1322 done();
1323 })
1324 });
1325 });
1326
1327 // BIP44 extended private key is shown
1328 it('Shows the extended private key for bip44 tab', function(done) {
1329 driver.findElement(By.css('.phrase'))
1330 .sendKeys('abandon abandon ability');
1331 driver.sleep(generateDelay).then(function() {
1332 driver.findElement(By.css('.extended-priv-key'))
1333 .getAttribute("value")
1334 .then(function(path) {
1335 expect(path).toBe("xprvA2DxxvPZcyRvYgZMGS53nadR32mVDeCyqQYyFhrCVbJNjPoxMeVf7QT5g7mQASbTf9Kp4cryvcXnu2qurjWKcrdsr91jXymdCDNxKgLFKJG");
1336 done();
1337 })
1338 });
1339 });
1340
1341 // BIP44 extended public key is shown
1342 it('Shows the extended public key for bip44 tab', function(done) {
1343 driver.findElement(By.css('.phrase'))
1344 .sendKeys('abandon abandon ability');
1345 driver.sleep(generateDelay).then(function() {
1346 driver.findElement(By.css('.extended-pub-key'))
1347 .getAttribute("value")
1348 .then(function(path) {
1349 expect(path).toBe("xpub6FDKNRvTTLzDmAdpNTc49ia9b4byd6vqCdUa46Fp3vqMcC96uBoufCmZXQLiN5AK3iSCJMhf9gT2sxkpyaPepRuA7W3MujV5tGmF5VfbueM");
1350 done();
1351 })
1352 });
1353 });
1354
1355 // BIP44 account field changes address list
1356 it('Changes the address list if bip44 account is changed', function(done) {
1357 driver.findElement(By.css('#bip44 .account'))
1358 .sendKeys('1');
1359 driver.findElement(By.css('.phrase'))
1360 .sendKeys('abandon abandon ability');
1361 driver.sleep(generateDelay).then(function() {
1362 getFirstAddress(function(address) {
1363 expect(address).toBe("1Nq2Wmu726XHCuGhctEtGmhxo3wzk5wZ1H");
1364 done();
1365 });
1366 });
1367 });
1368
1369 // BIP44 change field changes address list
1370 it('Changes the address list if bip44 change is changed', function(done) {
1371 driver.findElement(By.css('#bip44 .change'))
1372 .sendKeys('1');
1373 driver.findElement(By.css('.phrase'))
1374 .sendKeys('abandon abandon ability');
1375 driver.sleep(generateDelay).then(function() {
1376 getFirstAddress(function(address) {
1377 expect(address).toBe("1KAGfWgqfVbSSXY56fNQ7YnhyKuoskHtYo");
1378 done();
1379 });
1380 });
1381 });
1382
1383 // BIP32 derivation path can be set
1384 it('Can use a custom bip32 derivation path', function(done) {
1385 driver.findElement(By.css('#bip32-tab a'))
1386 .click();
1387 driver.findElement(By.css('#bip32 .path'))
1388 .clear();
1389 driver.findElement(By.css('#bip32 .path'))
1390 .sendKeys('m/1');
1391 driver.findElement(By.css('.phrase'))
1392 .sendKeys('abandon abandon ability');
1393 driver.sleep(generateDelay).then(function() {
1394 getFirstAddress(function(address) {
1395 expect(address).toBe("16pYQQdLD1hH4hwTGLXBaZ9Teboi1AGL8L");
1396 done();
1397 });
1398 });
1399 });
1400
1401 // BIP32 can use hardened derivation paths
1402 it('Can use a hardened derivation paths', function(done) {
1403 driver.findElement(By.css('#bip32-tab a'))
1404 .click();
1405 driver.findElement(By.css('#bip32 .path'))
1406 .clear();
1407 driver.findElement(By.css('#bip32 .path'))
1408 .sendKeys("m/0'");
1409 driver.findElement(By.css('.phrase'))
1410 .sendKeys('abandon abandon ability');
1411 driver.sleep(generateDelay).then(function() {
1412 getFirstAddress(function(address) {
1413 expect(address).toBe("14aXZeprXAE3UUKQc4ihvwBvww2LuEoHo4");
1414 done();
1415 });
1416 });
1417 });
1418
1419 // BIP32 extended private key is shown
1420 it('Shows the BIP32 extended private key', function(done) {
1421 driver.findElement(By.css('#bip32-tab a'))
1422 .click();
1423 driver.findElement(By.css('.phrase'))
1424 .sendKeys('abandon abandon ability');
1425 driver.sleep(generateDelay).then(function() {
1426 driver.findElement(By.css('.extended-priv-key'))
1427 .getAttribute("value")
1428 .then(function(privKey) {
1429 expect(privKey).toBe("xprv9va99uTVE5aLiutUVLTyfxfe8v8aaXjSQ1XxZbK6SezYVuikA9MnjQVTA8rQHpNA5LKvyQBpLiHbBQiiccKiBDs7eRmBogsvq3THFeLHYbe");
1430 done();
1431 });
1432 });
1433 });
1434
1435 // BIP32 extended public key is shown
1436 it('Shows the BIP32 extended public key', function(done) {
1437 driver.findElement(By.css('#bip32-tab a'))
1438 .click();
1439 driver.findElement(By.css('.phrase'))
1440 .sendKeys('abandon abandon ability');
1441 driver.sleep(generateDelay).then(function() {
1442 driver.findElement(By.css('.extended-pub-key'))
1443 .getAttribute("value")
1444 .then(function(pubKey) {
1445 expect(pubKey).toBe("xpub69ZVZQzP4T8dwPxwbMzz36cNgwy4yzTHmETZMyihzzXXNi3thgg3HCow1RtY252wdw5rS8369xKnraN5Q93y3FkFfJp2XEHWUrkyXsjS93P");
1446 done();
1447 });
1448 });
1449 });
1450
1451 // Derivation path is shown in table
1452 it('Shows the derivation path in the table', function(done) {
1453 driver.findElement(By.css('.phrase'))
1454 .sendKeys('abandon abandon ability');
1455 driver.sleep(generateDelay).then(function() {
1456 getFirstPath(function(path) {
1457 expect(path).toBe("m/44'/0'/0'/0/0");
1458 done();
1459 });
1460 });
1461 });
1462
1463 // Derivation path for address can be hardened
1464 it('Can derive hardened addresses', function(done) {
1465 driver.findElement(By.css('#bip32-tab a'))
1466 .click();
1467 driver.executeScript(function() {
1468 $(".hardened-addresses").prop("checked", true);
1469 });
1470 driver.findElement(By.css('.phrase'))
1471 .sendKeys('abandon abandon ability');
1472 driver.sleep(generateDelay).then(function() {
1473 getFirstAddress(function(address) {
1474 expect(address).toBe("18exLzUv7kfpiXRzmCjFDoC9qwNLFyvwyd");
1475 done();
1476 });
1477 });
1478 });
1479
1480 // Derivation path visibility can be toggled
1481 it('Can toggle visibility of the derivation path column', function(done) {
1482 driver.findElement(By.css('.phrase'))
1483 .sendKeys('abandon abandon ability');
1484 driver.sleep(generateDelay).then(function() {
1485 driver.findElement(By.css('.index-toggle'))
1486 .click();
1487 testColumnValuesAreInvisible(done, "index");
1488 });
1489 });
1490
1491 // Address is shown
1492 it('Shows the address in the table', function(done) {
1493 driver.findElement(By.css('.phrase'))
1494 .sendKeys('abandon abandon ability');
1495 driver.sleep(generateDelay).then(function() {
1496 getFirstAddress(function(address) {
1497 expect(address).toBe("1Di3Vp7tBWtyQaDABLAjfWtF6V7hYKJtug");
1498 done();
1499 });
1500 });
1501 });
1502
1503 // Addresses are shown in order of derivation path
1504 it('Shows the address in order of derivation path', function(done) {
1505 driver.findElement(By.css('.phrase'))
1506 .sendKeys('abandon abandon ability');
1507 driver.sleep(generateDelay).then(function() {
1508 testRowsAreInCorrectOrder(done);
1509 });
1510 });
1511
1512 // Address visibility can be toggled
1513 it('Can toggle visibility of the address column', function(done) {
1514 driver.findElement(By.css('.phrase'))
1515 .sendKeys('abandon abandon ability');
1516 driver.sleep(generateDelay).then(function() {
1517 driver.findElement(By.css('.address-toggle'))
1518 .click();
1519 testColumnValuesAreInvisible(done, "address");
1520 });
1521 });
1522
1523 // Public key is shown in table
1524 it('Shows the public key in the table', function(done) {
1525 driver.findElement(By.css('.phrase'))
1526 .sendKeys('abandon abandon ability');
1527 driver.sleep(generateDelay).then(function() {
1528 driver.findElements(By.css('.pubkey'))
1529 .then(function(els) {
1530 els[0].getText()
1531 .then(function(pubkey) {
1532 expect(pubkey).toBe("033f5aed5f6cfbafaf223188095b5980814897295f723815fea5d3f4b648d0d0b3");
1533 done();
1534 });
1535 });
1536 });
1537 });
1538
1539 // Public key visibility can be toggled
1540 it('Can toggle visibility of the public key column', function(done) {
1541 driver.findElement(By.css('.phrase'))
1542 .sendKeys('abandon abandon ability');
1543 driver.sleep(generateDelay).then(function() {
1544 driver.findElement(By.css('.public-key-toggle'))
1545 .click();
1546 testColumnValuesAreInvisible(done, "pubkey");
1547 });
1548 });
1549
1550 // Private key is shown in table
1551 it('Shows the private key in the table', function(done) {
1552 driver.findElement(By.css('.phrase'))
1553 .sendKeys('abandon abandon ability');
1554 driver.sleep(generateDelay).then(function() {
1555 driver.findElements(By.css('.privkey'))
1556 .then(function(els) {
1557 els[0].getText()
1558 .then(function(pubkey) {
1559 expect(pubkey).toBe("L26cVSpWFkJ6aQkPkKmTzLqTdLJ923e6CzrVh9cmx21QHsoUmrEE");
1560 done();
1561 });
1562 });
1563 });
1564 });
1565
1566 // Private key visibility can be toggled
1567 it('Can toggle visibility of the private key column', function(done) {
1568 driver.findElement(By.css('.phrase'))
1569 .sendKeys('abandon abandon ability');
1570 driver.sleep(generateDelay).then(function() {
1571 driver.findElement(By.css('.private-key-toggle'))
1572 .click();
1573 testColumnValuesAreInvisible(done, "privkey");
1574 });
1575 });
1576
1577 // More addresses can be generated
1578 it('Can generate more rows in the table', function(done) {
1579 driver.findElement(By.css('.phrase'))
1580 .sendKeys('abandon abandon ability');
1581 driver.sleep(generateDelay).then(function() {
1582 driver.findElement(By.css('.more'))
1583 .click();
1584 driver.sleep(generateDelay).then(function() {
1585 driver.findElements(By.css('.address'))
1586 .then(function(els) {
1587 expect(els.length).toBe(40);
1588 done();
1589 });
1590 });
1591 });
1592 });
1593
1594 // A custom number of additional addresses can be generated
1595 it('Can generate more rows in the table', function(done) {
1596 driver.findElement(By.css('.phrase'))
1597 .sendKeys('abandon abandon ability');
1598 driver.sleep(generateDelay).then(function() {
1599 driver.findElement(By.css('.rows-to-add'))
1600 .clear();
1601 driver.findElement(By.css('.rows-to-add'))
1602 .sendKeys('1');
1603 driver.findElement(By.css('.more'))
1604 .click();
1605 driver.sleep(generateDelay).then(function() {
1606 driver.findElements(By.css('.address'))
1607 .then(function(els) {
1608 expect(els.length).toBe(21);
1609 done();
1610 });
1611 });
1612 });
1613 });
1614
1615 // Additional addresses are shown in order of derivation path
1616 it('Shows additional addresses in order of derivation path', function(done) {
1617 driver.findElement(By.css('.phrase'))
1618 .sendKeys('abandon abandon ability');
1619 driver.sleep(generateDelay).then(function() {
1620 driver.findElement(By.css('.more'))
1621 .click();
1622 driver.sleep(generateDelay).then(function() {
1623 testRowsAreInCorrectOrder(done);
1624 });
1625 });
1626 });
1627
1628 // BIP32 root key can be set by the user
1629 it('Allows the user to set the BIP32 root key', function(done) {
1630 driver.findElement(By.css('.root-key'))
1631 .sendKeys('xprv9s21ZrQH143K2jkGDCeTLgRewT9F2pH5JZs2zDmmjXes34geVnFiuNa8KTvY5WoYvdn4Ag6oYRoB6cXtc43NgJAEqDXf51xPm6fhiMCKwpi');
1632 driver.sleep(generateDelay).then(function() {
1633 getFirstAddress(function(address) {
1634 expect(address).toBe("1Di3Vp7tBWtyQaDABLAjfWtF6V7hYKJtug");
1635 done();
1636 });
1637 });
1638 });
1639
1640 // Setting BIP32 root key clears the existing phrase, passphrase and seed
1641 // TODO this doesn't work in selenium with chrome
1642 it('Confirms the existing phrase should be cleared', function(done) {
1643 if (browser == "chrome") {
1644 pending("Selenium + Chrome headless bug for alert, see https://stackoverflow.com/q/45242264");
1645 }
1646 driver.findElement(By.css('.phrase'))
1647 .sendKeys('A non-blank but invalid value');
1648 driver.findElement(By.css('.root-key'))
1649 .sendKeys('xprv9s21ZrQH143K2jkGDCeTLgRewT9F2pH5JZs2zDmmjXes34geVnFiuNa8KTvY5WoYvdn4Ag6oYRoB6cXtc43NgJAEqDXf51xPm6fhiMCKwpi');
1650 driver.switchTo().alert().accept();
1651 driver.findElement(By.css('.phrase'))
1652 .getAttribute("value").then(function(value) {
1653 expect(value).toBe("");
1654 done();
1655 });
1656 });
1657
1658 // Clearing of phrase, passphrase and seed can be cancelled by user
1659 // TODO this doesn't work in selenium with chrome
1660 it('Allows the clearing of the phrase to be cancelled', function(done) {
1661 if (browser == "chrome") {
1662 pending("Selenium + Chrome headless bug for alert, see https://stackoverflow.com/q/45242264");
1663 }
1664 driver.findElement(By.css('.phrase'))
1665 .sendKeys('abandon abandon ability');
1666 driver.sleep(generateDelay).then(function() {
1667 driver.findElement(By.css('.root-key'))
1668 .clear();
1669 driver.findElement(By.css('.root-key'))
1670 .sendKeys('x');
1671 driver.switchTo().alert().dismiss();
1672 driver.findElement(By.css('.phrase'))
1673 .getAttribute("value").then(function(value) {
1674 expect(value).toBe("abandon abandon ability");
1675 done();
1676 });
1677 });
1678 });
1679
1680 // Custom BIP32 root key is used when changing the derivation path
1681 it('Can set derivation path for root key instead of phrase', function(done) {
1682 driver.findElement(By.css('#bip44 .account'))
1683 .sendKeys('1');
1684 driver.findElement(By.css('.root-key'))
1685 .sendKeys('xprv9s21ZrQH143K2jkGDCeTLgRewT9F2pH5JZs2zDmmjXes34geVnFiuNa8KTvY5WoYvdn4Ag6oYRoB6cXtc43NgJAEqDXf51xPm6fhiMCKwpi');
1686 driver.sleep(generateDelay).then(function() {
1687 getFirstAddress(function(address) {
1688 expect(address).toBe("1Nq2Wmu726XHCuGhctEtGmhxo3wzk5wZ1H");
1689 done();
1690 });
1691 });
1692 });
1693
1694 // Incorrect mnemonic shows error
1695 it('Shows an error for incorrect mnemonic', function(done) {
1696 driver.findElement(By.css('.phrase'))
1697 .sendKeys('abandon abandon abandon');
1698 driver.sleep(feedbackDelay).then(function() {
1699 driver.findElement(By.css('.feedback'))
1700 .getText()
1701 .then(function(feedback) {
1702 expect(feedback).toBe("Invalid mnemonic");
1703 done();
1704 });
1705 });
1706 });
1707
1708 // Incorrect word shows suggested replacement
1709 it('Shows word suggestion for incorrect word', function(done) {
1710 driver.findElement(By.css('.phrase'))
1711 .sendKeys('abandon abandon abiliti');
1712 driver.sleep(feedbackDelay).then(function() {
1713 driver.findElement(By.css('.feedback'))
1714 .getText()
1715 .then(function(feedback) {
1716 var msg = "abiliti not in wordlist, did you mean ability?";
1717 expect(feedback).toBe(msg);
1718 done();
1719 });
1720 });
1721 });
1722
1723 // Github pull request 48
1724 // First four letters of word shows that word, not closest
1725 // since first four letters gives unique word in BIP39 wordlist
1726 // eg ille should show illegal, not idle
1727 it('Shows word suggestion based on first four chars', function(done) {
1728 driver.findElement(By.css('.phrase'))
1729 .sendKeys('ille');
1730 driver.sleep(feedbackDelay).then(function() {
1731 driver.findElement(By.css('.feedback'))
1732 .getText()
1733 .then(function(feedback) {
1734 var msg = "ille not in wordlist, did you mean illegal?";
1735 expect(feedback).toBe(msg);
1736 done();
1737 });
1738 });
1739 });
1740
1741 // Incorrect BIP32 root key shows error
1742 it('Shows error for incorrect root key', function(done) {
1743 driver.findElement(By.css('.root-key'))
1744 .sendKeys('xprv9s21ZrQH143K2jkGDCeTLgRewT9F2pH5JZs2zDmmjXes34geVnFiuNa8KTvY5WoYvdn4Ag6oYRoB6cXtc43NgJAEqDXf51xPm6fhiMCKwpj');
1745 driver.sleep(feedbackDelay).then(function() {
1746 driver.findElement(By.css('.feedback'))
1747 .getText()
1748 .then(function(feedback) {
1749 var msg = "Invalid root key";
1750 expect(feedback).toBe(msg);
1751 done();
1752 });
1753 });
1754 });
1755
1756 // Derivation path not starting with m shows error
1757 it('Shows error for derivation path not starting with m', function(done) {
1758 driver.findElement(By.css('#bip32-tab a'))
1759 .click();
1760 driver.findElement(By.css('#bip32 .path'))
1761 .clear();
1762 driver.findElement(By.css('#bip32 .path'))
1763 .sendKeys('n/0');
1764 driver.findElement(By.css('.phrase'))
1765 .sendKeys('abandon abandon ability');
1766 driver.sleep(feedbackDelay).then(function() {
1767 driver.findElement(By.css('.feedback'))
1768 .getText()
1769 .then(function(feedback) {
1770 var msg = "First character must be 'm'";
1771 expect(feedback).toBe(msg);
1772 done();
1773 });
1774 });
1775 });
1776
1777 // Derivation path containing invalid characters shows useful error
1778 it('Shows error for derivation path not starting with m', function(done) {
1779 driver.findElement(By.css('#bip32-tab a'))
1780 .click();
1781 driver.findElement(By.css('#bip32 .path'))
1782 .clear();
1783 driver.findElement(By.css('#bip32 .path'))
1784 .sendKeys('m/1/0wrong1/1');
1785 driver.findElement(By.css('.phrase'))
1786 .sendKeys('abandon abandon ability');
1787 driver.sleep(feedbackDelay).then(function() {
1788 driver.findElement(By.css('.feedback'))
1789 .getText()
1790 .then(function(feedback) {
1791 var msg = "Invalid characters 0wrong1 found at depth 2";
1792 expect(feedback).toBe(msg);
1793 done();
1794 });
1795 });
1796 });
1797
1798 // Github Issue 11: Default word length is 15
1799 // https://github.com/iancoleman/bip39/issues/11
1800 it('Sets the default word length to 15', function(done) {
1801 driver.findElement(By.css('.strength'))
1802 .getAttribute("value")
1803 .then(function(strength) {
1804 expect(strength).toBe("15");
1805 done();
1806 });
1807 });
1808
1809 // Github Issue 12: Generate more rows with private keys hidden
1810 // https://github.com/iancoleman/bip39/issues/12
1811 it('Sets the correct hidden column state on new rows', function(done) {
1812 driver.findElement(By.css('.phrase'))
1813 .sendKeys("abandon abandon ability");
1814 driver.sleep(generateDelay).then(function() {
1815 driver.findElement(By.css('.private-key-toggle'))
1816 .click();
1817 driver.findElement(By.css('.more'))
1818 .click();
1819 driver.sleep(generateDelay).then(function() {
1820 driver.findElements(By.css('.privkey'))
1821 .then(function(els) {
1822 expect(els.length).toBe(40);
1823 });
1824 testColumnValuesAreInvisible(done, "privkey");
1825 });
1826 });
1827 });
1828
1829 // Github Issue 19: Mnemonic is not sensitive to whitespace
1830 // https://github.com/iancoleman/bip39/issues/19
1831 it('Ignores excess whitespace in the mnemonic', function(done) {
1832 var doublespace = " ";
1833 var mnemonic = "urge cat" + doublespace + "bid";
1834 driver.findElement(By.css('.phrase'))
1835 .sendKeys(mnemonic);
1836 driver.sleep(generateDelay).then(function() {
1837 driver.findElement(By.css('.root-key'))
1838 .getAttribute("value")
1839 .then(function(seed) {
1840 expect(seed).toBe("xprv9s21ZrQH143K3isaZsWbKVoTtbvd34Y1ZGRugGdMeBGbM3AgBVzTH159mj1cbbtYSJtQr65w6L5xy5L9SFC7c9VJZWHxgAzpj4mun5LhrbC");
1841 done();
1842 });
1843 });
1844 });
1845
1846 // Github Issue 23: Part 1: Use correct derivation path when changing tabs
1847 // https://github.com/iancoleman/bip39/issues/23
1848 it('Uses the correct derivation path when changing tabs', function(done) {
1849 // 1) and 2) set the phrase
1850 driver.findElement(By.css('.phrase'))
1851 .sendKeys("abandon abandon ability");
1852 driver.sleep(generateDelay).then(function() {
1853 // 3) select bip32 tab
1854 driver.findElement(By.css('#bip32-tab a'))
1855 .click();
1856 driver.sleep(generateDelay).then(function() {
1857 // 4) switch from bitcoin to litecoin
1858 selectNetwork("LTC - Litecoin");
1859 driver.sleep(generateDelay).then(function() {
1860 // 5) Check address is displayed correctly
1861 getFirstAddress(function(address) {
1862 expect(address).toBe("LS8MP5LZ5AdzSZveRrjm3aYVoPgnfFh5T5");
1863 // 5) Check derivation path is displayed correctly
1864 getFirstPath(function(path) {
1865 expect(path).toBe("m/0/0");
1866 done();
1867 });
1868 });
1869 });
1870 });
1871 });
1872 });
1873
1874 // Github Issue 23 Part 2: Coin selection in derivation path
1875 // https://github.com/iancoleman/bip39/issues/23#issuecomment-238011920
1876 it('Uses the correct derivation path when changing coins', function(done) {
1877 // set the phrase
1878 driver.findElement(By.css('.phrase'))
1879 .sendKeys("abandon abandon ability");
1880 driver.sleep(generateDelay).then(function() {
1881 // switch from bitcoin to clam
1882 selectNetwork("CLAM - Clams");
1883 driver.sleep(generateDelay).then(function() {
1884 // check derivation path is displayed correctly
1885 getFirstPath(function(path) {
1886 expect(path).toBe("m/44'/23'/0'/0/0");
1887 done();
1888 });
1889 });
1890 });
1891 });
1892
1893 // Github Issue 26: When using a Root key derrived altcoins are incorrect
1894 // https://github.com/iancoleman/bip39/issues/26
1895 it('Uses the correct derivation for altcoins with root keys', function(done) {
1896 // 1) 2) and 3) set the root key
1897 driver.findElement(By.css('.root-key'))
1898 .sendKeys("xprv9s21ZrQH143K2jkGDCeTLgRewT9F2pH5JZs2zDmmjXes34geVnFiuNa8KTvY5WoYvdn4Ag6oYRoB6cXtc43NgJAEqDXf51xPm6fhiMCKwpi");
1899 driver.sleep(generateDelay).then(function() {
1900 // 4) switch from bitcoin to viacoin
1901 selectNetwork("VIA - Viacoin");
1902 driver.sleep(generateDelay).then(function() {
1903 // 5) ensure the derived address is correct
1904 getFirstAddress(function(address) {
1905 expect(address).toBe("Vq9Eq4N5SQnjqZvxtxzo7hZPW5XnyJsmXT");
1906 done();
1907 });
1908 });
1909 });
1910 });
1911
1912 // Selecting a language with no existing phrase should generate a phrase in
1913 // that language.
1914 it('Generate a random phrase when language is selected and no current phrase', function(done) {
1915 driver.findElement(By.css("a[href='#japanese']"))
1916 .click();
1917 driver.sleep(generateDelay).then(function() {
1918 driver.findElement(By.css(".phrase"))
1919 .getAttribute("value").then(function(phrase) {
1920 expect(phrase.search(/[a-z]/)).toBe(-1);
1921 expect(phrase.length).toBeGreaterThan(0);
1922 done();
1923 });
1924 });
1925 });
1926
1927 // Selecting a language with existing phrase should update the phrase to use
1928 // that language.
1929 it('Updates existing phrases when the language is changed', function(done) {
1930 driver.findElement(By.css(".phrase"))
1931 .sendKeys("abandon abandon ability");
1932 driver.sleep(generateDelay).then(function() {
1933 driver.findElement(By.css("a[href='#italian']"))
1934 .click();
1935 driver.sleep(generateDelay).then(function() {
1936 driver.findElement(By.css(".phrase"))
1937 .getAttribute("value").then(function(phrase) {
1938 // Check only the language changes, not the phrase
1939 expect(phrase).toBe("abaco abaco abbaglio");
1940 getFirstAddress(function(address) {
1941 // Check the address is correct
1942 expect(address).toBe("1Dz5TgDhdki9spa6xbPFbBqv5sjMrx3xgV");
1943 done();
1944 });
1945 });
1946 });
1947 });
1948 });
1949
1950 // Suggested replacement for erroneous word in non-English language
1951 it('Shows word suggestion for incorrect word in non-English language', function(done) {
1952 driver.findElement(By.css('.phrase'))
1953 .sendKeys('abaco abaco zbbaglio');
1954 driver.sleep(feedbackDelay).then(function() {
1955 driver.findElement(By.css('.feedback'))
1956 .getText()
1957 .then(function(feedback) {
1958 var msg = "zbbaglio not in wordlist, did you mean abbaglio?";
1959 expect(feedback).toBe(msg);
1960 done();
1961 });
1962 });
1963 });
1964
1965 // Japanese word does not break across lines.
1966 // Point 2 from
1967 // https://github.com/bitcoin/bips/blob/master/bip-0039/bip-0039-wordlists.md#japanese
1968 it('Does not break Japanese words across lines', function(done) {
1969 driver.findElement(By.css('.phrase'))
1970 .getCssValue("word-break")
1971 .then(function(value) {
1972 expect(value).toBe("keep-all");
1973 done();
1974 });
1975 });
1976
1977 // Language can be specified at page load using hash value in url
1978 it('Can set the language from the url hash', function(done) {
1979 driver.get(url + "#japanese").then(function() {
1980 driver.findElement(By.css('.generate')).click();
1981 driver.sleep(generateDelay).then(function() {
1982 driver.findElement(By.css(".phrase"))
1983 .getAttribute("value").then(function(phrase) {
1984 expect(phrase.search(/[a-z]/)).toBe(-1);
1985 expect(phrase.length).toBeGreaterThan(0);
1986 done();
1987 });
1988 });
1989 });
1990 });
1991
1992 // Entropy can be entered by the user
1993 it('Allows entropy to be entered', function(done) {
1994 driver.findElement(By.css('.use-entropy'))
1995 .click();
1996 driver.findElement(By.css('.entropy'))
1997 .sendKeys('00000000 00000000 00000000 00000000');
1998 driver.sleep(generateDelay).then(function() {
1999 driver.findElement(By.css(".phrase"))
2000 .getAttribute("value").then(function(phrase) {
2001 expect(phrase).toBe("abandon abandon ability");
2002 getFirstAddress(function(address) {
2003 expect(address).toBe("1Di3Vp7tBWtyQaDABLAjfWtF6V7hYKJtug");
2004 done();
2005 })
2006 });
2007 });
2008 });
2009
2010 // A warning about entropy is shown to the user, with additional information
2011 it('Shows a warning about using entropy', function(done) {
2012 driver.findElement(By.css('.use-entropy'))
2013 .click();
2014 driver.findElement(By.css('.entropy-container'))
2015 .getText()
2016 .then(function(containerText) {
2017 var warning = "mnemonic may be insecure";
2018 expect(containerText).toContain(warning);
2019 driver.findElement(By.css('#entropy-notes'))
2020 .findElement(By.xpath("parent::*"))
2021 .getText()
2022 .then(function(notesText) {
2023 var detail = "flipping a fair coin, rolling a fair dice, noise measurements etc";
2024 expect(notesText).toContain(detail);
2025 done();
2026 });
2027 });
2028 });
2029
2030 // The types of entropy available are described to the user
2031 it('Shows the types of entropy available', function(done) {
2032 driver.findElement(By.css('.entropy'))
2033 .getAttribute("placeholder")
2034 .then(function(placeholderText) {
2035 var options = [
2036 "binary",
2037 "base 6",
2038 "dice",
2039 "base 10",
2040 "hexadecimal",
2041 "cards",
2042 ];
2043 for (var i=0; i<options.length; i++) {
2044 var option = options[i];
2045 expect(placeholderText).toContain(option);
2046 }
2047 done();
2048 });
2049 });
2050
2051 // The actual entropy used is shown to the user
2052 it('Shows the actual entropy used', function(done) {
2053 driver.findElement(By.css('.use-entropy'))
2054 .click();
2055 driver.findElement(By.css('.entropy'))
2056 .sendKeys('Not A Very Good Entropy Source At All');
2057 driver.sleep(generateDelay).then(function() {
2058 driver.findElement(By.css('.entropy-container'))
2059 .getText()
2060 .then(function(text) {
2061 expect(text).toMatch(/Filtered Entropy\s+AedEceAA/);
2062 done();
2063 });
2064 });
2065 });
2066
2067 // Binary entropy can be entered
2068 it('Allows binary entropy to be entered', function(done) {
2069 testEntropyType(done, "01", "binary");
2070 });
2071
2072 // Base 6 entropy can be entered
2073 it('Allows base 6 entropy to be entered', function(done) {
2074 testEntropyType(done, "012345", "base 6");
2075 });
2076
2077 // Base 6 dice entropy can be entered
2078 it('Allows base 6 dice entropy to be entered', function(done) {
2079 testEntropyType(done, "123456", "base 6 (dice)");
2080 });
2081
2082 // Base 10 entropy can be entered
2083 it('Allows base 10 entropy to be entered', function(done) {
2084 testEntropyType(done, "789", "base 10");
2085 });
2086
2087 // Hexadecimal entropy can be entered
2088 it('Allows hexadecimal entropy to be entered', function(done) {
2089 testEntropyType(done, "abcdef", "hexadecimal");
2090 });
2091
2092 // Dice entropy value is shown as the converted base 6 value
2093 // ie 123456 is converted to 123450
2094 it('Shows dice entropy as base 6', function(done) {
2095 driver.findElement(By.css('.use-entropy'))
2096 .click();
2097 driver.findElement(By.css('.entropy'))
2098 .sendKeys("123456");
2099 driver.sleep(generateDelay).then(function() {
2100 driver.findElement(By.css('.entropy-container'))
2101 .getText()
2102 .then(function(text) {
2103 expect(text).toMatch(/Filtered Entropy\s+123450/);
2104 done();
2105 });
2106 });
2107 });
2108
2109 // The number of bits of entropy accumulated is shown
2110 it("Shows the number of bits of entropy for 20 bits of binary", function(done) {
2111 testEntropyBits(done, "0000 0000 0000 0000 0000", "20");
2112 });
2113 it("Shows the number of bits of entropy for 1 bit of binary", function(done) {
2114 testEntropyBits(done, "0", "1");
2115 });
2116 it("Shows the number of bits of entropy for 4 bits of binary", function(done) {
2117 testEntropyBits(done, "0000", "4");
2118 });
2119 it("Shows the number of bits of entropy for 1 character of base 6 (dice)", function(done) {
2120 // 6 in card is 0 in base 6, 0 in base 6 is 2.6 bits (rounded down to 2 bits)
2121 testEntropyBits(done, "6", "2");
2122 });
2123 it("Shows the number of bits of entropy for 1 character of base 10 with 3 bits", function(done) {
2124 // 7 in base 10 is 111 in base 2, no leading zeros
2125 testEntropyBits(done, "7", "3");
2126 });
2127 it("Shows the number of bits of entropy for 1 character of base 10 with 4 bis", function(done) {
2128 testEntropyBits(done, "8", "4");
2129 });
2130 it("Shows the number of bits of entropy for 1 character of hex", function(done) {
2131 testEntropyBits(done, "F", "4");
2132 });
2133 it("Shows the number of bits of entropy for 2 characters of base 10", function(done) {
2134 testEntropyBits(done, "29", "6");
2135 });
2136 it("Shows the number of bits of entropy for 2 characters of hex", function(done) {
2137 testEntropyBits(done, "0A", "8");
2138 });
2139 it("Shows the number of bits of entropy for 2 characters of hex with 3 leading zeros", function(done) {
2140 // hex is always multiple of 4 bits of entropy
2141 testEntropyBits(done, "1A", "8");
2142 });
2143 it("Shows the number of bits of entropy for 2 characters of hex with 2 leading zeros", function(done) {
2144 testEntropyBits(done, "2A", "8");
2145 });
2146 it("Shows the number of bits of entropy for 2 characters of hex with 1 leading zero", function(done) {
2147 testEntropyBits(done, "4A", "8");
2148 });
2149 it("Shows the number of bits of entropy for 2 characters of hex with no leading zeros", function(done) {
2150 testEntropyBits(done, "8A", "8");
2151 });
2152 it("Shows the number of bits of entropy for 2 characters of hex starting with F", function(done) {
2153 testEntropyBits(done, "FA", "8");
2154 });
2155 it("Shows the number of bits of entropy for 4 characters of hex with leading zeros", function(done) {
2156 testEntropyBits(done, "000A", "16");
2157 });
2158 it("Shows the number of bits of entropy for 4 characters of base 6", function(done) {
2159 testEntropyBits(done, "5555", "11");
2160 });
2161 it("Shows the number of bits of entropy for 4 characters of base 6 dice", function(done) {
2162 // uses dice, so entropy is actually 0000 in base 6, which is 4 lots of
2163 // 2.58 bits, which is 10.32 bits (rounded down to 10 bits)
2164 testEntropyBits(done, "6666", "10");
2165 });
2166 it("Shows the number of bits of entropy for 4 charactes of base 10", function(done) {
2167 // Uses base 10, which is 4 lots of 3.32 bits, which is 13.3 bits (rounded
2168 // down to 13)
2169 testEntropyBits(done, "2227", "13");
2170 });
2171 it("Shows the number of bits of entropy for 4 characters of hex with 2 leading zeros", function(done) {
2172 testEntropyBits(done, "222F", "16");
2173 });
2174 it("Shows the number of bits of entropy for 4 characters of hex starting with F", function(done) {
2175 testEntropyBits(done, "FFFF", "16");
2176 });
2177 it("Shows the number of bits of entropy for 10 characters of base 10", function(done) {
2178 // 10 events at 3.32 bits per event
2179 testEntropyBits(done, "0000101017", "33");
2180 });
2181 it("Shows the number of bits of entropy for a full deck of cards", function(done) {
2182 // cards are not replaced, so a full deck is not 52^52 entropy which is 296
2183 // bits, it's 52!, which is 225 bits
2184 testEntropyBits(done, "ac2c3c4c5c6c7c8c9ctcjcqckcad2d3d4d5d6d7d8d9dtdjdqdkdah2h3h4h5h6h7h8h9hthjhqhkhas2s3s4s5s6s7s8s9stsjsqsks", "225");
2185 });
2186
2187 it("Shows details about the entered entropy", function(done) {
2188 testEntropyFeedback(done,
2189 {
2190 entropy: "A",
2191 filtered: "A",
2192 type: "hexadecimal",
2193 events: "1",
2194 bits: "4",
2195 words: 0,
2196 strength: "less than a second",
2197 }
2198 );
2199 });
2200 it("Shows details about the entered entropy", function(done) {
2201 testEntropyFeedback(done,
2202 {
2203 entropy: "AAAAAAAA",
2204 filtered: "AAAAAAAA",
2205 type: "hexadecimal",
2206 events: "8",
2207 bits: "32",
2208 words: 3,
2209 strength: "less than a second - Repeats like \"aaa\" are easy to guess",
2210 }
2211 );
2212 });
2213 it("Shows details about the entered entropy", function(done) {
2214 testEntropyFeedback(done,
2215 {
2216 entropy: "AAAAAAAA B",
2217 filtered: "AAAAAAAAB",
2218 type: "hexadecimal",
2219 events: "9",
2220 bits: "36",
2221 words: 3,
2222 strength: "less than a second - Repeats like \"aaa\" are easy to guess",
2223 }
2224 );
2225 });
2226 it("Shows details about the entered entropy", function(done) {
2227 testEntropyFeedback(done,
2228 {
2229 entropy: "AAAAAAAA BBBBBBBB",
2230 filtered: "AAAAAAAABBBBBBBB",
2231 type: "hexadecimal",
2232 events: "16",
2233 bits: "64",
2234 words: 6,
2235 strength: "less than a second - Repeats like \"aaa\" are easy to guess",
2236 }
2237 );
2238 });
2239 it("Shows details about the entered entropy", function(done) {
2240 testEntropyFeedback(done,
2241 {
2242 entropy: "AAAAAAAA BBBBBBBB CCCCCCCC",
2243 filtered: "AAAAAAAABBBBBBBBCCCCCCCC",
2244 type: "hexadecimal",
2245 events: "24",
2246 bits: "96",
2247 words: 9,
2248 strength: "less than a second",
2249 }
2250 );
2251 });
2252 it("Shows details about the entered entropy", function(done) {
2253 testEntropyFeedback(done,
2254 {
2255 entropy: "AAAAAAAA BBBBBBBB CCCCCCCC DDDDDDDD",
2256 filtered: "AAAAAAAABBBBBBBBCCCCCCCCDDDDDDDD",
2257 type: "hexadecimal",
2258 events: "32",
2259 bits: "128",
2260 words: 12,
2261 strength: "2 minutes",
2262 }
2263 );
2264 });
2265 it("Shows details about the entered entropy", function(done) {
2266 testEntropyFeedback(done,
2267 {
2268 entropy: "AAAAAAAA BBBBBBBB CCCCCCCC DDDDDDDA",
2269 filtered: "AAAAAAAABBBBBBBBCCCCCCCCDDDDDDDA",
2270 type: "hexadecimal",
2271 events: "32",
2272 bits: "128",
2273 words: 12,
2274 strength: "2 days",
2275 }
2276 );
2277 });
2278 it("Shows details about the entered entropy", function(done) {
2279 testEntropyFeedback(done,
2280 {
2281 entropy: "AAAAAAAA BBBBBBBB CCCCCCCC DDDDDDDA EEEEEEEE",
2282 filtered: "AAAAAAAABBBBBBBBCCCCCCCCDDDDDDDAEEEEEEEE",
2283 type: "hexadecimal",
2284 events: "40",
2285 bits: "160",
2286 words: 15,
2287 strength: "3 years",
2288 }
2289 );
2290 });
2291 it("Shows details about the entered entropy", function(done) {
2292 testEntropyFeedback(done,
2293 {
2294 entropy: "AAAAAAAA BBBBBBBB CCCCCCCC DDDDDDDA EEEEEEEE FFFFFFFF",
2295 filtered: "AAAAAAAABBBBBBBBCCCCCCCCDDDDDDDAEEEEEEEEFFFFFFFF",
2296 type: "hexadecimal",
2297 events: "48",
2298 bits: "192",
2299 words: 18,
2300 strength: "centuries",
2301 }
2302 );
2303 });
2304 it("Shows details about the entered entropy", function(done) {
2305 testEntropyFeedback(done,
2306 {
2307 entropy: "7d",
2308 type: "card",
2309 events: "1",
2310 bits: "4",
2311 words: 0,
2312 strength: "less than a second",
2313 }
2314 );
2315 });
2316 it("Shows details about the entered entropy", function(done) {
2317 testEntropyFeedback(done,
2318 {
2319 entropy: "ac2c3c4c5c6c7c8c9ctcjcqckcad2d3d4d5d6d7d8d9dtdjdqdkdah2h3h4h5h6h7h8h9hthjhqhkhas2s3s4s5s6s7s8s9stsjsqsks",
2320 type: "card (full deck)",
2321 events: "52",
2322 bits: "225",
2323 words: 21,
2324 strength: "centuries",
2325 }
2326 );
2327 });
2328 it("Shows details about the entered entropy", function(done) {
2329 testEntropyFeedback(done,
2330 {
2331 entropy: "ac2c3c4c5c6c7c8c9ctcjcqckcad2d3d4d5d6d7d8d9dtdjdqdkdah2h3h4h5h6h7h8h9hthjhqhkhas2s3s4s5s6s7s8s9stsjsqsks3d",
2332 type: "card (full deck, 1 duplicate: 3d)",
2333 events: "53",
2334 bits: "254",
2335 words: 21,
2336 strength: "centuries",
2337 }
2338 );
2339 });
2340 it("Shows details about the entered entropy", function(done) {
2341 testEntropyFeedback(done,
2342 {
2343 entropy: "ac2c3c4c5c6c7c8c9ctcjcqckcad2d3d4d5d6d7d8d9dtdjdqdkdah2h3h4h5h6h7h8h9hthjhqhkhas2s3s4s5s6s7s8s9stsjsqs3d4d",
2344 type: "card (2 duplicates: 3d 4d, 1 missing: KS)",
2345 events: "53",
2346 bits: "254",
2347 words: 21,
2348 strength: "centuries",
2349 }
2350 );
2351 });
2352 it("Shows details about the entered entropy", function(done) {
2353 testEntropyFeedback(done,
2354 {
2355 entropy: "ac2c3c4c5c6c7c8c9ctcjcqckcad2d3d4d5d6d7d8d9dtdjdqdkdah2h3h4h5h6h7h8h9hthjhqhkhas2s3s4s5s6s7s8s9stsjsqs3d4d5d6d",
2356 type: "card (4 duplicates: 3d 4d 5d..., 1 missing: KS)",
2357 events: "55",
2358 bits: "264",
2359 words: 24,
2360 strength: "centuries",
2361 }
2362 );
2363 });
2364 it("Shows details about the entered entropy", function(done) {
2365 testEntropyFeedback(done,
2366 // Next test was throwing uncaught error in zxcvbn
2367 // Also tests 451 bits, ie Math.log2(52!)*2 = 225.58 * 2
2368 {
2369 entropy: "ac2c3c4c5c6c7c8c9ctcjcqckcad2d3d4d5d6d7d8d9dtdjdqdkdah2h3h4h5h6h7h8h9hthjhqhkhas2s3s4s5s6s7s8s9stsjsqsksac2c3c4c5c6c7c8c9ctcjcqckcad2d3d4d5d6d7d8d9dtdjdqdkdah2h3h4h5h6h7h8h9hthjhqhkhas2s3s4s5s6s7s8s9stsjsqsks",
2370 type: "card (full deck, 52 duplicates: ac 2c 3c...)",
2371 events: "104",
2372 bits: "499",
2373 words: 45,
2374 strength: "centuries",
2375 }
2376 );
2377 });
2378 it("Shows details about the entered entropy", function(done) {
2379 testEntropyFeedback(done,
2380 // Case insensitivity to duplicate cards
2381 {
2382 entropy: "asAS",
2383 type: "card (1 duplicate: AS)",
2384 events: "2",
2385 bits: "9",
2386 words: 0,
2387 strength: "less than a second",
2388 }
2389 );
2390 });
2391 it("Shows details about the entered entropy", function(done) {
2392 testEntropyFeedback(done,
2393 {
2394 entropy: "ASas",
2395 type: "card (1 duplicate: as)",
2396 events: "2",
2397 bits: "9",
2398 words: 0,
2399 strength: "less than a second",
2400 }
2401 );
2402 });
2403 it("Shows details about the entered entropy", function(done) {
2404 testEntropyFeedback(done,
2405 // Missing cards are detected
2406 {
2407 entropy: "ac2c3c4c5c6c7c8c tcjcqckcad2d3d4d5d6d7d8d9dtdjdqdkdah2h3h4h5h6h7h8h9hthjhqhkhas2s3s4s5s6s7s8s9stsjsqsks",
2408 type: "card (1 missing: 9C)",
2409 events: "51",
2410 bits: "221",
2411 words: 18,
2412 strength: "centuries",
2413 }
2414 );
2415 });
2416 it("Shows details about the entered entropy", function(done) {
2417 testEntropyFeedback(done,
2418 {
2419 entropy: "ac2c3c4c5c6c7c8c tcjcqckcad2d3d4d 6d7d8d9dtdjdqdkdah2h3h4h5h6h7h8h9hthjhqhkhas2s3s4s5s6s7s8s9stsjsqsks",
2420 type: "card (2 missing: 9C 5D)",
2421 events: "50",
2422 bits: "216",
2423 words: 18,
2424 strength: "centuries",
2425 }
2426 );
2427 });
2428 it("Shows details about the entered entropy", function(done) {
2429 testEntropyFeedback(done,
2430 {
2431 entropy: "ac2c3c4c5c6c7c8c tcjcqckcad2d3d4d 6d7d8d9dtdjd kdah2h3h 5h6h7h8h9hthjhqhkhas2s3s4s5s6s7s8s9stsjsqsks",
2432 type: "card (4 missing: 9C 5D QD...)",
2433 events: "48",
2434 bits: "208",
2435 words: 18,
2436 strength: "centuries",
2437 }
2438 );
2439 });
2440 it("Shows details about the entered entropy", function(done) {
2441 testEntropyFeedback(done,
2442 // More than six missing cards does not show message
2443 {
2444 entropy: "ac2c3c4c5c6c7c8c tcjcqckcad2d3d4d 6d 8d9d jd kdah2h3h 5h6h7h8h9hthjhqhkh 2s3s4s5s6s7s8s9stsjsqsks",
2445 type: "card",
2446 events: "45",
2447 bits: "195",
2448 words: 18,
2449 strength: "centuries",
2450 }
2451 );
2452 });
2453 it("Shows details about the entered entropy", function(done) {
2454 testEntropyFeedback(done,
2455 // Multiple decks of cards increases bits per event
2456 {
2457 entropy: "3d",
2458 events: "1",
2459 bits: "4",
2460 bitsPerEvent: "4.34",
2461 }
2462 );
2463 });
2464 it("Shows details about the entered entropy", function(done) {
2465 testEntropyFeedback(done,
2466 {
2467 entropy: "3d3d",
2468 events: "2",
2469 bits: "9",
2470 bitsPerEvent: "4.80",
2471 }
2472 );
2473 });
2474 it("Shows details about the entered entropy", function(done) {
2475 testEntropyFeedback(done,
2476 {
2477 entropy: "3d3d3d",
2478 events: "3",
2479 bits: "15",
2480 bitsPerEvent: "5.01",
2481 }
2482 );
2483 });
2484 it("Shows details about the entered entropy", function(done) {
2485 testEntropyFeedback(done,
2486 {
2487 entropy: "3d3d3d3d",
2488 events: "4",
2489 bits: "20",
2490 bitsPerEvent: "5.14",
2491 }
2492 );
2493 });
2494 it("Shows details about the entered entropy", function(done) {
2495 testEntropyFeedback(done,
2496 {
2497 entropy: "3d3d3d3d3d",
2498 events: "5",
2499 bits: "26",
2500 bitsPerEvent: "5.22",
2501 }
2502 );
2503 });
2504 it("Shows details about the entered entropy", function(done) {
2505 testEntropyFeedback(done,
2506 {
2507 entropy: "3d3d3d3d3d3d",
2508 events: "6",
2509 bits: "31",
2510 bitsPerEvent: "5.28",
2511 }
2512 );
2513 });
2514 it("Shows details about the entered entropy", function(done) {
2515 testEntropyFeedback(done,
2516 {
2517 entropy: "3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d",
2518 events: "33",
2519 bits: "184",
2520 bitsPerEvent: "5.59",
2521 strength: 'less than a second - Repeats like "abcabcabc" are only slightly harder to guess than "abc"',
2522 }
2523 );
2524 });
2525
2526 // Entropy is truncated from the left
2527 it('Truncates entropy from the left', function(done) {
2528 // Truncate from left means 0000 is removed from the start
2529 // which gives mnemonic 'avocado zoo zone'
2530 // not 1111 removed from the end
2531 // which gives the mnemonic 'abstract zoo zoo'
2532 var entropy = "00000000 00000000 00000000 00000000";
2533 entropy += "11111111 11111111 11111111 1111"; // Missing last byte
2534 driver.findElement(By.css('.use-entropy'))
2535 .click();
2536 driver.findElement(By.css('.entropy'))
2537 .sendKeys(entropy);
2538 driver.sleep(generateDelay).then(function() {
2539 driver.findElement(By.css(".phrase"))
2540 .getAttribute("value").then(function(phrase) {
2541 expect(phrase).toBe("avocado zoo zone");
2542 done();
2543 });
2544 });
2545 });
2546
2547 // Very large entropy results in very long mnemonics
2548 it('Converts very long entropy to very long mnemonics', function(done) {
2549 var entropy = "";
2550 for (var i=0; i<33; i++) {
2551 entropy += "AAAAAAAA"; // 3 words * 33 iterations = 99 words
2552 }
2553 driver.findElement(By.css('.use-entropy'))
2554 .click();
2555 driver.findElement(By.css('.entropy'))
2556 .sendKeys(entropy);
2557 driver.sleep(generateDelay).then(function() {
2558 driver.findElement(By.css(".phrase"))
2559 .getAttribute("value").then(function(phrase) {
2560 var wordCount = phrase.split(/\s+/g).length;
2561 expect(wordCount).toBe(99);
2562 done();
2563 });
2564 });
2565 });
2566
2567 // Is compatible with bip32jp entropy
2568 // https://bip32jp.github.io/english/index.html
2569 // NOTES:
2570 // Is incompatible with:
2571 // base 20
2572 it('Is compatible with bip32jp.github.io', function(done) {
2573 var entropy = "543210543210543210543210543210543210543210543210543210543210543210543210543210543210543210543210543";
2574 var expectedPhrase = "train then jungle barely whip fiber purpose puppy eagle cloud clump hospital robot brave balcony utility detect estate old green desk skill multiply virus";
2575 driver.findElement(By.css('.use-entropy'))
2576 .click();
2577 driver.findElement(By.css('.entropy'))
2578 .sendKeys(entropy);
2579 driver.sleep(generateDelay).then(function() {
2580 driver.findElement(By.css(".phrase"))
2581 .getAttribute("value").then(function(phrase) {
2582 expect(phrase).toBe(expectedPhrase);
2583 done();
2584 });
2585 });
2586 });
2587
2588 // Blank entropy does not generate mnemonic or addresses
2589 it('Does not generate mnemonic for blank entropy', function(done) {
2590 driver.findElement(By.css('.use-entropy'))
2591 .click();
2592 driver.findElement(By.css('.entropy'))
2593 .clear();
2594 // check there is no mnemonic
2595 driver.sleep(generateDelay).then(function() {
2596 driver.findElement(By.css(".phrase"))
2597 .getAttribute("value").then(function(phrase) {
2598 expect(phrase).toBe("");
2599 // check there is no mnemonic
2600 driver.findElements(By.css(".address"))
2601 .then(function(addresses) {
2602 expect(addresses.length).toBe(0);
2603 // Check the feedback says 'blank entropy'
2604 driver.findElement(By.css(".feedback"))
2605 .getText()
2606 .then(function(feedbackText) {
2607 expect(feedbackText).toBe("Blank entropy");
2608 done();
2609 });
2610 })
2611 });
2612 });
2613 });
2614
2615 // Mnemonic length can be selected even for weak entropy
2616 it('Allows selection of mnemonic length even for weak entropy', function(done) {
2617 driver.findElement(By.css('.use-entropy'))
2618 .click();
2619 driver.executeScript(function() {
2620 $(".mnemonic-length").val("18").trigger("change");
2621 });
2622 driver.findElement(By.css('.entropy'))
2623 .sendKeys("012345");
2624 driver.sleep(generateDelay).then(function() {
2625 driver.findElement(By.css(".phrase"))
2626 .getAttribute("value").then(function(phrase) {
2627 var wordCount = phrase.split(/\s+/g).length;
2628 expect(wordCount).toBe(18);
2629 done();
2630 });
2631 });
2632 });
2633
2634 // Github issue 33
2635 // https://github.com/iancoleman/bip39/issues/33
2636 // Final cards should contribute entropy
2637 it('Uses as much entropy as possible for the mnemonic', function(done) {
2638 driver.findElement(By.css('.use-entropy'))
2639 .click();
2640 driver.findElement(By.css('.entropy'))
2641 .sendKeys("7S 9H 9S QH 8C KS AS 7D 7C QD 4S 4D TC 2D 5S JS 3D 8S 8H 4C 3C AC 3S QC 9C JC 7H AD TD JD 6D KH 5C QS 2S 6S 6H JH KD 9D-6C TS TH 4H KC 5H 2H AH 2C 8D 3H 5D");
2642 driver.sleep(generateDelay).then(function() {
2643 // Get mnemonic
2644 driver.findElement(By.css(".phrase"))
2645 .getAttribute("value").then(function(originalPhrase) {
2646 // Set the last 12 cards to be AS
2647 driver.findElement(By.css('.entropy'))
2648 .clear();
2649 driver.findElement(By.css('.entropy'))
2650 .sendKeys("7S 9H 9S QH 8C KS AS 7D 7C QD 4S 4D TC 2D 5S JS 3D 8S 8H 4C 3C AC 3S QC 9C JC 7H AD TD JD 6D KH 5C QS 2S 6S 6H JH KD 9D-AS AS AS AS AS AS AS AS AS AS AS AS");
2651 driver.sleep(generateDelay).then(function() {
2652 // Get new mnemonic
2653 driver.findElement(By.css(".phrase"))
2654 .getAttribute("value").then(function(newPhrase) {
2655 expect(originalPhrase).not.toEqual(newPhrase);
2656 done();
2657 });
2658 });
2659 });
2660 });
2661 });
2662
2663 // Github issue 35
2664 // https://github.com/iancoleman/bip39/issues/35
2665 // QR Code support
2666 // TODO this doesn't work in selenium with firefox
2667 // see https://stackoverflow.com/q/40360223
2668 it('Shows a qr code on hover for the phrase', function(done) {
2669 if (browser == "firefox") {
2670 pending("Selenium + Firefox bug for mouseMove, see https://stackoverflow.com/q/40360223");
2671 }
2672 // generate a random mnemonic
2673 var generateEl = driver.findElement(By.css('.generate'));
2674 generateEl.click();
2675 // toggle qr to show (hidden by default)
2676 var phraseEl = driver.findElement(By.css(".phrase"));
2677 phraseEl.click();
2678 var rootKeyEl = driver.findElement(By.css(".root-key"));
2679 driver.sleep(generateDelay).then(function() {
2680 // hover over the root key
2681 driver.actions().mouseMove(rootKeyEl).perform().then(function() {
2682 // check the qr code shows
2683 driver.executeScript(function() {
2684 return $(".qr-container").find("canvas").length > 0;
2685 })
2686 .then(function(qrShowing) {
2687 expect(qrShowing).toBe(true);
2688 // hover away from the phrase
2689 driver.actions().mouseMove(generateEl).perform().then(function() {;
2690 // check the qr code hides
2691 driver.executeScript(function() {
2692 return $(".qr-container").find("canvas").length == 0;
2693 })
2694 .then(function(qrHidden) {
2695 expect(qrHidden).toBe(true);
2696 done();
2697 });
2698 });
2699 });
2700 });
2701 });
2702 });
2703
2704 // BIP44 account extendend private key is shown
2705 // github issue 37 - compatibility with electrum
2706 it('Shows the bip44 account extended private key', function(done) {
2707 driver.findElement(By.css(".phrase"))
2708 .sendKeys("abandon abandon ability");
2709 driver.sleep(generateDelay).then(function() {
2710 driver.findElement(By.css("#bip44 .account-xprv"))
2711 .getAttribute("value")
2712 .then(function(xprv) {
2713 expect(xprv).toBe("xprv9yzrnt4zWVJUr1k2VxSPy9ettKz5PpeDMgaVG7UKedhqnw1tDkxP2UyYNhuNSumk2sLE5ctwKZs9vwjsq3e1vo9egCK6CzP87H2cVYXpfwQ");
2714 done();
2715 });
2716 });
2717 });
2718
2719 // BIP44 account extendend public key is shown
2720 // github issue 37 - compatibility with electrum
2721 it('Shows the bip44 account extended public key', function(done) {
2722 driver.findElement(By.css(".phrase"))
2723 .sendKeys("abandon abandon ability");
2724 driver.sleep(generateDelay).then(function() {
2725 driver.findElement(By.css("#bip44 .account-xpub"))
2726 .getAttribute("value")
2727 .then(function(xprv) {
2728 expect(xprv).toBe("xpub6CzDCPbtLrrn4VpVbyyQLHbdSMpZoHN4iuW64VswCyEpfjM2mJGdaHJ2DyuZwtst96E16VvcERb8BBeJdHSCVmAq9RhtRQg6eAZFrTKCNqf");
2729 done();
2730 });
2731 });
2732 });
2733
2734 // github issue 40
2735 // BIP32 root key can be set as an xpub
2736 it('Generates addresses from xpub as bip32 root key', function(done) {
2737 driver.findElement(By.css('#bip32-tab a'))
2738 .click();
2739 // set xpub for account 0 of bip44 for 'abandon abandon ability'
2740 driver.findElement(By.css("#root-key"))
2741 .sendKeys("xpub6CzDCPbtLrrn4VpVbyyQLHbdSMpZoHN4iuW64VswCyEpfjM2mJGdaHJ2DyuZwtst96E16VvcERb8BBeJdHSCVmAq9RhtRQg6eAZFrTKCNqf");
2742 driver.sleep(generateDelay).then(function() {
2743 // check the addresses are generated
2744 getFirstAddress(function(address) {
2745 expect(address).toBe("1Di3Vp7tBWtyQaDABLAjfWtF6V7hYKJtug");
2746 // check the xprv key is not set
2747 driver.findElement(By.css(".extended-priv-key"))
2748 .getAttribute("value")
2749 .then(function(xprv) {
2750 expect(xprv).toBe("NA");
2751 // check the private key is not set
2752 driver.findElements(By.css(".privkey"))
2753 .then(function(els) {
2754 els[0]
2755 .getText()
2756 .then(function(privkey) {
2757 expect(xprv).toBe("NA");
2758 done();
2759 });
2760 });
2761 });
2762 });
2763 });
2764 });
2765
2766 // github issue 40
2767 // xpub for bip32 root key will not work with hardened derivation paths
2768 it('Shows error for hardened derivation paths with xpub root key', function(done) {
2769 // set xpub for account 0 of bip44 for 'abandon abandon ability'
2770 driver.findElement(By.css("#root-key"))
2771 .sendKeys("xpub6CzDCPbtLrrn4VpVbyyQLHbdSMpZoHN4iuW64VswCyEpfjM2mJGdaHJ2DyuZwtst96E16VvcERb8BBeJdHSCVmAq9RhtRQg6eAZFrTKCNqf");
2772 driver.sleep(feedbackDelay).then(function() {
2773 // Check feedback is correct
2774 driver.findElement(By.css('.feedback'))
2775 .getText()
2776 .then(function(feedback) {
2777 var msg = "Hardened derivation path is invalid with xpub key";
2778 expect(feedback).toBe(msg);
2779 // Check no addresses are shown
2780 driver.findElements(By.css('.addresses tr'))
2781 .then(function(rows) {
2782 expect(rows.length).toBe(0);
2783 done();
2784 });
2785 });
2786 });
2787 });
2788
2789 // github issue 39
2790 // no root key shows feedback
2791 it('Shows feedback for no root key', function(done) {
2792 // set xpub for account 0 of bip44 for 'abandon abandon ability'
2793 driver.findElement(By.css('#bip32-tab a'))
2794 .click();
2795 driver.sleep(feedbackDelay).then(function() {
2796 // Check feedback is correct
2797 driver.findElement(By.css('.feedback'))
2798 .getText()
2799 .then(function(feedback) {
2800 expect(feedback).toBe("Invalid root key");
2801 done();
2802 });
2803 });
2804 });
2805
2806 // Github issue 44
2807 // display error switching tabs while addresses are generating
2808 it('Can change details while old addresses are still being generated', function(done) {
2809 // Set to generate 199 more addresses.
2810 // This will take a long time allowing a new set of addresses to be
2811 // generated midway through this lot.
2812 // The newly generated addresses should not include any from the old set.
2813 // Any more than 199 will show an alert which needs to be accepted.
2814 driver.findElement(By.css('.rows-to-add'))
2815 .clear();
2816 driver.findElement(By.css('.rows-to-add'))
2817 .sendKeys('199');
2818 // set the prhase
2819 driver.findElement(By.css('.phrase'))
2820 .sendKeys("abandon abandon ability");
2821 driver.sleep(generateDelay).then(function() {
2822 // change tabs which should cancel the previous generating
2823 driver.findElement(By.css('.rows-to-add'))
2824 .clear();
2825 driver.findElement(By.css('.rows-to-add'))
2826 .sendKeys('20');
2827 driver.findElement(By.css('#bip32-tab a'))
2828 .click()
2829 driver.sleep(generateDelay).then(function() {
2830 driver.findElements(By.css('.index'))
2831 .then(function(els) {
2832 // check the derivation paths have the right quantity
2833 expect(els.length).toBe(20);
2834 // check the derivation paths are in order
2835 testRowsAreInCorrectOrder(done);
2836 });
2837 });
2838 });
2839 }, generateDelay + 5000);
2840
2841 // Github issue 49
2842 // padding for binary should give length with multiple of 256
2843 // hashed entropy 1111 is length 252, so requires 4 leading zeros
2844 // prior to issue 49 it would only generate 2 leading zeros, ie missing 2
2845 it('Pads hashed entropy with leading zeros', function(done) {
2846 driver.findElement(By.css('.use-entropy'))
2847 .click();
2848 driver.executeScript(function() {
2849 $(".mnemonic-length").val("15").trigger("change");
2850 });
2851 driver.findElement(By.css('.entropy'))
2852 .sendKeys("1111");
2853 driver.sleep(generateDelay).then(function() {
2854 driver.findElement(By.css('.phrase'))
2855 .getAttribute("value")
2856 .then(function(phrase) {
2857 expect(phrase).toBe("avocado valid quantum cross link predict excuse edit street able flame large galaxy ginger nuclear");
2858 done();
2859 });
2860 });
2861 });
2862
2863 // Github pull request 55
2864 // https://github.com/iancoleman/bip39/pull/55
2865 // Client select
2866 it('Can set the derivation path on bip32 tab for bitcoincore', function(done) {
2867 testClientSelect(done, {
2868 selectValue: "0",
2869 bip32path: "m/0'/0'",
2870 useHardenedAddresses: "true",
2871 });
2872 });
2873 it('Can set the derivation path on bip32 tab for multibit', function(done) {
2874 testClientSelect(done, {
2875 selectValue: "2",
2876 bip32path: "m/0'/0",
2877 useHardenedAddresses: null,
2878 });
2879 });
2880
2881 // github issue 58
2882 // https://github.com/iancoleman/bip39/issues/58
2883 // bip32 derivation is correct, does not drop leading zeros
2884 // see also
2885 // https://medium.com/@alexberegszaszi/why-do-my-bip32-wallets-disagree-6f3254cc5846
2886 it('Retains leading zeros for bip32 derivation', function(done) {
2887 driver.findElement(By.css(".phrase"))
2888 .sendKeys("fruit wave dwarf banana earth journey tattoo true farm silk olive fence");
2889 driver.findElement(By.css(".passphrase"))
2890 .sendKeys("banana");
2891 driver.sleep(generateDelay).then(function() {
2892 getFirstAddress(function(address) {
2893 // Note that bitcore generates an incorrect address
2894 // 13EuKhffWkBE2KUwcbkbELZb1MpzbimJ3Y
2895 // see the medium.com link above for more details
2896 expect(address).toBe("17rxURoF96VhmkcEGCj5LNQkmN9HVhWb7F");
2897 done();
2898 });
2899 });
2900 });
2901
2902 // github issue 60
2903 // Japanese mnemonics generate incorrect bip32 seed
2904 // BIP39 seed is set from phrase
2905 it('Generates correct seed for Japanese mnemonics', function(done) {
2906 driver.findElement(By.css(".phrase"))
2907 .sendKeys("あいこくしん あいこくしん あいこくしん あいこくしん あいこくしん あいこくしん あいこくしん あいこくしん あいこくしん あいこくしん あいこくしん あおぞら");
2908 driver.findElement(By.css(".passphrase"))
2909 .sendKeys("メートルガバヴァぱばぐゞちぢ十人十色");
2910 driver.sleep(generateDelay).then(function() {
2911 driver.findElement(By.css(".seed"))
2912 .getAttribute("value")
2913 .then(function(seed) {
2914 expect(seed).toBe("a262d6fb6122ecf45be09c50492b31f92e9beb7d9a845987a02cefda57a15f9c467a17872029a9e92299b5cbdf306e3a0ee620245cbd508959b6cb7ca637bd55");
2915 done();
2916 });
2917 });
2918 });
2919
2920 // BIP49 official test vectors
2921 // https://github.com/bitcoin/bips/blob/master/bip-0049.mediawiki#test-vectors
2922 it('Generates BIP49 addresses matching the official test vectors', function(done) {
2923 driver.findElement(By.css('#bip49-tab a'))
2924 .click();
2925 selectNetwork("BTC - Bitcoin Testnet");
2926 driver.findElement(By.css(".phrase"))
2927 .sendKeys("abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon about");
2928 driver.sleep(generateDelay).then(function() {
2929 getFirstAddress(function(address) {
2930 expect(address).toBe("2Mww8dCYPUpKHofjgcXcBCEGmniw9CoaiD2");
2931 done();
2932 });
2933 });
2934 });
2935
2936 // BIP49 derivation path is shown
2937 it('Shows the bip49 derivation path', function(done) {
2938 driver.findElement(By.css('#bip49-tab a'))
2939 .click();
2940 driver.findElement(By.css(".phrase"))
2941 .sendKeys("abandon abandon ability");
2942 driver.sleep(generateDelay).then(function() {
2943 driver.findElement(By.css('#bip49 .path'))
2944 .getAttribute("value")
2945 .then(function(path) {
2946 expect(path).toBe("m/49'/0'/0'/0");
2947 done();
2948 });
2949 });
2950 });
2951
2952 // BIP49 extended private key is shown
2953 it('Shows the bip49 extended private key', function(done) {
2954 driver.findElement(By.css('#bip49-tab a'))
2955 .click();
2956 driver.findElement(By.css(".phrase"))
2957 .sendKeys("abandon abandon ability");
2958 driver.sleep(generateDelay).then(function() {
2959 driver.findElement(By.css('.extended-priv-key'))
2960 .getAttribute("value")
2961 .then(function(xprv) {
2962 expect(xprv).toBe("yprvALYB4DYRG6CzzVgzQZwwqjAA2wjBGC3iEd7KYYScpoDdmf75qMRWZWxoFcRXBJjgEXdFqJ9vDRGRLJQsrL22Su5jMbNFeM9vetaGVqy9Qy2");
2963 done();
2964 });
2965 });
2966 });
2967
2968 // BIP49 extended public key is shown
2969 it('Shows the bip49 extended public key', function(done) {
2970 driver.findElement(By.css('#bip49-tab a'))
2971 .click();
2972 driver.findElement(By.css(".phrase"))
2973 .sendKeys("abandon abandon ability");
2974 driver.sleep(generateDelay).then(function() {
2975 driver.findElement(By.css('.extended-pub-key'))
2976 .getAttribute("value")
2977 .then(function(xprv) {
2978 expect(xprv).toBe("ypub6ZXXTj5K6TmJCymTWbUxCs6tayZffemZbr2vLvrEP8kceTSENtjm7KHH6thvAKxVar9fGe8rgsPEX369zURLZ68b4f7Vexz7RuXsjQ69YDt");
2979 done();
2980 });
2981 });
2982 });
2983
2984 // BIP49 account field changes address list
2985 it('Can set the bip49 account field', function(done) {
2986 driver.findElement(By.css('#bip49-tab a'))
2987 .click();
2988 driver.findElement(By.css('#bip49 .account'))
2989 .clear();
2990 driver.findElement(By.css('#bip49 .account'))
2991 .sendKeys("1");
2992 driver.findElement(By.css(".phrase"))
2993 .sendKeys("abandon abandon ability");
2994 driver.sleep(generateDelay).then(function() {
2995 getFirstAddress(function(address) {
2996 expect(address).toBe("381wg1GGN4rP88rNC9v7QWsiww63yLVPsn");
2997 done();
2998 });
2999 });
3000 });
3001
3002 // BIP49 change field changes address list
3003 it('Can set the bip49 change field', function(done) {
3004 driver.findElement(By.css('#bip49-tab a'))
3005 .click();
3006 driver.findElement(By.css('#bip49 .change'))
3007 .clear();
3008 driver.findElement(By.css('#bip49 .change'))
3009 .sendKeys("1");
3010 driver.findElement(By.css(".phrase"))
3011 .sendKeys("abandon abandon ability");
3012 driver.sleep(generateDelay).then(function() {
3013 getFirstAddress(function(address) {
3014 expect(address).toBe("3PEM7MiKed5konBoN66PQhK8r3hjGhy9dT");
3015 done();
3016 });
3017 });
3018 });
3019
3020 // BIP49 account extendend private key is shown
3021 it('Shows the bip49 account extended private key', function(done) {
3022 driver.findElement(By.css('#bip49-tab a'))
3023 .click();
3024 driver.findElement(By.css(".phrase"))
3025 .sendKeys("abandon abandon ability");
3026 driver.sleep(generateDelay).then(function() {
3027 driver.findElement(By.css('#bip49 .account-xprv'))
3028 .getAttribute("value")
3029 .then(function(xprv) {
3030 expect(xprv).toBe("yprvAHtB1M5Wp675aLzFy9TJYK2mSsLkg6mcBRh5DZTR7L4EnYSmYPaL63KFA4ycg1PngW5LfkmejxzosCs17TKZMpRFKc3z5SJar6QAKaFcaZL");
3031 done();
3032 });
3033 });
3034 });
3035
3036 // BIP49 account extendend public key is shown
3037 it('Shows the bip49 account extended public key', function(done) {
3038 driver.findElement(By.css('#bip49-tab a'))
3039 .click();
3040 driver.findElement(By.css(".phrase"))
3041 .sendKeys("abandon abandon ability");
3042 driver.sleep(generateDelay).then(function() {
3043 driver.findElement(By.css('#bip49 .account-xpub'))
3044 .getAttribute("value")
3045 .then(function(xprv) {
3046 expect(xprv).toBe("ypub6WsXQrcQeTfNnq4j5AzJuSyVzuBF5ZVTYecg1ws2ffbDfLmv5vtadqdj1NgR6C6gufMpMfJpHxvb6JEQKvETVNWCRanNedfJtnTchZiJtsL");
3047 done();
3048 });
3049 });
3050 });
3051
3052 // Test selecting coin where bip49 is unavailable (eg CLAM)
3053 it('Shows an error on bip49 tab for coins without bip49', function(done) {
3054 driver.findElement(By.css('#bip49-tab a'))
3055 .click();
3056 driver.findElement(By.css(".phrase"))
3057 .sendKeys("abandon abandon ability");
3058 driver.sleep(generateDelay).then(function() {
3059 selectNetwork("CLAM - Clams");
3060 // bip49 available is hidden
3061 driver.findElement(By.css('#bip49 .available'))
3062 .getAttribute("class")
3063 .then(function(classes) {
3064 expect(classes).toContain("hidden");
3065 // bip49 unavailable is shown
3066 driver.findElement(By.css('#bip49 .unavailable'))
3067 .getAttribute("class")
3068 .then(function(classes) {
3069 expect(classes).not.toContain("hidden");
3070 // check there are no addresses shown
3071 driver.findElements(By.css('.addresses tr'))
3072 .then(function(rows) {
3073 expect(rows.length).toBe(0);
3074 // check the derived private key is blank
3075 driver.findElement(By.css('.extended-priv-key'))
3076 .getAttribute("value")
3077 .then(function(xprv) {
3078 expect(xprv).toBe('');
3079 // check the derived public key is blank
3080 driver.findElement(By.css('.extended-pub-key'))
3081 .getAttribute("value")
3082 .then(function(xpub) {
3083 expect(xpub).toBe('');
3084 done();
3085 });
3086 });
3087 })
3088 });
3089 });
3090 });
3091 });
3092
3093 // github issue 43
3094 // Cleared mnemonic and root key still allows addresses to be generated
3095 // https://github.com/iancoleman/bip39/issues/43
3096 it('Clears old root keys from memory when mnemonic is cleared', function(done) {
3097 // set the phrase
3098 driver.findElement(By.css(".phrase"))
3099 .sendKeys("abandon abandon ability");
3100 driver.sleep(generateDelay).then(function() {
3101 // clear the mnemonic and root key
3102 // using selenium .clear() doesn't seem to trigger the 'input' event
3103 // so clear it using keys instead
3104 driver.findElement(By.css('.phrase'))
3105 .sendKeys(Key.CONTROL,"a");
3106 driver.findElement(By.css('.phrase'))
3107 .sendKeys(Key.DELETE);
3108 driver.findElement(By.css('.root-key'))
3109 .sendKeys(Key.CONTROL,"a");
3110 driver.findElement(By.css('.root-key'))
3111 .sendKeys(Key.DELETE);
3112 driver.sleep(generateDelay).then(function() {
3113 // try to generate more addresses
3114 driver.findElement(By.css('.more'))
3115 .click();
3116 driver.sleep(generateDelay).then(function() {
3117 driver.findElements(By.css(".addresses tr"))
3118 .then(function(els) {
3119 // check there are no addresses shown
3120 expect(els.length).toBe(0);
3121 done();
3122 });
3123 });
3124 });
3125 });
3126 });
3127
3128 // Github issue 95
3129 // error trying to generate addresses from xpub with hardened derivation
3130 it('Shows error for hardened addresses with xpub root key', function(done) {
3131 driver.findElement(By.css('#bip32-tab a'))
3132 .click()
3133 driver.executeScript(function() {
3134 $(".hardened-addresses").prop("checked", true);
3135 });
3136 // set xpub for account 0 of bip44 for 'abandon abandon ability'
3137 driver.findElement(By.css("#root-key"))
3138 .sendKeys("xpub6CzDCPbtLrrn4VpVbyyQLHbdSMpZoHN4iuW64VswCyEpfjM2mJGdaHJ2DyuZwtst96E16VvcERb8BBeJdHSCVmAq9RhtRQg6eAZFrTKCNqf");
3139 driver.sleep(feedbackDelay).then(function() {
3140 // Check feedback is correct
3141 driver.findElement(By.css('.feedback'))
3142 .getText()
3143 .then(function(feedback) {
3144 var msg = "Hardened derivation path is invalid with xpub key";
3145 expect(feedback).toBe(msg);
3146 done();
3147 });
3148 });
3149 });
3150
3151 // Litecoin uses ltub by default, and can optionally be set to xprv
3152 // github issue 96
3153 // https://github.com/iancoleman/bip39/issues/96
3154 // Issue with extended keys on Litecoin
3155 it('Uses ltub by default for litecoin, but can be set to xprv', function(done) {
3156 driver.findElement(By.css('.phrase'))
3157 .sendKeys("abandon abandon ability");
3158 selectNetwork("LTC - Litecoin");
3159 driver.sleep(generateDelay).then(function() {
3160 // check the extended key is generated correctly
3161 driver.findElement(By.css('.root-key'))
3162 .getAttribute("value")
3163 .then(function(rootKey) {
3164 expect(rootKey).toBe("Ltpv71G8qDifUiNesiPqf6h5V6eQ8ic77oxQiYtawiACjBEx3sTXNR2HGDGnHETYxESjqkMLFBkKhWVq67ey1B2MKQXannUqNy1RZVHbmrEjnEU");
3165 // set litecoin to use ltub
3166 driver.executeScript(function() {
3167 $(".litecoin-use-ltub").prop("checked", false);
3168 $(".litecoin-use-ltub").trigger("change");
3169 });
3170 driver.sleep(generateDelay).then(function() {
3171 driver.findElement(By.css('.root-key'))
3172 .getAttribute("value")
3173 .then(function(rootKey) {
3174 expect(rootKey).toBe("xprv9s21ZrQH143K2jkGDCeTLgRewT9F2pH5JZs2zDmmjXes34geVnFiuNa8KTvY5WoYvdn4Ag6oYRoB6cXtc43NgJAEqDXf51xPm6fhiMCKwpi");
3175 done();
3176 });
3177 })
3178 });
3179 });
3180 });
3181
3182 // github issue 99
3183 // https://github.com/iancoleman/bip39/issues/99#issuecomment-327094159
3184 // "warn me emphatically when they have detected invalid input" to the entropy field
3185 // A warning is shown when entropy is filtered and discarded
3186 it('Warns when entropy is filtered and discarded', function(done) {
3187 driver.findElement(By.css('.use-entropy'))
3188 .click();
3189 // set entropy to have no filtered content
3190 driver.findElement(By.css('.entropy'))
3191 .sendKeys("00000000 00000000 00000000 00000000");
3192 driver.sleep(generateDelay).then(function() {
3193 // check the filter warning does not show
3194 driver.findElement(By.css('.entropy-container .filter-warning'))
3195 .getAttribute("class")
3196 .then(function(classes) {
3197 expect(classes).toContain("hidden");
3198 // set entropy to have some filtered content
3199 driver.findElement(By.css('.entropy'))
3200 .sendKeys("10000000 zxcvbn 00000000 00000000 00000000");
3201 driver.sleep(entropyFeedbackDelay).then(function() {
3202 // check the filter warning shows
3203 driver.findElement(By.css('.entropy-container .filter-warning'))
3204 .getAttribute("class")
3205 .then(function(classes) {
3206 expect(classes).not.toContain("hidden");
3207 done();
3208 });
3209 });
3210 });
3211 });
3212 });
3213
3214 // Bitcoin Cash address can be set to use cashaddr format
3215 it('Can use cashaddr format for bitcoin cash addresses', function(done) {
3216 driver.executeScript(function() {
3217 $(".use-bch-cashaddr-addresses").prop("checked", true);
3218 });
3219 driver.findElement(By.css('.phrase'))
3220 .sendKeys("abandon abandon ability");
3221 selectNetwork("BCH - Bitcoin Cash");
3222 driver.sleep(generateDelay).then(function() {
3223 getFirstAddress(function(address) {
3224 expect(address).toBe("bitcoincash:qzlquk7w4hkudxypl4fgv8x279r754dkvur7jpcsps");
3225 done();
3226 });
3227 });
3228 });
3229
3230 // Bitcoin Cash address can be set to use bitpay format
3231 it('Can use bitpay format for bitcoin cash addresses', function(done) {
3232 driver.executeScript(function() {
3233 $(".use-bch-bitpay-addresses").prop("checked", true);
3234 });
3235 driver.findElement(By.css('.phrase'))
3236 .sendKeys("abandon abandon ability");
3237 selectNetwork("BCH - Bitcoin Cash");
3238 driver.sleep(generateDelay).then(function() {
3239 getFirstAddress(function(address) {
3240 expect(address).toBe("CZnpA9HPmvhuhLLPWJP8rNDpLUYXy1LXFk");
3241 done();
3242 });
3243 });
3244 });
3245
3246 // Bitcoin Cash address can be set to use legacy format
3247 it('Can use legacy format for bitcoin cash addresses', function(done) {
3248 driver.executeScript(function() {
3249 $(".use-bch-legacy-addresses").prop("checked", true);
3250 });
3251 driver.findElement(By.css('.phrase'))
3252 .sendKeys("abandon abandon ability");
3253 selectNetwork("BCH - Bitcoin Cash");
3254 driver.sleep(generateDelay).then(function() {
3255 getFirstAddress(function(address) {
3256 expect(address).toBe("1JKvb6wKtsjNoCRxpZ4DGrbniML7z5U16A");
3257 done();
3258 });
3259 });
3260 });
3261
3262 // End of tests ported from old suit, so no more comments above each test now
3263
3264 it('Can generate more addresses from a custom index', function(done) {
3265 var expectedIndexes = [
3266 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,
3267 40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59
3268 ];
3269 driver.findElement(By.css('.phrase'))
3270 .sendKeys("abandon abandon ability");
3271 driver.sleep(generateDelay).then(function() {
3272 // Set start of next lot of rows to be from index 40
3273 // which means indexes 20-39 will not be in the table.
3274 driver.findElement(By.css('.more-rows-start-index'))
3275 .sendKeys("40");
3276 driver.findElement(By.css('.more'))
3277 .click();
3278 driver.sleep(generateDelay).then(function() {
3279 // Check actual indexes in the table match the expected pattern
3280 driver.findElements(By.css(".index"))
3281 .then(function(els) {
3282 expect(els.length).toBe(expectedIndexes.length);
3283 var testRowAtIndex = function(i) {
3284 if (i >= expectedIndexes.length) {
3285 done();
3286 }
3287 else {
3288 els[i].getText()
3289 .then(function(actualPath) {
3290 var noHardened = actualPath.replace(/'/g, "");
3291 var pathBits = noHardened.split("/")
3292 var lastBit = pathBits[pathBits.length-1];
3293 var actualIndex = parseInt(lastBit);
3294 var expectedIndex = expectedIndexes[i];
3295 expect(actualIndex).toBe(expectedIndex);
3296 testRowAtIndex(i+1);
3297 });
3298 }
3299 }
3300 testRowAtIndex(0);
3301 });
3302 });
3303 });
3304 });
3305
3306 it('Can generate BIP141 addresses with P2WPKH-in-P2SH semanitcs', function(done) {
3307 // Sourced from BIP49 official test specs
3308 driver.findElement(By.css('#bip141-tab a'))
3309 .click();
3310 driver.findElement(By.css('.bip141-path'))
3311 .clear();
3312 driver.findElement(By.css('.bip141-path'))
3313 .sendKeys("m/49'/1'/0'/0");
3314 selectNetwork("BTC - Bitcoin Testnet");
3315 driver.findElement(By.css(".phrase"))
3316 .sendKeys("abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon about");
3317 driver.sleep(generateDelay).then(function() {
3318 getFirstAddress(function(address) {
3319 expect(address).toBe("2Mww8dCYPUpKHofjgcXcBCEGmniw9CoaiD2");
3320 done();
3321 });
3322 });
3323 });
3324
3325 it('Can generate BIP141 addresses with P2WPKH semanitcs', function(done) {
3326 // This result tested against bitcoinjs-lib test spec for segwit address
3327 // using the first private key of this mnemonic and default path m/0
3328 // https://github.com/bitcoinjs/bitcoinjs-lib/blob/9c8503cab0c6c30a95127042703bc18e8d28c76d/test/integration/addresses.js#L50
3329 // so whilst not directly comparable, substituting the private key produces
3330 // identical results between this tool and the bitcoinjs-lib test.
3331 // Private key generated is:
3332 // L3L8Nu9whawPBNLGtFqDhKut9DKKfG3CQoysupT7BimqVCZsLFNP
3333 driver.findElement(By.css('#bip141-tab a'))
3334 .click();
3335 // Choose P2WPKH
3336 driver.executeScript(function() {
3337 $(".bip141-semantics option[selected]").removeAttr("selected");
3338 $(".bip141-semantics option").filter(function(i,e) {
3339 return $(e).html() == "P2WPKH";
3340 }).prop("selected", true);
3341 $(".bip141-semantics").trigger("change");
3342 });
3343 driver.findElement(By.css(".phrase"))
3344 .sendKeys("abandon abandon ability");
3345 driver.sleep(generateDelay).then(function() {
3346 getFirstAddress(function(address) {
3347 expect(address).toBe("bc1qfwu6a5a3evygrk8zvdxxvz4547lmpyx5vsfxe9");
3348 done();
3349 });
3350 });
3351 });
3352
3353 it('Shows the entropy used by the PRNG when clicking generate', function(done) {
3354 driver.findElement(By.css('.generate')).click();
3355 driver.sleep(generateDelay).then(function() {
3356 driver.findElement(By.css('.entropy'))
3357 .getAttribute("value")
3358 .then(function(entropy) {
3359 expect(entropy).not.toBe("");
3360 done();
3361 });
3362 });
3363 });
3364
3365 it('Shows the index of each word in the mnemonic', function(done) {
3366 driver.findElement(By.css('.phrase'))
3367 .sendKeys("abandon abandon ability");
3368 driver.sleep(generateDelay).then(function() {
3369 driver.findElement(By.css('.use-entropy'))
3370 .click();
3371 driver.findElement(By.css('.word-indexes'))
3372 .getText()
3373 .then(function(indexes) {
3374 expect(indexes).toBe("0, 0, 1");
3375 done();
3376 });
3377 });
3378 });
3379
3380 it('Shows the derivation path for bip84 tab', function(done) {
3381 driver.findElement(By.css('#bip84-tab a'))
3382 .click()
3383 driver.findElement(By.css('.phrase'))
3384 .sendKeys('abandon abandon ability');
3385 driver.sleep(generateDelay).then(function() {
3386 driver.findElement(By.css('#bip84 .path'))
3387 .getAttribute("value")
3388 .then(function(path) {
3389 expect(path).toBe("m/84'/0'/0'/0");
3390 done();
3391 })
3392 });
3393 });
3394
3395 it('Shows the extended private key for bip84 tab', function(done) {
3396 driver.findElement(By.css('#bip84-tab a'))
3397 .click()
3398 driver.findElement(By.css('.phrase'))
3399 .sendKeys('abandon abandon ability');
3400 driver.sleep(generateDelay).then(function() {
3401 driver.findElement(By.css('.extended-priv-key'))
3402 .getAttribute("value")
3403 .then(function(path) {
3404 expect(path).toBe("zprvAev3RKrZ3QVKiUFCfdeMRen1BPDJgdNt1XpxiDy8acSs4kkAGTCvq7HeRYRNNpo8EtEjCFQBWavJwtCUR29y4TUCH4X5RXMcyq48uN8y9BP");
3405 done();
3406 })
3407 });
3408 });
3409
3410 it('Shows the extended public key for bip84 tab', function(done) {
3411 driver.findElement(By.css('#bip84-tab a'))
3412 .click()
3413 driver.findElement(By.css('.phrase'))
3414 .sendKeys('abandon abandon ability');
3415 driver.sleep(generateDelay).then(function() {
3416 driver.findElement(By.css('.extended-pub-key'))
3417 .getAttribute("value")
3418 .then(function(path) {
3419 expect(path).toBe("zpub6suPpqPSsn3cvxKfmfBMnnijjR3o666jNkkZWcNk8wyqwZ5JozXBNuc8Gs7DB3uLwTDvGVTspVEAUQcEjKF3pZHgywVbubdTqbXTUg7usyx");
3420 done();
3421 })
3422 });
3423 });
3424
3425 it('Changes the address list if bip84 account is changed', function(done) {
3426 driver.findElement(By.css('#bip84-tab a'))
3427 .click()
3428 driver.findElement(By.css('#bip84 .account'))
3429 .sendKeys('1');
3430 driver.findElement(By.css('.phrase'))
3431 .sendKeys('abandon abandon ability');
3432 driver.sleep(generateDelay).then(function() {
3433 getFirstAddress(function(address) {
3434 expect(address).toBe("bc1qp7vv669t2fy965jdzvqwrraana89ctd5ewc662");
3435 done();
3436 });
3437 });
3438 });
3439
3440 it('Changes the address list if bip84 change is changed', function(done) {
3441 driver.findElement(By.css('#bip84-tab a'))
3442 .click()
3443 driver.findElement(By.css('#bip84 .change'))
3444 .sendKeys('1');
3445 driver.findElement(By.css('.phrase'))
3446 .sendKeys('abandon abandon ability');
3447 driver.sleep(generateDelay).then(function() {
3448 getFirstAddress(function(address) {
3449 expect(address).toBe("bc1qr39vj6rh06ff05m53uxq8uazehwhccswylhrs2");
3450 done();
3451 });
3452 });
3453 });
3454
3455 it('Passes the official BIP84 test spec for rootpriv', function(done) {
3456 driver.findElement(By.css('#bip84-tab a'))
3457 .click()
3458 driver.findElement(By.css('.phrase'))
3459 .sendKeys('abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon about');
3460 driver.sleep(generateDelay).then(function() {
3461 driver.findElement(By.css(".root-key"))
3462 .getAttribute("value")
3463 .then(function(rootKey) {
3464 expect(rootKey).toBe("zprvAWgYBBk7JR8Gjrh4UJQ2uJdG1r3WNRRfURiABBE3RvMXYSrRJL62XuezvGdPvG6GFBZduosCc1YP5wixPox7zhZLfiUm8aunE96BBa4Kei5");
3465 done();
3466 })
3467 });
3468 });
3469
3470 it('Passes the official BIP84 test spec for account 0 xprv', function(done) {
3471 driver.findElement(By.css('#bip84-tab a'))
3472 .click()
3473 driver.findElement(By.css('.phrase'))
3474 .sendKeys('abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon about');
3475 driver.sleep(generateDelay).then(function() {
3476 driver.findElement(By.css("#bip84 .account-xprv"))
3477 .getAttribute("value")
3478 .then(function(rootKey) {
3479 expect(rootKey).toBe("zprvAdG4iTXWBoARxkkzNpNh8r6Qag3irQB8PzEMkAFeTRXxHpbF9z4QgEvBRmfvqWvGp42t42nvgGpNgYSJA9iefm1yYNZKEm7z6qUWCroSQnE");
3480 done();
3481 })
3482 });
3483 });
3484
3485 it('Passes the official BIP84 test spec for account 0 xpub', function(done) {
3486 driver.findElement(By.css('#bip84-tab a'))
3487 .click()
3488 driver.findElement(By.css('.phrase'))
3489 .sendKeys('abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon about');
3490 driver.sleep(generateDelay).then(function() {
3491 driver.findElement(By.css("#bip84 .account-xpub"))
3492 .getAttribute("value")
3493 .then(function(rootKey) {
3494 expect(rootKey).toBe("zpub6rFR7y4Q2AijBEqTUquhVz398htDFrtymD9xYYfG1m4wAcvPhXNfE3EfH1r1ADqtfSdVCToUG868RvUUkgDKf31mGDtKsAYz2oz2AGutZYs");
3495 done();
3496 })
3497 });
3498 });
3499
3500 it('Passes the official BIP84 test spec for account 0 first address', function(done) {
3501 driver.findElement(By.css('#bip84-tab a'))
3502 .click()
3503 driver.findElement(By.css('.phrase'))
3504 .sendKeys('abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon about');
3505 driver.sleep(generateDelay).then(function() {
3506 getFirstAddress(function(address) {
3507 expect(address).toBe("bc1qcr8te4kr609gcawutmrza0j4xv80jy8z306fyu");
3508 done();
3509 });
3510 });
3511 });
3512
3513 it('Passes the official BIP84 test spec for account 0 first change address', function(done) {
3514 driver.findElement(By.css('#bip84-tab a'))
3515 .click()
3516 driver.findElement(By.css('.phrase'))
3517 .sendKeys('abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon about');
3518 driver.findElement(By.css('#bip84 .change'))
3519 .sendKeys('1');
3520 driver.sleep(generateDelay).then(function() {
3521 getFirstAddress(function(address) {
3522 expect(address).toBe("bc1q8c6fshw2dlwun7ekn9qwf37cu2rn755upcp6el");
3523 done();
3524 });
3525 });
3526 });
3527
3528 it('Can display the table as csv', function(done) {
3529 var headings = "path,address,public key,private key";
3530 var row1 = "m/44'/0'/0'/0/0,1Di3Vp7tBWtyQaDABLAjfWtF6V7hYKJtug,033f5aed5f6cfbafaf223188095b5980814897295f723815fea5d3f4b648d0d0b3,L26cVSpWFkJ6aQkPkKmTzLqTdLJ923e6CzrVh9cmx21QHsoUmrEE";
3531 var row20 = "m/44'/0'/0'/0/19,1KhBy28XLAciXnnRvm71PvQJaETyrxGV55,02b4b3e396434d8cdd20c03ac4aaa07387784d5d867b75987f516f5705ee68cb3a,L4GrDrjReMsCAu5DkLXn79jSb95qR7Zfx7eshybCQZ1qL32MXJab";
3532 driver.findElement(By.css('.phrase'))
3533 .sendKeys('abandon abandon ability');
3534 driver.sleep(generateDelay).then(function() {
3535 driver.findElement(By.css('.csv'))
3536 .getAttribute("value")
3537 .then(function(csv) {
3538 expect(csv).toContain(headings);
3539 expect(csv).toContain(row1);
3540 expect(csv).toContain(row20);
3541 done();
3542 });
3543 });
3544 });
3545
3546 it('LeftPads ethereum keys that are less than 32 bytes', function(done) {
3547 // see https://github.com/iancoleman/bip39/issues/155
3548 selectNetwork("ETH - Ethereum");
3549 driver.findElement(By.css('#bip32-tab a'))
3550 .click()
3551 driver.findElement(By.css('#bip32-path'))
3552 .clear();
3553 driver.findElement(By.css('#bip32-path'))
3554 .sendKeys("m/44'/60'/0'");
3555 driver.findElement(By.css('.phrase'))
3556 .sendKeys('scout sort custom elite radar rare vivid thing trophy gesture cover snake change narrow kite list nation sustain buffalo erode open balance system young');
3557 driver.sleep(generateDelay).then(function() {
3558 getFirstAddress(function(address) {
3559 expect(address).toBe("0x8943E785B4a5714FC87a3aFAad1eB1FeB602B118");
3560 done();
3561 });
3562 });
3563 });
3564
3565 it('Can encrypt private keys using BIP38', function(done) {
3566 // see https://github.com/iancoleman/bip39/issues/140
3567 driver.executeScript(function() {
3568 $(".use-bip38").prop("checked", true);
3569 });
3570 driver.findElement(By.css('.bip38-password'))
3571 .sendKeys('bip38password');
3572 driver.findElement(By.css('.rows-to-add'))
3573 .clear();
3574 driver.findElement(By.css('.rows-to-add'))
3575 .sendKeys('1');
3576 driver.findElement(By.css('.phrase'))
3577 .sendKeys('abandon abandon ability');
3578 driver.sleep(bip38delay).then(function() {
3579 // address
3580 getFirstRowValue(function(address) {
3581 expect(address).toBe("1NCvSdumA3ngMM9c4aqU56AM6rqXddfuXB");
3582 // pubkey
3583 getFirstRowValue(function(pubkey) {
3584 expect(pubkey).toBe("043f5aed5f6cfbafaf223188095b5980814897295f723815fea5d3f4b648d0d0b3884a74447ea901729b1e73a999b7520e7cb55b4120e6432c64153ccab8a848e1");
3585 // privkey
3586 getFirstRowValue(function(privkey) {
3587 expect(privkey).toBe("6PRNRiFnj1RoR3sXhymdCvoZCgnUHQpfupNdKkFbWJkwWQEKesWt1EDMDM");
3588 done();
3589 }, ".privkey");
3590 }, ".pubkey");
3591 }, ".address");
3592 });
3593 }, bip38delay + 5000);
3594
3595 it('Shows the checksum for the entropy', function(done) {
3596 driver.findElement(By.css('.use-entropy'))
3597 .click();
3598 driver.findElement(By.css('.entropy'))
3599 .sendKeys("00000000000000000000000000000000");
3600 driver.sleep(generateDelay).then(function() {
3601 driver.findElement(By.css('.checksum'))
3602 .getText()
3603 .then(function(text) {
3604 expect(text).toBe("1");
3605 done();
3606 });
3607 });
3608 });
3609
3610 it('Shows the checksum for the entropy with the correct groupings', function(done) {
3611 driver.findElement(By.css('.use-entropy'))
3612 .click();
3613 // create a checksum of 20 bits, which spans multiple words
3614 driver.findElement(By.css('.entropy'))
3615 .sendKeys("F000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000");
3616 driver.sleep(generateDelay).then(function() {
3617 driver.findElement(By.css('.checksum'))
3618 .getText()
3619 .then(function(text) {
3620 // first group is 9 bits, second group is 11
3621 expect(text).toBe("011010111 01110000110");
3622 done();
3623 });
3624 });
3625 });
3626
3627 it('Uses vprv for bitcoin testnet p2wpkh', function(done) {
3628 selectNetwork("BTC - Bitcoin Testnet");
3629 driver.findElement(By.css('#bip84-tab a'))
3630 .click()
3631 driver.findElement(By.css('.phrase'))
3632 .sendKeys('abandon abandon ability');
3633 driver.sleep(generateDelay).then(function() {
3634 driver.findElement(By.css('.root-key'))
3635 .getAttribute("value")
3636 .then(function(path) {
3637 expect(path).toBe("vprv9DMUxX4ShgxML9N2YV5CvWEebWrM9aJ5ULpbRRyzyWu6vs4BzTvbfFFrH41N5hVi7MYSfiugd765L3JmAfDM5po36Y8ouCKRDeYQwByCmS7");
3638 done();
3639 })
3640 });
3641 });
3642
3643 it('Shows a warning if generating weak mnemonics', function(done) {
3644 driver.executeScript(function() {
3645 $(".strength option[selected]").removeAttr("selected");
3646 $(".strength option[value=6]").prop("selected", true);
3647 $(".strength").trigger("change");
3648 });
3649 driver.findElement(By.css(".generate-container .warning"))
3650 .getAttribute("class")
3651 .then(function(classes) {
3652 expect(classes).not.toContain("hidden");
3653 done();
3654 });
3655 });
3656
3657 it('Does not show a warning if generating strong mnemonics', function(done) {
3658 driver.executeScript(function() {
3659 $(".strength option[selected]").removeAttr("selected");
3660 $(".strength option[value=12]").prop("selected", true);
3661 });
3662 driver.findElement(By.css(".generate-container .warning"))
3663 .getAttribute("class")
3664 .then(function(classes) {
3665 expect(classes).toContain("hidden");
3666 done();
3667 });
3668 });
3669
3670 it('Shows a warning if overriding weak entropy with longer mnemonics', function(done) {
3671 driver.findElement(By.css('.use-entropy'))
3672 .click();
3673 driver.findElement(By.css('.entropy'))
3674 .sendKeys("0123456789abcdef"); // 6 words
3675 driver.executeScript(function() {
3676 $(".mnemonic-length").val("12").trigger("change");
3677 });
3678 driver.findElement(By.css(".weak-entropy-override-warning"))
3679 .getAttribute("class")
3680 .then(function(classes) {
3681 expect(classes).not.toContain("hidden");
3682 done();
3683 });
3684 });
3685
3686 it('Does not show a warning if entropy is stronger than mnemonic length', function(done) {
3687 driver.findElement(By.css('.use-entropy'))
3688 .click();
3689 driver.findElement(By.css('.entropy'))
3690 .sendKeys("0123456789abcdef0123456789abcdef0123456789abcdef"); // 18 words
3691 driver.executeScript(function() {
3692 $(".mnemonic-length").val("12").trigger("change");
3693 });
3694 driver.findElement(By.css(".weak-entropy-override-warning"))
3695 .getAttribute("class")
3696 .then(function(classes) {
3697 expect(classes).toContain("hidden");
3698 done();
3699 });
3700 });
3701
3702 it('Shows a warning for litecoin BIP84 (which does not have p2wpkh params)', function(done) {
3703 driver.findElement(By.css('.phrase'))
3704 .sendKeys('abandon abandon ability');
3705 selectNetwork("LTC - Litecoin");
3706 driver.findElement(By.css('#bip84-tab a'))
3707 .click()
3708 // bip84 unavailable is shown
3709 driver.sleep(feedbackDelay).then(function() {
3710 driver.findElement(By.css('#bip84 .unavailable'))
3711 .getAttribute("class")
3712 .then(function(classes) {
3713 expect(classes).not.toContain("hidden");
3714 done();
3715 });
3716 });
3717 });
3718
3719 it('Shows litecoin BIP49 addresses', function(done) {
3720 driver.findElement(By.css('.phrase'))
3721 .sendKeys('abandon abandon ability');
3722 selectNetwork("LTC - Litecoin");
3723 driver.findElement(By.css('#bip49-tab a'))
3724 .click()
3725 // bip49 addresses are shown
3726 driver.sleep(generateDelay).then(function() {
3727 driver.findElement(By.css('#bip49 .available'))
3728 .getAttribute("class")
3729 .then(function(classes) {
3730 expect(classes).not.toContain("hidden");
3731 // check first address
3732 getFirstAddress(function(address) {
3733 expect(address).toBe("MFwLPhsXoBuSLL8cLmW9uK6tChkzduV8qN");
3734 done();
3735 });
3736 });
3737 });
3738 });
3739
3740 it('Can use root keys to generate segwit table rows', function(done) {
3741 // segwit uses ypub / zpub instead of xpub but the root key should still
3742 // be valid regardless of the encoding used to import that key.
3743 // Maybe this breaks the reason for the different extended key prefixes, but
3744 // since the parsed root key is used behind the scenes anyhow this should be
3745 // allowed.
3746 driver.findElement(By.css('#root-key'))
3747 .sendKeys('xprv9s21ZrQH143K2jkGDCeTLgRewT9F2pH5JZs2zDmmjXes34geVnFiuNa8KTvY5WoYvdn4Ag6oYRoB6cXtc43NgJAEqDXf51xPm6fhiMCKwpi');
3748 driver.findElement(By.css('#bip49-tab a'))
3749 .click()
3750 // bip49 addresses are shown
3751 driver.sleep(generateDelay).then(function() {
3752 getFirstAddress(function(address) {
3753 expect(address).toBe("3QG2Y9AA4xZ846gKHZqNf7mvVKbLqMKxr2");
3754 done();
3755 });
3756 });
3757 });
3758
3759 });