]>
git.immae.eu Git - perso/Immae/Projets/Cryptomonnaies/BIP39.git/blob - tests.js
2 // $ phantomjs tests.js
5 var page
= require('webpage').create();
6 var url
= 'src/index.html';
7 var testMaxTime
= 5000;
9 page
.onResourceError = function(e
) {
10 console
.log("Error loading " + e
.url
);
15 console
.log("Failed");
19 function waitForGenerate(fn
, maxTime
) {
21 maxTime
= testMaxTime
;
23 var start
= new Date().getTime();
24 var prevAddressCount
= -1;
25 var wait
= function keepWaiting() {
26 var now
= new Date().getTime();
27 var hasTimedOut
= now
- start
> maxTime
;
28 var addressCount
= page
.evaluate(function() {
29 return $(".address").length
;
31 var hasFinished
= addressCount
> 0 && addressCount
== prevAddressCount
;
32 prevAddressCount
= addressCount
;
36 else if (hasTimedOut
) {
37 console
.log("Test timed out");
41 setTimeout(keepWaiting
, 100);
48 if (tests
.length
> 0) {
49 var testsStr
= tests
.length
== 1 ? "test" : "tests";
50 console
.log(tests
.length
+ " " + testsStr
+ " remaining");
54 console
.log("Finished with 0 failures");
60 * Randomize array element order in-place.
61 * Using Durstenfeld shuffle algorithm.
62 * See http://stackoverflow.com/a/12646864
64 function shuffle(array
) {
65 for (var i
= array
.length
- 1; i
> 0; i
--) {
66 var j
= Math
.floor(Math
.random() * (i
+ 1));
76 // Page loads with status of 'success'
78 page
.open(url
, function(status
) {
79 if (status
!= "success") {
80 console
.log("Page did not load with status 'success'");
89 page
.open(url
, function(status
) {
90 var content
= page
.evaluate(function() {
91 return document
.body
.textContent
.trim();
94 console
.log("Page does not have text");
101 // Entering mnemonic generates addresses
103 page
.open(url
, function(status
) {
105 page
.evaluate(function() {
106 $(".phrase").val("abandon abandon ability").trigger("input");
109 waitForGenerate(function() {
110 var addressCount
= page
.evaluate(function() {
111 return $(".address").length
;
113 if (addressCount
!= 20) {
114 console
.log("Mnemonic did not generate addresses");
115 console
.log("Expected: " + expected
);
116 console
.log("Got: " + actual
);
124 // Random button generates random mnemonic
126 page
.open(url
, function(status
) {
127 // check initial phrase is empty
128 var phrase
= page
.evaluate(function() {
129 return $(".phrase").text();
132 console
.log("Initial phrase is not blank");
135 // press the 'generate' button
136 page
.evaluate(function() {
137 $(".generate").click();
139 // get the new phrase
140 waitForGenerate(function() {
141 var phrase
= page
.evaluate(function() {
142 return $(".phrase").val();
144 if (phrase
.length
<= 0) {
145 console
.log("Phrase not generated by pressing button");
153 // Mnemonic length can be customized
155 page
.open(url
, function(status
) {
156 // set the length to 6
157 var expectedLength
= "6";
158 page
.evaluate(function() {
159 $(".strength option[selected]").removeAttr("selected");
160 $(".strength option[value=6]").prop("selected", true);
162 // press the 'generate' button
163 page
.evaluate(function() {
164 $(".generate").click();
166 // check the new phrase is six words long
167 waitForGenerate(function() {
168 var actualLength
= page
.evaluate(function() {
169 var words
= $(".phrase").val().split(" ");
172 if (actualLength
!= expectedLength
) {
173 console
.log("Phrase not generated with correct length");
174 console
.log("Expected: " + expectedLength
);
175 console
.log("Actual: " + actualLength
);
183 // Passphrase can be set
185 page
.open(url
, function(status
) {
186 // set the phrase and passphrase
187 var expected
= "15pJzUWPGzR7avffV9nY5by4PSgSKG9rba";
188 page
.evaluate(function() {
189 $(".phrase").val("abandon abandon ability");
190 $(".passphrase").val("secure_passphrase").trigger("input");
192 // check the address is generated correctly
193 waitForGenerate(function() {
194 var actual
= page
.evaluate(function() {
195 return $(".address:first").text();
197 if (actual
!= expected
) {
198 console
.log("Passphrase results in wrong address");
199 console
.log("Expected: " + expected
);
200 console
.log("Actual: " + actual
);
208 // Network can be set to bitcoin testnet
210 page
.open(url
, function(status
) {
211 // set the phrase and coin
212 var expected
= "mucaU5iiDaJDb69BHLeDv8JFfGiyg2nJKi";
213 page
.evaluate(function() {
214 $(".phrase").val("abandon abandon ability");
215 $(".phrase").trigger("input");
216 $(".network option[selected]").removeAttr("selected");
217 $(".network option[value=1]").prop("selected", true);
218 $(".network").trigger("change");
220 // check the address is generated correctly
221 waitForGenerate(function() {
222 var actual
= page
.evaluate(function() {
223 return $(".address:first").text();
225 if (actual
!= expected
) {
226 console
.log("Bitcoin testnet address is incorrect");
227 console
.log("Expected: " + expected
);
228 console
.log("Actual: " + actual
);
236 // Network can be set to litecoin
238 page
.open(url
, function(status
) {
239 // set the phrase and coin
240 var expected
= "LQ4XU8RX2ULPmPq9FcUHdVmPVchP9nwXdn";
241 page
.evaluate(function() {
242 $(".phrase").val("abandon abandon ability");
243 $(".phrase").trigger("input");
244 $(".network option[selected]").removeAttr("selected");
245 $(".network option[value=2]").prop("selected", true);
246 $(".network").trigger("change");
248 // check the address is generated correctly
249 waitForGenerate(function() {
250 var actual
= page
.evaluate(function() {
251 return $(".address:first").text();
253 if (actual
!= expected
) {
254 console
.log("Litecoin address is incorrect");
255 console
.log("Expected: " + expected
);
256 console
.log("Actual: " + actual
);
264 // Network can be set to dogecoin
266 page
.open(url
, function(status
) {
267 // set the phrase and coin
268 var expected
= "DPQH2AtuzkVSG6ovjKk4jbUmZ6iXLpgbJA";
269 page
.evaluate(function() {
270 $(".phrase").val("abandon abandon ability");
271 $(".phrase").trigger("input");
272 $(".network option[selected]").removeAttr("selected");
273 $(".network option[value=3]").prop("selected", true);
274 $(".network").trigger("change");
276 // check the address is generated correctly
277 waitForGenerate(function() {
278 var actual
= page
.evaluate(function() {
279 return $(".address:first").text();
281 if (actual
!= expected
) {
282 console
.log("Dogecoin address is incorrect");
283 console
.log("Expected: " + expected
);
284 console
.log("Actual: " + actual
);
292 // Network can be set to shadowcash
294 page
.open(url
, function(status
) {
295 // set the phrase and coin
296 var expected
= "SiSZtfYAXEFvMm3XM8hmtkGDyViRwErtCG";
297 page
.evaluate(function() {
298 $(".phrase").val("abandon abandon ability");
299 $(".phrase").trigger("input");
300 $(".network option[selected]").removeAttr("selected");
301 $(".network option[value=4]").prop("selected", true);
302 $(".network").trigger("change");
304 // check the address is generated correctly
305 waitForGenerate(function() {
306 var actual
= page
.evaluate(function() {
307 return $(".address:first").text();
309 if (actual
!= expected
) {
310 console
.log("Shadowcash address is incorrect");
311 console
.log("Expected: " + expected
);
312 console
.log("Actual: " + actual
);
320 // Network can be set to shadowcash testnet
322 page
.open(url
, function(status
) {
323 // set the phrase and coin
324 var expected
= "tM2EDpVKaTiEg2NZg3yKg8eqjLr55BErHe";
325 page
.evaluate(function() {
326 $(".phrase").val("abandon abandon ability");
327 $(".phrase").trigger("input");
328 $(".network option[selected]").removeAttr("selected");
329 $(".network option[value=5]").prop("selected", true);
330 $(".network").trigger("change");
332 // check the address is generated correctly
333 waitForGenerate(function() {
334 var actual
= page
.evaluate(function() {
335 return $(".address:first").text();
337 if (actual
!= expected
) {
338 console
.log("Shadowcash testnet address is incorrect");
339 console
.log("Expected: " + expected
);
340 console
.log("Actual: " + actual
);
348 // Network can be set to viacoin
350 page
.open(url
, function(status
) {
351 // set the phrase and coin
352 var expected
= "Vq9Eq4N5SQnjqZvxtxzo7hZPW5XnyJsmXT";
353 page
.evaluate(function() {
354 $(".phrase").val("abandon abandon ability");
355 $(".phrase").trigger("input");
356 $(".network option[selected]").removeAttr("selected");
357 $(".network option[value=6]").prop("selected", true);
358 $(".network").trigger("change");
360 // check the address is generated correctly
361 waitForGenerate(function() {
362 var actual
= page
.evaluate(function() {
363 return $(".address:first").text();
365 if (actual
!= expected
) {
366 console
.log("Viacoin address is incorrect");
367 console
.log("Expected: " + expected
);
368 console
.log("Actual: " + actual
);
376 // Network can be set to viacoin testnet
378 page
.open(url
, function(status
) {
379 // set the phrase and coin
380 var expected
= "tM2EDpVKaTiEg2NZg3yKg8eqjLr55BErHe";
381 page
.evaluate(function() {
382 $(".phrase").val("abandon abandon ability");
383 $(".phrase").trigger("input");
384 $(".network option[selected]").removeAttr("selected");
385 $(".network option[value=7]").prop("selected", true);
386 $(".network").trigger("change");
388 // check the address is generated correctly
389 waitForGenerate(function() {
390 var actual
= page
.evaluate(function() {
391 return $(".address:first").text();
393 if (actual
!= expected
) {
394 console
.log("Viacoin testnet address is incorrect");
395 console
.log("Expected: " + expected
);
396 console
.log("Actual: " + actual
);
404 // Network can be set to jumbucks
406 page
.open(url
, function(status
) {
407 // set the phrase and coin
408 var expected
= "JLEXccwDXADK4RxBPkRez7mqsHVoJBEUew";
409 page
.evaluate(function() {
410 $(".phrase").val("abandon abandon ability");
411 $(".phrase").trigger("input");
412 $(".network option[selected]").removeAttr("selected");
413 $(".network option[value=8]").prop("selected", true);
414 $(".network").trigger("change");
416 // check the address is generated correctly
417 waitForGenerate(function() {
418 var actual
= page
.evaluate(function() {
419 return $(".address:first").text();
421 if (actual
!= expected
) {
422 console
.log("Jumbucks address is incorrect");
423 console
.log("Expected: " + expected
);
424 console
.log("Actual: " + actual
);
432 // Network can be set to clam
434 page
.open(url
, function(status
) {
435 // set the phrase and coin
436 var expected
= "xCp4sakjVx4pUAZ6cBCtuin8Ddb6U1sk9y";
437 page
.evaluate(function() {
438 $(".phrase").val("abandon abandon ability");
439 $(".phrase").trigger("input");
440 $(".network option[selected]").removeAttr("selected");
441 $(".network option[value=9]").prop("selected", true);
442 $(".network").trigger("change");
444 // check the address is generated correctly
445 waitForGenerate(function() {
446 var actual
= page
.evaluate(function() {
447 return $(".address:first").text();
449 if (actual
!= expected
) {
450 console
.log("CLAM address is incorrect");
451 console
.log("Expected: " + expected
);
452 console
.log("Actual: " + actual
);
460 // BIP39 seed is set from phrase
462 page
.open(url
, function(status
) {
464 var expected
= "20da140d3dd1df8713cefcc4d54ce0e445b4151027a1ab567b832f6da5fcc5afc1c3a3f199ab78b8e0ab4652efd7f414ac2c9a3b81bceb879a70f377aa0a58f3";
465 page
.evaluate(function() {
466 $(".phrase").val("abandon abandon ability");
467 $(".phrase").trigger("input");
469 // check the address is generated correctly
470 waitForGenerate(function() {
471 var actual
= page
.evaluate(function() {
472 return $(".seed").val();
474 if (actual
!= expected
) {
475 console
.log("BIP39 seed is incorrectly generated from mnemonic");
476 console
.log("Expected: " + expected
);
477 console
.log("Actual: " + actual
);
485 // BIP32 root key is set from phrase
487 page
.open(url
, function(status
) {
489 var expected
= "xprv9s21ZrQH143K2jkGDCeTLgRewT9F2pH5JZs2zDmmjXes34geVnFiuNa8KTvY5WoYvdn4Ag6oYRoB6cXtc43NgJAEqDXf51xPm6fhiMCKwpi";
490 page
.evaluate(function() {
491 $(".phrase").val("abandon abandon ability");
492 $(".phrase").trigger("input");
494 // check the address is generated correctly
495 waitForGenerate(function() {
496 var actual
= page
.evaluate(function() {
497 return $(".root-key").val();
499 if (actual
!= expected
) {
500 console
.log("Root key is incorrectly generated from mnemonic");
501 console
.log("Expected: " + expected
);
502 console
.log("Actual: " + actual
);
510 // Tabs show correct addresses when changed
512 page
.open(url
, function(status
) {
514 var expected
= "17uQ7s2izWPwBmEVFikTmZUjbBKWYdJchz";
515 page
.evaluate(function() {
516 $(".phrase").val("abandon abandon ability");
517 $(".phrase").trigger("input");
520 waitForGenerate(function() {
521 page
.evaluate(function() {
522 $("#bip32-tab a").click();
524 // check the address is generated correctly
525 waitForGenerate(function() {
526 var actual
= page
.evaluate(function() {
527 return $(".address:first").text();
529 if (actual
!= expected
) {
530 console
.log("Clicking tab generates incorrect address");
531 console
.log("Expected: " + expected
);
532 console
.log("Actual: " + actual
);
541 // BIP44 derivation path is shown
543 page
.open(url
, function(status
) {
545 var expected
= "m/44'/0'/0'/0";
546 page
.evaluate(function() {
547 $(".phrase").val("abandon abandon ability");
548 $(".phrase").trigger("input");
550 // check the derivation path of the first address
551 waitForGenerate(function() {
552 var actual
= page
.evaluate(function() {
553 return $("#bip44 .path").val();
555 if (actual
!= expected
) {
556 console
.log("BIP44 derivation path is incorrect");
557 console
.log("Expected: " + expected
);
558 console
.log("Actual: " + actual
);
566 // BIP44 extended private key is shown
568 page
.open(url
, function(status
) {
570 var expected
= "xprvA2DxxvPZcyRvYgZMGS53nadR32mVDeCyqQYyFhrCVbJNjPoxMeVf7QT5g7mQASbTf9Kp4cryvcXnu2qurjWKcrdsr91jXymdCDNxKgLFKJG";
571 page
.evaluate(function() {
572 $(".phrase").val("abandon abandon ability");
573 $(".phrase").trigger("input");
575 // check the BIP44 extended private key
576 waitForGenerate(function() {
577 var actual
= page
.evaluate(function() {
578 return $(".extended-priv-key").val();
580 if (actual
!= expected
) {
581 console
.log("BIP44 extended private key is incorrect");
582 console
.log("Expected: " + expected
);
583 console
.log("Actual: " + actual
);
591 // BIP44 extended public key is shown
593 page
.open(url
, function(status
) {
595 var expected
= "xpub6FDKNRvTTLzDmAdpNTc49ia9b4byd6vqCdUa46Fp3vqMcC96uBoufCmZXQLiN5AK3iSCJMhf9gT2sxkpyaPepRuA7W3MujV5tGmF5VfbueM";
596 page
.evaluate(function() {
597 $(".phrase").val("abandon abandon ability");
598 $(".phrase").trigger("input");
600 // check the BIP44 extended public key
601 waitForGenerate(function() {
602 var actual
= page
.evaluate(function() {
603 return $(".extended-pub-key").val();
605 if (actual
!= expected
) {
606 console
.log("BIP44 extended public key is incorrect");
607 console
.log("Expected: " + expected
);
608 console
.log("Actual: " + actual
);
616 // BIP44 purpose field changes address list
618 page
.open(url
, function(status
) {
620 var expected
= "1JbDzRJ2cDT8aat2xwKd6Pb2zzavow5MhF";
621 page
.evaluate(function() {
622 $(".phrase").val("abandon abandon ability");
623 $(".phrase").trigger("input");
625 waitForGenerate(function() {
626 // change the bip44 purpose field to 45
627 page
.evaluate(function() {
628 $("#bip44 .purpose").val("45");
629 $("#bip44 .purpose").trigger("input");
631 waitForGenerate(function() {
632 // check the address for the new derivation path
633 var actual
= page
.evaluate(function() {
634 return $(".address:first").text();
636 if (actual
!= expected
) {
637 console
.log("BIP44 purpose field generates incorrect address");
638 console
.log("Expected: " + expected
);
639 console
.log("Actual: " + actual
);
648 // BIP44 coin field changes address list
650 page
.open(url
, function(status
) {
652 var expected
= "1F6dB2djQYrxoyfZZmfr6D5voH8GkJTghk";
653 page
.evaluate(function() {
654 $(".phrase").val("abandon abandon ability");
655 $(".phrase").trigger("input");
657 waitForGenerate(function() {
658 // change the bip44 purpose field to 45
659 page
.evaluate(function() {
660 $("#bip44 .coin").val("1");
661 $("#bip44 .coin").trigger("input");
663 waitForGenerate(function() {
664 // check the address for the new derivation path
665 var actual
= page
.evaluate(function() {
666 return $(".address:first").text();
668 if (actual
!= expected
) {
669 console
.log("BIP44 coin field generates incorrect address");
670 console
.log("Expected: " + expected
);
671 console
.log("Actual: " + actual
);
680 // BIP44 account field changes address list
682 page
.open(url
, function(status
) {
684 var expected
= "1Nq2Wmu726XHCuGhctEtGmhxo3wzk5wZ1H";
685 page
.evaluate(function() {
686 $(".phrase").val("abandon abandon ability");
687 $(".phrase").trigger("input");
689 waitForGenerate(function() {
690 // change the bip44 purpose field to 45
691 page
.evaluate(function() {
692 $("#bip44 .account").val("1");
693 $("#bip44 .account").trigger("input");
695 waitForGenerate(function() {
696 // check the address for the new derivation path
697 var actual
= page
.evaluate(function() {
698 return $(".address:first").text();
700 if (actual
!= expected
) {
701 console
.log("BIP44 account field generates incorrect address");
702 console
.log("Expected: " + expected
);
703 console
.log("Actual: " + actual
);
712 // BIP44 change field changes address list
714 page
.open(url
, function(status
) {
716 var expected
= "1KAGfWgqfVbSSXY56fNQ7YnhyKuoskHtYo";
717 page
.evaluate(function() {
718 $(".phrase").val("abandon abandon ability");
719 $(".phrase").trigger("input");
721 waitForGenerate(function() {
722 // change the bip44 purpose field to 45
723 page
.evaluate(function() {
724 $("#bip44 .change").val("1");
725 $("#bip44 .change").trigger("input");
727 waitForGenerate(function() {
728 // check the address for the new derivation path
729 var actual
= page
.evaluate(function() {
730 return $(".address:first").text();
732 if (actual
!= expected
) {
733 console
.log("BIP44 change field generates incorrect address");
734 console
.log("Expected: " + expected
);
735 console
.log("Actual: " + actual
);
744 // BIP32 derivation path can be set
746 page
.open(url
, function(status
) {
748 var expected
= "16pYQQdLD1hH4hwTGLXBaZ9Teboi1AGL8L";
749 page
.evaluate(function() {
750 $(".phrase").val("abandon abandon ability");
751 $(".phrase").trigger("input");
754 waitForGenerate(function() {
755 page
.evaluate(function() {
756 $("#bip32-tab a").click();
758 // set the derivation path to m/1
759 waitForGenerate(function() {
760 page
.evaluate(function() {
761 $("#bip32 .path").val("m/1");
762 $("#bip32 .path").trigger("input");
764 // check the address is generated correctly
765 waitForGenerate(function() {
766 var actual
= page
.evaluate(function() {
767 return $(".address:first").text();
769 if (actual
!= expected
) {
770 console
.log("Custom BIP32 path generates incorrect address");
771 console
.log("Expected: " + expected
);
772 console
.log("Actual: " + actual
);
782 // BIP32 can use hardened derivation paths
784 page
.open(url
, function(status
) {
786 var expected
= "14aXZeprXAE3UUKQc4ihvwBvww2LuEoHo4";
787 page
.evaluate(function() {
788 $(".phrase").val("abandon abandon ability");
789 $(".phrase").trigger("input");
792 waitForGenerate(function() {
793 page
.evaluate(function() {
794 $("#bip32-tab a").click();
796 // set the derivation path to m/0'
797 waitForGenerate(function() {
798 page
.evaluate(function() {
799 $("#bip32 .path").val("m/0'");
800 $("#bip32 .path").trigger("input");
802 // check the address is generated correctly
803 waitForGenerate(function() {
804 var actual
= page
.evaluate(function() {
805 return $(".address:first").text();
807 if (actual
!= expected
) {
808 console
.log("Hardened BIP32 path generates incorrect address");
809 console
.log("Expected: " + expected
);
810 console
.log("Actual: " + actual
);
820 // BIP32 extended private key is shown
822 page
.open(url
, function(status
) {
824 var expected
= "xprv9va99uTVE5aLiutUVLTyfxfe8v8aaXjSQ1XxZbK6SezYVuikA9MnjQVTA8rQHpNA5LKvyQBpLiHbBQiiccKiBDs7eRmBogsvq3THFeLHYbe";
825 page
.evaluate(function() {
826 $(".phrase").val("abandon abandon ability");
827 $(".phrase").trigger("input");
830 waitForGenerate(function() {
831 page
.evaluate(function() {
832 $("#bip32-tab a").click();
834 // check the extended private key is generated correctly
835 waitForGenerate(function() {
836 var actual
= page
.evaluate(function() {
837 return $(".extended-priv-key").val();
839 if (actual
!= expected
) {
840 console
.log("BIP32 extended private key is incorrect");
841 console
.log("Expected: " + expected
);
842 console
.log("Actual: " + actual
);
851 // BIP32 extended public key is shown
853 page
.open(url
, function(status
) {
855 var expected
= "xpub69ZVZQzP4T8dwPxwbMzz36cNgwy4yzTHmETZMyihzzXXNi3thgg3HCow1RtY252wdw5rS8369xKnraN5Q93y3FkFfJp2XEHWUrkyXsjS93P";
856 page
.evaluate(function() {
857 $(".phrase").val("abandon abandon ability");
858 $(".phrase").trigger("input");
861 waitForGenerate(function() {
862 page
.evaluate(function() {
863 $("#bip32-tab a").click();
865 // check the extended public key is generated correctly
866 waitForGenerate(function() {
867 var actual
= page
.evaluate(function() {
868 return $(".extended-pub-key").val();
870 if (actual
!= expected
) {
871 console
.log("BIP32 extended public key is incorrect");
872 console
.log("Expected: " + expected
);
873 console
.log("Actual: " + actual
);
882 // Derivation path is shown in table
884 page
.open(url
, function(status
) {
886 var expected
= "m/44'/0'/0'/0/0";
887 page
.evaluate(function() {
888 $(".phrase").val("abandon abandon ability");
889 $(".phrase").trigger("input");
891 // check for derivation path in table
892 waitForGenerate(function() {
893 var actual
= page
.evaluate(function() {
894 return $(".index:first").text();
896 if (actual
!= expected
) {
897 console
.log("Derivation path shown incorrectly in table");
898 console
.log("Expected: " + expected
);
899 console
.log("Actual: " + actual
);
907 // Derivation path for address can be hardened
909 page
.open(url
, function(status
) {
911 var expected
= "18exLzUv7kfpiXRzmCjFDoC9qwNLFyvwyd";
912 page
.evaluate(function() {
913 $(".phrase").val("abandon abandon ability");
914 $(".phrase").trigger("input");
917 waitForGenerate(function() {
918 page
.evaluate(function() {
919 $("#bip32-tab a").click();
921 waitForGenerate(function() {
922 // select the hardened addresses option
923 page
.evaluate(function() {
924 $(".hardened-addresses").prop("checked", true);
925 $(".hardened-addresses").trigger("change");
927 waitForGenerate(function() {
928 // check the generated address is hardened
929 var actual
= page
.evaluate(function() {
930 return $(".address:first").text();
932 if (actual
!= expected
) {
933 console
.log("Hardened address is incorrect");
934 console
.log("Expected: " + expected
);
935 console
.log("Actual: " + actual
);
945 // Derivation path visibility can be toggled
947 page
.open(url
, function(status
) {
949 page
.evaluate(function() {
950 $(".phrase").val("abandon abandon ability");
951 $(".phrase").trigger("input");
953 // check the path is not shown
954 waitForGenerate(function() {
955 // toggle path visibility
956 page
.evaluate(function() {
957 $(".index-toggle").click();
959 // check the path is not visible
960 var isInvisible
= page
.evaluate(function() {
961 return $(".index:first span").hasClass("invisible");
964 console
.log("Toggled derivation path is visible");
974 page
.open(url
, function(status
) {
975 var expected
= "1Di3Vp7tBWtyQaDABLAjfWtF6V7hYKJtug";
977 page
.evaluate(function() {
978 $(".phrase").val("abandon abandon ability").trigger("input");
981 waitForGenerate(function() {
982 var actual
= page
.evaluate(function() {
983 return $(".address:first").text();
985 if (actual
!= expected
) {
986 console
.log("Address is not shown");
987 console
.log("Expected: " + expected
);
988 console
.log("Got: " + actual
);
996 // Addresses are shown in order of derivation path
997 // Address visibility can be toggled
998 // Private key is shown
999 // Private key visibility can be toggled
1001 // More addresses can be generated
1002 // A custom number of additional addresses can be generated
1003 // Additional addresses are shown in order of derivation path
1005 // BIP32 root key can be set by the user
1006 // Setting BIP32 root key clears the existing phrase, passphrase and seed
1007 // Clearing of phrase, passphrase and seed can be cancelled by user
1008 // Custom BIP32 root key is used when changing the derivation path
1010 // Incorrect mnemonic shows error
1011 // Incorrect word shows suggested replacement
1012 // Incorrect BIP32 root key shows error
1013 // Derivation path not starting with m shows error
1014 // Derivation path containing invalid characters shows useful error
1016 // Github Issue 11: Default word length is 15
1017 // https://github.com/dcpos/bip39/issues/11
1019 // Github Issue 12: Generate more rows with private keys hidden
1020 // https://github.com/dcpos/bip39/issues/12
1022 // Github Issue 19: Mnemonic is not sensitive to whitespace
1023 // https://github.com/dcpos/bip39/issues/19
1025 // Github Issue 23: Use correct derivation path when changing tabs
1026 // https://github.com/dcpos/bip39/issues/23
1030 console
.log("Running tests...");
1031 tests
= shuffle(tests
);