MSWin/MSYS2 testing fixes

This commit is contained in:
The MMGen Project 2023-05-19 16:16:53 +00:00
commit f97869702d
Signed by: mmgen
GPG key ID: 3F8B1861E32B7DA2
12 changed files with 36 additions and 15 deletions

View file

@ -1 +1 @@
13.3.dev55
13.3.dev56

View file

@ -272,7 +272,12 @@ class MMGenTermMSWinStub(MMGenTermMSWin):
Use stdin to allow UTF-8 and emulate the one-character behavior of MMGenTermMSWin
"""
msg_r(prompt)
return sys.stdin.read(1)
while True:
try:
return sys.stdin.read(1)
except:
msg('[read error, trying again]')
time.sleep(0.5)
get_char_raw = get_char

View file

@ -54,7 +54,9 @@ class TwJSON:
from ..addrlist import AddrIdxList
prune_id = AddrIdxList(idx_list=self.pruned).id_str
fn = get_fn(prune_id)
if len(fn) > os.statvfs(self.cfg.outdir or os.curdir).f_namemax:
from ..cfg import gc
mf = 255 if gc.platform == 'win' else os.statvfs(self.cfg.outdir or os.curdir).f_namemax
if len(fn) > mf:
fn = get_fn(f'idhash={make_chksum_8(prune_id.encode()).lower()}')
else:
fn = get_fn(None)

View file

@ -22,7 +22,7 @@ xmrwallet.py - MoneroWalletOps class
import re,time,json,atexit
from collections import namedtuple
from pathlib import PosixPath as Path
from pathlib import Path
from .objmethods import MMGenObject,Hilite,InitErrors
from .obj import CoinTxID,Int

View file

@ -672,6 +672,10 @@ class TestSuiteRunner(object):
ts_cls = CmdGroupMgr().load_mod(gname)
if gc.platform == 'win' and ts_cls.win_skip:
omsg(f'Skipping test {gname!r} for Windows platform')
return False
for k in ('segwit','segwit_random','bech32'):
if getattr(cfg,k):
segwit_opt = k

View file

@ -116,7 +116,8 @@ def get_file_with_ext(tdir,ext,delete=True,no_dot=False,return_list=False,delete
or fn.endswith( dot + ext )
or (substr and ext in fn) )
flist = [f.path for f in os.scandir(tdir) if have_match(f.name)]
# Don’t use os.scandir here - it returns broken paths under Windows/MSYS2
flist = [os.path.join(tdir,name) for name in os.listdir(tdir) if have_match(name)]
if not flist:
return False

View file

@ -81,6 +81,7 @@ class TestSuiteAutosignBase(TestSuiteBase):
color = True
mountpoint_basename = 'mmgen_autosign'
no_insert_check = True
win_skip = True
def __init__(self,trunner,cfgs,spawn):
@ -89,9 +90,6 @@ class TestSuiteAutosignBase(TestSuiteBase):
if trunner == None:
return
if gc.platform == 'win':
die(1,f'Test {self.name} not supported for Windows platform')
self.network_ids = [c+'_tn' for c in self.daemon_coins] + self.daemon_coins
if not self.live:

View file

@ -34,6 +34,7 @@ class TestSuiteBase:
segwit_opts_ok = False
color = False
need_daemon = False
win_skip = False
def __init__(self,trunner,cfgs,spawn):
if hasattr(self,'tr'): # init will be called multiple times for classes with multiple inheritance

View file

@ -182,6 +182,9 @@ class TestSuiteHelp(TestSuiteBase):
if self.proto.coin not in ('BTC','XMR') and 'xmrwallet' in scripts:
scripts.remove('xmrwallet')
if gc.platform == 'win' and 'autosign' in scripts:
scripts.remove('autosign')
for s in sorted(scripts):
t = self.spawn(f'mmgen-{s}',[arg],extra_desc=f'(mmgen-{s})')
t.expect(expect,regex=True)

View file

@ -47,6 +47,7 @@ class TestSuiteXMRAutosign(TestSuiteXMRWallet,TestSuiteAutosignBase):
bad_tx_count = 0
tx_relay_user = 'miner'
no_insert_check = False
win_skip = True
cmd_group = (
('daemon_version', 'checking daemon version'),

View file

@ -60,10 +60,11 @@ class TestSuiteXMRWallet(TestSuiteBase):
dfl_random_txs = 3
color = True
socks_port = 49237
# Bob’s daemon is stopped via process kill, not RPC, so put Bob last in list:
user_data = (
('miner', '98831F3A', False, 130, '1-2', []),
('bob', '1378FC64', False, 140, None, ['--restricted-rpc']),
('alice', 'FE3C6545', False, 150, '1-4', []),
('bob', '1378FC64', False, 140, None, ['--restricted-rpc']),
)
tx_relay_user = 'bob'
datadir_base = os.path.join('test','daemons','xmrtest')
@ -814,9 +815,11 @@ class TestSuiteXMRWallet(TestSuiteBase):
h = await self._get_height()
imsg_r(f'Chain height: {h} ')
for count in range(50):
max_iterations,height_threshold = (300,80) if gc.platform == 'win' else (50,300)
for count in range(max_iterations):
bal_info = await get_balance(dest,count)
if h > 300 and (dest.test(bal_info) is True or ( chk_bal_chg and bal_info.ub != bal_info_start.ub )):
if h > height_threshold and (dest.test(bal_info) is True or ( chk_bal_chg and bal_info.ub != bal_info_start.ub )):
imsg('')
oqmsg_r('+')
print_balance(dest,bal_info)

View file

@ -211,14 +211,17 @@ class unit_tests:
filename = fn,
password = 'foo',
seed = xmrseed().fromhex('beadface'*8,tostr=True) )
if gc.platform == 'win':
wd.stop()
wd.start()
qmsg(f'Opening {wd.network} wallet')
c.call( 'open_wallet', filename=fn, password='foo' )
for md,wd in daemons:
wd.wait = False
await wd.rpc.stop_daemon()
await c.stop_daemon()
if not cfg.no_daemon_stop:
md.wait = False
await md.rpc.stop_daemon()
gmsg('OK')