diff options
author | Riccardo Spagni <ric@spagni.net> | 2019-04-01 17:19:10 +0200 |
---|---|---|
committer | Riccardo Spagni <ric@spagni.net> | 2019-04-01 17:19:10 +0200 |
commit | e55b3f9dda39a5fe6a7fff86a50125cec15596a0 (patch) | |
tree | aaf0dcfd82ea9fda8b428a788d6b732c4ee43d90 /tests/hash-target.cpp | |
parent | Merge pull request #5359 (diff) | |
parent | Make difficulty 128 bit instead of 64 bit (diff) | |
download | monero-e55b3f9dda39a5fe6a7fff86a50125cec15596a0.tar.xz |
Merge pull request #5239
91f4c7f4 Make difficulty 128 bit instead of 64 bit (moneromooo-monero)
Diffstat (limited to 'tests/hash-target.cpp')
-rw-r--r-- | tests/hash-target.cpp | 12 |
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; } } } |