X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;ds=sidebyside;f=tests.js;h=e5a40ae1447b138d7043ee5a462ea3e1a59fd674;hb=7ff86d4c983f1e8c80b87b31acfd69fcf98c1b82;hp=cef6e138828af369827332194fcb5a354f476527;hpb=61ed16a9cefec8a9a9b7d7c41141e6ef10c3e3e1;p=perso%2FImmae%2FProjets%2FCryptomonnaies%2FBIP39.git diff --git a/tests.js b/tests.js index cef6e13..e5a40ae 100644 --- a/tests.js +++ b/tests.js @@ -1303,7 +1303,7 @@ page.open(url, function(status) { return $(".address:first").text(); }); if (actual != expected) { - console.log("Passphrase results in wrong address"); + console.log("Setting BIP32 root key results in wrong address"); console.log("Expected: " + expected); console.log("Actual: " + actual); fail(); @@ -1314,8 +1314,94 @@ page.open(url, function(status) { }, // Setting BIP32 root key clears the existing phrase, passphrase and seed +function() { +page.open(url, function(status) { + var expected = ""; + // set a mnemonic + page.evaluate(function() { + $(".phrase").val("A non-blank but invalid value"); + }); + // Accept any confirm dialogs + page.onConfirm = function() { + return true; + }; + // set the root key + page.evaluate(function() { + $(".root-key").val("xprv9s21ZrQH143K2jkGDCeTLgRewT9F2pH5JZs2zDmmjXes34geVnFiuNa8KTvY5WoYvdn4Ag6oYRoB6cXtc43NgJAEqDXf51xPm6fhiMCKwpi").trigger("input"); + }); + waitForGenerate(function() { + var actual = page.evaluate(function() { + return $(".phrase").val(); + }); + if (actual != expected) { + console.log("Phrase not cleared when setting BIP32 root key"); + console.log("Expected: " + expected); + console.log("Actual: " + actual); + fail(); + } + next(); + }); +}); +}, + // Clearing of phrase, passphrase and seed can be cancelled by user +function() { +page.open(url, function(status) { + var expected = "abandon abandon ability"; + // set a mnemonic + page.evaluate(function() { + $(".phrase").val("abandon abandon ability"); + }); + // Cancel any confirm dialogs + page.onConfirm = function() { + return false; + }; + // set the root key + page.evaluate(function() { + $(".root-key").val("xprv9s21ZrQH143K3d3vzEDD3KpSKmxsZ3y7CqhAL1tinwtP6wqK4TKEKjpBuo6P2hUhB6ZENo7TTSRytiP857hBZVpBdk8PooFuRspE1eywwNZ").trigger("input"); + }); + var actual = page.evaluate(function() { + return $(".phrase").val(); + }); + if (actual != expected) { + console.log("Phrase not retained when cancelling changes to BIP32 root key"); + console.log("Expected: " + expected); + console.log("Actual: " + actual); + fail(); + } + next(); +}); +}, + // Custom BIP32 root key is used when changing the derivation path +function() { +page.open(url, function(status) { + var expected = "1Nq2Wmu726XHCuGhctEtGmhxo3wzk5wZ1H"; + // set the root key + page.evaluate(function() { + $(".root-key").val("xprv9s21ZrQH143K2jkGDCeTLgRewT9F2pH5JZs2zDmmjXes34geVnFiuNa8KTvY5WoYvdn4Ag6oYRoB6cXtc43NgJAEqDXf51xPm6fhiMCKwpi").trigger("input"); + }); + waitForGenerate(function() { + // change the derivation path + page.evaluate(function() { + $("#account").val("1").trigger("input"); + }); + // check the bip32 root key is used for derivation, not the blank phrase + waitForGenerate(function() { + var actual = page.evaluate(function() { + return $(".address:first").text(); + }); + if (actual != expected) { + console.log("Changing the derivation path does not use BIP32 root key"); + console.log("Expected: " + expected); + console.log("Actual: " + actual); + fail(); + } + next(); + }); + }); +}); +}, // Incorrect mnemonic shows error // Incorrect word shows suggested replacement