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