Test suggested word for first four letters of word

See https://github.com/iancoleman/bip39/pull/48
This commit is contained in:
Ian Coleman
2017-01-04 10:59:21 +11:00
parent fef188cd1e
commit 6ea15134a4
3 changed files with 31 additions and 4 deletions

View 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;

View File

@@ -647,8 +647,9 @@
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;

View File

@@ -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) {