Browse Source

install,test: disable pysha3 for Python 3.11

The MMGen Project 1 year ago
parent
commit
2345dc4665
4 changed files with 19 additions and 6 deletions
  1. 1 1
      mmgen/data/version
  2. 1 1
      setup.cfg
  3. 11 3
      test/hashfunc.py
  4. 6 1
      test/unit_tests_d/ut_dep.py

+ 1 - 1
mmgen/data/version

@@ -1 +1 @@
-13.3.dev53
+13.3.dev54

+ 1 - 1
setup.cfg

@@ -37,7 +37,7 @@ install_requires =
 	pexpect
 	pexpect
 	scrypt; platform_system != "Windows" # must be installed by hand on MSYS2
 	scrypt; platform_system != "Windows" # must be installed by hand on MSYS2
 	semantic-version; platform_system != "Windows" # scripts/create-token.py
 	semantic-version; platform_system != "Windows" # scripts/create-token.py
-	pysha3; platform_system != "Windows"
+	pysha3; platform_system != "Windows" and python_version < "3.11"
 
 
 packages =
 packages =
 	mmgen
 	mmgen

+ 11 - 3
test/hashfunc.py

@@ -22,7 +22,7 @@ test/hashfunc.py: Test internal implementations of SHA256, SHA512 and Keccak256
 
 
 import sys,os
 import sys,os
 import include.tests_header
 import include.tests_header
-from mmgen.util import die
+from mmgen.util import die,ymsg
 
 
 assert len(sys.argv) in (2,3),"Test takes 1 or 2 arguments: test name, plus optional rounds count"
 assert len(sys.argv) in (2,3),"Test takes 1 or 2 arguments: test name, plus optional rounds count"
 test = sys.argv[1].capitalize()
 test = sys.argv[1].capitalize()
@@ -60,6 +60,8 @@ class TestHashFunc(object):
 		msg('OK\n')
 		msg('OK\n')
 
 
 	def test_random(self,rounds):
 	def test_random(self,rounds):
+		if not self.hashlib:
+			return
 		for i in range(rounds):
 		for i in range(rounds):
 			if i+1 in (1,rounds) or not (i+1) % 10:
 			if i+1 in (1,rounds) or not (i+1) % 10:
 				msg(f'\rTesting random input data:    {i+1:4}/{rounds} ')
 				msg(f'\rTesting random input data:    {i+1:4}/{rounds} ')
@@ -105,9 +107,15 @@ class TestKeccak(TestHashFunc):
 
 
 	def __init__(self):
 	def __init__(self):
 		from mmgen.contrib.keccak import keccak_256
 		from mmgen.contrib.keccak import keccak_256
-		import sha3
 		self.t_cls = keccak_256
 		self.t_cls = keccak_256
-		self.hashlib = sha3
+		import platform
+		major,minor,_ = [int(s) for s in platform.python_version_tuple()]
+		if major > 3 or (major == 3 and minor >= 11):
+			ymsg(f'Skipping keccak random data test for Python version {major}.{minor} (no pysha3)')
+			self.hashlib = None
+		else:
+			import sha3
+			self.hashlib = sha3
 
 
 	def test_constants(self): pass
 	def test_constants(self): pass
 
 

+ 6 - 1
test/unit_tests_d/ut_dep.py

@@ -29,7 +29,12 @@ class unit_tests:
 		return True
 		return True
 
 
 	def pysha3(self,name,ut): # ETH,XMR
 	def pysha3(self,name,ut): # ETH,XMR
-		from sha3 import keccak_256
+		import platform
+		major,minor,_ = [int(s) for s in platform.python_version_tuple()]
+		if major > 3 or (major == 3 and minor >= 11):
+			ymsg(f'Skipping pysha3 for Python version {major}.{minor}')
+		else:
+			from sha3 import keccak_256
 		return True
 		return True
 
 
 	def py_ecc(self,name,ut): # ETH
 	def py_ecc(self,name,ut): # ETH