Use proofofwork.trial_value() in tests.test_openclpow

This commit is contained in:
Dmitri Bogomolov 2021-09-01 18:42:30 +03:00
parent 659b292357
commit b80fb5a675
Signed by untrusted user: g1itch
GPG Key ID: 720A756F18DEED13

View File

@ -1,10 +1,10 @@
"""
Tests for openclpow module
"""
import hashlib
import unittest
from struct import pack, unpack
from pybitmessage import openclpow
from pybitmessage import openclpow, proofofwork
class TestOpenClPow(unittest.TestCase):
@ -25,7 +25,5 @@ class TestOpenClPow(unittest.TestCase):
"b93f3ffeba0ef2fd08a8dc2f87b68ae5a0dc819ab57f22ad2c4c9c8618a43b3"
).decode("hex")
nonce = openclpow.do_opencl_pow(initialHash.encode("hex"), target_)
trialValue, = unpack(
'>Q', hashlib.sha512(hashlib.sha512(
pack('>Q', nonce) + initialHash).digest()).digest()[0:8])
self.assertLess((nonce - trialValue), target_)
self.assertLess(
nonce - proofofwork.trial_value(nonce, initialHash), target_)