From ddc698640180b70979f5b66c39b707da076a3272 Mon Sep 17 00:00:00 2001 From: SChernykh Date: Wed, 18 Oct 2023 11:01:16 +0200 Subject: [PATCH] Self-test: calculate 100 hashes instead of just 1 --- src/main.cpp | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 2ecaebf..00441e5 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -115,14 +115,21 @@ int p2pool_test() return 1; } - randomx_calculate_hash(myMachine, &myInput, sizeof(myInput) - 1, hash); + memset(hash, 0, sizeof(hash)); + memcpy(hash, myInput, sizeof(myInput)); + + for (size_t i = 0; i < 100; ++i) { + randomx_calculate_hash(myMachine, &hash, sizeof(hash), hash); + } char buf[RANDOMX_HASH_SIZE * 2 + 1] = {}; p2pool::log::Stream s(buf); - s << p2pool::log::hex_buf(hash, RANDOMX_HASH_SIZE); + s << p2pool::log::hex_buf(hash, RANDOMX_HASH_SIZE) << '\0'; - if (memcmp(buf, "639183aae1bf4c9a35884cb46b09cad9175f04efd7684e7262a0ac1c2f0b4e3f", RANDOMX_HASH_SIZE * 2) != 0) { - printf("Invalid hash calculated\n"); + constexpr char expected_hash[] = "3b5ecc2bb14f467161a04fe476b541194fba82dbbbfc7c320961f922a0294dee"; + + if (memcmp(buf, expected_hash, RANDOMX_HASH_SIZE * 2) != 0) { + printf("Invalid hash calculated: expected %s, got %s\n", expected_hash, buf); return 1; }