MCPcopy Create free account
hub / github.com/BTCGPU/BTCGPU / TestEquihashValidator

Function TestEquihashValidator

src/test/equihash_tests.cpp:87–101  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

85}
86
87void 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
103BOOST_AUTO_TEST_CASE(solver_testvectors) {
104 TestEquihashSolvers(96, 5, "block header", 0, {

Callers 1

BOOST_AUTO_TEST_CASEFunction · 0.85

Calls 7

ArithToUint256Function · 0.85
PrintSolutionFunction · 0.85
GetMinimalFromIndicesFunction · 0.85
strMethod · 0.80
sizeMethod · 0.45
beginMethod · 0.45
GetHexMethod · 0.45

Tested by

no test coverage detected