@@ -90,7 +90,7 @@ int p2pool_test()
90
90
#ifdef WITH_RANDOMX
91
91
const char myKey[] = " test key 000" ;
92
92
const char myInput[] = " This is a test" ;
93
- char hash[RANDOMX_HASH_SIZE];
93
+ char hash[RANDOMX_HASH_SIZE] = {} ;
94
94
95
95
const randomx_flags flags = randomx_get_flags () | RANDOMX_FLAG_FULL_MEM;
96
96
randomx_cache* myCache = randomx_alloc_cache (flags);
@@ -115,14 +115,20 @@ int p2pool_test()
115
115
return 1 ;
116
116
}
117
117
118
- randomx_calculate_hash (myMachine, &myInput, sizeof (myInput) - 1 , hash);
118
+ memcpy (hash, myInput, sizeof (myInput));
119
+
120
+ for (size_t i = 0 ; i < 100 ; ++i) {
121
+ randomx_calculate_hash (myMachine, &hash, sizeof (hash), hash);
122
+ }
119
123
120
124
char buf[RANDOMX_HASH_SIZE * 2 + 1 ] = {};
121
125
p2pool::log::Stream s (buf);
122
- s << p2pool::log::hex_buf (hash, RANDOMX_HASH_SIZE);
126
+ s << p2pool::log::hex_buf (hash, RANDOMX_HASH_SIZE) << ' \0 ' ;
127
+
128
+ constexpr char expected_hash[] = " 3b5ecc2bb14f467161a04fe476b541194fba82dbbbfc7c320961f922a0294dee" ;
123
129
124
- if (memcmp (buf, " 639183aae1bf4c9a35884cb46b09cad9175f04efd7684e7262a0ac1c2f0b4e3f " , RANDOMX_HASH_SIZE * 2 ) != 0 ) {
125
- printf (" Invalid hash calculated\n " );
130
+ if (memcmp (buf, expected_hash , RANDOMX_HASH_SIZE * 2 ) != 0 ) {
131
+ printf (" Invalid hash calculated: expected %s, got %s \n " , expected_hash, buf );
126
132
return 1 ;
127
133
}
128
134
0 commit comments