2 // $ phantomjs tests.js
5 var page
= require('webpage').create();
6 var url
= 'src/index.html';
7 var testMaxTime
= 20000;
14 page
.onResourceError = function(e
) {
15 console
.log("Error loading " + e
.url
);
20 console
.log("Failed");
24 function waitForGenerate(fn
, maxTime
) {
26 maxTime
= testMaxTime
;
28 var start
= new Date().getTime();
29 var prevAddressCount
= -1;
30 var wait
= function keepWaiting() {
31 var now
= new Date().getTime();
32 var hasTimedOut
= now
- start
> maxTime
;
33 var addressCount
= page
.evaluate(function() {
34 return $(".address").length
;
36 var hasFinished
= addressCount
> 0 && addressCount
== prevAddressCount
;
37 prevAddressCount
= addressCount
;
41 else if (hasTimedOut
) {
42 console
.log("Test timed out");
46 setTimeout(keepWaiting
, 100);
52 function waitForFeedback(fn
, maxTime
) {
54 maxTime
= testMaxTime
;
56 var start
= new Date().getTime();
57 var wait
= function keepWaiting() {
58 var now
= new Date().getTime();
59 var hasTimedOut
= now
- start
> maxTime
;
61 console
.log("Test timed out");
65 var feedback
= page
.evaluate(function() {
66 var feedback
= $(".feedback");
67 if (feedback
.css("display") == "none") {
70 return feedback
.text();
72 var hasFinished
= feedback
.length
> 0 && feedback
!= "Calculating...";
77 setTimeout(keepWaiting
, 100);
83 function waitForEntropyFeedback(fn
, maxTime
) {
85 maxTime
= testMaxTime
;
87 var origFeedback
= page
.evaluate(function() {
88 return $(".entropy-container").text();
90 var start
= new Date().getTime();
91 var wait
= function keepWaiting() {
92 var now
= new Date().getTime();
93 var hasTimedOut
= now
- start
> maxTime
;
95 console
.log("Test timed out");
99 var feedback
= page
.evaluate(function() {
100 return $(".entropy-container").text();
102 var hasFinished
= feedback
!= origFeedback
;
107 setTimeout(keepWaiting
, 100);
114 if (tests
.length
> 0) {
115 var testsStr
= tests
.length
== 1 ? "test" : "tests";
116 console
.log(tests
.length
+ " " + testsStr
+ " remaining");
120 console
.log("Finished with 0 failures");
126 * Randomize array element order in-place.
127 * Using Durstenfeld shuffle algorithm.
128 * See http://stackoverflow.com/a/12646864
130 function shuffle(array
) {
131 for (var i
= array
.length
- 1; i
> 0; i
--) {
132 var j
= Math
.floor(Math
.random() * (i
+ 1));
142 // Page loads with status of 'success'
144 page
.open(url
, function(status
) {
145 if (status
!= "success") {
146 console
.log("Page did not load with status 'success'");
155 page
.open(url
, function(status
) {
156 var content
= page
.evaluate(function() {
157 return document
.body
.textContent
.trim();
160 console
.log("Page does not have text");
167 // Entering mnemonic generates addresses
169 page
.open(url
, function(status
) {
171 page
.evaluate(function() {
172 $(".phrase").val("abandon abandon ability").trigger("input");
175 waitForGenerate(function() {
176 var addressCount
= page
.evaluate(function() {
177 return $(".address").length
;
179 if (addressCount
!= 20) {
180 console
.log("Mnemonic did not generate addresses");
181 console
.log("Expected: " + expected
);
182 console
.log("Got: " + actual
);
190 // Random button generates random mnemonic
192 page
.open(url
, function(status
) {
193 // check initial phrase is empty
194 var phrase
= page
.evaluate(function() {
195 return $(".phrase").text();
198 console
.log("Initial phrase is not blank");
201 // press the 'generate' button
202 page
.evaluate(function() {
203 $(".generate").click();
205 // get the new phrase
206 waitForGenerate(function() {
207 var phrase
= page
.evaluate(function() {
208 return $(".phrase").val();
210 if (phrase
.length
<= 0) {
211 console
.log("Phrase not generated by pressing button");
219 // Mnemonic length can be customized
221 page
.open(url
, function(status
) {
222 // set the length to 6
223 var expectedLength
= "6";
224 page
.evaluate(function() {
225 $(".strength option[selected]").removeAttr("selected");
226 $(".strength option[value=6]").prop("selected", true);
228 // press the 'generate' button
229 page
.evaluate(function() {
230 $(".generate").click();
232 // check the new phrase is six words long
233 waitForGenerate(function() {
234 var actualLength
= page
.evaluate(function() {
235 var words
= $(".phrase").val().split(" ");
238 if (actualLength
!= expectedLength
) {
239 console
.log("Phrase not generated with correct length");
240 console
.log("Expected: " + expectedLength
);
241 console
.log("Actual: " + actualLength
);
249 // Passphrase can be set
251 page
.open(url
, function(status
) {
252 // set the phrase and passphrase
253 var expected
= "15pJzUWPGzR7avffV9nY5by4PSgSKG9rba";
254 page
.evaluate(function() {
255 $(".phrase").val("abandon abandon ability");
256 $(".passphrase").val("secure_passphrase").trigger("input");
258 // check the address is generated correctly
259 waitForGenerate(function() {
260 var actual
= page
.evaluate(function() {
261 return $(".address:first").text();
263 if (actual
!= expected
) {
264 console
.log("Passphrase results in wrong address");
265 console
.log("Expected: " + expected
);
266 console
.log("Actual: " + actual
);
274 // Network can be set to bitcoin testnet
276 page
.open(url
, function(status
) {
277 // set the phrase and coin
278 var expected
= "mucaU5iiDaJDb69BHLeDv8JFfGiyg2nJKi";
279 page
.evaluate(function() {
280 $(".phrase").val("abandon abandon ability");
281 $(".phrase").trigger("input");
282 $(".network option[selected]").removeAttr("selected");
283 $(".network option").filter(function() {
284 return $(this).html() == "BTC - Bitcoin Testnet";
285 }).prop("selected", true);
286 $(".network").trigger("change");
288 // check the address is generated correctly
289 waitForGenerate(function() {
290 var actual
= page
.evaluate(function() {
291 return $(".address:first").text();
293 if (actual
!= expected
) {
294 console
.log("Bitcoin testnet address is incorrect");
295 console
.log("Expected: " + expected
);
296 console
.log("Actual: " + actual
);
304 // Network can be set to litecoin
306 page
.open(url
, function(status
) {
307 // set the phrase and coin
308 var expected
= "LQ4XU8RX2ULPmPq9FcUHdVmPVchP9nwXdn";
309 page
.evaluate(function() {
310 $(".phrase").val("abandon abandon ability");
311 $(".phrase").trigger("input");
312 $(".network option[selected]").removeAttr("selected");
313 $(".network option").filter(function() {
314 return $(this).html() == "LTC - Litecoin";
315 }).prop("selected", true);
316 $(".network").trigger("change");
318 // check the address is generated correctly
319 waitForGenerate(function() {
320 var actual
= page
.evaluate(function() {
321 return $(".address:first").text();
323 if (actual
!= expected
) {
324 console
.log("Litecoin address is incorrect");
325 console
.log("Expected: " + expected
);
326 console
.log("Actual: " + actual
);
334 // Network can be set to ripple
336 page
.open(url
, function(status
) {
337 // set the phrase and coin
338 var expected
= "rLTFnqbmCVPGx6VfaygdtuKWJgcN4v1zRS";
339 page
.evaluate(function() {
340 $(".phrase").val("ill clump only blind unit burden thing track silver cloth review awake useful craft whale all satisfy else trophy sunset walk vanish hope valve");
341 $(".phrase").trigger("input");
342 $(".network option[selected]").removeAttr("selected");
343 $(".network option").filter(function() {
344 return $(this).html() == "XRP - Ripple";
345 }).prop("selected", true);
346 $(".network").trigger("change");
348 // check the address is generated correctly
349 waitForGenerate(function() {
350 var actual
= page
.evaluate(function() {
351 return $(".address:first").text();
353 if (actual
!= expected
) {
354 console
.log("Ripple address is incorrect");
355 console
.log("Expected: " + expected
);
356 console
.log("Actual: " + actual
);
364 // Network can be set to dogecoin
366 page
.open(url
, function(status
) {
367 // set the phrase and coin
368 var expected
= "DPQH2AtuzkVSG6ovjKk4jbUmZ6iXLpgbJA";
369 page
.evaluate(function() {
370 $(".phrase").val("abandon abandon ability");
371 $(".phrase").trigger("input");
372 $(".network option[selected]").removeAttr("selected");
373 $(".network option").filter(function() {
374 return $(this).html() == "DOGE - Dogecoin";
375 }).prop("selected", true);
376 $(".network").trigger("change");
378 // check the address is generated correctly
379 waitForGenerate(function() {
380 var actual
= page
.evaluate(function() {
381 return $(".address:first").text();
383 if (actual
!= expected
) {
384 console
.log("Dogecoin address is incorrect");
385 console
.log("Expected: " + expected
);
386 console
.log("Actual: " + actual
);
394 // Network can be set to shadowcash
396 page
.open(url
, function(status
) {
397 // set the phrase and coin
398 var expected
= "SiSZtfYAXEFvMm3XM8hmtkGDyViRwErtCG";
399 page
.evaluate(function() {
400 $(".phrase").val("abandon abandon ability");
401 $(".phrase").trigger("input");
402 $(".network option[selected]").removeAttr("selected");
403 $(".network option").filter(function() {
404 return $(this).html() == "SDC - ShadowCash";
405 }).prop("selected", true);
406 $(".network").trigger("change");
408 // check the address is generated correctly
409 waitForGenerate(function() {
410 var actual
= page
.evaluate(function() {
411 return $(".address:first").text();
413 if (actual
!= expected
) {
414 console
.log("Shadowcash address is incorrect");
415 console
.log("Expected: " + expected
);
416 console
.log("Actual: " + actual
);
424 // Network can be set to shadowcash testnet
426 page
.open(url
, function(status
) {
427 // set the phrase and coin
428 var expected
= "tM2EDpVKaTiEg2NZg3yKg8eqjLr55BErHe";
429 page
.evaluate(function() {
430 $(".phrase").val("abandon abandon ability");
431 $(".phrase").trigger("input");
432 $(".network option[selected]").removeAttr("selected");
433 $(".network option").filter(function() {
434 return $(this).html() == "SDC - ShadowCash Testnet";
435 }).prop("selected", true);
436 $(".network").trigger("change");
438 // check the address is generated correctly
439 waitForGenerate(function() {
440 var actual
= page
.evaluate(function() {
441 return $(".address:first").text();
443 if (actual
!= expected
) {
444 console
.log("Shadowcash testnet address is incorrect");
445 console
.log("Expected: " + expected
);
446 console
.log("Actual: " + actual
);
454 // Network can be set to viacoin
456 page
.open(url
, function(status
) {
457 // set the phrase and coin
458 var expected
= "Vq9Eq4N5SQnjqZvxtxzo7hZPW5XnyJsmXT";
459 page
.evaluate(function() {
460 $(".phrase").val("abandon abandon ability");
461 $(".phrase").trigger("input");
462 $(".network option[selected]").removeAttr("selected");
463 $(".network option").filter(function() {
464 return $(this).html() == "VIA - Viacoin";
465 }).prop("selected", true);
466 $(".network").trigger("change");
468 // check the address is generated correctly
469 waitForGenerate(function() {
470 var actual
= page
.evaluate(function() {
471 return $(".address:first").text();
473 if (actual
!= expected
) {
474 console
.log("Viacoin address is incorrect");
475 console
.log("Expected: " + expected
);
476 console
.log("Actual: " + actual
);
484 // Network can be set to viacoin testnet
486 page
.open(url
, function(status
) {
487 // set the phrase and coin
488 var expected
= "tM2EDpVKaTiEg2NZg3yKg8eqjLr55BErHe";
489 page
.evaluate(function() {
490 $(".phrase").val("abandon abandon ability");
491 $(".phrase").trigger("input");
492 $(".network option[selected]").removeAttr("selected");
493 $(".network option").filter(function() {
494 return $(this).html() == "VIA - Viacoin Testnet";
495 }).prop("selected", true);
496 $(".network").trigger("change");
498 // check the address is generated correctly
499 waitForGenerate(function() {
500 var actual
= page
.evaluate(function() {
501 return $(".address:first").text();
503 if (actual
!= expected
) {
504 console
.log("Viacoin testnet address is incorrect");
505 console
.log("Expected: " + expected
);
506 console
.log("Actual: " + actual
);
514 // Network can be set to jumbucks
516 page
.open(url
, function(status
) {
517 // set the phrase and coin
518 var expected
= "JLEXccwDXADK4RxBPkRez7mqsHVoJBEUew";
519 page
.evaluate(function() {
520 $(".phrase").val("abandon abandon ability");
521 $(".phrase").trigger("input");
522 $(".network option[selected]").removeAttr("selected");
523 $(".network option").filter(function() {
524 return $(this).html() == "JBS - Jumbucks";
525 }).prop("selected", true);
526 $(".network").trigger("change");
528 // check the address is generated correctly
529 waitForGenerate(function() {
530 var actual
= page
.evaluate(function() {
531 return $(".address:first").text();
533 if (actual
!= expected
) {
534 console
.log("Jumbucks address is incorrect");
535 console
.log("Expected: " + expected
);
536 console
.log("Actual: " + actual
);
544 // Network can be set to clam
546 page
.open(url
, function(status
) {
547 // set the phrase and coin
548 var expected
= "xCp4sakjVx4pUAZ6cBCtuin8Ddb6U1sk9y";
549 page
.evaluate(function() {
550 $(".phrase").val("abandon abandon ability");
551 $(".phrase").trigger("input");
552 $(".network option[selected]").removeAttr("selected");
553 $(".network option").filter(function() {
554 return $(this).html() == "CLAM - Clams";
555 }).prop("selected", true);
556 $(".network").trigger("change");
558 // check the address is generated correctly
559 waitForGenerate(function() {
560 var actual
= page
.evaluate(function() {
561 return $(".address:first").text();
563 if (actual
!= expected
) {
564 console
.log("CLAM address is incorrect");
565 console
.log("Expected: " + expected
);
566 console
.log("Actual: " + actual
);
574 // Network can be set to crown
576 page
.open(url
, function(status
) {
577 // set the phrase and coin
578 var expected
= "18pWSwSUAQdiwMHUfFZB1fM2xue9X1FqE5";
579 page
.evaluate(function() {
580 $(".phrase").val("abandon abandon ability");
581 $(".phrase").trigger("input");
582 $(".network option[selected]").removeAttr("selected");
583 $(".network option").filter(function() {
584 return $(this).html() == "CRW - Crown";
585 }).prop("selected", true);
586 $(".network").trigger("change");
588 // check the address is generated correctly
589 waitForGenerate(function() {
590 var actual
= page
.evaluate(function() {
591 return $(".address:first").text();
593 if (actual
!= expected
) {
594 console
.log("CRW address is incorrect");
595 console
.log("Expected: " + expected
);
596 console
.log("Actual: " + actual
);
604 // Network can be set to dash
606 page
.open(url
, function(status
) {
607 // set the phrase and coin
608 var expected
= "XdbhtMuGsPSkE6bPdNTHoFSszQKmK4S5LT";
609 page
.evaluate(function() {
610 $(".phrase").val("abandon abandon ability");
611 $(".phrase").trigger("input");
612 $(".network option[selected]").removeAttr("selected");
613 $(".network option").filter(function() {
614 return $(this).html() == "DASH - Dash";
615 }).prop("selected", true);
616 $(".network").trigger("change");
618 // check the address is generated correctly
619 waitForGenerate(function() {
620 var actual
= page
.evaluate(function() {
621 return $(".address:first").text();
623 if (actual
!= expected
) {
624 console
.log("DASH address is incorrect");
625 console
.log("Expected: " + expected
);
626 console
.log("Actual: " + actual
);
635 page
.open(url
, function(status
) {
636 // set the phrase and coin
637 var expected
= "yaR52EN4oojdJfBgzWJTymC4uuCLPT29Gw";
638 page
.evaluate(function() {
639 $(".phrase").val("abandon abandon ability");
640 $(".phrase").trigger("input");
641 $(".network option[selected]").removeAttr("selected");
642 $(".network option").filter(function() {
643 return $(this).html() == "DASH - Dash Testnet";
644 }).prop("selected", true);
645 $(".network").trigger("change");
647 // check the address is generated correctly
648 waitForGenerate(function() {
649 var actual
= page
.evaluate(function() {
650 return $(".address:first").text();
652 if (actual
!= expected
) {
653 console
.log("DASH Testnet address is incorrect");
654 console
.log("Expected: " + expected
);
655 console
.log("Actual: " + actual
);
663 // Network can be set to game
665 page
.open(url
, function(status
) {
666 // set the phrase and coin
667 var expected
= "GSMY9bAp36cMR4zyT4uGVS7GFjpdXbao5Q";
668 page
.evaluate(function() {
669 $(".phrase").val("abandon abandon ability");
670 $(".phrase").trigger("input");
671 $(".network option[selected]").removeAttr("selected");
672 $(".network option").filter(function() {
673 return $(this).html() == "GAME - GameCredits";
674 }).prop("selected", true);
675 $(".network").trigger("change");
677 // check the address is generated correctly
678 waitForGenerate(function() {
679 var actual
= page
.evaluate(function() {
680 return $(".address:first").text();
682 if (actual
!= expected
) {
683 console
.log("GAME address is incorrect");
684 console
.log("Expected: " + expected
);
685 console
.log("Actual: " + actual
);
693 // Network can be set to namecoin
695 page
.open(url
, function(status
) {
696 // set the phrase and coin
697 var expected
= "Mw2vK2Bvex1yYtYF6sfbEg2YGoUc98YUD2";
698 page
.evaluate(function() {
699 $(".phrase").val("abandon abandon ability");
700 $(".phrase").trigger("input");
701 $(".network option[selected]").removeAttr("selected");
702 $(".network option").filter(function() {
703 return $(this).html() == "NMC - Namecoin";
704 }).prop("selected", true);
705 $(".network").trigger("change");
707 // check the address is generated correctly
708 waitForGenerate(function() {
709 var actual
= page
.evaluate(function() {
710 return $(".address:first").text();
712 if (actual
!= expected
) {
713 console
.log("Namecoin address is incorrect");
714 console
.log("Expected: " + expected
);
715 console
.log("Actual: " + actual
);
723 // Network can be set to peercoin
725 page
.open(url
, function(status
) {
726 // set the phrase and coin
727 var expected
= "PVAiioTaK2eDHSEo3tppT9AVdBYqxRTBAm";
728 page
.evaluate(function() {
729 $(".phrase").val("abandon abandon ability");
730 $(".phrase").trigger("input");
731 $(".network option[selected]").removeAttr("selected");
732 $(".network option").filter(function() {
733 return $(this).html() == "PPC - Peercoin";
734 }).prop("selected", true);
735 $(".network").trigger("change");
737 // check the address is generated correctly
738 waitForGenerate(function() {
739 var actual
= page
.evaluate(function() {
740 return $(".address:first").text();
742 if (actual
!= expected
) {
743 console
.log("Peercoin address is incorrect");
744 console
.log("Expected: " + expected
);
745 console
.log("Actual: " + actual
);
753 // Network can be set to ethereum
756 page
.open(url
, function(status
) {
758 // set the phrase and coin
759 page
.evaluate(function() {
760 $(".phrase").val("abandon abandon ability");
761 $(".phrase").trigger("input");
762 $(".network option[selected]").removeAttr("selected");
763 $(".network option").filter(function() {
764 return $(this).html() == "ETH - Ethereum";
765 }).prop("selected", true);
766 $(".network").trigger("change");
768 waitForGenerate(function() {
769 // check the address is generated correctly
770 // this value comes from
771 // https://www.myetherwallet.com/#view-wallet-info
772 // Unusual capitalization is due to checksum
773 var expected
= "0xe5815d5902Ad612d49283DEdEc02100Bd44C2772";
774 var actual
= page
.evaluate(function() {
775 return $(".address:first").text();
777 if (actual
!= expected
) {
778 console
.log("Ethereum address is incorrect");
779 console
.log("Expected: " + expected
);
780 console
.log("Actual: " + actual
);
783 // check the private key is correct
784 // this private key can be imported into
785 // https://www.myetherwallet.com/#view-wallet-info
786 // and it should correlate to the address above
787 var expected
= "0x8f253078b73d7498302bb78c171b23ce7a8fb511987d2b2702b731638a4a15e7";
788 var actual
= page
.evaluate(function() {
789 return $(".privkey:first").text();
791 if (actual
!= expected
) {
792 console
.log("Ethereum privkey is incorrect");
793 console
.log("Expected: " + expected
);
794 console
.log("Actual: " + actual
);
797 // check the public key is correct
799 // don't have any third-party source to generate the expected value
800 //var expected = "?";
801 //var actual = page.evaluate(function() {
802 // return $(".pubkey:first").text();
804 //if (actual != expected) {
805 // console.log("Ethereum privkey is incorrect");
806 // console.log("Expected: " + expected);
807 // console.log("Actual: " + actual);
815 // Network can be set to Slimcoin
817 page
.open(url
, function(status
) {
818 // set the phrase and coin
819 var expected
= "SNzPi1CafHFm3WWjRo43aMgiaEEj3ogjww";
820 page
.evaluate(function() {
821 $(".phrase").val("abandon abandon ability");
822 $(".phrase").trigger("input");
823 $(".network option[selected]").removeAttr("selected");
824 $(".network option").filter(function() {
825 return $(this).html() == "SLM - Slimcoin";
826 }).prop("selected", true);
827 $(".network").trigger("change");
829 // check the address is generated correctly
830 waitForGenerate(function() {
831 var actual
= page
.evaluate(function() {
832 return $(".address:first").text();
834 if (actual
!= expected
) {
835 console
.log("Slimcoin address is incorrect");
836 console
.log("Expected: " + expected
);
837 console
.log("Actual: " + actual
);
845 // Network can be set to Slimcointn
847 page
.open(url
, function(status
) {
848 // set the phrase and coin
849 var expected
= "n3nMgWufTek5QQAr6uwMhg5xbzj8xqc4Dq";
850 page
.evaluate(function() {
851 $(".phrase").val("abandon abandon ability");
852 $(".phrase").trigger("input");
853 $(".network option[selected]").removeAttr("selected");
854 $(".network option").filter(function() {
855 return $(this).html() == "SLM - Slimcoin Testnet";
856 }).prop("selected", true);
857 $(".network").trigger("change");
859 // check the address is generated correctly
860 waitForGenerate(function() {
861 var actual
= page
.evaluate(function() {
862 return $(".address:first").text();
864 if (actual
!= expected
) {
865 console
.log("Slimcoin testnet address is incorrect");
866 console
.log("Expected: " + expected
);
867 console
.log("Actual: " + actual
);
875 // Network can be set to bitcoin cash
877 page
.open(url
, function(status
) {
878 // set the phrase and coin
879 var expected
= "1JKvb6wKtsjNoCRxpZ4DGrbniML7z5U16A";
880 page
.evaluate(function() {
881 $(".phrase").val("abandon abandon ability");
882 $(".phrase").trigger("input");
883 $(".network option[selected]").removeAttr("selected");
884 $(".network option").filter(function() {
885 return $(this).html() == "BCH - Bitcoin Cash";
886 }).prop("selected", true);
887 $(".network").trigger("change");
889 // check the address is generated correctly
890 waitForGenerate(function() {
891 var actual
= page
.evaluate(function() {
892 return $(".address:first").text();
894 if (actual
!= expected
) {
895 console
.log("Bitcoin Cash address is incorrect");
896 console
.log("Expected: " + expected
);
897 console
.log("Actual: " + actual
);
905 // Network can be set to myriadcoin
907 page
.open(url
, function(status
) {
908 // set the phrase and coin
909 var expected
= "MJEswvRR46wh9BoiVj9DzKYMBkCramhoBV";
910 page
.evaluate(function() {
911 $(".phrase").val("abandon abandon ability");
912 $(".phrase").trigger("input");
913 $(".network option[selected]").removeAttr("selected");
914 $(".network option").filter(function() {
915 return $(this).html() == "XMY - Myriadcoin";
916 }).prop("selected", true);
917 $(".network").trigger("change");
919 // check the address is generated correctly
920 waitForGenerate(function() {
921 var actual
= page
.evaluate(function() {
922 return $(".address:first").text();
924 if (actual
!= expected
) {
925 console
.log("Myriadcoin address is incorrect");
926 console
.log("Expected: " + expected
);
927 console
.log("Actual: " + actual
);
935 // Network can be set to pivx
937 page
.open(url
, function(status
) {
938 // set the phrase and coin
939 var expected
= "DBxgT7faCuno7jmtKuu6KWCiwqsVPqh1tS";
940 page
.evaluate(function() {
941 $(".phrase").val("abandon abandon ability");
942 $(".phrase").trigger("input");
943 $(".network option[selected]").removeAttr("selected");
944 $(".network option").filter(function() {
945 return $(this).html() == "PIVX - PIVX";
946 }).prop("selected", true);
947 $(".network").trigger("change");
949 // check the address is generated correctly
950 waitForGenerate(function() {
951 var actual
= page
.evaluate(function() {
952 return $(".address:first").text();
954 if (actual
!= expected
) {
955 console
.log("PIVX address is incorrect");
956 console
.log("Expected: " + expected
);
957 console
.log("Actual: " + actual
);
965 // Network can be set to pivx testnet
967 page
.open(url
, function(status
) {
968 // set the phrase and coin
969 var expected
= "yB5U384n6dGkVE3by5y9VdvHHPwPg68fQj";
970 page
.evaluate(function() {
971 $(".phrase").val("abandon abandon ability");
972 $(".phrase").trigger("input");
973 $(".network option[selected]").removeAttr("selected");
974 $(".network option").filter(function() {
975 return $(this).html() == "PIVX - PIVX Testnet";
976 }).prop("selected", true);
977 $(".network").trigger("change");
979 // check the address is generated correctly
980 waitForGenerate(function() {
981 var actual
= page
.evaluate(function() {
982 return $(".address:first").text();
984 if (actual
!= expected
) {
985 console
.log("PIVX Testnet address is incorrect");
986 console
.log("Expected: " + expected
);
987 console
.log("Actual: " + actual
);
995 // Network can be set to maza
997 page
.open(url
, function(status
) {
998 // set the phrase and coin
999 var expected
= "MGW4Bmi2NEm4PxSjgeFwhP9vg18JHoRnfw";
1000 page
.evaluate(function() {
1001 $(".phrase").val("abandon abandon ability");
1002 $(".phrase").trigger("input");
1003 $(".network option[selected]").removeAttr("selected");
1004 $(".network option").filter(function() {
1005 return $(this).html() == "MAZA - Maza";
1006 }).prop("selected", true);
1007 $(".network").trigger("change");
1009 // check the address is generated correctly
1010 waitForGenerate(function() {
1011 var actual
= page
.evaluate(function() {
1012 return $(".address:first").text();
1014 if (actual
!= expected
) {
1015 console
.log("Maza address is incorrect");
1016 console
.log("Expected: " + expected
);
1017 console
.log("Actual: " + actual
);
1025 // Network can be set to fujicoin
1027 page
.open(url
, function(status
) {
1028 // set the phrase and coin
1029 var expected
= "FgiaLpG7C99DyR4WnPxXedRVHXSfKzUDhF";
1030 page
.evaluate(function() {
1031 $(".phrase").val("abandon abandon ability");
1032 $(".phrase").trigger("input");
1033 $(".network option[selected]").removeAttr("selected");
1034 $(".network option").filter(function() {
1035 return $(this).html() == "FJC - Fujicoin";
1036 }).prop("selected", true);
1037 $(".network").trigger("change");
1039 // check the address is generated correctly
1040 waitForGenerate(function() {
1041 var actual
= page
.evaluate(function() {
1042 return $(".address:first").text();
1044 if (actual
!= expected
) {
1045 console
.log("Fujicoin address is incorrect");
1046 console
.log("Expected: " + expected
);
1047 console
.log("Actual: " + actual
);
1055 // BIP39 seed is set from phrase
1057 page
.open(url
, function(status
) {
1059 var expected
= "20da140d3dd1df8713cefcc4d54ce0e445b4151027a1ab567b832f6da5fcc5afc1c3a3f199ab78b8e0ab4652efd7f414ac2c9a3b81bceb879a70f377aa0a58f3";
1060 page
.evaluate(function() {
1061 $(".phrase").val("abandon abandon ability");
1062 $(".phrase").trigger("input");
1064 // check the address is generated correctly
1065 waitForGenerate(function() {
1066 var actual
= page
.evaluate(function() {
1067 return $(".seed").val();
1069 if (actual
!= expected
) {
1070 console
.log("BIP39 seed is incorrectly generated from mnemonic");
1071 console
.log("Expected: " + expected
);
1072 console
.log("Actual: " + actual
);
1080 // BIP32 root key is set from phrase
1082 page
.open(url
, function(status
) {
1084 var expected
= "xprv9s21ZrQH143K2jkGDCeTLgRewT9F2pH5JZs2zDmmjXes34geVnFiuNa8KTvY5WoYvdn4Ag6oYRoB6cXtc43NgJAEqDXf51xPm6fhiMCKwpi";
1085 page
.evaluate(function() {
1086 $(".phrase").val("abandon abandon ability");
1087 $(".phrase").trigger("input");
1089 // check the address is generated correctly
1090 waitForGenerate(function() {
1091 var actual
= page
.evaluate(function() {
1092 return $(".root-key").val();
1094 if (actual
!= expected
) {
1095 console
.log("Root key is incorrectly generated from mnemonic");
1096 console
.log("Expected: " + expected
);
1097 console
.log("Actual: " + actual
);
1105 // Tabs show correct addresses when changed
1107 page
.open(url
, function(status
) {
1109 var expected
= "17uQ7s2izWPwBmEVFikTmZUjbBKWYdJchz";
1110 page
.evaluate(function() {
1111 $(".phrase").val("abandon abandon ability");
1112 $(".phrase").trigger("input");
1115 waitForGenerate(function() {
1116 page
.evaluate(function() {
1117 $("#bip32-tab a").click();
1119 // check the address is generated correctly
1120 waitForGenerate(function() {
1121 var actual
= page
.evaluate(function() {
1122 return $(".address:first").text();
1124 if (actual
!= expected
) {
1125 console
.log("Clicking tab generates incorrect address");
1126 console
.log("Expected: " + expected
);
1127 console
.log("Actual: " + actual
);
1136 // BIP44 derivation path is shown
1138 page
.open(url
, function(status
) {
1140 var expected
= "m/44'/0'/0'/0";
1141 page
.evaluate(function() {
1142 $(".phrase").val("abandon abandon ability");
1143 $(".phrase").trigger("input");
1145 // check the derivation path of the first address
1146 waitForGenerate(function() {
1147 var actual
= page
.evaluate(function() {
1148 return $("#bip44 .path").val();
1150 if (actual
!= expected
) {
1151 console
.log("BIP44 derivation path is incorrect");
1152 console
.log("Expected: " + expected
);
1153 console
.log("Actual: " + actual
);
1161 // BIP44 extended private key is shown
1163 page
.open(url
, function(status
) {
1165 var expected
= "xprvA2DxxvPZcyRvYgZMGS53nadR32mVDeCyqQYyFhrCVbJNjPoxMeVf7QT5g7mQASbTf9Kp4cryvcXnu2qurjWKcrdsr91jXymdCDNxKgLFKJG";
1166 page
.evaluate(function() {
1167 $(".phrase").val("abandon abandon ability");
1168 $(".phrase").trigger("input");
1170 // check the BIP44 extended private key
1171 waitForGenerate(function() {
1172 var actual
= page
.evaluate(function() {
1173 return $(".extended-priv-key").val();
1175 if (actual
!= expected
) {
1176 console
.log("BIP44 extended private key is incorrect");
1177 console
.log("Expected: " + expected
);
1178 console
.log("Actual: " + actual
);
1186 // BIP44 extended public key is shown
1188 page
.open(url
, function(status
) {
1190 var expected
= "xpub6FDKNRvTTLzDmAdpNTc49ia9b4byd6vqCdUa46Fp3vqMcC96uBoufCmZXQLiN5AK3iSCJMhf9gT2sxkpyaPepRuA7W3MujV5tGmF5VfbueM";
1191 page
.evaluate(function() {
1192 $(".phrase").val("abandon abandon ability");
1193 $(".phrase").trigger("input");
1195 // check the BIP44 extended public key
1196 waitForGenerate(function() {
1197 var actual
= page
.evaluate(function() {
1198 return $(".extended-pub-key").val();
1200 if (actual
!= expected
) {
1201 console
.log("BIP44 extended public key is incorrect");
1202 console
.log("Expected: " + expected
);
1203 console
.log("Actual: " + actual
);
1211 // BIP44 account field changes address list
1213 page
.open(url
, function(status
) {
1215 var expected
= "1Nq2Wmu726XHCuGhctEtGmhxo3wzk5wZ1H";
1216 page
.evaluate(function() {
1217 $(".phrase").val("abandon abandon ability");
1218 $(".phrase").trigger("input");
1220 waitForGenerate(function() {
1221 // change the bip44 purpose field to 45
1222 page
.evaluate(function() {
1223 $("#bip44 .account").val("1");
1224 $("#bip44 .account").trigger("input");
1226 waitForGenerate(function() {
1227 // check the address for the new derivation path
1228 var actual
= page
.evaluate(function() {
1229 return $(".address:first").text();
1231 if (actual
!= expected
) {
1232 console
.log("BIP44 account field generates incorrect address");
1233 console
.log("Expected: " + expected
);
1234 console
.log("Actual: " + actual
);
1243 // BIP44 change field changes address list
1245 page
.open(url
, function(status
) {
1247 var expected
= "1KAGfWgqfVbSSXY56fNQ7YnhyKuoskHtYo";
1248 page
.evaluate(function() {
1249 $(".phrase").val("abandon abandon ability");
1250 $(".phrase").trigger("input");
1252 waitForGenerate(function() {
1253 // change the bip44 purpose field to 45
1254 page
.evaluate(function() {
1255 $("#bip44 .change").val("1");
1256 $("#bip44 .change").trigger("input");
1258 waitForGenerate(function() {
1259 // check the address for the new derivation path
1260 var actual
= page
.evaluate(function() {
1261 return $(".address:first").text();
1263 if (actual
!= expected
) {
1264 console
.log("BIP44 change field generates incorrect address");
1265 console
.log("Expected: " + expected
);
1266 console
.log("Actual: " + actual
);
1275 // BIP32 derivation path can be set
1277 page
.open(url
, function(status
) {
1279 var expected
= "16pYQQdLD1hH4hwTGLXBaZ9Teboi1AGL8L";
1280 page
.evaluate(function() {
1281 $(".phrase").val("abandon abandon ability");
1282 $(".phrase").trigger("input");
1285 waitForGenerate(function() {
1286 page
.evaluate(function() {
1287 $("#bip32-tab a").click();
1289 // set the derivation path to m/1
1290 waitForGenerate(function() {
1291 page
.evaluate(function() {
1292 $("#bip32 .path").val("m/1");
1293 $("#bip32 .path").trigger("input");
1295 // check the address is generated correctly
1296 waitForGenerate(function() {
1297 var actual
= page
.evaluate(function() {
1298 return $(".address:first").text();
1300 if (actual
!= expected
) {
1301 console
.log("Custom BIP32 path generates incorrect address");
1302 console
.log("Expected: " + expected
);
1303 console
.log("Actual: " + actual
);
1313 // BIP32 can use hardened derivation paths
1315 page
.open(url
, function(status
) {
1317 var expected
= "14aXZeprXAE3UUKQc4ihvwBvww2LuEoHo4";
1318 page
.evaluate(function() {
1319 $(".phrase").val("abandon abandon ability");
1320 $(".phrase").trigger("input");
1323 waitForGenerate(function() {
1324 page
.evaluate(function() {
1325 $("#bip32-tab a").click();
1327 // set the derivation path to m/0'
1328 waitForGenerate(function() {
1329 page
.evaluate(function() {
1330 $("#bip32 .path").val("m/0'");
1331 $("#bip32 .path").trigger("input");
1333 // check the address is generated correctly
1334 waitForGenerate(function() {
1335 var actual
= page
.evaluate(function() {
1336 return $(".address:first").text();
1338 if (actual
!= expected
) {
1339 console
.log("Hardened BIP32 path generates incorrect address");
1340 console
.log("Expected: " + expected
);
1341 console
.log("Actual: " + actual
);
1351 // BIP32 extended private key is shown
1353 page
.open(url
, function(status
) {
1355 var expected
= "xprv9va99uTVE5aLiutUVLTyfxfe8v8aaXjSQ1XxZbK6SezYVuikA9MnjQVTA8rQHpNA5LKvyQBpLiHbBQiiccKiBDs7eRmBogsvq3THFeLHYbe";
1356 page
.evaluate(function() {
1357 $(".phrase").val("abandon abandon ability");
1358 $(".phrase").trigger("input");
1361 waitForGenerate(function() {
1362 page
.evaluate(function() {
1363 $("#bip32-tab a").click();
1365 // check the extended private key is generated correctly
1366 waitForGenerate(function() {
1367 var actual
= page
.evaluate(function() {
1368 return $(".extended-priv-key").val();
1370 if (actual
!= expected
) {
1371 console
.log("BIP32 extended private key is incorrect");
1372 console
.log("Expected: " + expected
);
1373 console
.log("Actual: " + actual
);
1382 // BIP32 extended public key is shown
1384 page
.open(url
, function(status
) {
1386 var expected
= "xpub69ZVZQzP4T8dwPxwbMzz36cNgwy4yzTHmETZMyihzzXXNi3thgg3HCow1RtY252wdw5rS8369xKnraN5Q93y3FkFfJp2XEHWUrkyXsjS93P";
1387 page
.evaluate(function() {
1388 $(".phrase").val("abandon abandon ability");
1389 $(".phrase").trigger("input");
1392 waitForGenerate(function() {
1393 page
.evaluate(function() {
1394 $("#bip32-tab a").click();
1396 // check the extended public key is generated correctly
1397 waitForGenerate(function() {
1398 var actual
= page
.evaluate(function() {
1399 return $(".extended-pub-key").val();
1401 if (actual
!= expected
) {
1402 console
.log("BIP32 extended public key is incorrect");
1403 console
.log("Expected: " + expected
);
1404 console
.log("Actual: " + actual
);
1413 // Derivation path is shown in table
1415 page
.open(url
, function(status
) {
1417 var expected
= "m/44'/0'/0'/0/0";
1418 page
.evaluate(function() {
1419 $(".phrase").val("abandon abandon ability");
1420 $(".phrase").trigger("input");
1422 // check for derivation path in table
1423 waitForGenerate(function() {
1424 var actual
= page
.evaluate(function() {
1425 return $(".index:first").text();
1427 if (actual
!= expected
) {
1428 console
.log("Derivation path shown incorrectly in table");
1429 console
.log("Expected: " + expected
);
1430 console
.log("Actual: " + actual
);
1438 // Derivation path for address can be hardened
1440 page
.open(url
, function(status
) {
1442 var expected
= "18exLzUv7kfpiXRzmCjFDoC9qwNLFyvwyd";
1443 page
.evaluate(function() {
1444 $(".phrase").val("abandon abandon ability");
1445 $(".phrase").trigger("input");
1448 waitForGenerate(function() {
1449 page
.evaluate(function() {
1450 $("#bip32-tab a").click();
1452 waitForGenerate(function() {
1453 // select the hardened addresses option
1454 page
.evaluate(function() {
1455 $(".hardened-addresses").prop("checked", true);
1456 $(".hardened-addresses").trigger("change");
1458 waitForGenerate(function() {
1459 // check the generated address is hardened
1460 var actual
= page
.evaluate(function() {
1461 return $(".address:first").text();
1463 if (actual
!= expected
) {
1464 console
.log("Hardened address is incorrect");
1465 console
.log("Expected: " + expected
);
1466 console
.log("Actual: " + actual
);
1476 // Derivation path visibility can be toggled
1478 page
.open(url
, function(status
) {
1480 page
.evaluate(function() {
1481 $(".phrase").val("abandon abandon ability");
1482 $(".phrase").trigger("input");
1484 waitForGenerate(function() {
1485 // toggle path visibility
1486 page
.evaluate(function() {
1487 $(".index-toggle").click();
1489 // check the path is not visible
1490 var isInvisible
= page
.evaluate(function() {
1491 return $(".index:first span").hasClass("invisible");
1494 console
.log("Toggled derivation path is visible");
1504 page
.open(url
, function(status
) {
1505 var expected
= "1Di3Vp7tBWtyQaDABLAjfWtF6V7hYKJtug";
1507 page
.evaluate(function() {
1508 $(".phrase").val("abandon abandon ability").trigger("input");
1511 waitForGenerate(function() {
1512 var actual
= page
.evaluate(function() {
1513 return $(".address:first").text();
1515 if (actual
!= expected
) {
1516 console
.log("Address is not shown");
1517 console
.log("Expected: " + expected
);
1518 console
.log("Got: " + actual
);
1526 // Addresses are shown in order of derivation path
1528 page
.open(url
, function(status
) {
1530 page
.evaluate(function() {
1531 $(".phrase").val("abandon abandon ability").trigger("input");
1533 // get the derivation paths
1534 waitForGenerate(function() {
1535 var paths
= page
.evaluate(function() {
1536 return $(".index").map(function(i
, e
) {
1540 if (paths
.length
!= 20) {
1541 console
.log("Total paths is less than expected: " + paths
.length
);
1544 for (var i
=0; i
<paths
.length
; i
++) {
1545 var expected
= "m/44'/0'/0'/0/" + i
;
1546 var actual
= paths
[i
];
1547 if (actual
!= expected
) {
1548 console
.log("Path " + i
+ " is incorrect");
1549 console
.log("Expected: " + expected
);
1550 console
.log("Actual: " + actual
);
1559 // Address visibility can be toggled
1561 page
.open(url
, function(status
) {
1563 page
.evaluate(function() {
1564 $(".phrase").val("abandon abandon ability");
1565 $(".phrase").trigger("input");
1567 waitForGenerate(function() {
1568 // toggle address visibility
1569 page
.evaluate(function() {
1570 $(".address-toggle").click();
1572 // check the address is not visible
1573 var isInvisible
= page
.evaluate(function() {
1574 return $(".address:first span").hasClass("invisible");
1577 console
.log("Toggled address is visible");
1585 // Public key is shown
1587 page
.open(url
, function(status
) {
1588 var expected
= "033f5aed5f6cfbafaf223188095b5980814897295f723815fea5d3f4b648d0d0b3";
1590 page
.evaluate(function() {
1591 $(".phrase").val("abandon abandon ability").trigger("input");
1594 waitForGenerate(function() {
1595 var actual
= page
.evaluate(function() {
1596 return $(".pubkey:first").text();
1598 if (actual
!= expected
) {
1599 console
.log("Public key is not shown");
1600 console
.log("Expected: " + expected
);
1601 console
.log("Got: " + actual
);
1609 // Public key visibility can be toggled
1611 page
.open(url
, function(status
) {
1613 page
.evaluate(function() {
1614 $(".phrase").val("abandon abandon ability");
1615 $(".phrase").trigger("input");
1617 waitForGenerate(function() {
1618 // toggle public key visibility
1619 page
.evaluate(function() {
1620 $(".public-key-toggle").click();
1622 // check the public key is not visible
1623 var isInvisible
= page
.evaluate(function() {
1624 return $(".pubkey:first span").hasClass("invisible");
1627 console
.log("Toggled public key is visible");
1635 // Private key is shown
1637 page
.open(url
, function(status
) {
1638 var expected
= "L26cVSpWFkJ6aQkPkKmTzLqTdLJ923e6CzrVh9cmx21QHsoUmrEE";
1640 page
.evaluate(function() {
1641 $(".phrase").val("abandon abandon ability").trigger("input");
1644 waitForGenerate(function() {
1645 var actual
= page
.evaluate(function() {
1646 return $(".privkey:first").text();
1648 if (actual
!= expected
) {
1649 console
.log("Private key is not shown");
1650 console
.log("Expected: " + expected
);
1651 console
.log("Got: " + actual
);
1659 // Private key visibility can be toggled
1661 page
.open(url
, function(status
) {
1663 page
.evaluate(function() {
1664 $(".phrase").val("abandon abandon ability");
1665 $(".phrase").trigger("input");
1667 waitForGenerate(function() {
1668 // toggle private key visibility
1669 page
.evaluate(function() {
1670 $(".private-key-toggle").click();
1672 // check the private key is not visible
1673 var isInvisible
= page
.evaluate(function() {
1674 return $(".privkey:first span").hasClass("invisible");
1677 console
.log("Toggled private key is visible");
1685 // More addresses can be generated
1687 page
.open(url
, function(status
) {
1689 page
.evaluate(function() {
1690 $(".phrase").val("abandon abandon ability");
1691 $(".phrase").trigger("input");
1693 waitForGenerate(function() {
1694 // generate more addresses
1695 page
.evaluate(function() {
1698 waitForGenerate(function() {
1699 // check there are more addresses
1700 var addressCount
= page
.evaluate(function() {
1701 return $(".address").length
;
1703 if (addressCount
!= 40) {
1704 console
.log("More addresses cannot be generated");
1713 // A custom number of additional addresses can be generated
1715 page
.open(url
, function(status
) {
1717 page
.evaluate(function() {
1718 $(".phrase").val("abandon abandon ability");
1719 $(".phrase").trigger("input");
1721 waitForGenerate(function() {
1722 // get the current number of addresses
1723 var oldAddressCount
= page
.evaluate(function() {
1724 return $(".address").length
;
1726 // set a custom number of additional addresses
1727 page
.evaluate(function() {
1728 $(".rows-to-add").val(1);
1730 // generate more addresses
1731 page
.evaluate(function() {
1734 waitForGenerate(function() {
1735 // check there are the correct number of addresses
1736 var newAddressCount
= page
.evaluate(function() {
1737 return $(".address").length
;
1739 if (newAddressCount
- oldAddressCount
!= 1) {
1740 console
.log("Number of additional addresses cannot be customized");
1741 console
.log(newAddressCount
)
1742 console
.log(oldAddressCount
)
1751 // Additional addresses are shown in order of derivation path
1753 page
.open(url
, function(status
) {
1755 page
.evaluate(function() {
1756 $(".phrase").val("abandon abandon ability").trigger("input");
1758 waitForGenerate(function() {
1759 // generate more addresses
1760 page
.evaluate(function() {
1763 // get the derivation paths
1764 waitForGenerate(function() {
1765 var paths
= page
.evaluate(function() {
1766 return $(".index").map(function(i
, e
) {
1770 if (paths
.length
!= 40) {
1771 console
.log("Total additional paths is less than expected: " + paths
.length
);
1774 for (var i
=0; i
<paths
.length
; i
++) {
1775 var expected
= "m/44'/0'/0'/0/" + i
;
1776 var actual
= paths
[i
];
1777 if (actual
!= expected
) {
1778 console
.log("Path " + i
+ " is not in correct order");
1779 console
.log("Expected: " + expected
);
1780 console
.log("Actual: " + actual
);
1790 // BIP32 root key can be set by the user
1792 page
.open(url
, function(status
) {
1793 var expected
= "1Di3Vp7tBWtyQaDABLAjfWtF6V7hYKJtug";
1795 page
.evaluate(function() {
1796 $(".root-key").val("xprv9s21ZrQH143K2jkGDCeTLgRewT9F2pH5JZs2zDmmjXes34geVnFiuNa8KTvY5WoYvdn4Ag6oYRoB6cXtc43NgJAEqDXf51xPm6fhiMCKwpi").trigger("input");
1798 waitForGenerate(function() {
1799 var actual
= page
.evaluate(function() {
1800 return $(".address:first").text();
1802 if (actual
!= expected
) {
1803 console
.log("Setting BIP32 root key results in wrong address");
1804 console
.log("Expected: " + expected
);
1805 console
.log("Actual: " + actual
);
1813 // Setting BIP32 root key clears the existing phrase, passphrase and seed
1815 page
.open(url
, function(status
) {
1818 page
.evaluate(function() {
1819 $(".phrase").val("A non-blank but invalid value");
1821 // Accept any confirm dialogs
1822 page
.onConfirm = function() {
1826 page
.evaluate(function() {
1827 $(".root-key").val("xprv9s21ZrQH143K2jkGDCeTLgRewT9F2pH5JZs2zDmmjXes34geVnFiuNa8KTvY5WoYvdn4Ag6oYRoB6cXtc43NgJAEqDXf51xPm6fhiMCKwpi").trigger("input");
1829 waitForGenerate(function() {
1830 var actual
= page
.evaluate(function() {
1831 return $(".phrase").val();
1833 if (actual
!= expected
) {
1834 console
.log("Phrase not cleared when setting BIP32 root key");
1835 console
.log("Expected: " + expected
);
1836 console
.log("Actual: " + actual
);
1844 // Clearing of phrase, passphrase and seed can be cancelled by user
1846 page
.open(url
, function(status
) {
1847 var expected
= "abandon abandon ability";
1849 page
.evaluate(function() {
1850 $(".phrase").val("abandon abandon ability");
1852 // Cancel any confirm dialogs
1853 page
.onConfirm = function() {
1857 page
.evaluate(function() {
1858 $(".root-key").val("xprv9s21ZrQH143K3d3vzEDD3KpSKmxsZ3y7CqhAL1tinwtP6wqK4TKEKjpBuo6P2hUhB6ZENo7TTSRytiP857hBZVpBdk8PooFuRspE1eywwNZ").trigger("input");
1860 var actual
= page
.evaluate(function() {
1861 return $(".phrase").val();
1863 if (actual
!= expected
) {
1864 console
.log("Phrase not retained when cancelling changes to BIP32 root key");
1865 console
.log("Expected: " + expected
);
1866 console
.log("Actual: " + actual
);
1873 // Custom BIP32 root key is used when changing the derivation path
1875 page
.open(url
, function(status
) {
1876 var expected
= "1Nq2Wmu726XHCuGhctEtGmhxo3wzk5wZ1H";
1878 page
.evaluate(function() {
1879 $(".root-key").val("xprv9s21ZrQH143K2jkGDCeTLgRewT9F2pH5JZs2zDmmjXes34geVnFiuNa8KTvY5WoYvdn4Ag6oYRoB6cXtc43NgJAEqDXf51xPm6fhiMCKwpi").trigger("input");
1881 waitForGenerate(function() {
1882 // change the derivation path
1883 page
.evaluate(function() {
1884 $("#account").val("1").trigger("input");
1886 // check the bip32 root key is used for derivation, not the blank phrase
1887 waitForGenerate(function() {
1888 var actual
= page
.evaluate(function() {
1889 return $(".address:first").text();
1891 if (actual
!= expected
) {
1892 console
.log("Changing the derivation path does not use BIP32 root key");
1893 console
.log("Expected: " + expected
);
1894 console
.log("Actual: " + actual
);
1903 // Incorrect mnemonic shows error
1905 page
.open(url
, function(status
) {
1907 page
.evaluate(function() {
1908 $(".phrase").val("abandon abandon abandon").trigger("input");
1910 waitForFeedback(function() {
1911 // check there is an error shown
1912 var feedback
= page
.evaluate(function() {
1913 return $(".feedback").text();
1915 if (feedback
.length
<= 0) {
1916 console
.log("Invalid mnemonic does not show error");
1924 // Incorrect word shows suggested replacement
1926 page
.open(url
, function(status
) {
1928 page
.evaluate(function() {
1929 $(".phrase").val("abandon abandon abiliti").trigger("input");
1931 // check there is a suggestion shown
1932 waitForFeedback(function() {
1933 var feedback
= page
.evaluate(function() {
1934 return $(".feedback").text();
1936 if (feedback
.indexOf("did you mean ability?") < 0) {
1937 console
.log("Incorrect word does not show suggested replacement");
1938 console
.log("Error: " + error
);
1946 // Github pull request 48
1947 // First four letters of word shows that word, not closest
1948 // since first four letters gives unique word in BIP39 wordlist
1949 // eg ille should show illegal, not idle
1951 page
.open(url
, function(status
) {
1952 // set the incomplete word
1953 page
.evaluate(function() {
1954 $(".phrase").val("ille").trigger("input");
1956 // check there is a suggestion shown
1957 waitForFeedback(function() {
1958 var feedback
= page
.evaluate(function() {
1959 return $(".feedback").text();
1961 if (feedback
.indexOf("did you mean illegal?") < 0) {
1962 console
.log("Start of word does not show correct suggestion");
1963 console
.log("Error: " + error
);
1971 // Incorrect BIP32 root key shows error
1973 page
.open(url
, function(status
) {
1975 page
.evaluate(function() {
1976 $(".root-key").val("xprv9s21ZrQH143K2jkGDCeTLgRewT9F2pH5JZs2zDmmjXes34geVnFiuNa8KTvY5WoYvdn4Ag6oYRoB6cXtc43NgJAEqDXf51xPm6fhiMCKwpj").trigger("input");
1978 // check there is an error shown
1979 waitForFeedback(function() {
1980 var feedback
= page
.evaluate(function() {
1981 return $(".feedback").text();
1983 if (feedback
!= "Invalid root key") {
1984 console
.log("Invalid root key does not show error");
1985 console
.log("Error: " + error
);
1993 // Derivation path not starting with m shows error
1995 page
.open(url
, function(status
) {
1996 // set the mnemonic phrase
1997 page
.evaluate(function() {
1998 $(".phrase").val("abandon abandon ability").trigger("input");
2000 waitForGenerate(function() {
2001 // select the bip32 tab so custom derivation path can be set
2002 page
.evaluate(function() {
2003 $("#bip32-tab a").click();
2005 waitForGenerate(function() {
2006 // set the incorrect derivation path
2007 page
.evaluate(function() {
2008 $("#bip32 .path").val("n/0").trigger("input");
2010 waitForFeedback(function() {
2011 var feedback
= page
.evaluate(function() {
2012 return $(".feedback").text();
2014 if (feedback
!= "First character must be 'm'") {
2015 console
.log("Derivation path not starting with m should show error");
2016 console
.log("Error: " + error
);
2026 // Derivation path containing invalid characters shows useful error
2028 page
.open(url
, function(status
) {
2029 // set the mnemonic phrase
2030 page
.evaluate(function() {
2031 $(".phrase").val("abandon abandon ability").trigger("input");
2033 waitForGenerate(function() {
2034 // select the bip32 tab so custom derivation path can be set
2035 page
.evaluate(function() {
2036 $("#bip32-tab a").click();
2038 waitForGenerate(function() {
2039 // set the incorrect derivation path
2040 page
.evaluate(function() {
2041 $("#bip32 .path").val("m/1/0wrong1/1").trigger("input");
2043 waitForFeedback(function() {
2044 var feedback
= page
.evaluate(function() {
2045 return $(".feedback").text();
2047 if (feedback
!= "Invalid characters 0wrong1 found at depth 2") {
2048 console
.log("Derivation path with invalid characters should show error");
2049 console
.log("Error: " + error
);
2059 // Github Issue 11: Default word length is 15
2060 // https://github.com/iancoleman/bip39/issues/11
2062 page
.open(url
, function(status
) {
2063 // get the word length
2064 var defaultLength
= page
.evaluate(function() {
2065 return $(".strength").val();
2067 if (defaultLength
!= 15) {
2068 console
.log("Default word length is not 15");
2076 // Github Issue 12: Generate more rows with private keys hidden
2077 // https://github.com/iancoleman/bip39/issues/12
2079 page
.open(url
, function(status
) {
2081 page
.evaluate(function() {
2082 $(".phrase").val("abandon abandon ability");
2083 $(".phrase").trigger("input");
2085 waitForGenerate(function() {
2086 // toggle private keys hidden, then generate more addresses
2087 page
.evaluate(function() {
2088 $(".private-key-toggle").click();
2091 waitForGenerate(function() {
2092 // check more have been generated
2094 var numPrivKeys
= page
.evaluate(function() {
2095 return $(".privkey").length
;
2097 if (numPrivKeys
!= expected
) {
2098 console
.log("Wrong number of addresses when clicking 'more' with hidden privkeys");
2099 console
.log("Expected: " + expected
);
2100 console
.log("Actual: " + numPrivKeys
);
2103 // check no private keys are shown
2104 var numHiddenPrivKeys
= page
.evaluate(function() {
2105 return $(".privkey span[class=invisible]").length
;
2107 if (numHiddenPrivKeys
!= expected
) {
2108 console
.log("Generating more does not retain hidden state of privkeys");
2109 console
.log("Expected: " + expected
);
2110 console
.log("Actual: " + numHiddenPrivKeys
);
2119 // Github Issue 19: Mnemonic is not sensitive to whitespace
2120 // https://github.com/iancoleman/bip39/issues/19
2122 page
.open(url
, function(status
) {
2124 var expected
= "xprv9s21ZrQH143K3isaZsWbKVoTtbvd34Y1ZGRugGdMeBGbM3AgBVzTH159mj1cbbtYSJtQr65w6L5xy5L9SFC7c9VJZWHxgAzpj4mun5LhrbC";
2125 page
.evaluate(function() {
2126 var doubleSpace
= " ";
2127 $(".phrase").val("urge cat" + doubleSpace
+ "bid");
2128 $(".phrase").trigger("input");
2130 waitForGenerate(function() {
2131 // Check the bip32 root key is correct
2132 var actual
= page
.evaluate(function() {
2133 return $(".root-key").val();
2135 if (actual
!= expected
) {
2136 console
.log("Mnemonic is sensitive to whitespace");
2137 console
.log("Expected: " + expected
);
2138 console
.log("Actual: " + actual
);
2146 // Github Issue 23: Part 1: Use correct derivation path when changing tabs
2147 // https://github.com/iancoleman/bip39/issues/23
2149 page
.open(url
, function(status
) {
2150 // 1) and 2) set the phrase
2151 page
.evaluate(function() {
2152 $(".phrase").val("abandon abandon ability").trigger("input");
2154 waitForGenerate(function() {
2155 // 3) select bip32 tab
2156 page
.evaluate(function() {
2157 $("#bip32-tab a").click();
2159 waitForGenerate(function() {
2160 // 4) switch from bitcoin to litecoin
2161 page
.evaluate(function() {
2162 $(".network option").filter(function() {
2163 return $(this).html() == "LTC - Litecoin";
2164 }).prop("selected", true);
2165 $(".network").trigger("change");
2167 waitForGenerate(function() {
2168 // 5) Check derivation path is displayed correctly
2169 var expected
= "m/0/0";
2170 var actual
= page
.evaluate(function() {
2171 return $(".index:first").text();
2173 if (actual
!= expected
) {
2174 console
.log("Github Issue 23 Part 1: derivation path display error");
2175 console
.log("Expected: " + expected
);
2176 console
.log("Actual: " + actual
);
2179 // 5) Check address is displayed correctly
2180 var expected
= "LS8MP5LZ5AdzSZveRrjm3aYVoPgnfFh5T5";
2181 var actual
= page
.evaluate(function() {
2182 return $(".address:first").text();
2184 if (actual
!= expected
) {
2185 console
.log("Github Issue 23 Part 1: address display error");
2186 console
.log("Expected: " + expected
);
2187 console
.log("Actual: " + actual
);
2197 // Github Issue 23 Part 2: Coin selection in derivation path
2198 // https://github.com/iancoleman/bip39/issues/23#issuecomment-238011920
2200 page
.open(url
, function(status
) {
2202 page
.evaluate(function() {
2203 $(".phrase").val("abandon abandon ability").trigger("input");
2205 waitForGenerate(function() {
2206 // switch from bitcoin to clam
2207 page
.evaluate(function() {
2208 $(".network option").filter(function() {
2209 return $(this).html() == "CLAM - Clams";
2210 }).prop("selected", true);
2211 $(".network").trigger("change");
2213 waitForGenerate(function() {
2214 // check derivation path is displayed correctly
2215 var expected
= "m/44'/23'/0'/0/0";
2216 var actual
= page
.evaluate(function() {
2217 return $(".index:first").text();
2219 if (actual
!= expected
) {
2220 console
.log("Github Issue 23 Part 2: Coin in BIP44 derivation path is incorrect");
2221 console
.log("Expected: " + expected
);
2222 console
.log("Actual: " + actual
);
2231 // Github Issue 26: When using a Root key derrived altcoins are incorrect
2232 // https://github.com/iancoleman/bip39/issues/26
2234 page
.open(url
, function(status
) {
2235 // 1) 2) and 3) set the root key
2236 page
.evaluate(function() {
2237 $(".root-key").val("xprv9s21ZrQH143K2jkGDCeTLgRewT9F2pH5JZs2zDmmjXes34geVnFiuNa8KTvY5WoYvdn4Ag6oYRoB6cXtc43NgJAEqDXf51xPm6fhiMCKwpi").trigger("input");
2239 waitForGenerate(function() {
2240 // 4) switch from bitcoin to viacoin
2241 page
.evaluate(function() {
2242 $(".network option").filter(function() {
2243 return $(this).html() == "VIA - Viacoin";
2244 }).prop("selected", true);
2245 $(".network").trigger("change");
2247 waitForGenerate(function() {
2248 // 5) ensure the derived address is correct
2249 var expected
= "Vq9Eq4N5SQnjqZvxtxzo7hZPW5XnyJsmXT";
2250 var actual
= page
.evaluate(function() {
2251 return $(".address:first").text();
2253 if (actual
!= expected
) {
2254 console
.log("Github Issue 26: address is incorrect when changing networks and using root-key to derive");
2255 console
.log("Expected: " + expected
);
2256 console
.log("Actual: " + actual
);
2265 // Selecting a language with no existing phrase should generate a phrase in
2268 page
.open(url
, function(status
) {
2269 // Select a language
2270 // Need to manually simulate hash being set due to quirk between
2271 // 'click' event triggered by javascript vs triggered by mouse.
2272 // Perhaps look into page.sendEvent
2273 // http://phantomjs.org/api/webpage/method/send-event.html
2274 page
.evaluate(function() {
2275 window
.location
.hash
= "#japanese";
2276 $("a[href='#japanese']").trigger("click");
2278 waitForGenerate(function() {
2279 // Check the mnemonic is in Japanese
2280 var phrase
= page
.evaluate(function() {
2281 return $(".phrase").val();
2283 if (phrase
.length
<= 0) {
2284 console
.log("No Japanese phrase generated");
2287 if (phrase
.charCodeAt(0) < 128) {
2288 console
.log("First character of Japanese phrase is ascii");
2289 console
.log("Phrase: " + phrase
);
2297 // Selecting a language with existing phrase should update the phrase to use
2300 page
.open(url
, function(status
) {
2301 // Set the phrase to an English phrase.
2302 page
.evaluate(function() {
2303 $(".phrase").val("abandon abandon ability").trigger("input");
2305 waitForGenerate(function() {
2306 // Change to Italian
2307 // Need to manually simulate hash being set due to quirk between
2308 // 'click' event triggered by javascript vs triggered by mouse.
2309 // Perhaps look into page.sendEvent
2310 // http://phantomjs.org/api/webpage/method/send-event.html
2311 page
.evaluate(function() {
2312 window
.location
.hash
= "#italian";
2313 $("a[href='#italian']").trigger("click");
2315 waitForGenerate(function() {
2316 // Check only the language changes, not the phrase
2317 var expected
= "abaco abaco abbaglio";
2318 var actual
= page
.evaluate(function() {
2319 return $(".phrase").val();
2321 if (actual
!= expected
) {
2322 console
.log("Changing language with existing phrase");
2323 console
.log("Expected: " + expected
);
2324 console
.log("Actual: " + actual
);
2327 // Check the address is correct
2328 var expected
= "1Dz5TgDhdki9spa6xbPFbBqv5sjMrx3xgV";
2329 var actual
= page
.evaluate(function() {
2330 return $(".address:first").text();
2332 if (actual
!= expected
) {
2333 console
.log("Changing language generates incorrect address");
2334 console
.log("Expected: " + expected
);
2335 console
.log("Actual: " + actual
);
2344 // Suggested replacement for erroneous word in non-English language
2346 page
.open(url
, function(status
) {
2347 // Set an incorrect phrase in Italian
2348 page
.evaluate(function() {
2349 $(".phrase").val("abaco abaco zbbaglio").trigger("input");
2351 waitForFeedback(function() {
2352 // Check the suggestion is correct
2353 var feedback
= page
.evaluate(function() {
2354 return $(".feedback").text();
2356 if (feedback
.indexOf("did you mean abbaglio?") < 0) {
2357 console
.log("Incorrect Italian word does not show suggested replacement");
2358 console
.log("Error: " + error
);
2367 // Japanese word does not break across lines.
2369 // https://github.com/bitcoin/bips/blob/master/bip-0039/bip-0039-wordlists.md#japanese
2371 page
.open(url
, function(status
) {
2372 hasWordBreakCss
= page
.content
.indexOf("word-break: keep-all;") > -1;
2373 if (!hasWordBreakCss
) {
2374 console
.log("Japanese words can break across lines mid-word");
2375 console
.log("Check CSS for '.phrase { word-break: keep-all; }'");
2378 // Run the next test
2383 // Language can be specified at page load using hash value in url
2385 page
.open(url
, function(status
) {
2386 // Set the page hash as if it were on a fresh page load
2387 page
.evaluate(function() {
2388 window
.location
.hash
= "#japanese";
2390 // Generate a random phrase
2391 page
.evaluate(function() {
2392 $(".generate").trigger("click");
2394 waitForGenerate(function() {
2395 // Check the phrase is in Japanese
2396 var phrase
= page
.evaluate(function() {
2397 return $(".phrase").val();
2399 if (phrase
.length
<= 0) {
2400 console
.log("No phrase generated using url hash");
2403 if (phrase
.charCodeAt(0) < 128) {
2404 console
.log("Language not detected from url hash on page load.");
2405 console
.log("Phrase: " + phrase
);
2413 // Entropy unit tests
2415 page
.open(url
, function(status
) {
2416 var response
= page
.evaluate(function() {
2418 // binary entropy is detected
2420 e
= Entropy
.fromString("01010101");
2421 if (e
.base
.str
!= "binary") {
2422 return "Binary entropy not detected correctly";
2428 // base6 entropy is detected
2430 e
= Entropy
.fromString("012345012345");
2431 if (e
.base
.str
!= "base 6") {
2432 return "base6 entropy not detected correctly";
2438 // dice entropy is detected
2440 e
= Entropy
.fromString("123456123456");
2441 if (e
.base
.str
!= "base 6 (dice)") {
2442 return "dice entropy not detected correctly";
2448 // base10 entropy is detected
2450 e
= Entropy
.fromString("0123456789");
2451 if (e
.base
.str
!= "base 10") {
2452 return "base10 entropy not detected correctly";
2458 // hex entropy is detected
2460 e
= Entropy
.fromString("0123456789ABCDEF");
2461 if (e
.base
.str
!= "hexadecimal") {
2462 return "hexadecimal entropy not detected correctly";
2468 // card entropy is detected
2470 e
= Entropy
.fromString("AC4DTHKS");
2471 if (e
.base
.str
!= "card") {
2472 return "card entropy not detected correctly";
2478 // entropy is case insensitive
2480 e
= Entropy
.fromString("aBcDeF");
2481 if (e
.cleanStr
!= "aBcDeF") {
2482 return "Entropy should not be case sensitive";
2488 // dice entropy is converted to base6
2490 e
= Entropy
.fromString("123456");
2491 if (e
.cleanStr
!= "123450") {
2492 return "Dice entropy is not automatically converted to base6";
2498 // dice entropy is preferred to base6 if ambiguous
2500 e
= Entropy
.fromString("12345");
2501 if (e
.base
.str
!= "base 6 (dice)") {
2502 return "dice not used as default over base 6";
2508 // unused characters are ignored
2510 e
= Entropy
.fromString("fghijkl");
2511 if (e
.cleanStr
!= "f") {
2512 return "additional characters are not ignored";
2518 // the lowest base is used by default
2519 // 7 could be decimal or hexadecimal, but should be detected as decimal
2521 e
= Entropy
.fromString("7");
2522 if (e
.base
.str
!= "base 10") {
2523 return "lowest base is not used";
2529 // Leading zeros are retained
2531 e
= Entropy
.fromString("000A");
2532 if (e
.cleanStr
!= "000A") {
2533 return "Leading zeros are not retained";
2539 // Leading zeros are correctly preserved for hex in binary string
2541 e
= Entropy
.fromString("2A");
2542 if (e
.binaryStr
!= "00101010") {
2543 return "Hex leading zeros are not correct in binary";
2549 // Leading zeros for base 6 as binary string
2550 // 20 = 2 events at 2.58 bits per event = 5 bits
2551 // 20 in base 6 = 12 in base 10 = 1100 in base 2
2552 // so it needs 1 bit of padding to be the right bit length
2554 e
= Entropy
.fromString("20");
2555 if (e
.binaryStr
!= "01100") {
2556 return "Base 6 as binary has leading zeros";
2562 // Leading zeros for base 10 as binary string
2564 e
= Entropy
.fromString("17");
2565 if (e
.binaryStr
!= "010001") {
2566 return "Base 10 as binary has leading zeros";
2572 // Leading zeros for card entropy as binary string.
2573 // Card entropy is hashed so 2c does not necessarily produce leading zeros.
2575 e
= Entropy
.fromString("2c");
2576 if (e
.binaryStr
!= "0010") {
2577 return "Card entropy as binary has leading zeros";
2583 // Keyboard mashing results in weak entropy
2584 // Despite being a long string, it's less than 30 bits of entropy
2586 e
= Entropy
.fromString("aj;se ifj; ask,dfv js;ifj");
2587 if (e
.binaryStr
.length
>= 30) {
2588 return "Keyboard mashing should produce weak entropy";
2594 // Card entropy is used if every pair could be a card
2596 e
= Entropy
.fromString("4c3c2c");
2597 if (e
.base
.str
!= "card") {
2598 return "Card entropy not used if all pairs are cards";
2604 // Card entropy uses base 52
2605 // [ cards, binary ]
2609 [ "acqs", "11011100" ],
2610 [ "acks", "01011100" ],
2611 [ "2cac", "11111000" ],
2624 [ "ks2c", "01010100" ],
2625 [ "KS2C", "01010100" ],
2627 for (var i
=0; i
<cards
.length
; i
++) {
2628 var card
= cards
[i
][0];
2629 var result
= cards
[i
][1];
2630 e
= Entropy
.fromString(card
);
2631 console
.log(e
.binary
+ " " + result
);
2632 if (e
.binaryStr
!== result
) {
2633 return "card entropy " + card
+ " not parsed correctly: " + result
+ " != " + e
.binaryStr
;
2642 if (response
!= "PASS") {
2643 console
.log("Entropy unit tests");
2644 console
.log(response
);
2651 // Entropy can be entered by the user
2653 page
.open(url
, function(status
) {
2655 mnemonic: "abandon abandon ability",
2656 address: "1Di3Vp7tBWtyQaDABLAjfWtF6V7hYKJtug",
2659 page
.evaluate(function() {
2660 $(".use-entropy").prop("checked", true).trigger("change");
2661 $(".entropy").val("00000000 00000000 00000000 00000000").trigger("input");
2663 // check the mnemonic is set and address is correct
2664 waitForGenerate(function() {
2665 var actual
= page
.evaluate(function() {
2667 address: $(".address:first").text(),
2668 mnemonic: $(".phrase").val(),
2671 if (actual
.mnemonic
!= expected
.mnemonic
) {
2672 console
.log("Entropy does not generate correct mnemonic");
2673 console
.log("Expected: " + expected
.mnemonic
);
2674 console
.log("Got: " + actual
.mnemonic
);
2677 if (actual
.address
!= expected
.address
) {
2678 console
.log("Entropy does not generate correct address");
2679 console
.log("Expected: " + expected
.address
);
2680 console
.log("Got: " + actual
.address
);
2688 // A warning about entropy is shown to the user, with additional information
2690 page
.open(url
, function(status
) {
2691 // get text content from entropy sections of page
2692 var hasWarning
= page
.evaluate(function() {
2693 var entropyText
= $(".entropy-container").text();
2694 var warning
= "mnemonic may be insecure";
2695 if (entropyText
.indexOf(warning
) == -1) {
2698 var readMoreText
= $("#entropy-notes").parent().text();
2699 var goodSources
= "flipping a fair coin, rolling a fair dice, noise measurements etc";
2700 if (readMoreText
.indexOf(goodSources
) == -1) {
2705 // check the warnings and information are shown
2707 console
.log("Page does not contain warning about using own entropy");
2714 // The types of entropy available are described to the user
2716 page
.open(url
, function(status
) {
2717 // get placeholder text for entropy field
2718 var placeholder
= page
.evaluate(function() {
2719 return $(".entropy").attr("placeholder");
2729 for (var i
=0; i
<options
.length
; i
++) {
2730 var option
= options
[i
];
2731 if (placeholder
.indexOf(option
) == -1) {
2732 console
.log("Available entropy type is not shown to user: " + option
);
2740 // The actual entropy used is shown to the user
2742 page
.open(url
, function(status
) {
2744 var badEntropySource
= page
.evaluate(function() {
2745 var entropy
= "Not A Very Good Entropy Source At All";
2746 $(".use-entropy").prop("checked", true).trigger("change");
2747 $(".entropy").val(entropy
).trigger("input");
2749 // check the actual entropy being used is shown
2750 waitForEntropyFeedback(function() {
2751 var expectedText
= "AedEceAA";
2752 var entropyText
= page
.evaluate(function() {
2753 return $(".entropy-container").text();
2755 if (entropyText
.indexOf(expectedText
) == -1) {
2756 console
.log("Actual entropy used is not shown");
2764 // Binary entropy can be entered
2766 page
.open(url
, function(status
) {
2768 page
.evaluate(function() {
2769 $(".use-entropy").prop("checked", true).trigger("change");
2770 $(".entropy").val("01").trigger("input");
2772 // check the entropy is shown to be the correct type
2773 waitForEntropyFeedback(function() {
2774 var entropyText
= page
.evaluate(function() {
2775 return $(".entropy-container").text();
2777 if (entropyText
.indexOf("binary") == -1) {
2778 console
.log("Binary entropy is not detected and presented to user");
2786 // Base 6 entropy can be entered
2788 page
.open(url
, function(status
) {
2790 page
.evaluate(function() {
2791 $(".use-entropy").prop("checked", true).trigger("change");
2792 $(".entropy").val("012345").trigger("input");
2794 // check the entropy is shown to be the correct type
2795 waitForEntropyFeedback(function() {
2796 var entropyText
= page
.evaluate(function() {
2797 return $(".entropy-container").text();
2799 if (entropyText
.indexOf("base 6") == -1) {
2800 console
.log("Base 6 entropy is not detected and presented to user");
2808 // Base 6 dice entropy can be entered
2810 page
.open(url
, function(status
) {
2812 page
.evaluate(function() {
2813 $(".use-entropy").prop("checked", true).trigger("change");
2814 $(".entropy").val("123456").trigger("input");
2816 // check the entropy is shown to be the correct type
2817 waitForEntropyFeedback(function() {
2818 var entropyText
= page
.evaluate(function() {
2819 return $(".entropy-container").text();
2821 if (entropyText
.indexOf("dice") == -1) {
2822 console
.log("Dice entropy is not detected and presented to user");
2830 // Base 10 entropy can be entered
2832 page
.open(url
, function(status
) {
2834 page
.evaluate(function() {
2835 $(".use-entropy").prop("checked", true).trigger("change");
2836 $(".entropy").val("789").trigger("input");
2838 // check the entropy is shown to be the correct type
2839 waitForEntropyFeedback(function() {
2840 var entropyText
= page
.evaluate(function() {
2841 return $(".entropy-container").text();
2843 if (entropyText
.indexOf("base 10") == -1) {
2844 console
.log("Base 10 entropy is not detected and presented to user");
2852 // Hexadecimal entropy can be entered
2854 page
.open(url
, function(status
) {
2856 page
.evaluate(function() {
2857 $(".use-entropy").prop("checked", true).trigger("change");
2858 $(".entropy").val("abcdef").trigger("input");
2860 // check the entropy is shown to be the correct type
2861 waitForEntropyFeedback(function() {
2862 var entropyText
= page
.evaluate(function() {
2863 return $(".entropy-container").text();
2865 if (entropyText
.indexOf("hexadecimal") == -1) {
2866 console
.log("Hexadecimal entropy is not detected and presented to user");
2874 // Dice entropy value is shown as the converted base 6 value
2876 page
.open(url
, function(status
) {
2878 page
.evaluate(function() {
2879 $(".use-entropy").prop("checked", true).trigger("change");
2880 $(".entropy").val("123456").trigger("input");
2882 // check the entropy is shown as base 6, not as the original dice value
2883 waitForEntropyFeedback(function() {
2884 var entropyText
= page
.evaluate(function() {
2885 return $(".entropy-container").text();
2887 if (entropyText
.indexOf("123450") == -1) {
2888 console
.log("Dice entropy is not shown to user as base 6 value");
2891 if (entropyText
.indexOf("123456") > -1) {
2892 console
.log("Dice entropy value is shown instead of true base 6 value");
2900 // The number of bits of entropy accumulated is shown
2902 page
.open(url
, function(status
) {
2905 [ "0000 0000 0000 0000 0000", "20" ],
2908 [ "6", "2" ], // 6 in card is 0 in base 6, 0 in base 6 is 2.6 bits (rounded down to 2 bits)
2909 [ "7", "3" ], // 7 in base 10 is 111 in base 2, no leading zeros
2914 [ "1A", "8" ], // hex is always multiple of 4 bits of entropy
2921 [ "6666", "10" ], // uses dice, so entropy is actually 0000 in base 6, which is 4 lots of 2.58 bits, which is 10.32 bits (rounded down to 10 bits)
2922 [ "2227", "13" ], // Uses base 10, which is 4 lots of 3.32 bits, which is 13.3 bits (rounded down to 13)
2925 [ "0000101017", "33" ], // 10 events at 3.32 bits per event
2926 [ "ac2c3c4c5c6c7c8c9ctcjcqckcad2d3d4d5d6d7d8d9dtdjdqdkdah2h3h4h5h6h7h8h9hthjhqhkhas2s3s4s5s6s7s8s9stsjsqsks", "225" ], // cards are not replaced, so a full deck is not 52^52 entropy which is 296 bits, it's 52!, which is 225 bits
2929 page
.evaluate(function(e
) {
2930 $(".use-entropy").prop("checked", true).trigger("change");
2933 var nextTest
= function runNextTest(i
) {
2934 var entropy
= tests
[i
][0];
2935 var expected
= tests
[i
][1];
2937 page
.evaluate(function(e
) {
2938 $(".entropy").val(e
).trigger("input");
2940 // check the number of bits of entropy is shown
2941 waitForEntropyFeedback(function() {
2942 var entropyText
= page
.evaluate(function() {
2943 return $(".entropy-container").text();
2945 if (entropyText
.replace(/\s/g,"").indexOf("Bits" + expected
) == -1) {
2946 console
.log("Accumulated entropy is not shown correctly for " + entropy
);
2949 var isLastTest
= i
== tests
.length
- 1;
2962 // There is feedback provided about the supplied entropy
2964 page
.open(url
, function(status
) {
2969 type: "hexadecimal",
2973 strength: "less than a second",
2976 entropy: "AAAAAAAA",
2977 filtered: "AAAAAAAA",
2978 type: "hexadecimal",
2982 strength: "less than a second - Repeats like \"aaa\" are easy to guess",
2985 entropy: "AAAAAAAA B",
2986 filtered: "AAAAAAAAB",
2987 type: "hexadecimal",
2991 strength: "less than a second - Repeats like \"aaa\" are easy to guess",
2994 entropy: "AAAAAAAA BBBBBBBB",
2995 filtered: "AAAAAAAABBBBBBBB",
2996 type: "hexadecimal",
3000 strength: "less than a second - Repeats like \"aaa\" are easy to guess",
3003 entropy: "AAAAAAAA BBBBBBBB CCCCCCCC",
3004 filtered: "AAAAAAAABBBBBBBBCCCCCCCC",
3005 type: "hexadecimal",
3009 strength: "less than a second",
3012 entropy: "AAAAAAAA BBBBBBBB CCCCCCCC DDDDDDDD",
3013 filtered: "AAAAAAAABBBBBBBBCCCCCCCCDDDDDDDD",
3014 type: "hexadecimal",
3018 strength: "2 minutes",
3021 entropy: "AAAAAAAA BBBBBBBB CCCCCCCC DDDDDDDA",
3022 filtered: "AAAAAAAABBBBBBBBCCCCCCCCDDDDDDDA",
3023 type: "hexadecimal",
3030 entropy: "AAAAAAAA BBBBBBBB CCCCCCCC DDDDDDDA EEEEEEEE",
3031 filtered: "AAAAAAAABBBBBBBBCCCCCCCCDDDDDDDAEEEEEEEE",
3032 type: "hexadecimal",
3036 strength: "3 years",
3039 entropy: "AAAAAAAA BBBBBBBB CCCCCCCC DDDDDDDA EEEEEEEE FFFFFFFF",
3040 filtered: "AAAAAAAABBBBBBBBCCCCCCCCDDDDDDDAEEEEEEEEFFFFFFFF",
3041 type: "hexadecimal",
3045 strength: "centuries",
3053 strength: "less than a second",
3056 entropy: "ac2c3c4c5c6c7c8c9ctcjcqckcad2d3d4d5d6d7d8d9dtdjdqdkdah2h3h4h5h6h7h8h9hthjhqhkhas2s3s4s5s6s7s8s9stsjsqsks",
3057 type: "card (full deck)",
3061 strength: "centuries",
3064 entropy: "ac2c3c4c5c6c7c8c9ctcjcqckcad2d3d4d5d6d7d8d9dtdjdqdkdah2h3h4h5h6h7h8h9hthjhqhkhas2s3s4s5s6s7s8s9stsjsqsks3d",
3065 type: "card (full deck, 1 duplicate: 3d)",
3069 strength: "centuries",
3072 entropy: "ac2c3c4c5c6c7c8c9ctcjcqckcad2d3d4d5d6d7d8d9dtdjdqdkdah2h3h4h5h6h7h8h9hthjhqhkhas2s3s4s5s6s7s8s9stsjsqs3d4d",
3073 type: "card (2 duplicates: 3d 4d, 1 missing: KS)",
3077 strength: "centuries",
3080 entropy: "ac2c3c4c5c6c7c8c9ctcjcqckcad2d3d4d5d6d7d8d9dtdjdqdkdah2h3h4h5h6h7h8h9hthjhqhkhas2s3s4s5s6s7s8s9stsjsqs3d4d5d6d",
3081 type: "card (4 duplicates: 3d 4d 5d..., 1 missing: KS)",
3085 strength: "centuries",
3087 // Next test was throwing uncaught error in zxcvbn
3088 // Also tests 451 bits, ie Math.log2(52!)*2 = 225.58 * 2
3090 entropy: "ac2c3c4c5c6c7c8c9ctcjcqckcad2d3d4d5d6d7d8d9dtdjdqdkdah2h3h4h5h6h7h8h9hthjhqhkhas2s3s4s5s6s7s8s9stsjsqsksac2c3c4c5c6c7c8c9ctcjcqckcad2d3d4d5d6d7d8d9dtdjdqdkdah2h3h4h5h6h7h8h9hthjhqhkhas2s3s4s5s6s7s8s9stsjsqsks",
3091 type: "card (full deck, 52 duplicates: ac 2c 3c...)",
3095 strength: "centuries",
3097 // Case insensitivity to duplicate cards
3100 type: "card (1 duplicate: AS)",
3104 strength: "less than a second",
3108 type: "card (1 duplicate: as)",
3112 strength: "less than a second",
3114 // Missing cards are detected
3116 entropy: "ac2c3c4c5c6c7c8c tcjcqckcad2d3d4d5d6d7d8d9dtdjdqdkdah2h3h4h5h6h7h8h9hthjhqhkhas2s3s4s5s6s7s8s9stsjsqsks",
3117 type: "card (1 missing: 9C)",
3121 strength: "centuries",
3124 entropy: "ac2c3c4c5c6c7c8c tcjcqckcad2d3d4d 6d7d8d9dtdjdqdkdah2h3h4h5h6h7h8h9hthjhqhkhas2s3s4s5s6s7s8s9stsjsqsks",
3125 type: "card (2 missing: 9C 5D)",
3129 strength: "centuries",
3132 entropy: "ac2c3c4c5c6c7c8c tcjcqckcad2d3d4d 6d7d8d9dtdjd kdah2h3h 5h6h7h8h9hthjhqhkhas2s3s4s5s6s7s8s9stsjsqsks",
3133 type: "card (4 missing: 9C 5D QD...)",
3137 strength: "centuries",
3139 // More than six missing cards does not show message
3141 entropy: "ac2c3c4c5c6c7c8c tcjcqckcad2d3d4d 6d 8d9d jd kdah2h3h 5h6h7h8h9hthjhqhkh 2s3s4s5s6s7s8s9stsjsqsks",
3146 strength: "centuries",
3148 // Multiple decks of cards increases bits per event
3168 entropy: "3d3d3d3d",
3174 entropy: "3d3d3d3d3d",
3180 entropy: "3d3d3d3d3d3d",
3186 entropy: "3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d",
3190 strength: 'less than a second - Repeats like "abcabcabc" are only slightly harder to guess than "abc"',
3194 page
.evaluate(function() {
3195 $(".use-entropy").prop("checked", true).trigger("change");
3197 var nextTest
= function runNextTest(i
) {
3198 function getFeedbackError(expected
, actual
) {
3199 if ("filtered" in expected
&& actual
.indexOf(expected
.filtered
) == -1) {
3200 return "Filtered value not in feedback";
3202 if ("type" in expected
&& actual
.indexOf(expected
.type
) == -1) {
3203 return "Entropy type not in feedback";
3205 if ("events" in expected
&& actual
.indexOf(expected
.events
) == -1) {
3206 return "Event count not in feedback";
3208 if ("bits" in expected
&& actual
.indexOf(expected
.bits
) == -1) {
3209 return "Bit count not in feedback";
3211 if ("strength" in expected
&& actual
.indexOf(expected
.strength
) == -1) {
3212 return "Strength not in feedback";
3214 if ("bitsPerEvent" in expected
&& actual
.indexOf(expected
.bitsPerEvent
) == -1) {
3215 return "bitsPerEvent not in feedback";
3220 page
.evaluate(function(e
) {
3221 $(".addresses").empty();
3222 $(".phrase").val("");
3223 $(".entropy").val(e
).trigger("input");
3225 waitForEntropyFeedback(function() {
3226 var mnemonic
= page
.evaluate(function() {
3227 return $(".phrase").val();
3229 // Check mnemonic length
3230 if ("words" in test
&& test
.words
== 0) {
3231 if (mnemonic
.length
> 0) {
3232 console
.log("Mnemonic length for " + test
.strength
+ " strength is not " + test
.words
);
3233 console
.log("Entropy: " + test
.entropy
);
3234 console
.log("Mnemonic: " + mnemonic
);
3238 else if ("words" in test
) {
3239 if (mnemonic
.split(" ").length
!= test
.words
) {
3240 console
.log("Mnemonic length for " + test
.strength
+ " strength is not " + test
.words
);
3241 console
.log("Entropy: " + test
.entropy
);
3242 console
.log("Mnemonic: " + mnemonic
);
3247 var feedback
= page
.evaluate(function() {
3248 return $(".entropy-container").text();
3250 var feedbackError
= getFeedbackError(test
, feedback
);
3251 if (feedbackError
) {
3252 console
.log("Entropy feedback for " + test
.entropy
+ " returned error");
3253 console
.log(feedbackError
);
3257 var isLastTest
= i
== tests
.length
- 1;
3270 // Entropy is truncated from the left
3272 page
.open(url
, function(status
) {
3273 var expected
= "avocado zoo zone";
3275 page
.evaluate(function() {
3276 $(".use-entropy").prop("checked", true).trigger("change");
3277 var entropy
= "00000000 00000000 00000000 00000000";
3278 entropy
+= "11111111 11111111 11111111 1111"; // Missing last byte
3279 $(".entropy").val(entropy
).trigger("input");
3281 // check the entropy is truncated from the right
3282 waitForGenerate(function() {
3283 var actual
= page
.evaluate(function() {
3284 return $(".phrase").val();
3286 if (actual
!= expected
) {
3287 console
.log("Entropy is not truncated from the right");
3288 console
.log("Expected: " + expected
);
3289 console
.log("Got: " + actual
);
3297 // Very large entropy results in very long mnemonics
3299 page
.open(url
, function(status
) {
3301 page
.evaluate(function() {
3302 $(".use-entropy").prop("checked", true).trigger("change");
3304 // Generate a very long entropy string
3305 for (var i
=0; i
<33; i
++) {
3306 entropy
+= "AAAAAAAA"; // 3 words * 33 iterations = 99 words
3308 $(".entropy").val(entropy
).trigger("input");
3310 // check the mnemonic is very long
3311 waitForGenerate(function() {
3312 var wordCount
= page
.evaluate(function() {
3313 return $(".phrase").val().split(" ").length
;
3315 if (wordCount
!= 99) {
3316 console
.log("Large entropy does not generate long mnemonic");
3317 console
.log("Expected 99 words, got " + wordCount
);
3325 // Is compatible with bip32jp entropy
3326 // https://bip32jp.github.io/english/index.html
3328 // Is incompatible with:
3331 page
.open(url
, function(status
) {
3332 var expected
= "train then jungle barely whip fiber purpose puppy eagle cloud clump hospital robot brave balcony utility detect estate old green desk skill multiply virus";
3334 page
.evaluate(function() {
3335 $(".use-entropy").prop("checked", true).trigger("change");
3336 var entropy
= "543210543210543210543210543210543210543210543210543210543210543210543210543210543210543210543210543";
3337 $(".entropy").val(entropy
).trigger("input");
3339 // check the mnemonic matches the expected value from bip32jp
3340 waitForGenerate(function() {
3341 var actual
= page
.evaluate(function() {
3342 return $(".phrase").val();
3344 if (actual
!= expected
) {
3345 console
.log("Mnemonic does not match bip32jp for base 6 entropy");
3346 console
.log("Expected: " + expected
);
3347 console
.log("Got: " + actual
);
3355 // Blank entropy does not generate mnemonic or addresses
3357 page
.open(url
, function(status
) {
3359 page
.evaluate(function() {
3360 $(".use-entropy").prop("checked", true).trigger("change");
3361 $(".entropy").val("").trigger("input");
3363 waitForFeedback(function() {
3364 // check there is no mnemonic
3365 var phrase
= page
.evaluate(function() {
3366 return $(".phrase").val();
3369 console
.log("Blank entropy does not result in blank mnemonic");
3370 console
.log("Got: " + phrase
);
3373 // check there are no addresses displayed
3374 var addresses
= page
.evaluate(function() {
3375 return $(".address").length
;
3377 if (addresses
!= 0) {
3378 console
.log("Blank entropy does not result in zero addresses");
3381 // Check the feedback says 'blank entropy'
3382 var feedback
= page
.evaluate(function() {
3383 return $(".feedback").text();
3385 if (feedback
!= "Blank entropy") {
3386 console
.log("Blank entropy does not show feedback message");
3394 // Mnemonic length can be selected even for weak entropy
3396 page
.open(url
, function(status
) {
3398 page
.evaluate(function() {
3399 $(".use-entropy").prop("checked", true).trigger("change");
3400 $(".entropy").val("012345");
3401 $(".mnemonic-length").val("18").trigger("change");
3403 // check the mnemonic is the correct length
3404 waitForGenerate(function() {
3405 var phrase
= page
.evaluate(function() {
3406 return $(".phrase").val();
3408 var numberOfWords
= phrase
.split(/\s/g).length
;
3409 if (numberOfWords
!= 18) {
3410 console
.log("Weak entropy cannot be overridden to give 18 word mnemonic");
3411 console
.log(phrase
);
3420 // https://github.com/iancoleman/bip39/issues/33
3421 // Final cards should contribute entropy
3423 page
.open(url
, function(status
) {
3425 page
.evaluate(function() {
3426 $(".use-entropy").prop("checked", true).trigger("change");
3427 $(".entropy").val("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").trigger("input");
3430 waitForGenerate(function() {
3431 var originalPhrase
= page
.evaluate(function() {
3432 return $(".phrase").val();
3434 // Set the last 12 cards to be AS
3435 page
.evaluate(function() {
3436 $(".addresses").empty();
3437 $(".entropy").val("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").trigger("input");
3439 // get the new mnemonic
3440 waitForGenerate(function() {
3441 var newPhrase
= page
.evaluate(function() {
3442 return $(".phrase").val();
3444 // check the phrase has changed
3445 if (newPhrase
== originalPhrase
) {
3446 console
.log("Changing last 12 cards does not change mnemonic");
3447 console
.log("Original:");
3448 console
.log(originalPhrase
);
3449 console
.log("New:");
3450 console
.log(newPhrase
);
3460 // https://github.com/iancoleman/bip39/issues/35
3463 page
.open(url
, function(status
) {
3465 page
.evaluate(function() {
3466 $(".generate").click();
3468 waitForGenerate(function() {
3469 var p
= page
.evaluate(function() {
3470 // get position of mnemonic element
3471 return $(".phrase").offset();
3473 p
.top
= Math
.ceil(p
.top
);
3474 p
.left
= Math
.ceil(p
.left
);
3475 // check the qr code shows
3476 page
.sendEvent("mousemove", p
.left
+4, p
.top
+4);
3477 var qrShowing
= page
.evaluate(function() {
3478 return $(".qr-container").find("canvas").length
> 0;
3481 console
.log("QR Code does not show");
3484 // check the qr code hides
3485 page
.sendEvent("mousemove", p
.left
-4, p
.top
-4);
3486 var qrHidden
= page
.evaluate(function() {
3487 return $(".qr-container").find("canvas").length
== 0;
3490 console
.log("QR Code does not hide");
3498 // BIP44 account extendend private key is shown
3499 // github issue 37 - compatibility with electrum
3501 page
.open(url
, function(status
) {
3503 var expected
= "xprv9yzrnt4zWVJUr1k2VxSPy9ettKz5PpeDMgaVG7UKedhqnw1tDkxP2UyYNhuNSumk2sLE5ctwKZs9vwjsq3e1vo9egCK6CzP87H2cVYXpfwQ";
3504 page
.evaluate(function() {
3505 $(".phrase").val("abandon abandon ability");
3506 $(".phrase").trigger("input");
3508 // check the BIP44 account extended private key
3509 waitForGenerate(function() {
3510 var actual
= page
.evaluate(function() {
3511 return $("#bip44 .account-xprv").val();
3513 if (actual
!= expected
) {
3514 console
.log("BIP44 account extended private key is incorrect");
3515 console
.log("Expected: " + expected
);
3516 console
.log("Actual: " + actual
);
3524 // BIP44 account extendend public key is shown
3525 // github issue 37 - compatibility with electrum
3527 page
.open(url
, function(status
) {
3529 var expected
= "xpub6CzDCPbtLrrn4VpVbyyQLHbdSMpZoHN4iuW64VswCyEpfjM2mJGdaHJ2DyuZwtst96E16VvcERb8BBeJdHSCVmAq9RhtRQg6eAZFrTKCNqf";
3530 page
.evaluate(function() {
3531 $(".phrase").val("abandon abandon ability");
3532 $(".phrase").trigger("input");
3534 // check the BIP44 account extended public key
3535 waitForGenerate(function() {
3536 var actual
= page
.evaluate(function() {
3537 return $("#bip44 .account-xpub").val();
3539 if (actual
!= expected
) {
3540 console
.log("BIP44 account extended public key is incorrect");
3541 console
.log("Expected: " + expected
);
3542 console
.log("Actual: " + actual
);
3551 // BIP32 root key can be set as an xpub
3553 page
.open(url
, function(status
) {
3555 page
.evaluate(function() {
3556 // set xpub for account 0 of bip44 for 'abandon abandon ability'
3557 var bip44AccountXpub
= "xpub6CzDCPbtLrrn4VpVbyyQLHbdSMpZoHN4iuW64VswCyEpfjM2mJGdaHJ2DyuZwtst96E16VvcERb8BBeJdHSCVmAq9RhtRQg6eAZFrTKCNqf";
3558 $("#root-key").val(bip44AccountXpub
);
3559 $("#root-key").trigger("input");
3561 waitForFeedback(function() {
3562 page
.evaluate(function() {
3564 $("#bip32-tab a").click();
3566 waitForGenerate(function() {
3567 page
.evaluate(function() {
3568 // derive external addresses for this xpub
3569 var firstAccountDerivationPath
= "m/0";
3570 $("#bip32-path").val(firstAccountDerivationPath
);
3571 $("#bip32-path").trigger("input");
3573 waitForGenerate(function() {
3574 // check the addresses are generated
3575 var expected
= "1Di3Vp7tBWtyQaDABLAjfWtF6V7hYKJtug";
3576 var actual
= page
.evaluate(function() {
3577 return $(".address:first").text();
3579 if (actual
!= expected
) {
3580 console
.log("xpub key does not generate addresses in table");
3581 console
.log("Expected: " + expected
);
3582 console
.log("Actual: " + actual
);
3585 // check the xprv key is not set
3586 var expected
= "NA";
3587 var actual
= page
.evaluate(function() {
3588 return $(".extended-priv-key").val();
3590 if (actual
!= expected
) {
3591 console
.log("xpub key as root shows derived bip32 xprv key");
3592 console
.log("Expected: " + expected
);
3593 console
.log("Actual: " + actual
);
3596 // check the private key is not set
3597 var expected
= "NA";
3598 var actual
= page
.evaluate(function() {
3599 return $(".privkey:first").text();
3601 if (actual
!= expected
) {
3602 console
.log("xpub key generates private key in addresses table");
3603 console
.log("Expected: " + expected
);
3604 console
.log("Actual: " + actual
);
3615 // xpub for bip32 root key will not work with hardened derivation paths
3617 page
.open(url
, function(status
) {
3619 page
.evaluate(function() {
3620 // set xpub for account 0 of bip44 for 'abandon abandon ability'
3621 var bip44AccountXpub
= "xpub6CzDCPbtLrrn4VpVbyyQLHbdSMpZoHN4iuW64VswCyEpfjM2mJGdaHJ2DyuZwtst96E16VvcERb8BBeJdHSCVmAq9RhtRQg6eAZFrTKCNqf";
3622 $("#root-key").val(bip44AccountXpub
);
3623 $("#root-key").trigger("input");
3625 waitForFeedback(function() {
3626 // Check feedback is correct
3627 var expected
= "Hardened derivation path is invalid with xpub key";
3628 var actual
= page
.evaluate(function() {
3629 return $(".feedback").text();
3631 if (actual
!= expected
) {
3632 console
.log("xpub key with hardened derivation path does not show feedback");
3633 console
.log("Expected: " + expected
);
3634 console
.log("Actual: " + actual
);
3637 // Check no addresses are shown
3639 var actual
= page
.evaluate(function() {
3640 return $(".addresses tr").length
;
3642 if (actual
!= expected
) {
3643 console
.log("addresses still show after setting xpub key with hardened derivation path");
3644 console
.log("Expected: " + expected
);
3645 console
.log("Actual: " + actual
);
3654 // no root key shows feedback
3656 page
.open(url
, function(status
) {
3657 // click the bip32 tab on fresh page
3658 page
.evaluate(function() {
3659 $("#bip32-tab a").click();
3661 waitForFeedback(function() {
3662 // Check feedback is correct
3663 var expected
= "No root key";
3664 var actual
= page
.evaluate(function() {
3665 return $(".feedback").text();
3667 if (actual
!= expected
) {
3668 console
.log("Blank root key not detected");
3669 console
.log("Expected: " + expected
);
3670 console
.log("Actual: " + actual
);
3679 // display error switching tabs while addresses are generating
3681 page
.open(url
, function(status
) {
3683 page
.evaluate(function() {
3684 $(".phrase").val("abandon abandon ability").trigger("input");
3686 waitForGenerate(function() {
3687 // set to generate 500 more addresses
3688 // generate more addresses
3689 // change tabs which should cancel the previous generating
3690 page
.evaluate(function() {
3691 $(".rows-to-add").val("100");
3693 $("#bip32-tab a").click();
3695 // check the derivation paths are in order and of the right quantity
3696 waitForGenerate(function() {
3697 var paths
= page
.evaluate(function() {
3698 return $(".index").map(function(i
, e
) {
3702 for (var i
=0; i
<paths
.length
; i
++) {
3703 var expected
= "m/0/" + i
;
3704 var actual
= paths
[i
];
3705 if (actual
!= expected
) {
3706 console
.log("Path " + i
+ " is not in correct order");
3707 console
.log("Expected: " + expected
);
3708 console
.log("Actual: " + actual
);
3712 if (paths
.length
!= 20) {
3713 console
.log("Generation was not cancelled by new action");
3723 // padding for binary should give length with multiple of 256
3724 // hashed entropy 1111 is length 252, so requires 4 leading zeros
3725 // prior to issue 49 it would only generate 2 leading zeros, ie missing 2
3727 page
.open(url
, function(status
) {
3728 expected
= "avocado valid quantum cross link predict excuse edit street able flame large galaxy ginger nuclear"
3730 page
.evaluate(function() {
3731 $(".use-entropy").prop("checked", true).trigger("change");
3732 $(".mnemonic-length").val("15");
3733 $(".entropy").val("1111").trigger("input");
3735 waitForGenerate(function() {
3737 var actual
= page
.evaluate(function() {
3738 return $(".phrase").val();
3740 // check the mnemonic is correct
3741 if (actual
!= expected
) {
3742 console
.log("Left padding error for entropy");
3743 console
.log("Expected: " + expected
);
3744 console
.log("Actual: " + actual
);
3752 // Github pull request 55
3753 // https://github.com/iancoleman/bip39/pull/55
3756 page
.open(url
, function(status
) {
3757 // set mnemonic and select bip32 tab
3758 page
.evaluate(function() {
3759 $("#bip32-tab a").click();
3760 $(".phrase").val("abandon abandon ability").trigger("input");
3762 waitForGenerate(function() {
3764 // set bip32 client to bitcoin core
3765 page
.evaluate(function() {
3766 var bitcoinCoreIndex
= "0";
3767 $("#bip32-client").val(bitcoinCoreIndex
).trigger("change");
3769 waitForGenerate(function() {
3770 // get the derivation path
3771 var actual
= page
.evaluate(function() {
3772 return $("#bip32-path").val();
3774 // check the derivation path is correct
3775 expected
= "m/0'/0'"
3776 if (actual
!= expected
) {
3777 console
.log("Selecting Bitcoin Core client does not set correct derivation path");
3778 console
.log("Expected: " + expected
);
3779 console
.log("Actual: " + actual
);
3782 // get hardened addresses
3783 var usesHardenedAddresses
= page
.evaluate(function() {
3784 return $(".hardened-addresses").prop("checked");
3786 // check hardened addresses is selected
3787 if(!usesHardenedAddresses
) {
3788 console
.log("Selecting Bitcoin Core client does not use hardened addresses");
3791 // check input is readonly
3792 var pathIsReadonly
= page
.evaluate(function() {
3793 return $("#bip32-path").prop("readonly");
3795 if (!pathIsReadonly
) {
3796 console
.log("Selecting Bitcoin Core client does not set derivation path to readonly");
3800 // set bip32 client to multibit
3801 page
.evaluate(function() {
3802 var multibitIndex
= "2";
3803 $("#bip32-client").val(multibitIndex
).trigger("change");
3805 waitForGenerate(function() {
3806 // get the derivation path
3807 var actual
= page
.evaluate(function() {
3808 return $("#bip32-path").val();
3810 // check the derivation path is correct
3812 if (actual
!= expected
) {
3813 console
.log("Selecting Multibit client does not set correct derivation path");
3814 console
.log("Expected: " + expected
);
3815 console
.log("Actual: " + actual
);
3818 // get hardened addresses
3819 var usesHardenedAddresses
= page
.evaluate(function() {
3820 return $(".hardened-addresses").prop("checked");
3822 // check hardened addresses is selected
3823 if(usesHardenedAddresses
) {
3824 console
.log("Selecting Multibit client does not uncheck hardened addresses");
3827 // CUSTOM DERIVATION PATH
3828 // check input is not readonly
3829 page
.evaluate(function() {
3830 $("#bip32-client").val("custom").trigger("change");
3832 // do not wait for generate, since there is no change to the
3833 // derivation path there is no new generation performed
3834 var pathIsReadonly
= page
.evaluate(function() {
3835 return $("#bip32-path").prop("readonly");
3837 if (pathIsReadonly
) {
3838 console
.log("Selecting Custom Derivation Path does not allow derivation path input");
3849 // https://github.com/iancoleman/bip39/issues/58
3850 // bip32 derivation is correct, does not drop leading zeros
3852 // https://medium.com/@alexberegszaszi/why-do-my-bip32-wallets-disagree-6f3254cc5846
3854 page
.open(url
, function(status
) {
3855 // set the phrase and passphrase
3856 var expected
= "17rxURoF96VhmkcEGCj5LNQkmN9HVhWb7F";
3857 // Note that bitcore generates an incorrect address
3858 // 13EuKhffWkBE2KUwcbkbELZb1MpzbimJ3Y
3859 // see the medium.com link above for more details
3860 page
.evaluate(function() {
3861 $(".phrase").val("fruit wave dwarf banana earth journey tattoo true farm silk olive fence");
3862 $(".passphrase").val("banana").trigger("input");
3864 // check the address is generated correctly
3865 waitForGenerate(function() {
3866 var actual
= page
.evaluate(function() {
3867 return $(".address:first").text();
3869 if (actual
!= expected
) {
3870 console
.log("BIP32 derivation is incorrect");
3871 console
.log("Expected: " + expected
);
3872 console
.log("Actual: " + actual
);
3882 // Japanese mnemonics generate incorrect bip32 seed
3883 // BIP39 seed is set from phrase
3885 page
.open(url
, function(status
) {
3887 var expected
= "a262d6fb6122ecf45be09c50492b31f92e9beb7d9a845987a02cefda57a15f9c467a17872029a9e92299b5cbdf306e3a0ee620245cbd508959b6cb7ca637bd55";
3888 page
.evaluate(function() {
3889 $(".phrase").val("あいこくしん あいこくしん あいこくしん あいこくしん あいこくしん あいこくしん あいこくしん あいこくしん あいこくしん あいこくしん あいこくしん あおぞら");
3890 $("#passphrase").val("メートルガバヴァぱばぐゞちぢ十人十色");
3891 $("#passphrase").trigger("input");
3893 // check the seed is generated correctly
3894 waitForGenerate(function() {
3895 var actual
= page
.evaluate(function() {
3896 return $(".seed").val();
3898 if (actual
!= expected
) {
3899 console
.log("BIP39 seed is incorrectly generated from Japanese mnemonic");
3900 console
.log("Expected: " + expected
);
3901 console
.log("Actual: " + actual
);
3909 // BIP49 official test vectors
3910 // https://github.com/bitcoin/bips/blob/master/bip-0049.mediawiki#test-vectors
3912 page
.open(url
, function(status
) {
3913 // set the phrase and select bitcoin testnet
3914 var expected
= "2Mww8dCYPUpKHofjgcXcBCEGmniw9CoaiD2";
3915 page
.evaluate(function() {
3916 $("#bip49-tab a").click();
3917 $(".phrase").val("abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon about");
3918 $(".network option[selected]").removeAttr("selected");
3919 $(".network option").filter(function() {
3920 return $(this).html() == "BTC - Bitcoin Testnet";
3921 }).prop("selected", true);
3922 $(".network").trigger("change");
3923 $(".phrase").trigger("input");
3925 // check the first address
3926 waitForGenerate(function() {
3927 var actual
= page
.evaluate(function() {
3928 return $(".address:first").text();
3930 if (actual
!= expected
) {
3931 console
.log("BIP49 address is incorrect");
3932 console
.log("Expected: " + expected
);
3933 console
.log("Actual: " + actual
);
3941 // BIP49 derivation path is shown
3943 page
.open(url
, function(status
) {
3945 var expected
= "m/49'/0'/0'/0";
3946 page
.evaluate(function() {
3947 $("#bip49-tab a").click();
3948 $(".phrase").val("abandon abandon ability").trigger("input");
3950 // check the derivation path of the first address
3951 waitForGenerate(function() {
3952 var actual
= page
.evaluate(function() {
3953 return $("#bip49 .path").val();
3955 if (actual
!= expected
) {
3956 console
.log("BIP49 derivation path is incorrect");
3957 console
.log("Expected: " + expected
);
3958 console
.log("Actual: " + actual
);
3966 // BIP49 extended private key is shown
3968 page
.open(url
, function(status
) {
3970 var expected
= "xprvA1hukYsW7QfX9CVsaDAKde4eryajKa4DKWb6m9YjSnqkiZHrahFwwTJfEQTwBQ5kptWT5pZMkkusT1oK8dc1efQ8VFfq4SLSPAWd7Cpt423";
3971 page
.evaluate(function() {
3972 $("#bip49-tab a").click();
3973 $(".phrase").val("abandon abandon ability").trigger("input");
3975 // check the BIP49 extended private key
3976 waitForGenerate(function() {
3977 var actual
= page
.evaluate(function() {
3978 return $(".extended-priv-key").val();
3980 if (actual
!= expected
) {
3981 console
.log("BIP49 extended private key is incorrect");
3982 console
.log("Expected: " + expected
);
3983 console
.log("Actual: " + actual
);
3991 // BIP49 extended public key is shown
3993 page
.open(url
, function(status
) {
3995 var expected
= "xpub6EhGA4QPwnDpMgaLgEhKzn1PR1RDj2n4gjWhZXxM18NjbMd18EaCVFd95gkLARJaBD2rXAYJED2gdkUbGn1KkrSzCKR554AdABUELoainnt";
3996 page
.evaluate(function() {
3997 $("#bip49-tab a").click();
3998 $(".phrase").val("abandon abandon ability").trigger("input");
4000 // check the BIP49 extended public key
4001 waitForGenerate(function() {
4002 var actual
= page
.evaluate(function() {
4003 return $(".extended-pub-key").val();
4005 if (actual
!= expected
) {
4006 console
.log("BIP49 extended public key is incorrect");
4007 console
.log("Expected: " + expected
);
4008 console
.log("Actual: " + actual
);
4016 // BIP49 account field changes address list
4018 page
.open(url
, function(status
) {
4020 var expected
= "381wg1GGN4rP88rNC9v7QWsiww63yLVPsn";
4021 page
.evaluate(function() {
4022 $("#bip49-tab a").click();
4023 $(".phrase").val("abandon abandon ability").trigger("input");
4025 waitForGenerate(function() {
4026 // change the bip49 account field to 1
4027 page
.evaluate(function() {
4028 $("#bip49 .account").val("1");
4029 $("#bip49 .account").trigger("input");
4031 waitForGenerate(function() {
4032 // check the address for the new derivation path
4033 var actual
= page
.evaluate(function() {
4034 return $(".address:first").text();
4036 if (actual
!= expected
) {
4037 console
.log("BIP49 account field generates incorrect address");
4038 console
.log("Expected: " + expected
);
4039 console
.log("Actual: " + actual
);
4048 // BIP49 change field changes address list
4050 page
.open(url
, function(status
) {
4052 var expected
= "3PEM7MiKed5konBoN66PQhK8r3hjGhy9dT";
4053 page
.evaluate(function() {
4054 $("#bip49-tab a").click();
4055 $(".phrase").val("abandon abandon ability").trigger("input");
4057 waitForGenerate(function() {
4058 // change the bip49 change field to 1
4059 page
.evaluate(function() {
4060 $("#bip49 .change").val("1");
4061 $("#bip49 .change").trigger("input");
4063 waitForGenerate(function() {
4064 // check the address for the new derivation path
4065 var actual
= page
.evaluate(function() {
4066 return $(".address:first").text();
4068 if (actual
!= expected
) {
4069 console
.log("BIP49 change field generates incorrect address");
4070 console
.log("Expected: " + expected
);
4071 console
.log("Actual: " + actual
);
4080 // BIP49 account extendend private key is shown
4082 page
.open(url
, function(status
) {
4084 var expected
= "xprv9y3uhgQbfQZbj3o98nfgLDwGGuCJjUn7GKArSAZXjKgMjSdYHjQmTyf78s22g6jsGrxXvHB6HJeFyvFSPkuYZajeTGMZVXV6aNLWw2fagCn";
4085 page
.evaluate(function() {
4086 $("#bip49-tab a").click();
4087 $(".phrase").val("abandon abandon ability");
4088 $(".phrase").trigger("input");
4090 // check the BIP49 account extended private key
4091 waitForGenerate(function() {
4092 var actual
= page
.evaluate(function() {
4093 return $("#bip49 .account-xprv").val();
4095 if (actual
!= expected
) {
4096 console
.log("BIP49 account extended private key is incorrect");
4097 console
.log("Expected: " + expected
);
4098 console
.log("Actual: " + actual
);
4106 // BIP49 account extendend public key is shown
4108 page
.open(url
, function(status
) {
4110 var expected
= "xpub6C3G7BwVVn7twXscEpCghMszpw2o8wVxdY6TEYy9HfDLcExgqGj21myazAiq6HSmW2F1cBiFqJa3D1cqcDpSh8pbZF5x4iqpd4PyJvd3gjB";
4111 page
.evaluate(function() {
4112 $("#bip49-tab a").click();
4113 $(".phrase").val("abandon abandon ability");
4114 $(".phrase").trigger("input");
4116 // check the BIP49 account extended public key
4117 waitForGenerate(function() {
4118 var actual
= page
.evaluate(function() {
4119 return $("#bip49 .account-xpub").val();
4121 if (actual
!= expected
) {
4122 console
.log("BIP49 account extended public key is incorrect");
4123 console
.log("Expected: " + expected
);
4124 console
.log("Actual: " + actual
);
4132 // Test selecting coin where bip49 is unavailable (eg CLAM)
4134 page
.open(url
, function(status
) {
4136 page
.evaluate(function() {
4137 $("#bip49-tab a").click();
4138 $(".phrase").val("abandon abandon ability");
4139 $(".phrase").trigger("input");
4141 waitForGenerate(function() {
4142 // select non-bip49 network, ie CLAM network
4143 page
.evaluate(function() {
4144 $(".network option[selected]").removeAttr("selected");
4145 $(".network option").filter(function() {
4146 return $(this).html() == "CLAM - Clams";
4147 }).prop("selected", true);
4148 $(".network").trigger("change");
4150 // check the BIP49 error is shown
4151 var bip49ErrorShown
= page
.evaluate(function() {
4152 var bip49hidden
= $("#bip49 .available").hasClass("hidden");
4153 bip49hidden
= bip49hidden
&& !($("#bip49 .unavailable").hasClass("hidden"));
4156 if (!bip49ErrorShown
) {
4157 console
.log("BIP49 error not shown for non-bip49 network");
4160 // check there are no addresses shown
4161 var addressCount
= page
.evaluate(function() {
4162 return $(".address").length
;
4164 if (addressCount
!= 0) {
4165 console
.log("BIP49 address count for non-bip49 network is " + addressCount
);
4168 // check the derived keys are blank
4169 var areBlank
= page
.evaluate(function() {
4170 var prvKeyIsBlank
= $(".extended-priv-key").val().length
== 0;
4171 var pubKeyIsBlank
= $(".extended-pub-key").val().length
== 0;
4172 return prvKeyIsBlank
&& pubKeyIsBlank
;
4175 console
.log("BIP49 extended keys for non-bip49 network are not blank ");
4184 // Cleared mnemonic and root key still allows addresses to be generated
4185 // https://github.com/iancoleman/bip39/issues/43
4187 page
.open(url
, function(status
) {
4189 page
.evaluate(function() {
4190 $("#bip49-tab a").click();
4191 $(".phrase").val("abandon abandon ability");
4192 $(".phrase").trigger("input");
4194 waitForGenerate(function() {
4195 // clear the mnemonic and root key
4196 page
.evaluate(function() {
4197 $(".phrase").val("");
4198 $(".phrase").trigger("input");
4199 $(".root-key").val("");
4200 $(".root-key").trigger("input");
4203 waitForFeedback(function() {
4204 // check there are no addresses shown
4205 var addressCount
= page
.evaluate(function() {
4206 return $(".address").length
;
4208 if (addressCount
!= 0) {
4209 console
.log("Clearing mnemonic should not allow addresses to be generated");
4219 // error trying to generate addresses from xpub with hardened derivation
4221 page
.open(url
, function(status
) {
4223 page
.evaluate(function() {
4224 // Use bip32 tab with hardened addresses
4225 $(".hardened-addresses").prop("checked", true);
4226 $("#bip32-tab a").click();
4227 // set xpub for account 0 of bip44 for 'abandon abandon ability'
4228 var bip44AccountXpub
= "xpub6CzDCPbtLrrn4VpVbyyQLHbdSMpZoHN4iuW64VswCyEpfjM2mJGdaHJ2DyuZwtst96E16VvcERb8BBeJdHSCVmAq9RhtRQg6eAZFrTKCNqf";
4229 $("#root-key").val(bip44AccountXpub
);
4230 $("#root-key").trigger("input");
4232 waitForFeedback(function() {
4233 // check the error message shows
4234 var expected
= "Hardened derivation path is invalid with xpub key";
4235 var actual
= page
.evaluate(function() {
4236 return $(".feedback").text();
4238 if (actual
!= expected
) {
4239 console
.log("xpub key with hardened addresses does not show feedback");
4240 console
.log("Expected: " + expected
);
4241 console
.log("Actual: " + actual
);
4249 // Litecoin uses xprv by default, and can optionally be set to ltpv
4251 // https://github.com/iancoleman/bip39/issues/96
4252 // Issue with extended keys on Litecoin
4254 page
.open(url
, function(status
) {
4255 // set the phrase and coin
4256 page
.evaluate(function() {
4257 $(".phrase").val("abandon abandon ability");
4258 $(".network option[selected]").removeAttr("selected");
4259 $(".network option").filter(function() {
4260 return $(this).html() == "LTC - Litecoin";
4261 }).prop("selected", true);
4262 $(".network").trigger("change");
4263 $(".phrase").trigger("input");
4265 // check the extended key is generated correctly
4266 waitForGenerate(function() {
4267 var expected
= "xprv9s21ZrQH143K2jkGDCeTLgRewT9F2pH5JZs2zDmmjXes34geVnFiuNa8KTvY5WoYvdn4Ag6oYRoB6cXtc43NgJAEqDXf51xPm6fhiMCKwpi";
4268 var actual
= page
.evaluate(function() {
4269 return $(".root-key").val();
4271 if (actual
!= expected
) {
4272 console
.log("Litecoin root key does not default to xprv");
4273 console
.log("Expected: " + expected
);
4274 console
.log("Actual: " + actual
);
4277 // set litecoin to use ltub
4278 page
.evaluate(function() {
4279 $(".addresses").empty();
4280 $(".litecoin-use-ltub").prop("checked", true);
4281 $(".litecoin-use-ltub").trigger("change");
4283 waitForGenerate(function() {
4284 var expected
= "Ltpv71G8qDifUiNesiPqf6h5V6eQ8ic77oxQiYtawiACjBEx3sTXNR2HGDGnHETYxESjqkMLFBkKhWVq67ey1B2MKQXannUqNy1RZVHbmrEjnEU";
4285 var actual
= page
.evaluate(function() {
4286 return $(".root-key").val();
4288 if (actual
!= expected
) {
4289 console
.log("Litecoin root key cannot be set to use ltub");
4290 console
.log("Expected: " + expected
);
4291 console
.log("Actual: " + actual
);
4300 // BIP32 tab can use P2WPKH Nested In P2SH
4301 // github issue 91 part 2
4302 // https://github.com/iancoleman/bip39/issues/91
4303 // generate new addresses from xpub?
4305 page
.open(url
, function(status
) {
4306 // set the xpub and coin and select bip32 tab with p2wpkh addresses
4307 page
.evaluate(function() {
4308 // use p2wpkh addresses
4309 $(".p2wpkh-nested-in-p2sh").prop("checked", true);
4311 $("#bip32-tab a").click();
4313 $(".network option[selected]").removeAttr("selected");
4314 $(".network option").filter(function() {
4315 return $(this).html() == "BTC - Bitcoin Testnet";
4316 }).prop("selected", true);
4317 $(".network").trigger("change");
4318 // Set root xpub to BIP49 official test vector account 0
4319 $(".root-key").val("tpubDD7tXK8KeQ3YY83yWq755fHY2JW8Ha8Q765tknUM5rSvjPcGWfUppDFMpQ1ScziKfW3ZNtZvAD7M3u7bSs7HofjTD3KP3YxPK7X6hwV8Rk2");
4320 $(".root-key").trigger("input");
4322 // check the address is generated correctly
4323 waitForGenerate(function() {
4324 var expected
= "2Mww8dCYPUpKHofjgcXcBCEGmniw9CoaiD2";
4325 var actual
= page
.evaluate(function() {
4326 return $(".address:first").text();
4328 if (actual
!= expected
) {
4329 console
.log("BIP32 tab cannot generate P2WPKH Nested In P2SH addresses");
4330 console
.log("Expected: " + expected
);
4331 console
.log("Actual: " + actual
);
4340 // https://github.com/iancoleman/bip39/issues/99#issuecomment-327094159
4341 // "warn me emphatically when they have detected invalid input" to the entropy field
4342 // A warning is shown when entropy is filtered and discarded
4344 page
.open(url
, function(status
) {
4346 page
.evaluate(function() {
4347 $(".use-entropy").prop("checked", true).trigger("change");
4348 $(".entropy").val("00000000 00000000 00000000 00000000").trigger("input");
4350 // check the filter warning does not show
4351 waitForGenerate(function() {
4352 var warningIsHidden
= page
.evaluate(function() {
4353 return $(".entropy-container .filter-warning").hasClass("hidden");
4355 if (!warningIsHidden
) {
4356 console
.log("Entropy filter warning is showing when it should not");
4359 page
.evaluate(function() {
4360 $(".entropy").val("10000000 zxcvbn 00000000 00000000 00000000").trigger("input");
4362 // check the filter warning shows
4363 waitForEntropyFeedback(function() {
4364 var warningIsHidden
= page
.evaluate(function() {
4365 return $(".entropy-container .filter-warning").hasClass("hidden");
4367 if (warningIsHidden
) {
4368 console
.log("Entropy filter warning is not showing when it should");
4377 // If you wish to add more tests, do so here...
4379 // Here is a blank test template
4383 page.open(url, function(status) {
4384 // Do something on the page
4385 page.evaluate(function() {
4386 $(".phrase").val("abandon abandon ability").trigger("input");
4388 waitForGenerate(function() {
4389 // Check the result of doing the thing
4390 var expected = "1Di3Vp7tBWtyQaDABLAjfWtF6V7hYKJtug";
4391 var actual = page.evaluate(function() {
4392 return $(".address:first").text();
4394 if (actual != expected) {
4395 console.log("A specific message about what failed");
4396 console.log("Expected: " + expected);
4397 console.log("Actual: " + actual);
4400 // Run the next test
4410 console
.log("Running tests...");
4411 tests
= shuffle(tests
);