minor fixes and cleanups

This commit is contained in:
The MMGen Project 2021-08-04 10:47:20 +00:00
commit 9f24236188
Signed by: mmgen
GPG key ID: 3F8B1861E32B7DA2
6 changed files with 25 additions and 17 deletions

View file

@ -28,14 +28,21 @@ if os.getenv('MMGEN_DEBUG') or os.getenv('MMGEN_TEST_SUITE') or os.getenv('MMGEN
pexit(*args,out=sys.stdout)
def print_stack_trace(message=None):
tb1 = traceback.extract_stack()
tb2 = [t for t in tb1 if t.filename[:1] != '<'][2:-2]
sys.stderr.write('STACK TRACE {}:\n'.format(message or '(unnamed)'))
fs = ' {}:{}: in {}:\n {}\n'
for t in tb2:
fn = re.sub(r'^\./','',os.path.relpath(t.filename))
func = t.name+'()' if t.name[-1] != '>' else t.name
sys.stderr.write(fs.format(fn,t.lineno,func,t.line or '(none)'))
tb = [t for t in traceback.extract_stack() if t.filename[:1] != '<'][:-1]
fs = '{}:{}: in {}:\n {}'
out = [
fs.format(
re.sub(r'^\./','',os.path.relpath(t.filename)),
t.lineno,
(t.name+'()' if t.name[-1] != '>' else t.name),
t.line or '(none)')
for t in tb ]
sys.stderr.write(
'STACK TRACE {}:\n '.format(message or '[unnamed]') +
'\n '.join(out) + '\n' )
open('devtools.trace','w').write('\n'.join(out))
class MMGenObject(object):

View file

@ -65,12 +65,12 @@ class GlobalContext(Lockable):
err_disp_timeout = 0.7
short_disp_timeout = 0.3
min_time_precision = 18
dfl_seed_len = 256
# Variables - these might be altered at runtime:
user_entropy = b''
dfl_hash_preset = '3'
dfl_seed_len = 256
usr_randchars = 30
tx_fee_adj = Decimal('1.0')
@ -91,7 +91,6 @@ class GlobalContext(Lockable):
testnet = False
regtest = False
accept_defaults = False
use_internal_keccak_module = False
# rpc:
rpc_host = ''
@ -111,6 +110,9 @@ class GlobalContext(Lockable):
bob = False
alice = False
# miscellaneous features:
use_internal_keccak_module = False
# test suite:
bogus_wallet_data = ''
bogus_send = False

View file

@ -35,8 +35,7 @@ def help_notes_func(proto,k):
def coind_exec():
from .daemon import CoinDaemon
return (
CoinDaemon(proto.coin).exec_fn if proto.coin.lower() in CoinDaemon.coins else
'bitcoind' )
CoinDaemon(proto.coin).exec_fn if proto.coin in CoinDaemon.coins else 'bitcoind' )
class help_notes:

View file

@ -24,7 +24,6 @@ import os,time,shutil
from subprocess import run,PIPE
from .common import *
from .protocol import init_proto
from .daemon import CoinDaemon
from .rpc import rpc_init
def create_data_dir(data_dir):
@ -52,6 +51,7 @@ class MMGenRegtest(MMGenObject):
self.coin = coin.lower()
assert self.coin in self.coins, f'{coin!r}: invalid coin for regtest'
from .daemon import CoinDaemon
self.proto = init_proto(self.coin,regtest=True)
self.d = CoinDaemon(self.coin+'_rt',test_suite=g.test_suite_regtest)

View file

@ -709,11 +709,11 @@ class MoneroWalletRPCClient(MoneroRPCClient):
'refresh', # start_height
)
def handle_unsupported_daemon_version(rpc,proto,ignore_daemon_version,warning_shown=[]):
def handle_unsupported_daemon_version(rpc,proto,ignore_daemon_version,unsupported_daemon_warning_shown=[]):
if ignore_daemon_version or proto.ignore_daemon_version or g.ignore_daemon_version:
if not type(proto) in warning_shown:
if not type(proto) in unsupported_daemon_warning_shown:
ymsg(f'WARNING: ignoring unsupported {rpc.daemon.coind_name} daemon version at user request')
warning_shown.append(type(proto))
unsupported_daemon_warning_shown.append(type(proto))
else:
rdie(1,fmt(
"""

View file

@ -77,7 +77,6 @@ try: os.unlink(os.path.join(repo_root,'my.err'))
except: pass
from mmgen.common import *
from mmgen.daemon import CoinDaemon
from test.include.common import *
from test.test_py_d.common import *
@ -163,6 +162,7 @@ def add_cmdline_opts():
sys.argv.insert(1,'--data-dir=' + data_dir)
sys.argv.insert(1,'--daemon-data-dir=test/daemons/' + get_coin())
from mmgen.daemon import CoinDaemon
sys.argv.insert(1,'--rpc-port={}'.format(CoinDaemon(network_id,test_suite=True).rpc_port))
# add_cmdline_opts()