aboutsummaryrefslogtreecommitdiff
path: root/tests/unit_tests
diff options
context:
space:
mode:
authorRiccardo Spagni <ric@spagni.net>2017-01-15 14:58:09 -0500
committerRiccardo Spagni <ric@spagni.net>2017-01-15 14:58:09 -0500
commitb2e1568335228869de84ac39bb74f5589bc1b6db (patch)
treee6c812cc5046a6ab6bf56485fe4df312da789af1 /tests/unit_tests
parentMerge pull request #1577 (diff)
parentmnemonics: fix language detection with checksum word (diff)
downloadmonero-b2e1568335228869de84ac39bb74f5589bc1b6db.tar.xz
Merge pull request #1579
f5f4109f mnemonics: fix language detection with checksum word (moneromooo-monero)
Diffstat (limited to 'tests/unit_tests')
-rw-r--r--tests/unit_tests/mnemonics.cpp19
1 files changed, 19 insertions, 0 deletions
diff --git a/tests/unit_tests/mnemonics.cpp b/tests/unit_tests/mnemonics.cpp
index 3dc5db7d4..9c497ef29 100644
--- a/tests/unit_tests/mnemonics.cpp
+++ b/tests/unit_tests/mnemonics.cpp
@@ -148,3 +148,22 @@ TEST(mnemonics, all_languages)
test_language(*(*it));
}
}
+
+TEST(mnemonics, language_detection_with_bad_checksum)
+{
+ crypto::secret_key key;
+ std::string language_name;
+ bool res;
+
+ // This Portuguese (4-prefix) seed has all its words with 3-prefix that's also present in English
+ const std::string base_seed = "cinzento luxuriante leonardo gnostico digressao cupula fifa broxar iniquo louvor ovario dorsal ideologo besuntar decurso rosto susto lemure unheiro pagodeiro nitroglicerina eclusa mazurca bigorna";
+ const std::string real_checksum = "gnostico";
+
+ res = crypto::ElectrumWords::words_to_bytes(base_seed, key, language_name);
+ ASSERT_EQ(true, res);
+ ASSERT_STREQ(language_name.c_str(), "Portuguese");
+
+ res = crypto::ElectrumWords::words_to_bytes(base_seed + " " + real_checksum, key, language_name);
+ ASSERT_EQ(true, res);
+ ASSERT_STREQ(language_name.c_str(), "Portuguese");
+}