528f562eb0989233c42504b9277fe9600819afb5
[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 Crave', function(done) {
833 var params = {
834 selectText: "CRAVE - Crave",
835 firstAddress: "VCYJeti6uKMNBFKCL7eP96UwuFWYHM7c85",
836 };
837 testNetwork(done, params);
838 });
839 it('Allows selection of Defcoin', function(done) {
840 var params = {
841 selectText: "DFC - Defcoin",
842 firstAddress: "D8swcgyaaFUrXZU3ATwbgy16buCpWqbG1M",
843 };
844 testNetwork(done, params);
845 });
846 it('Allows selection of Diamond', function(done) {
847 var params = {
848 selectText: "DMD - Diamond",
849 firstAddress: "dJnrVbLL9UPjdaVRz2C8VpqHZknqAqjLek",
850 };
851 testNetwork(done, params);
852 });
853 it('Allows selection of Digibyte', function(done) {
854 var params = {
855 selectText: "DGB - Digibyte",
856 firstAddress: "D85Rp9jwLtMdmP6wGjTiqHBdVQLST3YCEq",
857 };
858 testNetwork(done, params);
859 });
860 it('Allows selection of Digitalcoin', function(done) {
861 var params = {
862 selectText: "DGC - Digitalcoin",
863 firstAddress: "DKw4UGKEAZWweDNEbBFNQx4EM8x1mpUdia",
864 };
865 testNetwork(done, params);
866 });
867 it('Allows selection of Ecoin', function(done) {
868 var params = {
869 selectText: "ECN - Ecoin",
870 firstAddress: "e6WFPLG5gcXyF7cESFteH1hE2XSmowW5yB",
871 };
872 testNetwork(done, params);
873 });
874 it('Allows selection of Edrcoin', function(done) {
875 var params = {
876 selectText: "EDRC - Edrcoin",
877 firstAddress: "eh1nUJsvgKPFv6ebMBfcwJ299GMCpjeZUG",
878 };
879 testNetwork(done, params);
880 });
881 it('Allows selection of Egulden', function(done) {
882 var params = {
883 selectText: "EFL - Egulden",
884 firstAddress: "Lg66yt55R7edRM58cDhKzXik2kFme3viX7",
885 };
886 testNetwork(done, params);
887 });
888 it('Allows selection of Einsteinium', function(done) {
889 var params = {
890 selectText: "EMC2 - Einsteinium",
891 firstAddress: "EVAABm9hXKHk2MpVMbwNakRubFnNha5m8m",
892 };
893 testNetwork(done, params);
894 });
895 it('Allows selection of EOSIO', function(done) {
896 var params = {
897 selectText: "EOS - EOSIO",
898 firstPubKey: "EOS692VJTBK3Rmw93onNnpnZ8ZtmE9PdxjDStArvbyzoe11QUTNoy",
899 };
900 testNetwork(done, params, true);
901 });
902 it('Allows selection of Europecoin', function(done) {
903 var params = {
904 selectText: "ERC - Europecoin",
905 firstAddress: "ESA2YwPYntAoaPrE8Fm5qkKRtkcwLcwD6R",
906 };
907 testNetwork(done, params);
908 });
909 it('Allows selection of Exclusivecoin', function(done) {
910 var params = {
911 selectText: "EXCL - Exclusivecoin",
912 firstAddress: "EbUa6m8UZW6nTxsYZD2FsDjkadKbp5M6JT",
913 };
914 testNetwork(done, params);
915 });
916 it('Allows selection of Feathercoin', function(done) {
917 var params = {
918 selectText: "FTC - Feathercoin",
919 firstAddress: "6gDdjAMoSgQaW8UhqK3oboHs6ftGAroKkM",
920 };
921 testNetwork(done, params);
922 });
923 it('Allows selection of Firstcoin', function(done) {
924 var params = {
925 selectText: "FRST - Firstcoin",
926 firstAddress: "FJN9GzfMm7Q8R4DJwK1H9F6A1GTghvFiMJ",
927 };
928 testNetwork(done, params);
929 });
930 it('Allows selection of Flashcoin', function(done) {
931 var params = {
932 selectText: "FLASH - Flashcoin",
933 firstAddress: "UWfpf5LfMmLxZYooEb2EyvWhZ8NG7EZDRt",
934 };
935 testNetwork(done, params);
936 });
937 it('Allows selection of GCRCoin', function(done) {
938 var params = {
939 selectText: "GCR - GCRCoin",
940 firstAddress: "GJjF5cLwyXLacpuvXAVksxGxKvHDjx58d6",
941 };
942 testNetwork(done, params);
943 });
944 it('Allows selection of Gobyte', function(done) {
945 var params = {
946 selectText: "GBX - Gobyte",
947 firstAddress: "GS813Ys2brkmvSUw1rUqGPm2HqQVDHJRyA",
948 };
949 testNetwork(done, params);
950 });
951 it('Allows selection of Gridcoin', function(done) {
952 var params = {
953 selectText: "GRC - Gridcoin",
954 firstAddress: "SGrWbBPvobgqKRF8td1Kdc9vbRY7MJ78Y9",
955 };
956 testNetwork(done, params);
957 });
958 it('Allows selection of Gulden', function(done) {
959 var params = {
960 selectText: "NLG - Gulden",
961 firstAddress: "GcDP7cNEc33MPPdTFNJ8pZc6VMZJ2CbKxY",
962 };
963 testNetwork(done, params);
964 });
965 it('Allows selection of Helleniccoin', function(done) {
966 var params = {
967 selectText: "HNC - Helleniccoin",
968 firstAddress: "LbHEKe5H72zp9G1fuWNiiNePTUfJb88915",
969 };
970 testNetwork(done, params);
971 });
972 it('Allows selection of Hempcoin', function(done) {
973 var params = {
974 selectText: "THC - Hempcoin",
975 firstAddress: "H8sdWbZyJV4gyXyHtLXDaNnAuUDhK5mfTV",
976 };
977 testNetwork(done, params);
978 });
979 it('Allows selection of Insane', function(done) {
980 var params = {
981 selectText: "INSN - Insane",
982 firstAddress: "iMPqEJMiXWuxC9U2NVinCCMr4t72h58EWx",
983 };
984 testNetwork(done, params);
985 });
986 it('Allows selection of Iop', function(done) {
987 var params = {
988 selectText: "IOP - Iop",
989 firstAddress: "pGKQmcaPf95Ur5o6oHK4qdiZ52p1yaTvq1",
990 };
991 testNetwork(done, params);
992 });
993 it('Allows selection of Ixcoin', function(done) {
994 var params = {
995 selectText: "IXC - Ixcoin",
996 firstAddress: "xgE9bTZ6YypT3E6ByzkTt31Hq68E9BqywH",
997 };
998 testNetwork(done, params);
999 });
1000 it('Allows selection of Kobocoin', function(done) {
1001 var params = {
1002 selectText: "KOBO - Kobocoin",
1003 firstAddress: "FTVoNJETXDAM8x7MnmdE8RwWndSr9PQWhy",
1004 };
1005 testNetwork(done, params);
1006 });
1007 it('Allows selection of Landcoin', function(done) {
1008 var params = {
1009 selectText: "LDCN - Landcoin",
1010 firstAddress: "LLvLwNjG1aJcn1RS4W4GJUbv8fNaRATG7c",
1011 };
1012 testNetwork(done, params);
1013 });
1014 it('Allows selection of Library Credits', function(done) {
1015 var params = {
1016 selectText: "LBC - Library Credits",
1017 firstAddress: "bQJEQrHDJyHdqycB32uysh1SWn8Ln8LMdg",
1018 };
1019 testNetwork(done, params);
1020 });
1021 it('Allows selection of Linx', function(done) {
1022 var params = {
1023 selectText: "LINX - Linx",
1024 firstAddress: "XGWQ3cb3LGUB3VnHmj6xYSMgnokNbf6dyk",
1025 };
1026 testNetwork(done, params);
1027 });
1028 it('Allows selection of Litecoincash', function(done) {
1029 var params = {
1030 selectText: "LCC - Litecoincash",
1031 firstAddress: "Ce5n7fjUuQPLutJ4W5nCCfQLKdKLE1mv9A",
1032 };
1033 testNetwork(done, params);
1034 });
1035 it('Allows selection of Lynx', function(done) {
1036 var params = {
1037 selectText: "LYNX - Lynx",
1038 firstAddress: "KUeY3ZdZkg96p4W98pj1JjygCFU1XqWdw3",
1039 };
1040 testNetwork(done, params);
1041 });
1042 it('Allows selection of Megacoin', function(done) {
1043 var params = {
1044 selectText: "MEC - Megacoin",
1045 firstAddress: "MDfAj9CzkC1HpcUiVGnHp8yKTa7WXgu8AY",
1046 };
1047 testNetwork(done, params);
1048 });
1049 it('Allows selection of Minexcoin', function(done) {
1050 var params = {
1051 selectText: "MNX - Minexcoin",
1052 firstAddress: "XC1VnyJVfiMDwWgFtAHDp41cgY3AHk3dJT",
1053 };
1054 testNetwork(done, params);
1055 });
1056 it('Allows selection of Navcoin', function(done) {
1057 var params = {
1058 selectText: "NAV - Navcoin",
1059 firstAddress: "NTQVTPK3NWSQLKoffkiQw99T8PifkF1Y2U",
1060 };
1061 testNetwork(done, params);
1062 });
1063 it('Allows selection of Nebulas', function(done) {
1064 var params = {
1065 selectText: "NAS - Nebulas",
1066 firstAddress: "n1PbK61DGBfDoDusLw621G6sVSMfLLHdfnm",
1067 };
1068 testNetwork(done, params);
1069 });
1070 it('Allows selection of Neoscoin', function(done) {
1071 var params = {
1072 selectText: "NEOS - Neoscoin",
1073 firstAddress: "NgATz6QbQNXvayHQ4CpZayugb9HeaPDdby",
1074 };
1075 testNetwork(done, params);
1076 });
1077 it('Allows selection of Nix', function(done) {
1078 var params = {
1079 selectText: "NIX - NIX Platform",
1080 firstAddress: "GgcNW2SQQXB4LWHRQTHKkQF3GzXNSLqS8u",
1081 };
1082 testNetwork(done, params);
1083 });
1084 it('Allows selection of Neurocoin', function(done) {
1085 var params = {
1086 selectText: "NRO - Neurocoin",
1087 firstAddress: "NVdYErQ3mFpDuF5DquW9WMiT7sLc8ufFTn",
1088 };
1089 testNetwork(done, params);
1090 });
1091 it('Allows selection of Newyorkc', function(done) {
1092 var params = {
1093 selectText: "NYC - Newyorkc",
1094 firstAddress: "RSVMfyH1fKfy3puADJEhut2vfkRyon6imm",
1095 };
1096 testNetwork(done, params);
1097 });
1098 it('Allows selection of Novacoin', function(done) {
1099 var params = {
1100 selectText: "NVC - Novacoin",
1101 firstAddress: "4JRvUmxcKCJmaMXZyvRoSS1cmG2XvnZfHN",
1102 };
1103 testNetwork(done, params);
1104 });
1105 it('Allows selection of Nushares', function(done) {
1106 var params = {
1107 selectText: "NSR - Nushares",
1108 firstAddress: "SecjXzU3c7EecdT7EbC4vvmbdtBBokWh6J",
1109 };
1110 testNetwork(done, params);
1111 });
1112 it('Allows selection of Okcash', function(done) {
1113 var params = {
1114 selectText: "OK - Okcash",
1115 firstAddress: "PV4Qp1TUYuGv4TqVtLZtqvrsWWRycfx1Yi",
1116 };
1117 testNetwork(done, params);
1118 });
1119 it('Allows selection of Omnicore', function(done) {
1120 var params = {
1121 selectText: "OMNI - Omnicore",
1122 firstAddress: "1Q1t3gonjCT3rW38TsTsCvgSc3hh7zBGbi",
1123 };
1124 testNetwork(done, params);
1125 });
1126 it('Allows selection of DeepOnion', function(done) {
1127 var params = {
1128 selectText: "ONION - DeepOnion",
1129 firstAddress: "DYREY7XCFXVqJ3x5UuN43k2JwD2s1kif48",
1130 };
1131 testNetwork(done, params);
1132 });
1133 it('Allows selection of Pesobit', function(done) {
1134 var params = {
1135 selectText: "PSB - Pesobit",
1136 firstAddress: "PDePsF7ALyXP7JaywokdYiRTDtKa14MAr1",
1137 };
1138 testNetwork(done, params);
1139 });
1140 it('Allows selection of Pinkcoin', function(done) {
1141 var params = {
1142 selectText: "PINK - Pinkcoin",
1143 firstAddress: "2TgjYQffjbzUHJghNaVbdsjHbRwruC3yzC",
1144 };
1145 testNetwork(done, params);
1146 });
1147 it('Allows selection of POSWcoin', function(done) {
1148 var params = {
1149 selectText: "POSW - POSWcoin",
1150 firstAddress: "PNxewmZoPnGBvoEbH6hgQZCK1igDiBCdgC",
1151 };
1152 testNetwork(done, params);
1153 });
1154 it('Allows selection of Potcoin', function(done) {
1155 var params = {
1156 selectText: "POT - Potcoin",
1157 firstAddress: "PEo7Vg2ctXgpP4vuLPeY9aGJtZotyrmiHc",
1158 };
1159 testNetwork(done, params);
1160 });
1161 it('Allows selection of Putincoin', function(done) {
1162 var params = {
1163 selectText: "PUT - Putincoin",
1164 firstAddress: "PViWnfr2uFtovd6e7joM49C94CsGSnqJis",
1165 };
1166 testNetwork(done, params);
1167 });
1168 it('Allows selection of Ravencoin', function(done) {
1169 var params = {
1170 selectText: "RVN - Ravencoin",
1171 firstAddress: "RBuDoVNnzvFsEcX8XKPm8ic4mgiCzjUCNk",
1172 };
1173 testNetwork(done, params);
1174 });
1175 it('Allows selection of Reddcoin', function(done) {
1176 var params = {
1177 selectText: "RDD - Reddcoin",
1178 firstAddress: "RtgRvXMBng1y51ftteveFqwNfyRG18HpxQ",
1179 };
1180 testNetwork(done, params);
1181 });
1182 it('Allows selection of RevolutionVR', function(done) {
1183 var params = {
1184 selectText: "RVR - RevolutionVR",
1185 firstAddress: "VXeeoP2jkzZnMFxtc66ZBZK1NHN5QJnnjL",
1186 };
1187 testNetwork(done, params);
1188 });
1189 it('Allows selection of Rubycoin', function(done) {
1190 var params = {
1191 selectText: "RBY - Rubycoin",
1192 firstAddress: "RV76JDtjTs11JdMDRToYn6CHecMRPLnKS6",
1193 };
1194 testNetwork(done, params);
1195 });
1196 it('Allows selection of Salus', function(done) {
1197 var params = {
1198 selectText: "SLS - Salus",
1199 firstAddress: "SNzPi1CafHFm3WWjRo43aMgiaEEj3ogjww",
1200 };
1201 testNetwork(done, params);
1202 });
1203 it('Allows selection of Smileycoin', function(done) {
1204 var params = {
1205 selectText: "SMLY - Smileycoin",
1206 firstAddress: "BEZVnEBCAyFByrgKpwAgYgtvP4rKAd9Sj2",
1207 };
1208 testNetwork(done, params);
1209 });
1210 it('Allows selection of Solarcoin', function(done) {
1211 var params = {
1212 selectText: "SLR - Solarcoin",
1213 firstAddress: "8LZ13HbnjtaMJWSvvVFNTLf71zFfDrhwLu",
1214 };
1215 testNetwork(done, params);
1216 });
1217 it('Allows selection of stash', function(done) {
1218 var params = {
1219 selectText: "STASH - Stash",
1220 firstAddress: "XxwAsWB7REDKmAvHA85SbEZQQtpxeUDxS3",
1221 };
1222 testNetwork(done, params);
1223 });
1224 it('Allows selection of stash testnet', function(done) {
1225 var params = {
1226 selectText: "STASH - Stash Testnet",
1227 firstAddress: "yWQCTSkUst7ddYuebKsqa1kSoXEjpCkGKR",
1228 };
1229 testNetwork(done, params);
1230 });
1231 it('Allows selection of Stratis', function(done) {
1232 var params = {
1233 selectText: "STRAT - Stratis",
1234 firstAddress: "ScfJnq3QDhKgDMEds6sqUE1ot6ShfhmXXq",
1235 };
1236 testNetwork(done, params);
1237 });
1238 it('Allows selection of Stratis Test', function(done) {
1239 var params = {
1240 selectText: "TSTRAT - Stratis Testnet",
1241 firstAddress: "TRLWm3dye4FRrDWouwYUSUZP96xb76mBE3",
1242 };
1243 testNetwork(done, params);
1244 });
1245 it('Allows selection of Syscoin', function(done) {
1246 var params = {
1247 selectText: "SYS - Syscoin",
1248 firstAddress: "SZwJi42Pst3VAMomyK5DG4157WM5ofRmSj",
1249 };
1250 testNetwork(done, params);
1251 });
1252 it('Allows selection of Toa', function(done) {
1253 var params = {
1254 selectText: "TOA - Toa",
1255 firstAddress: "TSe1QAnUwQzUfbBusDzRJ9URttrRGKoNKF",
1256 };
1257 testNetwork(done, params);
1258 });
1259 it('Allows selection of TWINS', function(done) {
1260 var params = {
1261 selectText: "TWINS - TWINS",
1262 firstAddress: "WPpJnfLLubNmF7HLNxg8d8zH5haxn4wri8",
1263 };
1264 testNetwork(done, params);
1265 });
1266 it('Allows selection of TWINS testnet', function(done) {
1267 var params = {
1268 selectText: "TWINS - TWINS Testnet",
1269 firstAddress: "XpnU1HHdNG5YxvG9Rez4wjmidchxqnZaNa",
1270 };
1271 testNetwork(done, params);
1272 });
1273 it('Allows selection of Ultimatesecurecash', function(done) {
1274 var params = {
1275 selectText: "USC - Ultimatesecurecash",
1276 firstAddress: "UPyLAZU2Che5fiy7Ed8xVJFmXAUhitA4ug",
1277 };
1278 testNetwork(done, params);
1279 });
1280 it('Allows selection of Unobtanium', function(done) {
1281 var params = {
1282 selectText: "UNO - Unobtanium",
1283 firstAddress: "uUBMPVMXrR6qhqornJqKTWgr8L69vihSL9",
1284 };
1285 testNetwork(done, params);
1286 });
1287 it('Allows selection of Vcash', function(done) {
1288 var params = {
1289 selectText: "XVC - Vcash",
1290 firstAddress: "VuL53MSY6KjvAjKSeRkh3NDnKykacDVeps",
1291 };
1292 testNetwork(done, params);
1293 });
1294 it('Allows selection of Verge', function(done) {
1295 var params = {
1296 selectText: "XVG - Verge",
1297 firstAddress: "DCrVuGkMjLJpTGgwAgv9AcMdeb1nkWbjZA",
1298 };
1299 testNetwork(done, params);
1300 });
1301 it('Allows selection of Vertcoin', function(done) {
1302 var params = {
1303 selectText: "VTC - Vertcoin",
1304 firstAddress: "Vf6koGuiWdXQfx8tNqxoNeEDxh4xh5cxsG",
1305 };
1306 testNetwork(done, params);
1307 });
1308 it('Allows selection of Vivo', function(done) {
1309 var params = {
1310 selectText: "VIVO - Vivo",
1311 firstAddress: "VFmBwuXXGhJe7MarQG2GfzHMFebRHgfSpB",
1312 };
1313 testNetwork(done, params);
1314 });
1315 it('Allows selection of Vpncoin', function(done) {
1316 var params = {
1317 selectText: "VASH - Vpncoin",
1318 firstAddress: "VoEmH1qXC4TsSgBAStR21QYetwnFqbqCx9",
1319 };
1320 testNetwork(done, params);
1321 });
1322 it('Allows selection of Whitecoin', function(done) {
1323 var params = {
1324 selectText: "XWC - Whitecoin",
1325 firstAddress: "WcSwCAUqrSgeSYbsaS3SSWWhsx8KRYTFDR",
1326 };
1327 testNetwork(done, params);
1328 });
1329 it('Allows selection of Wincoin', function(done) {
1330 var params = {
1331 selectText: "WC - Wincoin",
1332 firstAddress: "WaDVCESMGgyKgNESdn3u43NnwmGSkZED3Z",
1333 };
1334 testNetwork(done, params);
1335 });
1336 it('Allows selection of Zcoin', function(done) {
1337 var params = {
1338 selectText: "XZC - Zcoin",
1339 firstAddress: "a6VcMdP4XgAA9Tr7xNszmPG5FZpfRf17Cq",
1340 };
1341 testNetwork(done, params);
1342 });
1343 it('Allows selection of Zcash', function(done) {
1344 var params = {
1345 selectText: "ZEC - Zcash",
1346 firstAddress: "t1Sz8AneMcVuzUg3tPJ8et5AS5LFJ7K2EF9",
1347 };
1348 testNetwork(done, params);
1349 });
1350 it('Allows selection of Zclassic', function(done) {
1351 var params = {
1352 selectText: "ZCL - Zclassic",
1353 firstAddress: "t1TBMxTvVJRybUbMLGWq8H4A8F4VUL7czEc",
1354 };
1355 testNetwork(done, params);
1356 });
1357 it('Allows selection of Zencash', function(done) {
1358 var params = {
1359 selectText: "ZEN - Zencash",
1360 firstAddress: "znWh9XASyW2dZq5tck84wFjiwuqVysi7q3p",
1361 };
1362 testNetwork(done, params);
1363 });
1364 it('Allows selection of Energi', function(done) {
1365 var params = {
1366 selectText: "NRG - Energi",
1367 firstAddress: "EejRy4t4nidzhGGzkJUgFP3z4HYBjhTsRt",
1368 };
1369 testNetwork(done, params);
1370 });
1371 it('Allows selection of Ethereum Classic', function(done) {
1372 var params = {
1373 selectText: "ETC - Ethereum Classic",
1374 firstAddress: "0x3c05e5556693808367afB62eF3b63e35d6eD249A",
1375 };
1376 testNetwork(done, params);
1377 });
1378 it('Allows selection of Pirl', function(done) {
1379 var params = {
1380 selectText: "PIRL - Pirl",
1381 firstAddress: "0xe77FC0723dA122B5025CA79193c28563eB47e776",
1382 };
1383 testNetwork(done, params);
1384 });
1385 it('Allows selection of MIX', function(done) {
1386 var params = {
1387 selectText: "MIX - MIX",
1388 firstAddress: "0x98BC5e63aeb6A4e82d72850d20710F07E29A29F1",
1389 };
1390 testNetwork(done, params);
1391 });
1392 it('Allows selection of Musicoin', function(done) {
1393 var params = {
1394 selectText: "MUSIC - Musicoin",
1395 firstAddress: "0xDc060e4A0b0313ea83Cf6B3A39B9db2D29004897",
1396 };
1397 testNetwork(done, params);
1398 });
1399 it('Allows selection of Poa', function(done) {
1400 var params = {
1401 selectText: "POA - Poa",
1402 firstAddress: "0x53aF28d754e106210C3d0467Dd581eaf7e3C5e60",
1403 };
1404 testNetwork(done, params);
1405 });
1406 it('Allows selection of Expanse', function(done) {
1407 var params = {
1408 selectText: "EXP - Expanse",
1409 firstAddress: "0xf57FeAbf26582b6E3E666559d3B1Cc6fB2b2c5F6",
1410 };
1411 testNetwork(done, params);
1412 });
1413 it('Allows selection of Callisto', function(done) {
1414 var params = {
1415 selectText: "CLO - Callisto",
1416 firstAddress: "0x4f9364F7420B317266C51Dc8eB979717D4dE3f4E",
1417 };
1418 testNetwork(done, params);
1419 });
1420 it('Allows selection of HUSH', function(done) {
1421 var params = {
1422 selectText: "HUSH - Hush",
1423 firstAddress: "t1g6rLXUnJaiJuu4q4zmJjoa9Gk4fwKpiuA",
1424 };
1425 testNetwork(done, params);
1426 });
1427 it('Allows selection of ExchangeCoin', function(done) {
1428 var params = {
1429 selectText: "EXCC - ExchangeCoin",
1430 firstAddress: "22txYKpFN5fwGwdSs2UBf7ywewbLM92YqK7E",
1431 };
1432 testNetwork(done, params);
1433 });
1434 it('Allows selection of Artax', function(done) {
1435 var params = {
1436 selectText: "XAX - Artax",
1437 firstAddress: "AYxaQPY7XLidG31V7F3yNzwxPYpYzRqG4q",
1438 };
1439 testNetwork(done, params);
1440 });
1441 it('Allows selection of BitcoinGreen', function(done) {
1442 var params = {
1443 selectText: "BITG - Bitcoin Green",
1444 firstAddress: "GeNGm9SkEfwbsws3UrrUSE2sJeyWYjzraY",
1445 };
1446 testNetwork(done, params);
1447 });
1448 it('Allows selection of ANON', function(done) {
1449 var params = {
1450 selectText: "ANON - ANON",
1451 firstAddress: "AnU6pijpEeUZFWSTyM2qTqZQn996Zq1Xard",
1452 };
1453 testNetwork(done, params);
1454 });
1455 it('Allows selection of ProjectCoin', function(done) {
1456 var params = {
1457 selectText: "PRJ - ProjectCoin",
1458 firstAddress: "PXZG97saRseSCftfe1mcFmfAA7pf6qBbaz",
1459 };
1460 testNetwork(done, params);
1461 });
1462 it('Allows selection of Phore', function(done) {
1463 var params = {
1464 selectText: "PHR - Phore",
1465 firstAddress: "PJThxpoXAG6hqrmdeQQbVDX4TJtFTMMymC",
1466 };
1467 testNetwork(done, params);
1468 });
1469 it('Allows selection of Safecoin', function(done) {
1470 var params = {
1471 selectText: "SAFE - Safecoin",
1472 firstAddress: "RtxHpnhJz6RY8k9owP3ua5QWraunmewB1G",
1473 };
1474 testNetwork(done, params);
1475 });
1476 it('Allows selection of Blocknode', function(done) {
1477 var params = {
1478 selectText: "BND - Blocknode",
1479 firstAddress: "BG8xZSAur2jYLG9VXt8dYfkKxxeR7w9bSe",
1480 };
1481 testNetwork(done, params);
1482 });
1483 it('Allows selection of Blocknode Testnet', function(done) {
1484 var params = {
1485 selectText: "tBND - Blocknode Testnet",
1486 firstAddress: "bSptsFyDktFSKpWveRywJsDoJA2TC6qfHv",
1487 };
1488 testNetwork(done, params);
1489 });
1490 it('Allows selection of LitecoinZ', function(done) {
1491 var params = {
1492 selectText: "LTZ - LitecoinZ",
1493 firstAddress: "L1VTXju7hLgKV4T7fGXS9sKsnm2gmtRCmyw",
1494 };
1495 testNetwork(done, params);
1496 });
1497 it('Allows selection of BlockStamp', function(done) {
1498 var params = {
1499 selectText: "BST - BlockStamp",
1500 firstAddress: "15gypKtim4cVTj137ApfryG17RkvSbPazZ",
1501 };
1502 testNetwork(done, params);
1503 });
1504 it('Allows selection of DEXON', function(done) {
1505 var params = {
1506 selectText: "DXN - DEXON",
1507 firstAddress: "0x136a58788033E028CCd740FbDec6734358DB56Ec",
1508 };
1509 testNetwork(done, params);
1510 });
1511 it('Allows selection of Ellaism', function(done) {
1512 var params = {
1513 selectText: "ELLA - Ellaism",
1514 firstAddress: "0xa8B0BeA09eeBc41062308546a01d6E544277e2Ca",
1515 };
1516 testNetwork(done, params);
1517 });
1518 it('Allows selection of Ethersocial Network', function(done) {
1519 var params = {
1520 selectText: "ESN - Ethersocial Network",
1521 firstAddress: "0x6EE99Be2A0C7F887a71e21C8608ACF0aa0D2b767",
1522 };
1523 testNetwork(done, params);
1524 });
1525 it('Allows selection of Monkey Project', function(done) {
1526 var params = {
1527 selectText: "MONK - Monkey Project",
1528 firstAddress: "MnLrcnnUzKnf7TzufjRe5DLZqQJz18oYyu",
1529 };
1530 testNetwork(done, params);
1531 });
1532 it('Allows selection of Stellar', function(done) {
1533 var params = {
1534 selectText: "XLM - Stellar",
1535 firstAddress: "GCUK3NYYUXA2QGN6KU5RR36WAKN3Y5EANZV65XNAWN4XM4CHQ3G4DMO2",
1536 };
1537 testNetwork(done, params);
1538 });
1539
1540 // BIP39 seed is set from phrase
1541 it('Sets the bip39 seed from the prhase', function(done) {
1542 driver.findElement(By.css('.phrase'))
1543 .sendKeys('abandon abandon ability');
1544 driver.sleep(generateDelay).then(function() {
1545 driver.findElement(By.css('.seed'))
1546 .getAttribute("value")
1547 .then(function(seed) {
1548 expect(seed).toBe("20da140d3dd1df8713cefcc4d54ce0e445b4151027a1ab567b832f6da5fcc5afc1c3a3f199ab78b8e0ab4652efd7f414ac2c9a3b81bceb879a70f377aa0a58f3");
1549 done();
1550 })
1551 });
1552 });
1553
1554 // BIP32 root key is set from phrase
1555 it('Sets the bip39 root key from the prhase', function(done) {
1556 driver.findElement(By.css('.phrase'))
1557 .sendKeys('abandon abandon ability');
1558 driver.sleep(generateDelay).then(function() {
1559 driver.findElement(By.css('.root-key'))
1560 .getAttribute("value")
1561 .then(function(seed) {
1562 expect(seed).toBe("xprv9s21ZrQH143K2jkGDCeTLgRewT9F2pH5JZs2zDmmjXes34geVnFiuNa8KTvY5WoYvdn4Ag6oYRoB6cXtc43NgJAEqDXf51xPm6fhiMCKwpi");
1563 done();
1564 })
1565 });
1566 });
1567
1568 // Tabs show correct addresses when changed
1569 it('Shows the correct address when tab is changed', function(done) {
1570 driver.findElement(By.css('.phrase'))
1571 .sendKeys('abandon abandon ability');
1572 driver.sleep(generateDelay).then(function() {
1573 driver.findElement(By.css('#bip32-tab a'))
1574 .click();
1575 driver.sleep(generateDelay).then(function() {
1576 getFirstAddress(function(address) {
1577 expect(address).toBe("17uQ7s2izWPwBmEVFikTmZUjbBKWYdJchz");
1578 done();
1579 });
1580 });
1581 });
1582 });
1583
1584 // BIP44 derivation path is shown
1585 it('Shows the derivation path for bip44 tab', function(done) {
1586 driver.findElement(By.css('.phrase'))
1587 .sendKeys('abandon abandon ability');
1588 driver.sleep(generateDelay).then(function() {
1589 driver.findElement(By.css('#bip44 .path'))
1590 .getAttribute("value")
1591 .then(function(path) {
1592 expect(path).toBe("m/44'/0'/0'/0");
1593 done();
1594 })
1595 });
1596 });
1597
1598 // BIP44 extended private key is shown
1599 it('Shows the extended private key for bip44 tab', function(done) {
1600 driver.findElement(By.css('.phrase'))
1601 .sendKeys('abandon abandon ability');
1602 driver.sleep(generateDelay).then(function() {
1603 driver.findElement(By.css('.extended-priv-key'))
1604 .getAttribute("value")
1605 .then(function(path) {
1606 expect(path).toBe("xprvA2DxxvPZcyRvYgZMGS53nadR32mVDeCyqQYyFhrCVbJNjPoxMeVf7QT5g7mQASbTf9Kp4cryvcXnu2qurjWKcrdsr91jXymdCDNxKgLFKJG");
1607 done();
1608 })
1609 });
1610 });
1611
1612 // BIP44 extended public key is shown
1613 it('Shows the extended public key for bip44 tab', function(done) {
1614 driver.findElement(By.css('.phrase'))
1615 .sendKeys('abandon abandon ability');
1616 driver.sleep(generateDelay).then(function() {
1617 driver.findElement(By.css('.extended-pub-key'))
1618 .getAttribute("value")
1619 .then(function(path) {
1620 expect(path).toBe("xpub6FDKNRvTTLzDmAdpNTc49ia9b4byd6vqCdUa46Fp3vqMcC96uBoufCmZXQLiN5AK3iSCJMhf9gT2sxkpyaPepRuA7W3MujV5tGmF5VfbueM");
1621 done();
1622 })
1623 });
1624 });
1625
1626 // BIP44 account field changes address list
1627 it('Changes the address list if bip44 account is changed', function(done) {
1628 driver.findElement(By.css('#bip44 .account'))
1629 .sendKeys('1');
1630 driver.findElement(By.css('.phrase'))
1631 .sendKeys('abandon abandon ability');
1632 driver.sleep(generateDelay).then(function() {
1633 getFirstAddress(function(address) {
1634 expect(address).toBe("1Nq2Wmu726XHCuGhctEtGmhxo3wzk5wZ1H");
1635 done();
1636 });
1637 });
1638 });
1639
1640 // BIP44 change field changes address list
1641 it('Changes the address list if bip44 change is changed', function(done) {
1642 driver.findElement(By.css('#bip44 .change'))
1643 .sendKeys('1');
1644 driver.findElement(By.css('.phrase'))
1645 .sendKeys('abandon abandon ability');
1646 driver.sleep(generateDelay).then(function() {
1647 getFirstAddress(function(address) {
1648 expect(address).toBe("1KAGfWgqfVbSSXY56fNQ7YnhyKuoskHtYo");
1649 done();
1650 });
1651 });
1652 });
1653
1654 // BIP32 derivation path can be set
1655 it('Can use a custom bip32 derivation path', function(done) {
1656 driver.findElement(By.css('#bip32-tab a'))
1657 .click();
1658 driver.findElement(By.css('#bip32 .path'))
1659 .clear();
1660 driver.findElement(By.css('#bip32 .path'))
1661 .sendKeys('m/1');
1662 driver.findElement(By.css('.phrase'))
1663 .sendKeys('abandon abandon ability');
1664 driver.sleep(generateDelay).then(function() {
1665 getFirstAddress(function(address) {
1666 expect(address).toBe("16pYQQdLD1hH4hwTGLXBaZ9Teboi1AGL8L");
1667 done();
1668 });
1669 });
1670 });
1671
1672 // BIP32 can use hardened derivation paths
1673 it('Can use a hardened derivation paths', function(done) {
1674 driver.findElement(By.css('#bip32-tab a'))
1675 .click();
1676 driver.findElement(By.css('#bip32 .path'))
1677 .clear();
1678 driver.findElement(By.css('#bip32 .path'))
1679 .sendKeys("m/0'");
1680 driver.findElement(By.css('.phrase'))
1681 .sendKeys('abandon abandon ability');
1682 driver.sleep(generateDelay).then(function() {
1683 getFirstAddress(function(address) {
1684 expect(address).toBe("14aXZeprXAE3UUKQc4ihvwBvww2LuEoHo4");
1685 done();
1686 });
1687 });
1688 });
1689
1690 // BIP32 extended private key is shown
1691 it('Shows the BIP32 extended private key', function(done) {
1692 driver.findElement(By.css('#bip32-tab a'))
1693 .click();
1694 driver.findElement(By.css('.phrase'))
1695 .sendKeys('abandon abandon ability');
1696 driver.sleep(generateDelay).then(function() {
1697 driver.findElement(By.css('.extended-priv-key'))
1698 .getAttribute("value")
1699 .then(function(privKey) {
1700 expect(privKey).toBe("xprv9va99uTVE5aLiutUVLTyfxfe8v8aaXjSQ1XxZbK6SezYVuikA9MnjQVTA8rQHpNA5LKvyQBpLiHbBQiiccKiBDs7eRmBogsvq3THFeLHYbe");
1701 done();
1702 });
1703 });
1704 });
1705
1706 // BIP32 extended public key is shown
1707 it('Shows the BIP32 extended public key', function(done) {
1708 driver.findElement(By.css('#bip32-tab a'))
1709 .click();
1710 driver.findElement(By.css('.phrase'))
1711 .sendKeys('abandon abandon ability');
1712 driver.sleep(generateDelay).then(function() {
1713 driver.findElement(By.css('.extended-pub-key'))
1714 .getAttribute("value")
1715 .then(function(pubKey) {
1716 expect(pubKey).toBe("xpub69ZVZQzP4T8dwPxwbMzz36cNgwy4yzTHmETZMyihzzXXNi3thgg3HCow1RtY252wdw5rS8369xKnraN5Q93y3FkFfJp2XEHWUrkyXsjS93P");
1717 done();
1718 });
1719 });
1720 });
1721
1722 // Derivation path is shown in table
1723 it('Shows the derivation path in the table', function(done) {
1724 driver.findElement(By.css('.phrase'))
1725 .sendKeys('abandon abandon ability');
1726 driver.sleep(generateDelay).then(function() {
1727 getFirstPath(function(path) {
1728 expect(path).toBe("m/44'/0'/0'/0/0");
1729 done();
1730 });
1731 });
1732 });
1733
1734 // Derivation path for address can be hardened
1735 it('Can derive hardened addresses', function(done) {
1736 driver.findElement(By.css('#bip32-tab a'))
1737 .click();
1738 driver.executeScript(function() {
1739 $(".hardened-addresses").prop("checked", true);
1740 });
1741 driver.findElement(By.css('.phrase'))
1742 .sendKeys('abandon abandon ability');
1743 driver.sleep(generateDelay).then(function() {
1744 getFirstAddress(function(address) {
1745 expect(address).toBe("18exLzUv7kfpiXRzmCjFDoC9qwNLFyvwyd");
1746 done();
1747 });
1748 });
1749 });
1750
1751 // Derivation path visibility can be toggled
1752 it('Can toggle visibility of the derivation path column', function(done) {
1753 driver.findElement(By.css('.phrase'))
1754 .sendKeys('abandon abandon ability');
1755 driver.sleep(generateDelay).then(function() {
1756 driver.findElement(By.css('.index-toggle'))
1757 .click();
1758 testColumnValuesAreInvisible(done, "index");
1759 });
1760 });
1761
1762 // Address is shown
1763 it('Shows the address in the table', function(done) {
1764 driver.findElement(By.css('.phrase'))
1765 .sendKeys('abandon abandon ability');
1766 driver.sleep(generateDelay).then(function() {
1767 getFirstAddress(function(address) {
1768 expect(address).toBe("1Di3Vp7tBWtyQaDABLAjfWtF6V7hYKJtug");
1769 done();
1770 });
1771 });
1772 });
1773
1774 // Addresses are shown in order of derivation path
1775 it('Shows the address in order of derivation path', function(done) {
1776 driver.findElement(By.css('.phrase'))
1777 .sendKeys('abandon abandon ability');
1778 driver.sleep(generateDelay).then(function() {
1779 testRowsAreInCorrectOrder(done);
1780 });
1781 });
1782
1783 // Address visibility can be toggled
1784 it('Can toggle visibility of the address column', function(done) {
1785 driver.findElement(By.css('.phrase'))
1786 .sendKeys('abandon abandon ability');
1787 driver.sleep(generateDelay).then(function() {
1788 driver.findElement(By.css('.address-toggle'))
1789 .click();
1790 testColumnValuesAreInvisible(done, "address");
1791 });
1792 });
1793
1794 // Public key is shown in table
1795 it('Shows the public key in the table', function(done) {
1796 driver.findElement(By.css('.phrase'))
1797 .sendKeys('abandon abandon ability');
1798 driver.sleep(generateDelay).then(function() {
1799 driver.findElements(By.css('.pubkey'))
1800 .then(function(els) {
1801 els[0].getText()
1802 .then(function(pubkey) {
1803 expect(pubkey).toBe("033f5aed5f6cfbafaf223188095b5980814897295f723815fea5d3f4b648d0d0b3");
1804 done();
1805 });
1806 });
1807 });
1808 });
1809
1810 // Public key visibility can be toggled
1811 it('Can toggle visibility of the public key column', function(done) {
1812 driver.findElement(By.css('.phrase'))
1813 .sendKeys('abandon abandon ability');
1814 driver.sleep(generateDelay).then(function() {
1815 driver.findElement(By.css('.public-key-toggle'))
1816 .click();
1817 testColumnValuesAreInvisible(done, "pubkey");
1818 });
1819 });
1820
1821 // Private key is shown in table
1822 it('Shows the private key in the table', function(done) {
1823 driver.findElement(By.css('.phrase'))
1824 .sendKeys('abandon abandon ability');
1825 driver.sleep(generateDelay).then(function() {
1826 driver.findElements(By.css('.privkey'))
1827 .then(function(els) {
1828 els[0].getText()
1829 .then(function(pubkey) {
1830 expect(pubkey).toBe("L26cVSpWFkJ6aQkPkKmTzLqTdLJ923e6CzrVh9cmx21QHsoUmrEE");
1831 done();
1832 });
1833 });
1834 });
1835 });
1836
1837 // Private key visibility can be toggled
1838 it('Can toggle visibility of the private key column', function(done) {
1839 driver.findElement(By.css('.phrase'))
1840 .sendKeys('abandon abandon ability');
1841 driver.sleep(generateDelay).then(function() {
1842 driver.findElement(By.css('.private-key-toggle'))
1843 .click();
1844 testColumnValuesAreInvisible(done, "privkey");
1845 });
1846 });
1847
1848 // More addresses can be generated
1849 it('Can generate more rows in the table', function(done) {
1850 driver.findElement(By.css('.phrase'))
1851 .sendKeys('abandon abandon ability');
1852 driver.sleep(generateDelay).then(function() {
1853 driver.findElement(By.css('.more'))
1854 .click();
1855 driver.sleep(generateDelay).then(function() {
1856 driver.findElements(By.css('.address'))
1857 .then(function(els) {
1858 expect(els.length).toBe(40);
1859 done();
1860 });
1861 });
1862 });
1863 });
1864
1865 // A custom number of additional addresses can be generated
1866 it('Can generate more rows in the table', function(done) {
1867 driver.findElement(By.css('.phrase'))
1868 .sendKeys('abandon abandon ability');
1869 driver.sleep(generateDelay).then(function() {
1870 driver.findElement(By.css('.rows-to-add'))
1871 .clear();
1872 driver.findElement(By.css('.rows-to-add'))
1873 .sendKeys('1');
1874 driver.findElement(By.css('.more'))
1875 .click();
1876 driver.sleep(generateDelay).then(function() {
1877 driver.findElements(By.css('.address'))
1878 .then(function(els) {
1879 expect(els.length).toBe(21);
1880 done();
1881 });
1882 });
1883 });
1884 });
1885
1886 // Additional addresses are shown in order of derivation path
1887 it('Shows additional addresses in order of derivation path', function(done) {
1888 driver.findElement(By.css('.phrase'))
1889 .sendKeys('abandon abandon ability');
1890 driver.sleep(generateDelay).then(function() {
1891 driver.findElement(By.css('.more'))
1892 .click();
1893 driver.sleep(generateDelay).then(function() {
1894 testRowsAreInCorrectOrder(done);
1895 });
1896 });
1897 });
1898
1899 // BIP32 root key can be set by the user
1900 it('Allows the user to set the BIP32 root key', function(done) {
1901 driver.findElement(By.css('.root-key'))
1902 .sendKeys('xprv9s21ZrQH143K2jkGDCeTLgRewT9F2pH5JZs2zDmmjXes34geVnFiuNa8KTvY5WoYvdn4Ag6oYRoB6cXtc43NgJAEqDXf51xPm6fhiMCKwpi');
1903 driver.sleep(generateDelay).then(function() {
1904 getFirstAddress(function(address) {
1905 expect(address).toBe("1Di3Vp7tBWtyQaDABLAjfWtF6V7hYKJtug");
1906 done();
1907 });
1908 });
1909 });
1910
1911 // Setting BIP32 root key clears the existing phrase, passphrase and seed
1912 // TODO this doesn't work in selenium with chrome
1913 it('Confirms the existing phrase should be cleared', function(done) {
1914 if (browser == "chrome") {
1915 pending("Selenium + Chrome headless bug for alert, see https://stackoverflow.com/q/45242264");
1916 }
1917 driver.findElement(By.css('.phrase'))
1918 .sendKeys('A non-blank but invalid value');
1919 driver.findElement(By.css('.root-key'))
1920 .sendKeys('xprv9s21ZrQH143K2jkGDCeTLgRewT9F2pH5JZs2zDmmjXes34geVnFiuNa8KTvY5WoYvdn4Ag6oYRoB6cXtc43NgJAEqDXf51xPm6fhiMCKwpi');
1921 driver.switchTo().alert().accept();
1922 driver.findElement(By.css('.phrase'))
1923 .getAttribute("value").then(function(value) {
1924 expect(value).toBe("");
1925 done();
1926 });
1927 });
1928
1929 // Clearing of phrase, passphrase and seed can be cancelled by user
1930 // TODO this doesn't work in selenium with chrome
1931 it('Allows the clearing of the phrase to be cancelled', function(done) {
1932 if (browser == "chrome") {
1933 pending("Selenium + Chrome headless bug for alert, see https://stackoverflow.com/q/45242264");
1934 }
1935 driver.findElement(By.css('.phrase'))
1936 .sendKeys('abandon abandon ability');
1937 driver.sleep(generateDelay).then(function() {
1938 driver.findElement(By.css('.root-key'))
1939 .clear();
1940 driver.findElement(By.css('.root-key'))
1941 .sendKeys('x');
1942 driver.switchTo().alert().dismiss();
1943 driver.findElement(By.css('.phrase'))
1944 .getAttribute("value").then(function(value) {
1945 expect(value).toBe("abandon abandon ability");
1946 done();
1947 });
1948 });
1949 });
1950
1951 // Custom BIP32 root key is used when changing the derivation path
1952 it('Can set derivation path for root key instead of phrase', function(done) {
1953 driver.findElement(By.css('#bip44 .account'))
1954 .sendKeys('1');
1955 driver.findElement(By.css('.root-key'))
1956 .sendKeys('xprv9s21ZrQH143K2jkGDCeTLgRewT9F2pH5JZs2zDmmjXes34geVnFiuNa8KTvY5WoYvdn4Ag6oYRoB6cXtc43NgJAEqDXf51xPm6fhiMCKwpi');
1957 driver.sleep(generateDelay).then(function() {
1958 getFirstAddress(function(address) {
1959 expect(address).toBe("1Nq2Wmu726XHCuGhctEtGmhxo3wzk5wZ1H");
1960 done();
1961 });
1962 });
1963 });
1964
1965 // Incorrect mnemonic shows error
1966 it('Shows an error for incorrect mnemonic', function(done) {
1967 driver.findElement(By.css('.phrase'))
1968 .sendKeys('abandon abandon abandon');
1969 driver.sleep(feedbackDelay).then(function() {
1970 driver.findElement(By.css('.feedback'))
1971 .getText()
1972 .then(function(feedback) {
1973 expect(feedback).toBe("Invalid mnemonic");
1974 done();
1975 });
1976 });
1977 });
1978
1979 // Incorrect word shows suggested replacement
1980 it('Shows word suggestion for incorrect word', function(done) {
1981 driver.findElement(By.css('.phrase'))
1982 .sendKeys('abandon abandon abiliti');
1983 driver.sleep(feedbackDelay).then(function() {
1984 driver.findElement(By.css('.feedback'))
1985 .getText()
1986 .then(function(feedback) {
1987 var msg = "abiliti not in wordlist, did you mean ability?";
1988 expect(feedback).toBe(msg);
1989 done();
1990 });
1991 });
1992 });
1993
1994 // Github pull request 48
1995 // First four letters of word shows that word, not closest
1996 // since first four letters gives unique word in BIP39 wordlist
1997 // eg ille should show illegal, not idle
1998 it('Shows word suggestion based on first four chars', function(done) {
1999 driver.findElement(By.css('.phrase'))
2000 .sendKeys('ille');
2001 driver.sleep(feedbackDelay).then(function() {
2002 driver.findElement(By.css('.feedback'))
2003 .getText()
2004 .then(function(feedback) {
2005 var msg = "ille not in wordlist, did you mean illegal?";
2006 expect(feedback).toBe(msg);
2007 done();
2008 });
2009 });
2010 });
2011
2012 // Incorrect BIP32 root key shows error
2013 it('Shows error for incorrect root key', function(done) {
2014 driver.findElement(By.css('.root-key'))
2015 .sendKeys('xprv9s21ZrQH143K2jkGDCeTLgRewT9F2pH5JZs2zDmmjXes34geVnFiuNa8KTvY5WoYvdn4Ag6oYRoB6cXtc43NgJAEqDXf51xPm6fhiMCKwpj');
2016 driver.sleep(feedbackDelay).then(function() {
2017 driver.findElement(By.css('.feedback'))
2018 .getText()
2019 .then(function(feedback) {
2020 var msg = "Invalid root key";
2021 expect(feedback).toBe(msg);
2022 done();
2023 });
2024 });
2025 });
2026
2027 // Derivation path not starting with m shows error
2028 it('Shows error for derivation path not starting with m', function(done) {
2029 driver.findElement(By.css('#bip32-tab a'))
2030 .click();
2031 driver.findElement(By.css('#bip32 .path'))
2032 .clear();
2033 driver.findElement(By.css('#bip32 .path'))
2034 .sendKeys('n/0');
2035 driver.findElement(By.css('.phrase'))
2036 .sendKeys('abandon abandon ability');
2037 driver.sleep(feedbackDelay).then(function() {
2038 driver.findElement(By.css('.feedback'))
2039 .getText()
2040 .then(function(feedback) {
2041 var msg = "First character must be 'm'";
2042 expect(feedback).toBe(msg);
2043 done();
2044 });
2045 });
2046 });
2047
2048 // Derivation path containing invalid characters shows useful error
2049 it('Shows error for derivation path not starting with m', function(done) {
2050 driver.findElement(By.css('#bip32-tab a'))
2051 .click();
2052 driver.findElement(By.css('#bip32 .path'))
2053 .clear();
2054 driver.findElement(By.css('#bip32 .path'))
2055 .sendKeys('m/1/0wrong1/1');
2056 driver.findElement(By.css('.phrase'))
2057 .sendKeys('abandon abandon ability');
2058 driver.sleep(feedbackDelay).then(function() {
2059 driver.findElement(By.css('.feedback'))
2060 .getText()
2061 .then(function(feedback) {
2062 var msg = "Invalid characters 0wrong1 found at depth 2";
2063 expect(feedback).toBe(msg);
2064 done();
2065 });
2066 });
2067 });
2068
2069 // Github Issue 11: Default word length is 15
2070 // https://github.com/iancoleman/bip39/issues/11
2071 it('Sets the default word length to 15', function(done) {
2072 driver.findElement(By.css('.strength'))
2073 .getAttribute("value")
2074 .then(function(strength) {
2075 expect(strength).toBe("15");
2076 done();
2077 });
2078 });
2079
2080 // Github Issue 12: Generate more rows with private keys hidden
2081 // https://github.com/iancoleman/bip39/issues/12
2082 it('Sets the correct hidden column state on new rows', function(done) {
2083 driver.findElement(By.css('.phrase'))
2084 .sendKeys("abandon abandon ability");
2085 driver.sleep(generateDelay).then(function() {
2086 driver.findElement(By.css('.private-key-toggle'))
2087 .click();
2088 driver.findElement(By.css('.more'))
2089 .click();
2090 driver.sleep(generateDelay).then(function() {
2091 driver.findElements(By.css('.privkey'))
2092 .then(function(els) {
2093 expect(els.length).toBe(40);
2094 });
2095 testColumnValuesAreInvisible(done, "privkey");
2096 });
2097 });
2098 });
2099
2100 // Github Issue 19: Mnemonic is not sensitive to whitespace
2101 // https://github.com/iancoleman/bip39/issues/19
2102 it('Ignores excess whitespace in the mnemonic', function(done) {
2103 var doublespace = " ";
2104 var mnemonic = "urge cat" + doublespace + "bid";
2105 driver.findElement(By.css('.phrase'))
2106 .sendKeys(mnemonic);
2107 driver.sleep(generateDelay).then(function() {
2108 driver.findElement(By.css('.root-key'))
2109 .getAttribute("value")
2110 .then(function(seed) {
2111 expect(seed).toBe("xprv9s21ZrQH143K3isaZsWbKVoTtbvd34Y1ZGRugGdMeBGbM3AgBVzTH159mj1cbbtYSJtQr65w6L5xy5L9SFC7c9VJZWHxgAzpj4mun5LhrbC");
2112 done();
2113 });
2114 });
2115 });
2116
2117 // Github Issue 23: Part 1: Use correct derivation path when changing tabs
2118 // https://github.com/iancoleman/bip39/issues/23
2119 it('Uses the correct derivation path when changing tabs', function(done) {
2120 // 1) and 2) set the phrase
2121 driver.findElement(By.css('.phrase'))
2122 .sendKeys("abandon abandon ability");
2123 driver.sleep(generateDelay).then(function() {
2124 // 3) select bip32 tab
2125 driver.findElement(By.css('#bip32-tab a'))
2126 .click();
2127 driver.sleep(generateDelay).then(function() {
2128 // 4) switch from bitcoin to litecoin
2129 selectNetwork("LTC - Litecoin");
2130 driver.sleep(generateDelay).then(function() {
2131 // 5) Check address is displayed correctly
2132 getFirstAddress(function(address) {
2133 expect(address).toBe("LS8MP5LZ5AdzSZveRrjm3aYVoPgnfFh5T5");
2134 // 5) Check derivation path is displayed correctly
2135 getFirstPath(function(path) {
2136 expect(path).toBe("m/0/0");
2137 done();
2138 });
2139 });
2140 });
2141 });
2142 });
2143 });
2144
2145 // Github Issue 23 Part 2: Coin selection in derivation path
2146 // https://github.com/iancoleman/bip39/issues/23#issuecomment-238011920
2147 it('Uses the correct derivation path when changing coins', function(done) {
2148 // set the phrase
2149 driver.findElement(By.css('.phrase'))
2150 .sendKeys("abandon abandon ability");
2151 driver.sleep(generateDelay).then(function() {
2152 // switch from bitcoin to clam
2153 selectNetwork("CLAM - Clams");
2154 driver.sleep(generateDelay).then(function() {
2155 // check derivation path is displayed correctly
2156 getFirstPath(function(path) {
2157 expect(path).toBe("m/44'/23'/0'/0/0");
2158 done();
2159 });
2160 });
2161 });
2162 });
2163
2164 // Github Issue 26: When using a Root key derrived altcoins are incorrect
2165 // https://github.com/iancoleman/bip39/issues/26
2166 it('Uses the correct derivation for altcoins with root keys', function(done) {
2167 // 1) 2) and 3) set the root key
2168 driver.findElement(By.css('.root-key'))
2169 .sendKeys("xprv9s21ZrQH143K2jkGDCeTLgRewT9F2pH5JZs2zDmmjXes34geVnFiuNa8KTvY5WoYvdn4Ag6oYRoB6cXtc43NgJAEqDXf51xPm6fhiMCKwpi");
2170 driver.sleep(generateDelay).then(function() {
2171 // 4) switch from bitcoin to viacoin
2172 selectNetwork("VIA - Viacoin");
2173 driver.sleep(generateDelay).then(function() {
2174 // 5) ensure the derived address is correct
2175 getFirstAddress(function(address) {
2176 expect(address).toBe("Vq9Eq4N5SQnjqZvxtxzo7hZPW5XnyJsmXT");
2177 done();
2178 });
2179 });
2180 });
2181 });
2182
2183 // Selecting a language with no existing phrase should generate a phrase in
2184 // that language.
2185 it('Generate a random phrase when language is selected and no current phrase', function(done) {
2186 driver.findElement(By.css("a[href='#japanese']"))
2187 .click();
2188 driver.sleep(generateDelay).then(function() {
2189 driver.findElement(By.css(".phrase"))
2190 .getAttribute("value").then(function(phrase) {
2191 expect(phrase.search(/[a-z]/)).toBe(-1);
2192 expect(phrase.length).toBeGreaterThan(0);
2193 done();
2194 });
2195 });
2196 });
2197
2198 // Selecting a language with existing phrase should update the phrase to use
2199 // that language.
2200 it('Updates existing phrases when the language is changed', function(done) {
2201 driver.findElement(By.css(".phrase"))
2202 .sendKeys("abandon abandon ability");
2203 driver.sleep(generateDelay).then(function() {
2204 driver.findElement(By.css("a[href='#italian']"))
2205 .click();
2206 driver.sleep(generateDelay).then(function() {
2207 driver.findElement(By.css(".phrase"))
2208 .getAttribute("value").then(function(phrase) {
2209 // Check only the language changes, not the phrase
2210 expect(phrase).toBe("abaco abaco abbaglio");
2211 getFirstAddress(function(address) {
2212 // Check the address is correct
2213 expect(address).toBe("1Dz5TgDhdki9spa6xbPFbBqv5sjMrx3xgV");
2214 done();
2215 });
2216 });
2217 });
2218 });
2219 });
2220
2221 // Suggested replacement for erroneous word in non-English language
2222 it('Shows word suggestion for incorrect word in non-English language', function(done) {
2223 driver.findElement(By.css('.phrase'))
2224 .sendKeys('abaco abaco zbbaglio');
2225 driver.sleep(feedbackDelay).then(function() {
2226 driver.findElement(By.css('.feedback'))
2227 .getText()
2228 .then(function(feedback) {
2229 var msg = "zbbaglio not in wordlist, did you mean abbaglio?";
2230 expect(feedback).toBe(msg);
2231 done();
2232 });
2233 });
2234 });
2235
2236 // Japanese word does not break across lines.
2237 // Point 2 from
2238 // https://github.com/bitcoin/bips/blob/master/bip-0039/bip-0039-wordlists.md#japanese
2239 it('Does not break Japanese words across lines', function(done) {
2240 driver.findElement(By.css('.phrase'))
2241 .getCssValue("word-break")
2242 .then(function(value) {
2243 expect(value).toBe("keep-all");
2244 done();
2245 });
2246 });
2247
2248 // Language can be specified at page load using hash value in url
2249 it('Can set the language from the url hash', function(done) {
2250 driver.get(url + "#japanese").then(function() {
2251 driver.findElement(By.css('.generate')).click();
2252 driver.sleep(generateDelay).then(function() {
2253 driver.findElement(By.css(".phrase"))
2254 .getAttribute("value").then(function(phrase) {
2255 expect(phrase.search(/[a-z]/)).toBe(-1);
2256 expect(phrase.length).toBeGreaterThan(0);
2257 done();
2258 });
2259 });
2260 });
2261 });
2262
2263 // Entropy can be entered by the user
2264 it('Allows entropy to be entered', function(done) {
2265 driver.findElement(By.css('.use-entropy'))
2266 .click();
2267 driver.findElement(By.css('.entropy'))
2268 .sendKeys('00000000 00000000 00000000 00000000');
2269 driver.sleep(generateDelay).then(function() {
2270 driver.findElement(By.css(".phrase"))
2271 .getAttribute("value").then(function(phrase) {
2272 expect(phrase).toBe("abandon abandon ability");
2273 getFirstAddress(function(address) {
2274 expect(address).toBe("1Di3Vp7tBWtyQaDABLAjfWtF6V7hYKJtug");
2275 done();
2276 })
2277 });
2278 });
2279 });
2280
2281 // A warning about entropy is shown to the user, with additional information
2282 it('Shows a warning about using entropy', function(done) {
2283 driver.findElement(By.css('.use-entropy'))
2284 .click();
2285 driver.findElement(By.css('.entropy-container'))
2286 .getText()
2287 .then(function(containerText) {
2288 var warning = "mnemonic may be insecure";
2289 expect(containerText).toContain(warning);
2290 driver.findElement(By.css('#entropy-notes'))
2291 .findElement(By.xpath("parent::*"))
2292 .getText()
2293 .then(function(notesText) {
2294 var detail = "flipping a fair coin, rolling a fair dice, noise measurements etc";
2295 expect(notesText).toContain(detail);
2296 done();
2297 });
2298 });
2299 });
2300
2301 // The types of entropy available are described to the user
2302 it('Shows the types of entropy available', function(done) {
2303 driver.findElement(By.css('.entropy'))
2304 .getAttribute("placeholder")
2305 .then(function(placeholderText) {
2306 var options = [
2307 "binary",
2308 "base 6",
2309 "dice",
2310 "base 10",
2311 "hexadecimal",
2312 "cards",
2313 ];
2314 for (var i=0; i<options.length; i++) {
2315 var option = options[i];
2316 expect(placeholderText).toContain(option);
2317 }
2318 done();
2319 });
2320 });
2321
2322 // The actual entropy used is shown to the user
2323 it('Shows the actual entropy used', function(done) {
2324 driver.findElement(By.css('.use-entropy'))
2325 .click();
2326 driver.findElement(By.css('.entropy'))
2327 .sendKeys('Not A Very Good Entropy Source At All');
2328 driver.sleep(generateDelay).then(function() {
2329 driver.findElement(By.css('.entropy-container'))
2330 .getText()
2331 .then(function(text) {
2332 expect(text).toMatch(/Filtered Entropy\s+AedEceAA/);
2333 done();
2334 });
2335 });
2336 });
2337
2338 // Binary entropy can be entered
2339 it('Allows binary entropy to be entered', function(done) {
2340 testEntropyType(done, "01", "binary");
2341 });
2342
2343 // Base 6 entropy can be entered
2344 it('Allows base 6 entropy to be entered', function(done) {
2345 testEntropyType(done, "012345", "base 6");
2346 });
2347
2348 // Base 6 dice entropy can be entered
2349 it('Allows base 6 dice entropy to be entered', function(done) {
2350 testEntropyType(done, "123456", "base 6 (dice)");
2351 });
2352
2353 // Base 10 entropy can be entered
2354 it('Allows base 10 entropy to be entered', function(done) {
2355 testEntropyType(done, "789", "base 10");
2356 });
2357
2358 // Hexadecimal entropy can be entered
2359 it('Allows hexadecimal entropy to be entered', function(done) {
2360 testEntropyType(done, "abcdef", "hexadecimal");
2361 });
2362
2363 // Dice entropy value is shown as the converted base 6 value
2364 // ie 123456 is converted to 123450
2365 it('Shows dice entropy as base 6', function(done) {
2366 driver.findElement(By.css('.use-entropy'))
2367 .click();
2368 driver.findElement(By.css('.entropy'))
2369 .sendKeys("123456");
2370 driver.sleep(generateDelay).then(function() {
2371 driver.findElement(By.css('.entropy-container'))
2372 .getText()
2373 .then(function(text) {
2374 expect(text).toMatch(/Filtered Entropy\s+123450/);
2375 done();
2376 });
2377 });
2378 });
2379
2380 // The number of bits of entropy accumulated is shown
2381 it("Shows the number of bits of entropy for 20 bits of binary", function(done) {
2382 testEntropyBits(done, "0000 0000 0000 0000 0000", "20");
2383 });
2384 it("Shows the number of bits of entropy for 1 bit of binary", function(done) {
2385 testEntropyBits(done, "0", "1");
2386 });
2387 it("Shows the number of bits of entropy for 4 bits of binary", function(done) {
2388 testEntropyBits(done, "0000", "4");
2389 });
2390 it("Shows the number of bits of entropy for 1 character of base 6 (dice)", function(done) {
2391 // 6 in card is 0 in base 6, 0 in base 6 is 2.6 bits (rounded down to 2 bits)
2392 testEntropyBits(done, "6", "2");
2393 });
2394 it("Shows the number of bits of entropy for 1 character of base 10 with 3 bits", function(done) {
2395 // 7 in base 10 is 111 in base 2, no leading zeros
2396 testEntropyBits(done, "7", "3");
2397 });
2398 it("Shows the number of bits of entropy for 1 character of base 10 with 4 bis", function(done) {
2399 testEntropyBits(done, "8", "4");
2400 });
2401 it("Shows the number of bits of entropy for 1 character of hex", function(done) {
2402 testEntropyBits(done, "F", "4");
2403 });
2404 it("Shows the number of bits of entropy for 2 characters of base 10", function(done) {
2405 testEntropyBits(done, "29", "6");
2406 });
2407 it("Shows the number of bits of entropy for 2 characters of hex", function(done) {
2408 testEntropyBits(done, "0A", "8");
2409 });
2410 it("Shows the number of bits of entropy for 2 characters of hex with 3 leading zeros", function(done) {
2411 // hex is always multiple of 4 bits of entropy
2412 testEntropyBits(done, "1A", "8");
2413 });
2414 it("Shows the number of bits of entropy for 2 characters of hex with 2 leading zeros", function(done) {
2415 testEntropyBits(done, "2A", "8");
2416 });
2417 it("Shows the number of bits of entropy for 2 characters of hex with 1 leading zero", function(done) {
2418 testEntropyBits(done, "4A", "8");
2419 });
2420 it("Shows the number of bits of entropy for 2 characters of hex with no leading zeros", function(done) {
2421 testEntropyBits(done, "8A", "8");
2422 });
2423 it("Shows the number of bits of entropy for 2 characters of hex starting with F", function(done) {
2424 testEntropyBits(done, "FA", "8");
2425 });
2426 it("Shows the number of bits of entropy for 4 characters of hex with leading zeros", function(done) {
2427 testEntropyBits(done, "000A", "16");
2428 });
2429 it("Shows the number of bits of entropy for 4 characters of base 6", function(done) {
2430 testEntropyBits(done, "5555", "11");
2431 });
2432 it("Shows the number of bits of entropy for 4 characters of base 6 dice", function(done) {
2433 // uses dice, so entropy is actually 0000 in base 6, which is 4 lots of
2434 // 2.58 bits, which is 10.32 bits (rounded down to 10 bits)
2435 testEntropyBits(done, "6666", "10");
2436 });
2437 it("Shows the number of bits of entropy for 4 charactes of base 10", function(done) {
2438 // Uses base 10, which is 4 lots of 3.32 bits, which is 13.3 bits (rounded
2439 // down to 13)
2440 testEntropyBits(done, "2227", "13");
2441 });
2442 it("Shows the number of bits of entropy for 4 characters of hex with 2 leading zeros", function(done) {
2443 testEntropyBits(done, "222F", "16");
2444 });
2445 it("Shows the number of bits of entropy for 4 characters of hex starting with F", function(done) {
2446 testEntropyBits(done, "FFFF", "16");
2447 });
2448 it("Shows the number of bits of entropy for 10 characters of base 10", function(done) {
2449 // 10 events at 3.32 bits per event
2450 testEntropyBits(done, "0000101017", "33");
2451 });
2452 it("Shows the number of bits of entropy for a full deck of cards", function(done) {
2453 // cards are not replaced, so a full deck is not 52^52 entropy which is 296
2454 // bits, it's 52!, which is 225 bits
2455 testEntropyBits(done, "ac2c3c4c5c6c7c8c9ctcjcqckcad2d3d4d5d6d7d8d9dtdjdqdkdah2h3h4h5h6h7h8h9hthjhqhkhas2s3s4s5s6s7s8s9stsjsqsks", "225");
2456 });
2457
2458 it("Shows details about the entered entropy", function(done) {
2459 testEntropyFeedback(done,
2460 {
2461 entropy: "A",
2462 filtered: "A",
2463 type: "hexadecimal",
2464 events: "1",
2465 bits: "4",
2466 words: 0,
2467 strength: "less than a second",
2468 }
2469 );
2470 });
2471 it("Shows details about the entered entropy", function(done) {
2472 testEntropyFeedback(done,
2473 {
2474 entropy: "AAAAAAAA",
2475 filtered: "AAAAAAAA",
2476 type: "hexadecimal",
2477 events: "8",
2478 bits: "32",
2479 words: 3,
2480 strength: "less than a second - Repeats like \"aaa\" are easy to guess",
2481 }
2482 );
2483 });
2484 it("Shows details about the entered entropy", function(done) {
2485 testEntropyFeedback(done,
2486 {
2487 entropy: "AAAAAAAA B",
2488 filtered: "AAAAAAAAB",
2489 type: "hexadecimal",
2490 events: "9",
2491 bits: "36",
2492 words: 3,
2493 strength: "less than a second - Repeats like \"aaa\" are easy to guess",
2494 }
2495 );
2496 });
2497 it("Shows details about the entered entropy", function(done) {
2498 testEntropyFeedback(done,
2499 {
2500 entropy: "AAAAAAAA BBBBBBBB",
2501 filtered: "AAAAAAAABBBBBBBB",
2502 type: "hexadecimal",
2503 events: "16",
2504 bits: "64",
2505 words: 6,
2506 strength: "less than a second - Repeats like \"aaa\" are easy to guess",
2507 }
2508 );
2509 });
2510 it("Shows details about the entered entropy", function(done) {
2511 testEntropyFeedback(done,
2512 {
2513 entropy: "AAAAAAAA BBBBBBBB CCCCCCCC",
2514 filtered: "AAAAAAAABBBBBBBBCCCCCCCC",
2515 type: "hexadecimal",
2516 events: "24",
2517 bits: "96",
2518 words: 9,
2519 strength: "less than a second",
2520 }
2521 );
2522 });
2523 it("Shows details about the entered entropy", function(done) {
2524 testEntropyFeedback(done,
2525 {
2526 entropy: "AAAAAAAA BBBBBBBB CCCCCCCC DDDDDDDD",
2527 filtered: "AAAAAAAABBBBBBBBCCCCCCCCDDDDDDDD",
2528 type: "hexadecimal",
2529 events: "32",
2530 bits: "128",
2531 words: 12,
2532 strength: "2 minutes",
2533 }
2534 );
2535 });
2536 it("Shows details about the entered entropy", function(done) {
2537 testEntropyFeedback(done,
2538 {
2539 entropy: "AAAAAAAA BBBBBBBB CCCCCCCC DDDDDDDA",
2540 filtered: "AAAAAAAABBBBBBBBCCCCCCCCDDDDDDDA",
2541 type: "hexadecimal",
2542 events: "32",
2543 bits: "128",
2544 words: 12,
2545 strength: "2 days",
2546 }
2547 );
2548 });
2549 it("Shows details about the entered entropy", function(done) {
2550 testEntropyFeedback(done,
2551 {
2552 entropy: "AAAAAAAA BBBBBBBB CCCCCCCC DDDDDDDA EEEEEEEE",
2553 filtered: "AAAAAAAABBBBBBBBCCCCCCCCDDDDDDDAEEEEEEEE",
2554 type: "hexadecimal",
2555 events: "40",
2556 bits: "160",
2557 words: 15,
2558 strength: "3 years",
2559 }
2560 );
2561 });
2562 it("Shows details about the entered entropy", function(done) {
2563 testEntropyFeedback(done,
2564 {
2565 entropy: "AAAAAAAA BBBBBBBB CCCCCCCC DDDDDDDA EEEEEEEE FFFFFFFF",
2566 filtered: "AAAAAAAABBBBBBBBCCCCCCCCDDDDDDDAEEEEEEEEFFFFFFFF",
2567 type: "hexadecimal",
2568 events: "48",
2569 bits: "192",
2570 words: 18,
2571 strength: "centuries",
2572 }
2573 );
2574 });
2575 it("Shows details about the entered entropy", function(done) {
2576 testEntropyFeedback(done,
2577 {
2578 entropy: "7d",
2579 type: "card",
2580 events: "1",
2581 bits: "4",
2582 words: 0,
2583 strength: "less than a second",
2584 }
2585 );
2586 });
2587 it("Shows details about the entered entropy", function(done) {
2588 testEntropyFeedback(done,
2589 {
2590 entropy: "ac2c3c4c5c6c7c8c9ctcjcqckcad2d3d4d5d6d7d8d9dtdjdqdkdah2h3h4h5h6h7h8h9hthjhqhkhas2s3s4s5s6s7s8s9stsjsqsks",
2591 type: "card (full deck)",
2592 events: "52",
2593 bits: "225",
2594 words: 21,
2595 strength: "centuries",
2596 }
2597 );
2598 });
2599 it("Shows details about the entered entropy", function(done) {
2600 testEntropyFeedback(done,
2601 {
2602 entropy: "ac2c3c4c5c6c7c8c9ctcjcqckcad2d3d4d5d6d7d8d9dtdjdqdkdah2h3h4h5h6h7h8h9hthjhqhkhas2s3s4s5s6s7s8s9stsjsqsks3d",
2603 type: "card (full deck, 1 duplicate: 3d)",
2604 events: "53",
2605 bits: "254",
2606 words: 21,
2607 strength: "centuries",
2608 }
2609 );
2610 });
2611 it("Shows details about the entered entropy", function(done) {
2612 testEntropyFeedback(done,
2613 {
2614 entropy: "ac2c3c4c5c6c7c8c9ctcjcqckcad2d3d4d5d6d7d8d9dtdjdqdkdah2h3h4h5h6h7h8h9hthjhqhkhas2s3s4s5s6s7s8s9stsjsqs3d4d",
2615 type: "card (2 duplicates: 3d 4d, 1 missing: KS)",
2616 events: "53",
2617 bits: "254",
2618 words: 21,
2619 strength: "centuries",
2620 }
2621 );
2622 });
2623 it("Shows details about the entered entropy", function(done) {
2624 testEntropyFeedback(done,
2625 {
2626 entropy: "ac2c3c4c5c6c7c8c9ctcjcqckcad2d3d4d5d6d7d8d9dtdjdqdkdah2h3h4h5h6h7h8h9hthjhqhkhas2s3s4s5s6s7s8s9stsjsqs3d4d5d6d",
2627 type: "card (4 duplicates: 3d 4d 5d..., 1 missing: KS)",
2628 events: "55",
2629 bits: "264",
2630 words: 24,
2631 strength: "centuries",
2632 }
2633 );
2634 });
2635 it("Shows details about the entered entropy", function(done) {
2636 testEntropyFeedback(done,
2637 // Next test was throwing uncaught error in zxcvbn
2638 // Also tests 451 bits, ie Math.log2(52!)*2 = 225.58 * 2
2639 {
2640 entropy: "ac2c3c4c5c6c7c8c9ctcjcqckcad2d3d4d5d6d7d8d9dtdjdqdkdah2h3h4h5h6h7h8h9hthjhqhkhas2s3s4s5s6s7s8s9stsjsqsksac2c3c4c5c6c7c8c9ctcjcqckcad2d3d4d5d6d7d8d9dtdjdqdkdah2h3h4h5h6h7h8h9hthjhqhkhas2s3s4s5s6s7s8s9stsjsqsks",
2641 type: "card (full deck, 52 duplicates: ac 2c 3c...)",
2642 events: "104",
2643 bits: "499",
2644 words: 45,
2645 strength: "centuries",
2646 }
2647 );
2648 });
2649 it("Shows details about the entered entropy", function(done) {
2650 testEntropyFeedback(done,
2651 // Case insensitivity to duplicate cards
2652 {
2653 entropy: "asAS",
2654 type: "card (1 duplicate: AS)",
2655 events: "2",
2656 bits: "9",
2657 words: 0,
2658 strength: "less than a second",
2659 }
2660 );
2661 });
2662 it("Shows details about the entered entropy", function(done) {
2663 testEntropyFeedback(done,
2664 {
2665 entropy: "ASas",
2666 type: "card (1 duplicate: as)",
2667 events: "2",
2668 bits: "9",
2669 words: 0,
2670 strength: "less than a second",
2671 }
2672 );
2673 });
2674 it("Shows details about the entered entropy", function(done) {
2675 testEntropyFeedback(done,
2676 // Missing cards are detected
2677 {
2678 entropy: "ac2c3c4c5c6c7c8c tcjcqckcad2d3d4d5d6d7d8d9dtdjdqdkdah2h3h4h5h6h7h8h9hthjhqhkhas2s3s4s5s6s7s8s9stsjsqsks",
2679 type: "card (1 missing: 9C)",
2680 events: "51",
2681 bits: "221",
2682 words: 18,
2683 strength: "centuries",
2684 }
2685 );
2686 });
2687 it("Shows details about the entered entropy", function(done) {
2688 testEntropyFeedback(done,
2689 {
2690 entropy: "ac2c3c4c5c6c7c8c tcjcqckcad2d3d4d 6d7d8d9dtdjdqdkdah2h3h4h5h6h7h8h9hthjhqhkhas2s3s4s5s6s7s8s9stsjsqsks",
2691 type: "card (2 missing: 9C 5D)",
2692 events: "50",
2693 bits: "216",
2694 words: 18,
2695 strength: "centuries",
2696 }
2697 );
2698 });
2699 it("Shows details about the entered entropy", function(done) {
2700 testEntropyFeedback(done,
2701 {
2702 entropy: "ac2c3c4c5c6c7c8c tcjcqckcad2d3d4d 6d7d8d9dtdjd kdah2h3h 5h6h7h8h9hthjhqhkhas2s3s4s5s6s7s8s9stsjsqsks",
2703 type: "card (4 missing: 9C 5D QD...)",
2704 events: "48",
2705 bits: "208",
2706 words: 18,
2707 strength: "centuries",
2708 }
2709 );
2710 });
2711 it("Shows details about the entered entropy", function(done) {
2712 testEntropyFeedback(done,
2713 // More than six missing cards does not show message
2714 {
2715 entropy: "ac2c3c4c5c6c7c8c tcjcqckcad2d3d4d 6d 8d9d jd kdah2h3h 5h6h7h8h9hthjhqhkh 2s3s4s5s6s7s8s9stsjsqsks",
2716 type: "card",
2717 events: "45",
2718 bits: "195",
2719 words: 18,
2720 strength: "centuries",
2721 }
2722 );
2723 });
2724 it("Shows details about the entered entropy", function(done) {
2725 testEntropyFeedback(done,
2726 // Multiple decks of cards increases bits per event
2727 {
2728 entropy: "3d",
2729 events: "1",
2730 bits: "4",
2731 bitsPerEvent: "4.34",
2732 }
2733 );
2734 });
2735 it("Shows details about the entered entropy", function(done) {
2736 testEntropyFeedback(done,
2737 {
2738 entropy: "3d3d",
2739 events: "2",
2740 bits: "9",
2741 bitsPerEvent: "4.80",
2742 }
2743 );
2744 });
2745 it("Shows details about the entered entropy", function(done) {
2746 testEntropyFeedback(done,
2747 {
2748 entropy: "3d3d3d",
2749 events: "3",
2750 bits: "15",
2751 bitsPerEvent: "5.01",
2752 }
2753 );
2754 });
2755 it("Shows details about the entered entropy", function(done) {
2756 testEntropyFeedback(done,
2757 {
2758 entropy: "3d3d3d3d",
2759 events: "4",
2760 bits: "20",
2761 bitsPerEvent: "5.14",
2762 }
2763 );
2764 });
2765 it("Shows details about the entered entropy", function(done) {
2766 testEntropyFeedback(done,
2767 {
2768 entropy: "3d3d3d3d3d",
2769 events: "5",
2770 bits: "26",
2771 bitsPerEvent: "5.22",
2772 }
2773 );
2774 });
2775 it("Shows details about the entered entropy", function(done) {
2776 testEntropyFeedback(done,
2777 {
2778 entropy: "3d3d3d3d3d3d",
2779 events: "6",
2780 bits: "31",
2781 bitsPerEvent: "5.28",
2782 }
2783 );
2784 });
2785 it("Shows details about the entered entropy", function(done) {
2786 testEntropyFeedback(done,
2787 {
2788 entropy: "3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d",
2789 events: "33",
2790 bits: "184",
2791 bitsPerEvent: "5.59",
2792 strength: 'less than a second - Repeats like "abcabcabc" are only slightly harder to guess than "abc"',
2793 }
2794 );
2795 });
2796
2797 // Entropy is truncated from the left
2798 it('Truncates entropy from the left', function(done) {
2799 // Truncate from left means 0000 is removed from the start
2800 // which gives mnemonic 'avocado zoo zone'
2801 // not 1111 removed from the end
2802 // which gives the mnemonic 'abstract zoo zoo'
2803 var entropy = "00000000 00000000 00000000 00000000";
2804 entropy += "11111111 11111111 11111111 1111"; // Missing last byte
2805 driver.findElement(By.css('.use-entropy'))
2806 .click();
2807 driver.findElement(By.css('.entropy'))
2808 .sendKeys(entropy);
2809 driver.sleep(generateDelay).then(function() {
2810 driver.findElement(By.css(".phrase"))
2811 .getAttribute("value").then(function(phrase) {
2812 expect(phrase).toBe("avocado zoo zone");
2813 done();
2814 });
2815 });
2816 });
2817
2818 // Very large entropy results in very long mnemonics
2819 it('Converts very long entropy to very long mnemonics', function(done) {
2820 var entropy = "";
2821 for (var i=0; i<33; i++) {
2822 entropy += "AAAAAAAA"; // 3 words * 33 iterations = 99 words
2823 }
2824 driver.findElement(By.css('.use-entropy'))
2825 .click();
2826 driver.findElement(By.css('.entropy'))
2827 .sendKeys(entropy);
2828 driver.sleep(generateDelay).then(function() {
2829 driver.findElement(By.css(".phrase"))
2830 .getAttribute("value").then(function(phrase) {
2831 var wordCount = phrase.split(/\s+/g).length;
2832 expect(wordCount).toBe(99);
2833 done();
2834 });
2835 });
2836 });
2837
2838 // Is compatible with bip32jp entropy
2839 // https://bip32jp.github.io/english/index.html
2840 // NOTES:
2841 // Is incompatible with:
2842 // base 20
2843 it('Is compatible with bip32jp.github.io', function(done) {
2844 var entropy = "543210543210543210543210543210543210543210543210543210543210543210543210543210543210543210543210543";
2845 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";
2846 driver.findElement(By.css('.use-entropy'))
2847 .click();
2848 driver.findElement(By.css('.entropy'))
2849 .sendKeys(entropy);
2850 driver.sleep(generateDelay).then(function() {
2851 driver.findElement(By.css(".phrase"))
2852 .getAttribute("value").then(function(phrase) {
2853 expect(phrase).toBe(expectedPhrase);
2854 done();
2855 });
2856 });
2857 });
2858
2859 // Blank entropy does not generate mnemonic or addresses
2860 it('Does not generate mnemonic for blank entropy', function(done) {
2861 driver.findElement(By.css('.use-entropy'))
2862 .click();
2863 driver.findElement(By.css('.entropy'))
2864 .clear();
2865 // check there is no mnemonic
2866 driver.sleep(generateDelay).then(function() {
2867 driver.findElement(By.css(".phrase"))
2868 .getAttribute("value").then(function(phrase) {
2869 expect(phrase).toBe("");
2870 // check there is no mnemonic
2871 driver.findElements(By.css(".address"))
2872 .then(function(addresses) {
2873 expect(addresses.length).toBe(0);
2874 // Check the feedback says 'blank entropy'
2875 driver.findElement(By.css(".feedback"))
2876 .getText()
2877 .then(function(feedbackText) {
2878 expect(feedbackText).toBe("Blank entropy");
2879 done();
2880 });
2881 })
2882 });
2883 });
2884 });
2885
2886 // Mnemonic length can be selected even for weak entropy
2887 it('Allows selection of mnemonic length even for weak entropy', function(done) {
2888 driver.findElement(By.css('.use-entropy'))
2889 .click();
2890 driver.executeScript(function() {
2891 $(".mnemonic-length").val("18").trigger("change");
2892 });
2893 driver.findElement(By.css('.entropy'))
2894 .sendKeys("012345");
2895 driver.sleep(generateDelay).then(function() {
2896 driver.findElement(By.css(".phrase"))
2897 .getAttribute("value").then(function(phrase) {
2898 var wordCount = phrase.split(/\s+/g).length;
2899 expect(wordCount).toBe(18);
2900 done();
2901 });
2902 });
2903 });
2904
2905 // Github issue 33
2906 // https://github.com/iancoleman/bip39/issues/33
2907 // Final cards should contribute entropy
2908 it('Uses as much entropy as possible for the mnemonic', function(done) {
2909 driver.findElement(By.css('.use-entropy'))
2910 .click();
2911 driver.findElement(By.css('.entropy'))
2912 .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");
2913 driver.sleep(generateDelay).then(function() {
2914 // Get mnemonic
2915 driver.findElement(By.css(".phrase"))
2916 .getAttribute("value").then(function(originalPhrase) {
2917 // Set the last 12 cards to be AS
2918 driver.findElement(By.css('.entropy'))
2919 .clear();
2920 driver.findElement(By.css('.entropy'))
2921 .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");
2922 driver.sleep(generateDelay).then(function() {
2923 // Get new mnemonic
2924 driver.findElement(By.css(".phrase"))
2925 .getAttribute("value").then(function(newPhrase) {
2926 expect(originalPhrase).not.toEqual(newPhrase);
2927 done();
2928 });
2929 });
2930 });
2931 });
2932 });
2933
2934 // Github issue 35
2935 // https://github.com/iancoleman/bip39/issues/35
2936 // QR Code support
2937 // TODO this doesn't work in selenium with firefox
2938 // see https://stackoverflow.com/q/40360223
2939 it('Shows a qr code on hover for the phrase', function(done) {
2940 if (browser == "firefox") {
2941 pending("Selenium + Firefox bug for mouseMove, see https://stackoverflow.com/q/40360223");
2942 }
2943 // generate a random mnemonic
2944 var generateEl = driver.findElement(By.css('.generate'));
2945 generateEl.click();
2946 // toggle qr to show (hidden by default)
2947 var phraseEl = driver.findElement(By.css(".phrase"));
2948 phraseEl.click();
2949 var rootKeyEl = driver.findElement(By.css(".root-key"));
2950 driver.sleep(generateDelay).then(function() {
2951 // hover over the root key
2952 driver.actions().mouseMove(rootKeyEl).perform().then(function() {
2953 // check the qr code shows
2954 driver.executeScript(function() {
2955 return $(".qr-container").find("canvas").length > 0;
2956 })
2957 .then(function(qrShowing) {
2958 expect(qrShowing).toBe(true);
2959 // hover away from the phrase
2960 driver.actions().mouseMove(generateEl).perform().then(function() {;
2961 // check the qr code hides
2962 driver.executeScript(function() {
2963 return $(".qr-container").find("canvas").length == 0;
2964 })
2965 .then(function(qrHidden) {
2966 expect(qrHidden).toBe(true);
2967 done();
2968 });
2969 });
2970 });
2971 });
2972 });
2973 });
2974
2975 // BIP44 account extendend private key is shown
2976 // github issue 37 - compatibility with electrum
2977 it('Shows the bip44 account extended private key', function(done) {
2978 driver.findElement(By.css(".phrase"))
2979 .sendKeys("abandon abandon ability");
2980 driver.sleep(generateDelay).then(function() {
2981 driver.findElement(By.css("#bip44 .account-xprv"))
2982 .getAttribute("value")
2983 .then(function(xprv) {
2984 expect(xprv).toBe("xprv9yzrnt4zWVJUr1k2VxSPy9ettKz5PpeDMgaVG7UKedhqnw1tDkxP2UyYNhuNSumk2sLE5ctwKZs9vwjsq3e1vo9egCK6CzP87H2cVYXpfwQ");
2985 done();
2986 });
2987 });
2988 });
2989
2990 // BIP44 account extendend public key is shown
2991 // github issue 37 - compatibility with electrum
2992 it('Shows the bip44 account extended public key', function(done) {
2993 driver.findElement(By.css(".phrase"))
2994 .sendKeys("abandon abandon ability");
2995 driver.sleep(generateDelay).then(function() {
2996 driver.findElement(By.css("#bip44 .account-xpub"))
2997 .getAttribute("value")
2998 .then(function(xprv) {
2999 expect(xprv).toBe("xpub6CzDCPbtLrrn4VpVbyyQLHbdSMpZoHN4iuW64VswCyEpfjM2mJGdaHJ2DyuZwtst96E16VvcERb8BBeJdHSCVmAq9RhtRQg6eAZFrTKCNqf");
3000 done();
3001 });
3002 });
3003 });
3004
3005 // github issue 40
3006 // BIP32 root key can be set as an xpub
3007 it('Generates addresses from xpub as bip32 root key', function(done) {
3008 driver.findElement(By.css('#bip32-tab a'))
3009 .click();
3010 // set xpub for account 0 of bip44 for 'abandon abandon ability'
3011 driver.findElement(By.css("#root-key"))
3012 .sendKeys("xpub6CzDCPbtLrrn4VpVbyyQLHbdSMpZoHN4iuW64VswCyEpfjM2mJGdaHJ2DyuZwtst96E16VvcERb8BBeJdHSCVmAq9RhtRQg6eAZFrTKCNqf");
3013 driver.sleep(generateDelay).then(function() {
3014 // check the addresses are generated
3015 getFirstAddress(function(address) {
3016 expect(address).toBe("1Di3Vp7tBWtyQaDABLAjfWtF6V7hYKJtug");
3017 // check the xprv key is not set
3018 driver.findElement(By.css(".extended-priv-key"))
3019 .getAttribute("value")
3020 .then(function(xprv) {
3021 expect(xprv).toBe("NA");
3022 // check the private key is not set
3023 driver.findElements(By.css(".privkey"))
3024 .then(function(els) {
3025 els[0]
3026 .getText()
3027 .then(function(privkey) {
3028 expect(xprv).toBe("NA");
3029 done();
3030 });
3031 });
3032 });
3033 });
3034 });
3035 });
3036
3037 // github issue 40
3038 // xpub for bip32 root key will not work with hardened derivation paths
3039 it('Shows error for hardened derivation paths with xpub root key', function(done) {
3040 // set xpub for account 0 of bip44 for 'abandon abandon ability'
3041 driver.findElement(By.css("#root-key"))
3042 .sendKeys("xpub6CzDCPbtLrrn4VpVbyyQLHbdSMpZoHN4iuW64VswCyEpfjM2mJGdaHJ2DyuZwtst96E16VvcERb8BBeJdHSCVmAq9RhtRQg6eAZFrTKCNqf");
3043 driver.sleep(feedbackDelay).then(function() {
3044 // Check feedback is correct
3045 driver.findElement(By.css('.feedback'))
3046 .getText()
3047 .then(function(feedback) {
3048 var msg = "Hardened derivation path is invalid with xpub key";
3049 expect(feedback).toBe(msg);
3050 // Check no addresses are shown
3051 driver.findElements(By.css('.addresses tr'))
3052 .then(function(rows) {
3053 expect(rows.length).toBe(0);
3054 done();
3055 });
3056 });
3057 });
3058 });
3059
3060 // github issue 39
3061 // no root key shows feedback
3062 it('Shows feedback for no root key', function(done) {
3063 // set xpub for account 0 of bip44 for 'abandon abandon ability'
3064 driver.findElement(By.css('#bip32-tab a'))
3065 .click();
3066 driver.sleep(feedbackDelay).then(function() {
3067 // Check feedback is correct
3068 driver.findElement(By.css('.feedback'))
3069 .getText()
3070 .then(function(feedback) {
3071 expect(feedback).toBe("Invalid root key");
3072 done();
3073 });
3074 });
3075 });
3076
3077 // Github issue 44
3078 // display error switching tabs while addresses are generating
3079 it('Can change details while old addresses are still being generated', function(done) {
3080 // Set to generate 199 more addresses.
3081 // This will take a long time allowing a new set of addresses to be
3082 // generated midway through this lot.
3083 // The newly generated addresses should not include any from the old set.
3084 // Any more than 199 will show an alert which needs to be accepted.
3085 driver.findElement(By.css('.rows-to-add'))
3086 .clear();
3087 driver.findElement(By.css('.rows-to-add'))
3088 .sendKeys('199');
3089 // set the prhase
3090 driver.findElement(By.css('.phrase'))
3091 .sendKeys("abandon abandon ability");
3092 driver.sleep(generateDelay).then(function() {
3093 // change tabs which should cancel the previous generating
3094 driver.findElement(By.css('.rows-to-add'))
3095 .clear();
3096 driver.findElement(By.css('.rows-to-add'))
3097 .sendKeys('20');
3098 driver.findElement(By.css('#bip32-tab a'))
3099 .click()
3100 driver.sleep(generateDelay).then(function() {
3101 driver.findElements(By.css('.index'))
3102 .then(function(els) {
3103 // check the derivation paths have the right quantity
3104 expect(els.length).toBe(20);
3105 // check the derivation paths are in order
3106 testRowsAreInCorrectOrder(done);
3107 });
3108 });
3109 });
3110 }, generateDelay + 10000);
3111
3112 // Github issue 49
3113 // padding for binary should give length with multiple of 256
3114 // hashed entropy 1111 is length 252, so requires 4 leading zeros
3115 // prior to issue 49 it would only generate 2 leading zeros, ie missing 2
3116 it('Pads hashed entropy with leading zeros', function(done) {
3117 driver.findElement(By.css('.use-entropy'))
3118 .click();
3119 driver.executeScript(function() {
3120 $(".mnemonic-length").val("15").trigger("change");
3121 });
3122 driver.findElement(By.css('.entropy'))
3123 .sendKeys("1111");
3124 driver.sleep(generateDelay).then(function() {
3125 driver.findElement(By.css('.phrase'))
3126 .getAttribute("value")
3127 .then(function(phrase) {
3128 expect(phrase).toBe("avocado valid quantum cross link predict excuse edit street able flame large galaxy ginger nuclear");
3129 done();
3130 });
3131 });
3132 });
3133
3134 // Github pull request 55
3135 // https://github.com/iancoleman/bip39/pull/55
3136 // Client select
3137 it('Can set the derivation path on bip32 tab for bitcoincore', function(done) {
3138 testClientSelect(done, {
3139 selectValue: "0",
3140 bip32path: "m/0'/0'",
3141 useHardenedAddresses: "true",
3142 });
3143 });
3144 it('Can set the derivation path on bip32 tab for multibit', function(done) {
3145 testClientSelect(done, {
3146 selectValue: "2",
3147 bip32path: "m/0'/0",
3148 useHardenedAddresses: null,
3149 });
3150 });
3151 it('Can set the derivation path on bip32 tab for coinomi/ledger', function(done) {
3152 testClientSelect(done, {
3153 selectValue: "3",
3154 bip32path: "m/44'/0'/0'",
3155 useHardenedAddresses: null,
3156 });
3157 });
3158
3159 // github issue 58
3160 // https://github.com/iancoleman/bip39/issues/58
3161 // bip32 derivation is correct, does not drop leading zeros
3162 // see also
3163 // https://medium.com/@alexberegszaszi/why-do-my-bip32-wallets-disagree-6f3254cc5846
3164 it('Retains leading zeros for bip32 derivation', function(done) {
3165 driver.findElement(By.css(".phrase"))
3166 .sendKeys("fruit wave dwarf banana earth journey tattoo true farm silk olive fence");
3167 driver.findElement(By.css(".passphrase"))
3168 .sendKeys("banana");
3169 driver.sleep(generateDelay).then(function() {
3170 getFirstAddress(function(address) {
3171 // Note that bitcore generates an incorrect address
3172 // 13EuKhffWkBE2KUwcbkbELZb1MpzbimJ3Y
3173 // see the medium.com link above for more details
3174 expect(address).toBe("17rxURoF96VhmkcEGCj5LNQkmN9HVhWb7F");
3175 done();
3176 });
3177 });
3178 });
3179
3180 // github issue 60
3181 // Japanese mnemonics generate incorrect bip32 seed
3182 // BIP39 seed is set from phrase
3183 it('Generates correct seed for Japanese mnemonics', function(done) {
3184 driver.findElement(By.css(".phrase"))
3185 .sendKeys("あいこくしん あいこくしん あいこくしん あいこくしん あいこくしん あいこくしん あいこくしん あいこくしん あいこくしん あいこくしん あいこくしん あおぞら");
3186 driver.findElement(By.css(".passphrase"))
3187 .sendKeys("メートルガバヴァぱばぐゞちぢ十人十色");
3188 driver.sleep(generateDelay).then(function() {
3189 driver.findElement(By.css(".seed"))
3190 .getAttribute("value")
3191 .then(function(seed) {
3192 expect(seed).toBe("a262d6fb6122ecf45be09c50492b31f92e9beb7d9a845987a02cefda57a15f9c467a17872029a9e92299b5cbdf306e3a0ee620245cbd508959b6cb7ca637bd55");
3193 done();
3194 });
3195 });
3196 });
3197
3198 // BIP49 official test vectors
3199 // https://github.com/bitcoin/bips/blob/master/bip-0049.mediawiki#test-vectors
3200 it('Generates BIP49 addresses matching the official test vectors', function(done) {
3201 driver.findElement(By.css('#bip49-tab a'))
3202 .click();
3203 selectNetwork("BTC - Bitcoin Testnet");
3204 driver.findElement(By.css(".phrase"))
3205 .sendKeys("abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon about");
3206 driver.sleep(generateDelay).then(function() {
3207 getFirstAddress(function(address) {
3208 expect(address).toBe("2Mww8dCYPUpKHofjgcXcBCEGmniw9CoaiD2");
3209 done();
3210 });
3211 });
3212 });
3213
3214 // BIP49 derivation path is shown
3215 it('Shows the bip49 derivation path', function(done) {
3216 driver.findElement(By.css('#bip49-tab a'))
3217 .click();
3218 driver.findElement(By.css(".phrase"))
3219 .sendKeys("abandon abandon ability");
3220 driver.sleep(generateDelay).then(function() {
3221 driver.findElement(By.css('#bip49 .path'))
3222 .getAttribute("value")
3223 .then(function(path) {
3224 expect(path).toBe("m/49'/0'/0'/0");
3225 done();
3226 });
3227 });
3228 });
3229
3230 // BIP49 extended private key is shown
3231 it('Shows the bip49 extended private key', function(done) {
3232 driver.findElement(By.css('#bip49-tab a'))
3233 .click();
3234 driver.findElement(By.css(".phrase"))
3235 .sendKeys("abandon abandon ability");
3236 driver.sleep(generateDelay).then(function() {
3237 driver.findElement(By.css('.extended-priv-key'))
3238 .getAttribute("value")
3239 .then(function(xprv) {
3240 expect(xprv).toBe("yprvALYB4DYRG6CzzVgzQZwwqjAA2wjBGC3iEd7KYYScpoDdmf75qMRWZWxoFcRXBJjgEXdFqJ9vDRGRLJQsrL22Su5jMbNFeM9vetaGVqy9Qy2");
3241 done();
3242 });
3243 });
3244 });
3245
3246 // BIP49 extended public key is shown
3247 it('Shows the bip49 extended public key', function(done) {
3248 driver.findElement(By.css('#bip49-tab a'))
3249 .click();
3250 driver.findElement(By.css(".phrase"))
3251 .sendKeys("abandon abandon ability");
3252 driver.sleep(generateDelay).then(function() {
3253 driver.findElement(By.css('.extended-pub-key'))
3254 .getAttribute("value")
3255 .then(function(xprv) {
3256 expect(xprv).toBe("ypub6ZXXTj5K6TmJCymTWbUxCs6tayZffemZbr2vLvrEP8kceTSENtjm7KHH6thvAKxVar9fGe8rgsPEX369zURLZ68b4f7Vexz7RuXsjQ69YDt");
3257 done();
3258 });
3259 });
3260 });
3261
3262 // BIP49 account field changes address list
3263 it('Can set the bip49 account field', function(done) {
3264 driver.findElement(By.css('#bip49-tab a'))
3265 .click();
3266 driver.findElement(By.css('#bip49 .account'))
3267 .clear();
3268 driver.findElement(By.css('#bip49 .account'))
3269 .sendKeys("1");
3270 driver.findElement(By.css(".phrase"))
3271 .sendKeys("abandon abandon ability");
3272 driver.sleep(generateDelay).then(function() {
3273 getFirstAddress(function(address) {
3274 expect(address).toBe("381wg1GGN4rP88rNC9v7QWsiww63yLVPsn");
3275 done();
3276 });
3277 });
3278 });
3279
3280 // BIP49 change field changes address list
3281 it('Can set the bip49 change field', function(done) {
3282 driver.findElement(By.css('#bip49-tab a'))
3283 .click();
3284 driver.findElement(By.css('#bip49 .change'))
3285 .clear();
3286 driver.findElement(By.css('#bip49 .change'))
3287 .sendKeys("1");
3288 driver.findElement(By.css(".phrase"))
3289 .sendKeys("abandon abandon ability");
3290 driver.sleep(generateDelay).then(function() {
3291 getFirstAddress(function(address) {
3292 expect(address).toBe("3PEM7MiKed5konBoN66PQhK8r3hjGhy9dT");
3293 done();
3294 });
3295 });
3296 });
3297
3298 // BIP49 account extendend private key is shown
3299 it('Shows the bip49 account extended private key', function(done) {
3300 driver.findElement(By.css('#bip49-tab a'))
3301 .click();
3302 driver.findElement(By.css(".phrase"))
3303 .sendKeys("abandon abandon ability");
3304 driver.sleep(generateDelay).then(function() {
3305 driver.findElement(By.css('#bip49 .account-xprv'))
3306 .getAttribute("value")
3307 .then(function(xprv) {
3308 expect(xprv).toBe("yprvAHtB1M5Wp675aLzFy9TJYK2mSsLkg6mcBRh5DZTR7L4EnYSmYPaL63KFA4ycg1PngW5LfkmejxzosCs17TKZMpRFKc3z5SJar6QAKaFcaZL");
3309 done();
3310 });
3311 });
3312 });
3313
3314 // BIP49 account extendend public key is shown
3315 it('Shows the bip49 account extended public key', function(done) {
3316 driver.findElement(By.css('#bip49-tab a'))
3317 .click();
3318 driver.findElement(By.css(".phrase"))
3319 .sendKeys("abandon abandon ability");
3320 driver.sleep(generateDelay).then(function() {
3321 driver.findElement(By.css('#bip49 .account-xpub'))
3322 .getAttribute("value")
3323 .then(function(xprv) {
3324 expect(xprv).toBe("ypub6WsXQrcQeTfNnq4j5AzJuSyVzuBF5ZVTYecg1ws2ffbDfLmv5vtadqdj1NgR6C6gufMpMfJpHxvb6JEQKvETVNWCRanNedfJtnTchZiJtsL");
3325 done();
3326 });
3327 });
3328 });
3329
3330 // Test selecting coin where bip49 is unavailable (eg CLAM)
3331 it('Shows an error on bip49 tab for coins without bip49', function(done) {
3332 driver.findElement(By.css('#bip49-tab a'))
3333 .click();
3334 driver.findElement(By.css(".phrase"))
3335 .sendKeys("abandon abandon ability");
3336 driver.sleep(generateDelay).then(function() {
3337 selectNetwork("CLAM - Clams");
3338 // bip49 available is hidden
3339 driver.findElement(By.css('#bip49 .available'))
3340 .getAttribute("class")
3341 .then(function(classes) {
3342 expect(classes).toContain("hidden");
3343 // bip49 unavailable is shown
3344 driver.findElement(By.css('#bip49 .unavailable'))
3345 .getAttribute("class")
3346 .then(function(classes) {
3347 expect(classes).not.toContain("hidden");
3348 // check there are no addresses shown
3349 driver.findElements(By.css('.addresses tr'))
3350 .then(function(rows) {
3351 expect(rows.length).toBe(0);
3352 // check the derived private key is blank
3353 driver.findElement(By.css('.extended-priv-key'))
3354 .getAttribute("value")
3355 .then(function(xprv) {
3356 expect(xprv).toBe('');
3357 // check the derived public key is blank
3358 driver.findElement(By.css('.extended-pub-key'))
3359 .getAttribute("value")
3360 .then(function(xpub) {
3361 expect(xpub).toBe('');
3362 done();
3363 });
3364 });
3365 })
3366 });
3367 });
3368 });
3369 });
3370
3371 // github issue 43
3372 // Cleared mnemonic and root key still allows addresses to be generated
3373 // https://github.com/iancoleman/bip39/issues/43
3374 it('Clears old root keys from memory when mnemonic is cleared', function(done) {
3375 // set the phrase
3376 driver.findElement(By.css(".phrase"))
3377 .sendKeys("abandon abandon ability");
3378 driver.sleep(generateDelay).then(function() {
3379 // clear the mnemonic and root key
3380 // using selenium .clear() doesn't seem to trigger the 'input' event
3381 // so clear it using keys instead
3382 driver.findElement(By.css('.phrase'))
3383 .sendKeys(Key.CONTROL,"a");
3384 driver.findElement(By.css('.phrase'))
3385 .sendKeys(Key.DELETE);
3386 driver.findElement(By.css('.root-key'))
3387 .sendKeys(Key.CONTROL,"a");
3388 driver.findElement(By.css('.root-key'))
3389 .sendKeys(Key.DELETE);
3390 driver.sleep(generateDelay).then(function() {
3391 // try to generate more addresses
3392 driver.findElement(By.css('.more'))
3393 .click();
3394 driver.sleep(generateDelay).then(function() {
3395 driver.findElements(By.css(".addresses tr"))
3396 .then(function(els) {
3397 // check there are no addresses shown
3398 expect(els.length).toBe(0);
3399 done();
3400 });
3401 });
3402 });
3403 });
3404 });
3405
3406 // Github issue 95
3407 // error trying to generate addresses from xpub with hardened derivation
3408 it('Shows error for hardened addresses with xpub root key', function(done) {
3409 driver.findElement(By.css('#bip32-tab a'))
3410 .click()
3411 driver.executeScript(function() {
3412 $(".hardened-addresses").prop("checked", true);
3413 });
3414 // set xpub for account 0 of bip44 for 'abandon abandon ability'
3415 driver.findElement(By.css("#root-key"))
3416 .sendKeys("xpub6CzDCPbtLrrn4VpVbyyQLHbdSMpZoHN4iuW64VswCyEpfjM2mJGdaHJ2DyuZwtst96E16VvcERb8BBeJdHSCVmAq9RhtRQg6eAZFrTKCNqf");
3417 driver.sleep(feedbackDelay).then(function() {
3418 // Check feedback is correct
3419 driver.findElement(By.css('.feedback'))
3420 .getText()
3421 .then(function(feedback) {
3422 var msg = "Hardened derivation path is invalid with xpub key";
3423 expect(feedback).toBe(msg);
3424 done();
3425 });
3426 });
3427 });
3428
3429 // Litecoin uses ltub by default, and can optionally be set to xprv
3430 // github issue 96
3431 // https://github.com/iancoleman/bip39/issues/96
3432 // Issue with extended keys on Litecoin
3433 it('Uses ltub by default for litecoin, but can be set to xprv', function(done) {