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