forked from kik/progpow-exploit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_asic.cpp
29 lines (22 loc) · 987 Bytes
/
test_asic.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#include "helpers.hpp"
#include <ethash/endianness.hpp>
#include <ethash/progpow.hpp>
#include <ethash/keccak.hpp>
#include <gtest/gtest.h>
#include <array>
TEST(asic, search)
{
auto ctxp = ethash::create_epoch_context(0);
ASSERT_NE(ctxp, nullptr);
auto& ctx = *ctxp;
auto parent = to_hash256("f4ac202715ded4136e72887c39e63a4738331c57fd9eb79f6ec421c281aa8743");
auto boundary = to_hash256("00ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");
auto sr = progpow::search_asic(ctx, 0, {parent, 0}, boundary, 0, 1024, 0, uint64_t(1) << 36);
std::cout << "nonce = " << sr.nonce << std::endl;
std::cout << "extra nonce = " << sr.extra_nonce << std::endl;
ethash::block_header header{ parent, sr.extra_nonce };
ethash::hash256 header_hash = ethash_keccak256((const uint8_t *)&header, sizeof header);
auto success = progpow::verify(
ctx, 0, header_hash, sr.mix_hash, sr.nonce, sr.final_hash);
EXPECT_TRUE(success);
}