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