Fixed pool_block.deserialize test

This commit is contained in:
SChernykh 2023-03-19 20:54:09 +01:00
parent 6685a22118
commit 79ad29e99a

View file

@ -84,19 +84,31 @@ TEST(pool_block, deserialize)
ASSERT_EQ(b.m_broadcasted, false);
ASSERT_EQ(b.m_wantBroadcast, false);
#if !(defined(__FreeBSD__) || defined(__OpenBSD__))
RandomX_Hasher hasher(nullptr);
hash seed;
class RandomX_Hasher_Test : public RandomX_Hasher_Base
{
std::stringstream s;
s << "6fc9c4a55eb513eb31955c084d9342e0082987f9e42da042449b7c9001176d3a";
s >> seed;
}
public:
bool calculate(const void* data, size_t size, uint64_t, const hash&, hash& result) override
{
if (size == 76) {
char buf[76 * 2 + 1];
{
log::Stream s(buf);
s << log::hex_buf(reinterpret_cast<const uint8_t*>(data), size);
buf[76 * 2] = '\0';
}
const char ref[] = "1010c0c8dba006b78e04571806733a74ef1014f404484d3358bfca889a75bb0fe9aff64a41c92bdf040000ecf0a11f83c6eced7d7cdfbdcd5a193f64d334b2c5491a9c595b4527e531ae7209";
if (memcmp(buf, ref, sizeof(buf)) == 0) {
std::stringstream s;
s << "aa7a3c4a2d67cb6a728e244288219bf038024f3b511b0da197a19ec601000000";
s >> result;
return true;
}
}
return false;
}
} hasher;
hasher.set_seed(seed);
hash pow_hash;
hash seed, pow_hash;
ASSERT_EQ(b.get_pow_hash(&hasher, 0, seed, pow_hash), true);
std::stringstream s;
@ -104,7 +116,6 @@ TEST(pool_block, deserialize)
ASSERT_EQ(s.str(), "aa7a3c4a2d67cb6a728e244288219bf038024f3b511b0da197a19ec601000000");
ASSERT_EQ(b.m_difficulty.check_pow(pow_hash), true);
#endif
destroy_crypto_cache();
}