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