aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorRiccardo Spagni <ric@spagni.net>2016-02-08 18:31:42 +0200
committerRiccardo Spagni <ric@spagni.net>2016-02-08 18:31:42 +0200
commitcea6f6fb9c7cfb432536bdba71e406285a22aa31 (patch)
tree14009235ac12ca4b60f340b9e260fb7f5f8d2b89 /tests
parentMerge pull request #640 (diff)
parentblockchain: revert handle_get_objects adding block id on tx not found (diff)
downloadmonero-cea6f6fb9c7cfb432536bdba71e406285a22aa31.tar.xz
Merge pull request #641
7658ac0 blockchain: revert handle_get_objects adding block id on tx not found (moneromooo-monero) 3a0f4d8 berkeleydb: fix delete/free mismatch (moneromooo-monero) 1642be2 minor bugfixes and refactoring (Thomas Winget) 098dcf2 unit_tests: fix mnemonics unit test testing invalid seeds (moneromooo-monero)
Diffstat (limited to 'tests')
-rw-r--r--tests/unit_tests/mnemonics.cpp22
1 files changed, 9 insertions, 13 deletions
diff --git a/tests/unit_tests/mnemonics.cpp b/tests/unit_tests/mnemonics.cpp
index 92a4c57f9..3dc5db7d4 100644
--- a/tests/unit_tests/mnemonics.cpp
+++ b/tests/unit_tests/mnemonics.cpp
@@ -45,16 +45,6 @@
namespace
{
/*!
- * \brief Returns random index from 0 to max-1
- * \param max Range maximum
- * \return required random index
- */
- uint32_t get_random_index(int max)
- {
- return rand() % max;
- }
-
- /*!
* \brief Compares vectors for equality
* \param expected expected vector
* \param present current vector
@@ -78,11 +68,17 @@ namespace
const std::vector<std::string> &word_list = language.get_word_list();
std::string seed = "", return_seed = "";
// Generate a random seed without checksum
- for (int ii = 0; ii < crypto::ElectrumWords::seed_length; ii++)
+ crypto::secret_key randkey;
+ for (size_t ii = 0; ii < sizeof(randkey); ++ii)
{
- seed += (word_list[get_random_index(word_list.size())] + ' ');
+ randkey.data[ii] = rand();
}
- seed.pop_back();
+ crypto::ElectrumWords::bytes_to_words(randkey, seed, language.get_language_name());
+ // remove the checksum word
+ const char *space = strrchr(seed.c_str(), ' ');
+ ASSERT_TRUE(space != NULL);
+ seed = std::string(seed.c_str(), space-seed.c_str());
+
std::cout << "Test seed without checksum:\n";
std::cout << seed << std::endl;