]> git.immae.eu Git - perso/Immae/Projets/Cryptomonnaies/BIP39.git/commitdiff
Test suggested word for first four letters of word
authorIan Coleman <coleman.ian@gmail.com>
Tue, 3 Jan 2017 23:59:21 +0000 (10:59 +1100)
committerIan Coleman <coleman.ian@gmail.com>
Tue, 3 Jan 2017 23:59:21 +0000 (10:59 +1100)
See https://github.com/iancoleman/bip39/pull/48

bip39-standalone.html
src/js/index.js
tests.js

index 4a186578a992259a2224704771d4332218e92de2..5158b108ebed17ffe074807684de320592685a40 100644 (file)
@@ -19292,8 +19292,9 @@ window.Entropy = new (function() {
         var closestWord = words[0];
         for (var i=0; i<words.length; i++) {
             var comparedTo = words[i];
-            if (comparedTo.indexOf(word) == 0) return comparedTo;
-
+            if (comparedTo.indexOf(word) == 0) {
+                return comparedTo;
+            }
             var distance = Levenshtein.get(word, comparedTo);
             if (distance < minDistance) {
                 closestWord = comparedTo;
index af09606916b22b54d28829ca4dd68f1bfa42dd75..c1989775ede6aa8f9e591d77ed7b66ade282c29d 100644 (file)
         var closestWord = words[0];
         for (var i=0; i<words.length; i++) {
             var comparedTo = words[i];
-            if (comparedTo.indexOf(word) == 0) return comparedTo;
-
+            if (comparedTo.indexOf(word) == 0) {
+                return comparedTo;
+            }
             var distance = Levenshtein.get(word, comparedTo);
             if (distance < minDistance) {
                 closestWord = comparedTo;
index 4d229abe2ff56ad7152cefe9c2010ce723ceb931..48e863b5f91759b7cb7b520e38bffc65d54011ed 100644 (file)
--- a/tests.js
+++ b/tests.js
@@ -1562,6 +1562,31 @@ page.open(url, function(status) {
 });
 },
 
+// Github pull request 48
+// First four letters of word shows that word, not closest
+// since first four letters gives unique word in BIP39 wordlist
+// eg ille should show illegal, not idle
+function() {
+page.open(url, function(status) {
+    // set the incomplete word
+    page.evaluate(function() {
+        $(".phrase").val("ille").trigger("input");
+    });
+    // check there is a suggestion shown
+    waitForFeedback(function() {
+        var feedback = page.evaluate(function() {
+            return $(".feedback").text();
+        });
+        if (feedback.indexOf("did you mean illegal?") < 0) {
+            console.log("Start of word does not show correct suggestion");
+            console.log("Error: " + error);
+            fail();
+        }
+        next();
+    });
+});
+},
+
 // Incorrect BIP32 root key shows error
 function() {
 page.open(url, function(status) {