diff options
Diffstat (limited to 'tests.js')
-rw-r--r-- | tests.js | 69 |
1 files changed, 62 insertions, 7 deletions
@@ -4,7 +4,7 @@ | |||
4 | 4 | ||
5 | var page = require('webpage').create(); | 5 | var page = require('webpage').create(); |
6 | var url = 'src/index.html'; | 6 | var url = 'src/index.html'; |
7 | var testMaxTime = 10000; | 7 | var testMaxTime = 20000; |
8 | 8 | ||
9 | page.viewportSize = { | 9 | page.viewportSize = { |
10 | width: 1024, | 10 | width: 1024, |
@@ -607,6 +607,66 @@ page.open(url, function(status) { | |||
607 | }); | 607 | }); |
608 | }, | 608 | }, |
609 | 609 | ||
610 | // Network can be set to ethereum | ||
611 | function() { | ||
612 | |||
613 | page.open(url, function(status) { | ||
614 | |||
615 | // set the phrase and coin | ||
616 | page.evaluate(function() { | ||
617 | $(".phrase").val("abandon abandon ability"); | ||
618 | $(".phrase").trigger("input"); | ||
619 | $(".network option[selected]").removeAttr("selected"); | ||
620 | $(".network option[value=13]").prop("selected", true); | ||
621 | $(".network").trigger("change"); | ||
622 | }); | ||
623 | waitForGenerate(function() { | ||
624 | // check the address is generated correctly | ||
625 | // this value comes from | ||
626 | // https://www.myetherwallet.com/#view-wallet-info | ||
627 | // Unusual capitalization is due to checksum | ||
628 | var expected = "0xe5815d5902Ad612d49283DEdEc02100Bd44C2772"; | ||
629 | var actual = page.evaluate(function() { | ||
630 | return $(".address:first").text(); | ||
631 | }); | ||
632 | if (actual != expected) { | ||
633 | console.log("Ethereum address is incorrect"); | ||
634 | console.log("Expected: " + expected); | ||
635 | console.log("Actual: " + actual); | ||
636 | fail(); | ||
637 | } | ||
638 | // check the private key is correct | ||
639 | // this private key can be imported into | ||
640 | // https://www.myetherwallet.com/#view-wallet-info | ||
641 | // and it should correlate to the address above | ||
642 | var expected = "8f253078b73d7498302bb78c171b23ce7a8fb511987d2b2702b731638a4a15e7"; | ||
643 | var actual = page.evaluate(function() { | ||
644 | return $(".privkey:first").text(); | ||
645 | }); | ||
646 | if (actual != expected) { | ||
647 | console.log("Ethereum privkey is incorrect"); | ||
648 | console.log("Expected: " + expected); | ||
649 | console.log("Actual: " + actual); | ||
650 | fail(); | ||
651 | } | ||
652 | // check the public key is correct | ||
653 | // TODO | ||
654 | // don't have any third-party source to generate the expected value | ||
655 | //var expected = "?"; | ||
656 | //var actual = page.evaluate(function() { | ||
657 | // return $(".pubkey:first").text(); | ||
658 | //}); | ||
659 | //if (actual != expected) { | ||
660 | // console.log("Ethereum privkey is incorrect"); | ||
661 | // console.log("Expected: " + expected); | ||
662 | // console.log("Actual: " + actual); | ||
663 | // fail(); | ||
664 | //} | ||
665 | next(); | ||
666 | }); | ||
667 | }); | ||
668 | }, | ||
669 | |||
610 | // BIP39 seed is set from phrase | 670 | // BIP39 seed is set from phrase |
611 | function() { | 671 | function() { |
612 | page.open(url, function(status) { | 672 | page.open(url, function(status) { |
@@ -2268,7 +2328,6 @@ page.open(url, function(status) { | |||
2268 | // use entropy | 2328 | // use entropy |
2269 | page.evaluate(function() { | 2329 | page.evaluate(function() { |
2270 | $(".use-entropy").prop("checked", true).trigger("change"); | 2330 | $(".use-entropy").prop("checked", true).trigger("change"); |
2271 | $(".mnemonic-length").val("raw"); | ||
2272 | $(".entropy").val("00000000 00000000 00000000 00000000").trigger("input"); | 2331 | $(".entropy").val("00000000 00000000 00000000 00000000").trigger("input"); |
2273 | }); | 2332 | }); |
2274 | // check the mnemonic is set and address is correct | 2333 | // check the mnemonic is set and address is correct |
@@ -2804,7 +2863,6 @@ page.open(url, function(status) { | |||
2804 | // use entropy | 2863 | // use entropy |
2805 | page.evaluate(function() { | 2864 | page.evaluate(function() { |
2806 | $(".use-entropy").prop("checked", true).trigger("change"); | 2865 | $(".use-entropy").prop("checked", true).trigger("change"); |
2807 | $(".mnemonic-length").val("raw"); | ||
2808 | }); | 2866 | }); |
2809 | var nextTest = function runNextTest(i) { | 2867 | var nextTest = function runNextTest(i) { |
2810 | function getFeedbackError(expected, actual) { | 2868 | function getFeedbackError(expected, actual) { |
@@ -2886,7 +2944,6 @@ page.open(url, function(status) { | |||
2886 | // use entropy | 2944 | // use entropy |
2887 | page.evaluate(function() { | 2945 | page.evaluate(function() { |
2888 | $(".use-entropy").prop("checked", true).trigger("change"); | 2946 | $(".use-entropy").prop("checked", true).trigger("change"); |
2889 | $(".mnemonic-length").val("raw"); | ||
2890 | var entropy = "00000000 00000000 00000000 00000000"; | 2947 | var entropy = "00000000 00000000 00000000 00000000"; |
2891 | entropy += "11111111 11111111 11111111 1111"; // Missing last byte | 2948 | entropy += "11111111 11111111 11111111 1111"; // Missing last byte |
2892 | $(".entropy").val(entropy).trigger("input"); | 2949 | $(".entropy").val(entropy).trigger("input"); |
@@ -2913,7 +2970,6 @@ page.open(url, function(status) { | |||
2913 | // use entropy | 2970 | // use entropy |
2914 | page.evaluate(function() { | 2971 | page.evaluate(function() { |
2915 | $(".use-entropy").prop("checked", true).trigger("change"); | 2972 | $(".use-entropy").prop("checked", true).trigger("change"); |
2916 | $(".mnemonic-length").val("raw"); | ||
2917 | var entropy = ""; | 2973 | var entropy = ""; |
2918 | // Generate a very long entropy string | 2974 | // Generate a very long entropy string |
2919 | for (var i=0; i<33; i++) { | 2975 | for (var i=0; i<33; i++) { |
@@ -2947,7 +3003,6 @@ page.open(url, function(status) { | |||
2947 | // use entropy | 3003 | // use entropy |
2948 | page.evaluate(function() { | 3004 | page.evaluate(function() { |
2949 | $(".use-entropy").prop("checked", true).trigger("change"); | 3005 | $(".use-entropy").prop("checked", true).trigger("change"); |
2950 | $(".mnemonic-length").val("raw"); | ||
2951 | var entropy = "543210543210543210543210543210543210543210543210543210543210543210543210543210543210543210543210543"; | 3006 | var entropy = "543210543210543210543210543210543210543210543210543210543210543210543210543210543210543210543210543"; |
2952 | $(".entropy").val(entropy).trigger("input"); | 3007 | $(".entropy").val(entropy).trigger("input"); |
2953 | }); | 3008 | }); |
@@ -3039,7 +3094,6 @@ page.open(url, function(status) { | |||
3039 | // use entropy | 3094 | // use entropy |
3040 | page.evaluate(function() { | 3095 | page.evaluate(function() { |
3041 | $(".use-entropy").prop("checked", true).trigger("change"); | 3096 | $(".use-entropy").prop("checked", true).trigger("change"); |
3042 | $(".mnemonic-length").val("raw"); | ||
3043 | $(".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"); | 3097 | $(".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"); |
3044 | }); | 3098 | }); |
3045 | // get the mnemonic | 3099 | // get the mnemonic |
@@ -3345,6 +3399,7 @@ page.open(url, function(status) { | |||
3345 | // use entropy | 3399 | // use entropy |
3346 | page.evaluate(function() { | 3400 | page.evaluate(function() { |
3347 | $(".use-entropy").prop("checked", true).trigger("change"); | 3401 | $(".use-entropy").prop("checked", true).trigger("change"); |
3402 | $(".mnemonic-length").val("15"); | ||
3348 | $(".entropy").val("1111").trigger("input"); | 3403 | $(".entropy").val("1111").trigger("input"); |
3349 | }); | 3404 | }); |
3350 | waitForGenerate(function() { | 3405 | waitForGenerate(function() { |