]> git.immae.eu Git - perso/Immae/Projets/Cryptomonnaies/BIP39.git/blobdiff - tests.js
Test setting BIP32 root key clears phrase
[perso/Immae/Projets/Cryptomonnaies/BIP39.git] / tests.js
index 2800e6cf073b4ee6cc0f8a1dbcac9480eed55f63..97cb646b4780633d771ea767e36f7ae29c6986d5 100644 (file)
--- a/tests.js
+++ b/tests.js
@@ -1291,7 +1291,59 @@ page.open(url, function(status) {
 },
 
 // BIP32 root key can be set by the user
+function() {
+page.open(url, function(status) {
+    var expected = "1Di3Vp7tBWtyQaDABLAjfWtF6V7hYKJtug";
+    // set the root key
+    page.evaluate(function() {
+        $(".root-key").val("xprv9s21ZrQH143K2jkGDCeTLgRewT9F2pH5JZs2zDmmjXes34geVnFiuNa8KTvY5WoYvdn4Ag6oYRoB6cXtc43NgJAEqDXf51xPm6fhiMCKwpi").trigger("input");
+    });
+    waitForGenerate(function() {
+        var actual = page.evaluate(function() {
+            return $(".address:first").text();
+        });
+        if (actual != expected) {
+            console.log("Setting BIP32 root key results in wrong address");
+            console.log("Expected: " + expected);
+            console.log("Actual: " + actual);
+            fail();
+        }
+        next();
+    });
+});
+},
+
 // 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
 // Custom BIP32 root key is used when changing the derivation path