various fixes and cleanups

This commit is contained in:
The MMGen Project 2022-05-06 12:52:41 +00:00
commit d5e8d5b96f
Signed by: mmgen
GPG key ID: 3F8B1861E32B7DA2
7 changed files with 33 additions and 15 deletions

View file

@ -201,6 +201,7 @@ def KeyGenerator(proto,pubkey_type,backend=None,silent=False):
if not pubkey_type_cls.libsecp256k1.test_avail(silent=silent):
backend_id = 'python-ecdsa'
if not backend:
from .util import qmsg
qmsg('Using (slow) native Python ECDSA library for public key generation')
return getattr(pubkey_type_cls,backend_id.replace('-','_'))()

View file

@ -50,7 +50,7 @@ class ethereum_daemon(CoinDaemon):
getattr(self.chain_subdirs,self.network) )
class openethereum_daemon(ethereum_daemon):
daemon_data = _dd('OpenEthereum', 3003000, '3.3.0')
daemon_data = _dd('OpenEthereum', 3003005, '3.3.5')
version_pat = r'OpenEthereum//v(\d+)\.(\d+)\.(\d+)'
exec_fn = 'openethereum'
cfg_file = 'parity.conf'

View file

@ -3,10 +3,23 @@
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
#
# Source: https://github.com/bitcoin/bitcoin/blob/master/test/functional/test_framework/ripemd160.py
# Ported to MMGen with the following changes:
#
# Adapted for the MMGen Project with the following changes:
# - replace leading spaces with tabs
# - reimplement as class with digest() and hexdigest() methods
# - add custom test output display
#
# SECURITY DISCLAIMER:
# This code has been flagged as ‘test-only’ by its creator because it is not
# constant-time and therefore vulnerable to timing attacks.
#
# The RIPEMD-160 algorithm is used in the MMGen code base in two places: a)
# in hash160(); and b) as a checksum for a config file template. Here
# timing attacks are not meaningful, because in the first case the preimage
# is a secure cryptographic hash and in the second -- public data.
#
# The MMGen Project assumes no responsibility for the use of this code in
# other contexts.
"""Test-only pure Python RIPEMD160 implementation."""

View file

@ -12,9 +12,11 @@ def build_libsecp256k1():
if not os.path.exists(cache_path):
os.makedirs(cache_path)
if not os.path.exists(ext_path):
print('\nCloning libsecp256k1')
run(['git','clone','https://github.com/bitcoin-core/secp256k1.git'],check=True,cwd=cache_path)
if not os.path.exists(os.path.join(ext_path,'.libs/libsecp256k1.a')):
import platform
print('\nBuilding libsecp256k1')
cmds = {
'Windows': (
['sh','./autogen.sh'],
@ -24,16 +26,17 @@ def build_libsecp256k1():
'Linux': (
['./autogen.sh'],
['./configure','CFLAGS=-g -O2 -fPIC'],
['make','-j4']
['make'] + ([] if have_arm else ['-j4']),
),
}[platform.system()]
for cmd in cmds:
print('Executing {}'.format(' '.join(cmd)))
run(cmd,check=True,cwd=ext_path)
have_msys2 = run(['uname','-s'],stdout=PIPE,check=True).stdout.startswith(b'MSYS_NT')
if have_msys2:
print('MSYS2 system detected')
uname = {k:run(['uname',f'-{k}'],stdout=PIPE,check=True).stdout.strip().decode() for k in ('m','s')}
have_arm = uname['m'] in ('aarch64','armv7l') # x86_64, aarch64, armv7l
have_msys2 = uname['s'].startswith('MSYS_NT') # Linux, MSYS_NT.*
class my_build_ext(build_ext):
def build_extension(self,ext):

View file

@ -350,7 +350,7 @@ t_alts="
"
[ "$MSYS2" ] && t_alts_skip='m z' # no moneropy (pysha3), zcash-mini (golang)
[ "$ARM32" -o "$ARM64" ] && t_alts_skip='z e'
[ "$ARM32" ] && t_alts_skip='z e'
f_alts='Gen-only altcoin tests completed'
@ -510,7 +510,7 @@ t_tool="
a $tooltest_py --coin=zec cryptocoin
z $tooltest_py --coin=zec --type=zcash_z cryptocoin
"
[ "$MSYS2" -o "$ARM32" -o "$ARM64" ] && t_tool_skip='z'
[ "$MSYS2" -o "$ARM32" ] && t_tool_skip='z'
[ "$SKIP_ALT_DEP" ] && t_tool_skip='a z'
f_tool='tooltest tests completed'
@ -546,8 +546,8 @@ t_gen="
a $gentest_py --coin=ltc --type=segwit 1:2 $rounds
a $gentest_py --coin=ltc --testnet=1 1:2 $rounds
a $gentest_py --coin=ltc --testnet=1 --type=segwit 1:2 $rounds
a # all backends vs pycoin:
a $gentest_py all:pycoin $rounds
- # all backends vs pycoin:
- $gentest_py all:pycoin $rounds
"
[ "$SKIP_ALT_DEP" ] && t_gen_skip='a'

View file

@ -38,12 +38,13 @@ async def run_test(network_id,chksum,msghash_type='raw'):
bmsg(f'\nTesting {coin.upper()} {network.upper()}:\n')
restart_test_daemons(network_id)
m = get_obj(coin,network,msghash_type)
if m.proto.sign_mode == 'daemon':
restart_test_daemons(network_id)
pumsg('\nTesting data creation:\n')
m = get_obj(coin,network,msghash_type)
tmpdir = os.path.join('test','trash2')
os.makedirs(tmpdir,exist_ok=True)
@ -110,7 +111,8 @@ async def run_test(network_id,chksum,msghash_type='raw'):
pumsg('\nTesting single address display (exported data):\n')
msg(m.format(single_addr_coin))
stop_test_daemons(network_id)
if m.proto.sign_mode == 'daemon':
stop_test_daemons(network_id)
msg('\n')

View file

@ -12,7 +12,6 @@ class unit_tests:
altcoin_deps = ('pycoin','moneropy','keyconv','zcash_mini','ethkey','ssh_socks_proxy')
win_skip = ('losetup','moneropy','zcash_mini')
arm_skip = ('zcash_mini','ethkey')
def core_repo(self,name,ut):
crr = os.getenv('CORE_REPO_ROOT')