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