unit_tests.py dep: add solc (Solidity compiler) test

This commit is contained in:
The MMGen Project 2022-04-23 14:36:09 +00:00
commit 0d2b730ebf
Signed by: mmgen
GPG key ID: 3F8B1861E32B7DA2
3 changed files with 49 additions and 20 deletions

View file

@ -24,6 +24,7 @@ class TestSuiteException(Exception): pass
class TestSuiteFatalException(Exception): pass
import os
from subprocess import run,PIPE
from mmgen.common import *
from mmgen.devtools import *
from mmgen.fileutil import write_data_to_file,get_data_from_file
@ -231,3 +232,23 @@ def test_daemons_ops(*network_ids,op,remove_datadir=False):
d.remove_datadir()
ret = d.cmd(op,silent=silent)
return ret
tested_solc_ver = '0.8.7'
def check_solc_ver():
cmd = 'python3 scripts/create-token.py --check-solc-version'
try:
cp = run(cmd.split(),check=False,stdout=PIPE)
except Exception as e:
die(4,f'Unable to execute {cmd!r}: {e}')
res = cp.stdout.decode().strip()
if cp.returncode == 0:
omsg(
orange(f'Found supported solc version {res}') if res == tested_solc_ver else
yellow(f'WARNING: solc version ({res}) does not match tested version ({tested_solc_ver})')
)
return True
else:
omsg(yellow('Warning: Solidity compiler (solc) could not be executed or has unsupported version'))
omsg(res)
return False

View file

@ -51,25 +51,6 @@ amt2 = '888.111122223333444455'
parity_devkey_fn = 'parity.devkey'
erigon_devkey_fn = 'erigon.devkey'
tested_solc_ver = '0.8.7'
def check_solc_ver():
cmd = 'python3 scripts/create-token.py --check-solc-version'
try:
cp = run(cmd.split(),check=False,stdout=PIPE)
except Exception as e:
die(4,f'Unable to execute {cmd!r}: {e}')
res = cp.stdout.decode().strip()
if cp.returncode == 0:
omsg(
orange(f'Found supported solc version {res}') if res == tested_solc_ver else
yellow(f'WARNING: solc version ({res}) does not match tested version ({tested_solc_ver})')
)
return True
else:
omsg(yellow(res + '\nUsing precompiled contract data'))
return False
vbal1 = '1.2288409'
vbal9 = '1.22626295'
vbal2 = '99.997088755'
@ -327,6 +308,8 @@ class TestSuiteEthdev(TestSuiteBase,TestSuiteShared):
from mmgen.daemon import CoinDaemon
self.rpc_port = CoinDaemon(proto=self.proto,test_suite=True).rpc_port
self.using_solc = check_solc_ver()
if not self.using_solc:
omsg(yellow('Using precompiled contract data'))
write_to_file(
joinpath(self.tmpdir,parity_devkey_fn),

View file

@ -6,12 +6,15 @@ test.unit_tests_d.ut_dep: dependency unit tests for the MMGen suite
No data verification is performed.
"""
from subprocess import run,PIPE
from mmgen.common import *
from mmgen.exception import NoLEDSupport
from ..include.common import check_solc_ver
class unit_tests:
altcoin_deps = ('pysha3','py_ecc')
altcoin_deps = ('pysha3','py_ecc','solc')
win_skip = ('aiohttp','pysha3','led')
def led(self,name,ut):
@ -99,3 +102,25 @@ class unit_tests:
scrypt(password=passwd,salt=salt,n=2**N,r=r,p=p,maxmem=0,dklen=buflen)
return True
def solc(self,name,ut):
from mmgen.protocol import init_proto
solc_ok = check_solc_ver()
if solc_ok:
cmd = [
'python3',
'scripts/create-token.py',
'--coin=ETH',
'--name=My Fake Token',
'--symbol=FAKE',
'--supply=100000000000000000000000000',
'--decimals=18',
'--stdout',
init_proto('eth').checksummed_addr('deadbeef'*5),
]
cp = run(cmd,stdout=PIPE,stderr=PIPE)
vmsg(cp.stderr.decode())
if cp.returncode:
msg(cp.stderr.decode())
return False
return True