mirror of
https://github.com/OneKeyHQ/bip39.git
synced 2026-04-06 02:43:49 +00:00
Test suggested word for first four letters of word
See https://github.com/iancoleman/bip39/pull/48
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
25
tests.js
25
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) {
|
||||
|
||||
Reference in New Issue
Block a user