aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorluigi1111 <luigi1111w@gmail.com>2019-07-24 14:06:11 -0500
committerluigi1111 <luigi1111w@gmail.com>2019-07-24 14:06:11 -0500
commit7fc76451a5bc3b9f6a08eaa3f9bb31d450ee79a3 (patch)
tree720ec93a89696ce7f97fc01121cb341809be086b
parentMerge pull request #5528 (diff)
parentuse crypto::rand instead of libc rand in a few tests (diff)
downloadmonero-7fc76451a5bc3b9f6a08eaa3f9bb31d450ee79a3.tar.xz
Merge pull request #5529
de27651 use crypto::rand instead of libc rand in a few tests (moneromooo-monero)
-rw-r--r--tests/unit_tests/mnemonics.cpp4
-rw-r--r--tests/unit_tests/output_selection.cpp4
-rw-r--r--tests/unit_tests/rolling_median.cpp8
3 files changed, 8 insertions, 8 deletions
diff --git a/tests/unit_tests/mnemonics.cpp b/tests/unit_tests/mnemonics.cpp
index 16634e7a1..51feb54e4 100644
--- a/tests/unit_tests/mnemonics.cpp
+++ b/tests/unit_tests/mnemonics.cpp
@@ -82,7 +82,7 @@ namespace
crypto::secret_key randkey;
for (size_t ii = 0; ii < sizeof(randkey); ++ii)
{
- randkey.data[ii] = rand();
+ randkey.data[ii] = crypto::rand<uint8_t>();
}
crypto::ElectrumWords::bytes_to_words(randkey, w_seed, language.get_language_name());
seed = std::string(w_seed.data(), w_seed.size());
@@ -256,4 +256,4 @@ TEST(mnemonics, partial_word_tolerance)
res = crypto::ElectrumWords::words_to_bytes(seed_1, key_1, language_name_1);
ASSERT_EQ(true, res);
ASSERT_STREQ(language_name_1.c_str(), "English");
-} \ No newline at end of file
+}
diff --git a/tests/unit_tests/output_selection.cpp b/tests/unit_tests/output_selection.cpp
index 235b1c809..c98696fbd 100644
--- a/tests/unit_tests/output_selection.cpp
+++ b/tests/unit_tests/output_selection.cpp
@@ -138,7 +138,7 @@ TEST(select_outputs, density)
static const size_t NPICKS = 1000000;
std::vector<uint64_t> offsets;
- MKOFFSETS(300000, 1 + (rand() & 0x1f));
+ MKOFFSETS(300000, 1 + (crypto::rand<size_t>() & 0x1f));
tools::gamma_picker picker(offsets);
std::vector<int> picks(/*n_outs*/offsets.size(), 0);
@@ -181,7 +181,7 @@ TEST(select_outputs, same_distribution)
static const size_t NPICKS = 1000000;
std::vector<uint64_t> offsets;
- MKOFFSETS(300000, 1 + (rand() & 0x1f));
+ MKOFFSETS(300000, 1 + (crypto::rand<size_t>() & 0x1f));
tools::gamma_picker picker(offsets);
std::vector<int> chain_picks(offsets.size(), 0);
diff --git a/tests/unit_tests/rolling_median.cpp b/tests/unit_tests/rolling_median.cpp
index 6d6adcc7d..547fe092f 100644
--- a/tests/unit_tests/rolling_median.cpp
+++ b/tests/unit_tests/rolling_median.cpp
@@ -69,7 +69,7 @@ TEST(rolling_median, series)
v.reserve(100);
for (int i = 0; i < 10000; ++i)
{
- uint64_t r = rand();
+ uint64_t r = crypto::rand<uint64_t>();
v.push_back(r);
if (v.size() > 100)
v.erase(v.begin());
@@ -87,7 +87,7 @@ TEST(rolling_median, clear_whole)
median.reserve(10000);
for (int i = 0; i < 10000; ++i)
{
- random.push_back(rand());
+ random.push_back(crypto::rand<uint64_t>());
m.insert(random.back());
median.push_back(m.median());
}
@@ -107,7 +107,7 @@ TEST(rolling_median, clear_partway)
median.reserve(10000);
for (int i = 0; i < 10000; ++i)
{
- random.push_back(rand());
+ random.push_back(crypto::rand<uint64_t>());
m.insert(random.back());
median.push_back(m.median());
}
@@ -126,7 +126,7 @@ TEST(rolling_median, order)
random.reserve(1000);
for (int i = 0; i < 1000; ++i)
{
- random.push_back(rand());
+ random.push_back(crypto::rand<uint64_t>());
m.insert(random.back());
}
const uint64_t med = m.median();