diff options
author | Ian Coleman <coleman.ian@gmail.com> | 2017-02-11 20:15:11 +1100 |
---|---|---|
committer | Ian Coleman <coleman.ian@gmail.com> | 2017-02-11 20:26:21 +1100 |
commit | 24137d96070eb6cb47ef8239738ec6a135f0b675 (patch) | |
tree | f6de0c80cf9b19a988b9b44e1a88b9b17e06b09a /tests.js | |
parent | 0edac945e597099d1cabfa684e3c172b3d70cf6c (diff) | |
download | BIP39-24137d96070eb6cb47ef8239738ec6a135f0b675.tar.gz BIP39-24137d96070eb6cb47ef8239738ec6a135f0b675.tar.zst BIP39-24137d96070eb6cb47ef8239738ec6a135f0b675.zip |
Ethereum tests
Expected values come from
https://www.myetherwallet.com/#view-wallet-info
Polyfill for ArrayBuffer.isView is required for phantomjs-2.1.1 but
seems not required in modern browsers. I'll keep it there because the
tests need to pass.
Also see https://github.com/kvhnuke/etherwallet/issues/337
Unusual capitalization of hex encoded ethereum address
Diffstat (limited to 'tests.js')
-rw-r--r-- | tests.js | 60 |
1 files changed, 60 insertions, 0 deletions
@@ -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 | // I do not understand the capitalization scheme for this hex encoding | ||
628 | var expected = "0xe5815d5902Ad612d49283DEdEc02100Bd44C2772"; | ||
629 | var actual = page.evaluate(function() { | ||
630 | return $(".address:first").text(); | ||
631 | }); | ||
632 | if (actual != expected.toLowerCase()) { | ||
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) { |