forked from lthn/blockchain
random_in_range moved, unit_tests/db_tests fixed
This commit is contained in:
parent
386df3db2a
commit
e4293af219
4 changed files with 13 additions and 8 deletions
|
|
@ -187,13 +187,6 @@ inline bool mine_next_pos_block_in_playtime_with_wallet(tools::wallet2& w, const
|
|||
return w.build_minted_block(ctx.sp, ctx.rsp, miner_address);
|
||||
}
|
||||
|
||||
inline uint64_t random_in_range(uint64_t from, uint64_t to)
|
||||
{
|
||||
if (from == to)
|
||||
return from;
|
||||
CHECK_AND_ASSERT_MES(from < to, 0, "Invalid arguments: from = " << from << ", to = " << to);
|
||||
return crypto::rand<uint64_t>() % (to - from + 1) + from;
|
||||
}
|
||||
|
||||
struct log_level_scope_changer
|
||||
{
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@
|
|||
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||
|
||||
#pragma once
|
||||
#include "crypto/crypto.h"
|
||||
|
||||
// DISCLAIMER: designed for tests puposes ONLY!
|
||||
// This class is not intended to be used neither in multi-threaded environment nor in production.
|
||||
|
|
@ -64,6 +65,16 @@ inline std::string get_random_text(size_t len)
|
|||
}
|
||||
}
|
||||
|
||||
// boundaries are included
|
||||
inline uint64_t random_in_range(uint64_t from, uint64_t to)
|
||||
{
|
||||
if (from == to)
|
||||
return from;
|
||||
CHECK_AND_ASSERT_MES(from < to, 0, "Invalid arguments: from = " << from << ", to = " << to);
|
||||
return crypto::rand<uint64_t>() % (to - from + 1) + from;
|
||||
}
|
||||
|
||||
|
||||
bool random_state_manupulation_test();
|
||||
bool random_evenness_test();
|
||||
bool get_random_text_test();
|
||||
|
|
|
|||
|
|
@ -22,6 +22,7 @@ using namespace currency;
|
|||
#include "../core_tests/test_core_time.h"
|
||||
std::atomic<int64_t> test_core_time::m_time_shift;
|
||||
|
||||
#include "../core_tests/random_helper.h"
|
||||
#include "../core_tests/test_core_proxy.h"
|
||||
#include "../core_tests/chaingen_helpers.h"
|
||||
#include "../core_tests/core_state_helper.h"
|
||||
|
|
|
|||
|
|
@ -377,7 +377,7 @@ namespace db_test
|
|||
}
|
||||
|
||||
// restore PRNG state to keep other tests unaffected
|
||||
crypto::random_prng_get_state(prng_state, sizeof prng_state);
|
||||
crypto::random_prng_set_state(prng_state, sizeof prng_state);
|
||||
|
||||
ASSERT_TRUE(result);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue