]> git.immae.eu Git - perso/Immae/Projets/Cryptomonnaies/BIP39.git/blobdiff - tests.js
MIT license
[perso/Immae/Projets/Cryptomonnaies/BIP39.git] / tests.js
index 0ce34bdbb9ba688ed1dafb33d73db65a9e14c8da..c7d92e4ead3365d99a4955e40cb7448733226902 100644 (file)
--- a/tests.js
+++ b/tests.js
@@ -2237,6 +2237,7 @@ page.open(url, function(status) {
     // use entropy
     page.evaluate(function() {
         $(".use-entropy").prop("checked", true).trigger("change");
+        $(".mnemonic-length").val("raw");
         $(".entropy").val("00000000 00000000 00000000 00000000").trigger("input");
     });
     // check the mnemonic is set and address is correct
@@ -2858,6 +2859,7 @@ page.open(url, function(status) {
     // use entropy
     page.evaluate(function() {
         $(".use-entropy").prop("checked", true).trigger("change");
+        $(".mnemonic-length").val("raw");
     });
     var nextTest = function runNextTest(i) {
         function getFeedbackError(expected, actual) {
@@ -2934,6 +2936,7 @@ page.open(url, function(status) {
     // use entropy
     page.evaluate(function() {
         $(".use-entropy").prop("checked", true).trigger("change");
+        $(".mnemonic-length").val("raw");
         var entropy  = "00000000 00000000 00000000 00000000";
             entropy += "11111111 11111111 11111111 1111"; // Missing last byte
         $(".entropy").val(entropy).trigger("input");
@@ -2960,6 +2963,7 @@ page.open(url, function(status) {
     // use entropy
     page.evaluate(function() {
         $(".use-entropy").prop("checked", true).trigger("change");
+        $(".mnemonic-length").val("raw");
         var entropy  = "";
         // Generate a very long entropy string
         for (var i=0; i<33; i++) {
@@ -2993,6 +2997,7 @@ page.open(url, function(status) {
     // use entropy
     page.evaluate(function() {
         $(".use-entropy").prop("checked", true).trigger("change");
+        $(".mnemonic-length").val("raw");
         var entropy  = "543210543210543210543210543210543210543210543210543210543210543210543210543210543210543210543210543";
         $(".entropy").val(entropy).trigger("input");
     });
@@ -3084,6 +3089,7 @@ page.open(url, function(status) {
     // use entropy
     page.evaluate(function() {
         $(".use-entropy").prop("checked", true).trigger("change");
+        $(".mnemonic-length").val("raw");
         $(".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");
     });
     // get the mnemonic
@@ -3101,6 +3107,19 @@ page.open(url, function(status) {
             var newPhrase = page.evaluate(function() {
                 return $(".phrase").val();
             });
+            // check raw entropy is in use, ie the first bits should remain the same
+            var startLength = 20;
+            var originalPhraseStart = originalPhrase.substring(0,startLength);
+            var newPhraseStart = newPhrase.substring(0,startLength);
+            if (newPhraseStart != originalPhraseStart) {
+                console.log("Changing last 12 cards changed first portion of mnemonic");
+                console.log("Original:");
+                console.log(originalPhrase);
+                console.log("New:");
+                console.log(newPhrase);
+                fail();
+            }
+            // check the phrase has changed
             if (newPhrase == originalPhrase) {
                 console.log("Changing last 12 cards does not change mnemonic");
                 console.log("Original:");