X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=tests.js;h=e5a40ae1447b138d7043ee5a462ea3e1a59fd674;hb=7ff86d4c983f1e8c80b87b31acfd69fcf98c1b82;hp=683af9b6149153e8380e70c37b050109c5deb808;hpb=8cd5e23162bd8b339954f9cd57fcb533e619a158;p=perso%2FImmae%2FProjets%2FCryptomonnaies%2FBIP39.git diff --git a/tests.js b/tests.js index 683af9b..e5a40ae 100644 --- a/tests.js +++ b/tests.js @@ -485,6 +485,62 @@ page.open(url, function(status) { }); }, +// Network can be set to namecoin +function() { +page.open(url, function(status) { + // set the phrase and coin + var expected = "Mw2vK2Bvex1yYtYF6sfbEg2YGoUc98YUD2"; + page.evaluate(function() { + $(".phrase").val("abandon abandon ability"); + $(".phrase").trigger("input"); + $(".network option[selected]").removeAttr("selected"); + $(".network option[value=11]").prop("selected", true); + $(".network").trigger("change"); + }); + // check the address is generated correctly + waitForGenerate(function() { + var actual = page.evaluate(function() { + return $(".address:first").text(); + }); + if (actual != expected) { + console.log("Namecoin address is incorrect"); + console.log("Expected: " + expected); + console.log("Actual: " + actual); + fail(); + } + next(); + }); +}); +}, + +// Network can be set to peercoin +function() { +page.open(url, function(status) { + // set the phrase and coin + var expected = "PVAiioTaK2eDHSEo3tppT9AVdBYqxRTBAm"; + page.evaluate(function() { + $(".phrase").val("abandon abandon ability"); + $(".phrase").trigger("input"); + $(".network option[selected]").removeAttr("selected"); + $(".network option[value=12]").prop("selected", true); + $(".network").trigger("change"); + }); + // check the address is generated correctly + waitForGenerate(function() { + var actual = page.evaluate(function() { + return $(".address:first").text(); + }); + if (actual != expected) { + console.log("Peercoin address is incorrect"); + console.log("Expected: " + expected); + console.log("Actual: " + actual); + fail(); + } + next(); + }); +}); +}, + // BIP39 seed is set from phrase function() { page.open(url, function(status) { @@ -1104,15 +1160,248 @@ page.open(url, function(status) { }, // Private key visibility can be toggled +function() { +page.open(url, function(status) { + // set the phrase + page.evaluate(function() { + $(".phrase").val("abandon abandon ability"); + $(".phrase").trigger("input"); + }); + waitForGenerate(function() { + // toggle private key visibility + page.evaluate(function() { + $(".private-key-toggle").click(); + }); + // check the private key is not visible + var isInvisible = page.evaluate(function() { + return $(".privkey:first span").hasClass("invisible"); + }); + if (!isInvisible) { + console.log("Toggled private key is visible"); + fail(); + } + next(); + }); +}); +}, // More addresses can be generated +function() { +page.open(url, function(status) { + // set the phrase + page.evaluate(function() { + $(".phrase").val("abandon abandon ability"); + $(".phrase").trigger("input"); + }); + waitForGenerate(function() { + // generate more addresses + page.evaluate(function() { + $(".more").click(); + }); + waitForGenerate(function() { + // check there are more addresses + var addressCount = page.evaluate(function() { + return $(".address").length; + }); + if (addressCount != 40) { + console.log("More addresses cannot be generated"); + fail(); + } + next(); + }); + }); +}); +}, + // A custom number of additional addresses can be generated +function() { +page.open(url, function(status) { + // set the phrase + page.evaluate(function() { + $(".phrase").val("abandon abandon ability"); + $(".phrase").trigger("input"); + }); + waitForGenerate(function() { + // get the current number of addresses + var oldAddressCount = page.evaluate(function() { + return $(".address").length; + }); + // set a custom number of additional addresses + page.evaluate(function() { + $(".rows-to-add").val(1); + }); + // generate more addresses + page.evaluate(function() { + $(".more").click(); + }); + waitForGenerate(function() { + // check there are the correct number of addresses + var newAddressCount = page.evaluate(function() { + return $(".address").length; + }); + if (newAddressCount - oldAddressCount != 1) { + console.log("Number of additional addresses cannot be customized"); + console.log(newAddressCount) + console.log(oldAddressCount) + fail(); + } + next(); + }); + }); +}); +}, + // Additional addresses are shown in order of derivation path +function() { +page.open(url, function(status) { + // set the phrase + page.evaluate(function() { + $(".phrase").val("abandon abandon ability").trigger("input"); + }); + waitForGenerate(function() { + // generate more addresses + page.evaluate(function() { + $(".more").click(); + }); + // get the derivation paths + waitForGenerate(function() { + var paths = page.evaluate(function() { + return $(".index").map(function(i, e) { + return $(e).text(); + }); + }); + if (paths.length != 40) { + console.log("Total additional paths is less than expected: " + paths.length); + fail(); + } + for (var i=0; i