| 85 | } |
| 86 | |
| 87 | void TestEquihashValidator(unsigned int n, unsigned int k, const std::string &I, const arith_uint256 &nonce, std::vector<uint32_t> soln, bool expected) { |
| 88 | size_t cBitLen { n/(k+1) }; |
| 89 | blake2b_state state; |
| 90 | EhInitialiseState(n, k, state, false); |
| 91 | uint256 V = ArithToUint256(nonce); |
| 92 | blake2b_update(&state, (unsigned char*)&I[0], I.size()); |
| 93 | blake2b_update(&state, V.begin(), V.size()); |
| 94 | BOOST_TEST_MESSAGE("Running validator: n = " << n << ", k = " << k << ", I = " << I << ", V = " << V.GetHex() << ", expected = " << expected << ", soln ="); |
| 95 | std::stringstream strm; |
| 96 | PrintSolution(strm, soln); |
| 97 | BOOST_TEST_MESSAGE(strm.str()); |
| 98 | bool isValid; |
| 99 | EhIsValidSolution(n, k, state, GetMinimalFromIndices(soln, cBitLen), isValid); |
| 100 | BOOST_CHECK(isValid == expected); |
| 101 | } |
| 102 | |
| 103 | BOOST_AUTO_TEST_CASE(solver_testvectors) { |
| 104 | TestEquihashSolvers(96, 5, "block header", 0, { |
no test coverage detected