finish dependency unit test
This commit is contained in:
parent
8559b9c668
commit
1b1b511a09
2 changed files with 74 additions and 5 deletions
|
|
@ -35,10 +35,10 @@ mmgen_keygen='cmds/mmgen-keygen'
|
|||
python='python3'
|
||||
rounds=100 rounds_min=20 rounds_mid=250 rounds_max=500
|
||||
|
||||
dfl_tests='misc obj color unit hash ref altref alts xmr eth autosign btc btc_tn btc_rt bch bch_rt ltc ltc_rt tool tool2 gen'
|
||||
extra_tests='autosign_btc autosign_live etc ltc_tn bch_tn'
|
||||
noalt_tests='misc obj color unit hash ref autosign_btc btc btc_tn btc_rt tool tool2 gen'
|
||||
quick_tests='misc obj color unit hash ref altref alts xmr eth autosign btc btc_rt tool tool2 gen'
|
||||
dfl_tests='dep misc obj color unit hash ref altref alts xmr eth autosign btc btc_tn btc_rt bch bch_rt ltc ltc_rt tool tool2 gen'
|
||||
extra_tests='dep autosign_btc autosign_live etc ltc_tn bch_tn'
|
||||
noalt_tests='dep misc obj color unit hash ref autosign_btc btc btc_tn btc_rt tool tool2 gen'
|
||||
quick_tests='dep misc obj color unit hash ref altref alts xmr eth autosign btc btc_rt tool tool2 gen'
|
||||
qskip_tests='btc_tn bch bch_rt ltc ltc_rt'
|
||||
|
||||
PROGNAME=$(basename $0)
|
||||
|
|
@ -248,9 +248,14 @@ s_color='Testing terminal colors'
|
|||
t_color="- $colortest_py"
|
||||
f_color='Terminal color tests completed'
|
||||
|
||||
i_dep='Dependency'
|
||||
s_dep='Testing for installed dependencies'
|
||||
t_dep="- $unit_tests_py dep"
|
||||
f_dep='Dependency tests completed'
|
||||
|
||||
i_unit='Unit'
|
||||
s_unit='The bitcoin and bitcoin-bchn mainnet daemons must be running for the following tests'
|
||||
t_unit="- $unit_tests_py"
|
||||
t_unit="- $unit_tests_py --exclude dep"
|
||||
f_unit='Unit tests completed'
|
||||
|
||||
i_hash='Internal hash function implementations'
|
||||
|
|
|
|||
|
|
@ -10,6 +10,16 @@ from mmgen.common import *
|
|||
|
||||
class unit_tests:
|
||||
|
||||
altcoin_deps = ('keccak','py_ecc')
|
||||
|
||||
def keccak(self,name,ut): # ETH,XMR
|
||||
from sha3 import keccak_256
|
||||
return True
|
||||
|
||||
def py_ecc(self,name,ut): # ETH
|
||||
from py_ecc.secp256k1 import privtopub
|
||||
return True
|
||||
|
||||
def pysocks(self,name,ut):
|
||||
import requests,urllib3
|
||||
urllib3.disable_warnings()
|
||||
|
|
@ -23,3 +33,57 @@ class unit_tests:
|
|||
else:
|
||||
print(e)
|
||||
return False
|
||||
|
||||
def secp256k1(self,name,ut):
|
||||
from mmgen.secp256k1 import priv2pub
|
||||
priv2pub(bytes.fromhex('deadbeef'*8),1)
|
||||
return True
|
||||
|
||||
def cryptography(self,name,ut):
|
||||
from cryptography.hazmat.primitives.ciphers import Cipher,algorithms,modes
|
||||
from cryptography.hazmat.backends import default_backend
|
||||
c = Cipher(algorithms.AES(b'deadbeef'*4),modes.CTR(b'deadbeef'*2),backend=default_backend())
|
||||
encryptor = c.encryptor()
|
||||
enc_data = encryptor.update(b'foo') + encryptor.finalize()
|
||||
return True
|
||||
|
||||
def ecdsa(self,name,ut):
|
||||
import ecdsa
|
||||
pko = ecdsa.SigningKey.from_secret_exponent(12345678901234,curve=ecdsa.SECP256k1)
|
||||
pubkey = pko.get_verifying_key().to_string().hex()
|
||||
return True
|
||||
|
||||
def gmpy(self,name,ut):
|
||||
from gmpy2 import context,set_context,sqrt,cbrt
|
||||
# context() parameters are platform-dependent!
|
||||
set_context(context(precision=75,round=1)) # OK for gmp 6.1.2 / gmpy 2.1.0
|
||||
return True
|
||||
|
||||
def aiohttp(self,name,ut):
|
||||
import asyncio,aiohttp
|
||||
async def do():
|
||||
async with aiohttp.ClientSession(
|
||||
headers = { 'Content-Type': 'application/json' },
|
||||
connector = aiohttp.TCPConnector(),
|
||||
) as session:
|
||||
pass
|
||||
asyncio.run(do())
|
||||
return True
|
||||
|
||||
def pexpect(self,name,ut):
|
||||
import pexpect
|
||||
from pexpect.popen_spawn import PopenSpawn
|
||||
return True
|
||||
|
||||
def scrypt(self,name,ut):
|
||||
passwd,salt = b'foo',b'bar'
|
||||
N,r,p = 4,8,16
|
||||
buflen = 64
|
||||
|
||||
import scrypt
|
||||
scrypt.hash(passwd, salt, N=2**N, r=r, p=p, buflen=buflen)
|
||||
|
||||
from hashlib import scrypt # max N == 14!!
|
||||
scrypt(password=passwd,salt=salt,n=2**N,r=r,p=p,maxmem=0,dklen=buflen)
|
||||
|
||||
return True
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue