aboutsummaryrefslogtreecommitdiff
path: root/tests/hash-target.cpp
diff options
context:
space:
mode:
authormoneromooo-monero <moneromooo-monero@users.noreply.github.com>2019-01-31 10:44:08 +0000
committermoneromooo-monero <moneromooo-monero@users.noreply.github.com>2019-03-24 21:03:19 +0000
commit91f4c7f45f794fc7bee99356e56853369c98c410 (patch)
treeca5eb5edbdeb83511b12b39f0b534a3090fc76b4 /tests/hash-target.cpp
parentMerge pull request #5286 (diff)
downloadmonero-91f4c7f45f794fc7bee99356e56853369c98c410.tar.xz
Make difficulty 128 bit instead of 64 bit
Based on Boolberry work by: jahrsg <jahr@jahr.me> cr.zoidberg <crypto.zoidberg@gmail.com>
Diffstat (limited to 'tests/hash-target.cpp')
-rw-r--r--tests/hash-target.cpp12
1 files changed, 6 insertions, 6 deletions
diff --git a/tests/hash-target.cpp b/tests/hash-target.cpp
index 70368ce24..12acc5a67 100644
--- a/tests/hash-target.cpp
+++ b/tests/hash-target.cpp
@@ -40,7 +40,7 @@ using cryptonote::check_hash;
int main(int argc, char *argv[]) {
crypto::hash h;
- for (uint64_t diff = 1;; diff += 1 + (diff >> 8)) {
+ for (cryptonote::difficulty_type diff = 1;; diff += 1 + (diff >> 8)) {
for (uint16_t b = 0; b < 256; b++) {
memset(&h, b, sizeof(crypto::hash));
if (check_hash(h, diff) != (b == 0 || diff <= 255 / b)) {
@@ -50,7 +50,7 @@ int main(int argc, char *argv[]) {
memset(&h, 0, sizeof(crypto::hash));
((char *) &h)[31] = b;
if (check_hash(h, diff) != (diff <= 255 / b)) {
- return 1;
+ return 2;
}
}
}
@@ -58,11 +58,11 @@ int main(int argc, char *argv[]) {
uint64_t val = 0;
for (int i = 31; i >= 0; i--) {
val = val * 256 + 255;
- ((char *) &h)[i] = static_cast<char>(val / diff);
- val %= diff;
+ ((char *) &h)[i] = static_cast<char>(static_cast<uint64_t>(val / diff));
+ val %= diff.convert_to<uint64_t>();
}
if (check_hash(h, diff) != true) {
- return 1;
+ return 3;
}
if (diff > 1) {
for (int i = 0;; i++) {
@@ -74,7 +74,7 @@ int main(int argc, char *argv[]) {
}
}
if (check_hash(h, diff) != false) {
- return 1;
+ return 4;
}
}
}