aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authormoneromooo-monero <moneromooo-monero@users.noreply.github.com>2019-05-01 19:57:34 +0000
committermoneromooo-monero <moneromooo-monero@users.noreply.github.com>2019-05-01 19:58:09 +0000
commite9809382109765ce53fcbd95e1fc593d9b19e184 (patch)
treef79bcb4fd4f14e9b262f67c70b4181f6df86b5eb /tests
parentMerge pull request #5486 (diff)
downloadmonero-e9809382109765ce53fcbd95e1fc593d9b19e184.tar.xz
fix wide difficulty conversion with some versions of boost
Diffstat (limited to 'tests')
-rw-r--r--tests/difficulty/difficulty.cpp2
-rw-r--r--tests/hash-target.cpp2
-rw-r--r--tests/performance_tests/check_hash.h8
-rw-r--r--tests/unit_tests/difficulty.cpp8
4 files changed, 10 insertions, 10 deletions
diff --git a/tests/difficulty/difficulty.cpp b/tests/difficulty/difficulty.cpp
index 11ce0bd73..18f1d0030 100644
--- a/tests/difficulty/difficulty.cpp
+++ b/tests/difficulty/difficulty.cpp
@@ -124,7 +124,7 @@ int main(int argc, char *argv[]) {
cryptonote::difficulty_type wide_res = cryptonote::next_difficulty(
std::vector<uint64_t>(timestamps.begin() + begin, timestamps.begin() + end),
std::vector<cryptonote::difficulty_type>(wide_cumulative_difficulties.begin() + begin, wide_cumulative_difficulties.begin() + end), DEFAULT_TEST_DIFFICULTY_TARGET);
- if (wide_res.convert_to<uint64_t>() != res) {
+ if ((wide_res & 0xffffffffffffffff).convert_to<uint64_t>() != res) {
cerr << "Wrong wide difficulty for block " << n << endl
<< "Expected: " << res << endl
<< "Found: " << wide_res << endl;
diff --git a/tests/hash-target.cpp b/tests/hash-target.cpp
index 1e988c302..e95475cac 100644
--- a/tests/hash-target.cpp
+++ b/tests/hash-target.cpp
@@ -61,7 +61,7 @@ int main(int argc, char *argv[]) {
for (int i = 31; i >= 0; i--) {
val = val * 256 + 255;
((char *) &h)[i] = static_cast<char>(static_cast<uint64_t>(val / diff));
- val %= diff.convert_to<uint64_t>();
+ val %= (diff & 0xffffffffffffffff).convert_to<uint64_t>();
}
if (check_hash(h, diff) != true) {
return 3;
diff --git a/tests/performance_tests/check_hash.h b/tests/performance_tests/check_hash.h
index d24001903..53746fec4 100644
--- a/tests/performance_tests/check_hash.h
+++ b/tests/performance_tests/check_hash.h
@@ -44,13 +44,13 @@ public:
difficulty = difficulty_high;
difficulty = (difficulty << 64) | difficulty_low;
boost::multiprecision::uint256_t hash_value = std::numeric_limits<boost::multiprecision::uint256_t>::max() / hash_target;
- ((uint64_t*)&hash)[0] = (hash_value << 64 >> 64).convert_to<uint64_t>();
+ ((uint64_t*)&hash)[0] = (hash_value & 0xffffffffffffffff).convert_to<uint64_t>();
hash_value >>= 64;
- ((uint64_t*)&hash)[1] = (hash_value << 64 >> 64).convert_to<uint64_t>();
+ ((uint64_t*)&hash)[1] = (hash_value & 0xffffffffffffffff).convert_to<uint64_t>();
hash_value >>= 64;
- ((uint64_t*)&hash)[2] = (hash_value << 64 >> 64).convert_to<uint64_t>();
+ ((uint64_t*)&hash)[2] = (hash_value & 0xffffffffffffffff).convert_to<uint64_t>();
hash_value >>= 64;
- ((uint64_t*)&hash)[3] = (hash_value << 64 >> 64).convert_to<uint64_t>();
+ ((uint64_t*)&hash)[3] = (hash_value & 0xffffffffffffffff).convert_to<uint64_t>();
return true;
}
diff --git a/tests/unit_tests/difficulty.cpp b/tests/unit_tests/difficulty.cpp
index 090fecc84..a732e6969 100644
--- a/tests/unit_tests/difficulty.cpp
+++ b/tests/unit_tests/difficulty.cpp
@@ -42,13 +42,13 @@ static crypto::hash MKHASH(uint64_t high, uint64_t low)
hash_target = (hash_target << 64) | low;
boost::multiprecision::uint256_t hash_value = std::numeric_limits<boost::multiprecision::uint256_t>::max() / hash_target;
crypto::hash h;
- ((uint64_t*)&h)[0] = hash_value.convert_to<uint64_t>();
+ ((uint64_t*)&h)[0] = (hash_value & 0xffffffffffffffff).convert_to<uint64_t>();
hash_value >>= 64;
- ((uint64_t*)&h)[1] = hash_value.convert_to<uint64_t>();
+ ((uint64_t*)&h)[1] = (hash_value & 0xffffffffffffffff).convert_to<uint64_t>();
hash_value >>= 64;
- ((uint64_t*)&h)[2] = hash_value.convert_to<uint64_t>();
+ ((uint64_t*)&h)[2] = (hash_value & 0xffffffffffffffff).convert_to<uint64_t>();
hash_value >>= 64;
- ((uint64_t*)&h)[3] = hash_value.convert_to<uint64_t>();
+ ((uint64_t*)&h)[3] = (hash_value & 0xffffffffffffffff).convert_to<uint64_t>();
return h;
}