From 18ee26f851706cc962e0c5f347747a88cf5b1658 Mon Sep 17 00:00:00 2001 From: MMGen Date: Wed, 16 Oct 2019 16:39:04 +0000 Subject: [PATCH] test suite: minor changes --- test/common.py | 1 + test/pexpect.py | 2 +- test/scrambletest.py | 2 +- test/test_py_d/ts_shared.py | 20 ++++++++++---------- 4 files changed, 13 insertions(+), 12 deletions(-) diff --git a/test/common.py b/test/common.py index 4c99a401..a4469e5c 100755 --- a/test/common.py +++ b/test/common.py @@ -25,6 +25,7 @@ class TestSuiteFatalException(Exception): pass import os from mmgen.common import * +from mmgen.devtools import * ascii_uc = ''.join(map(chr,list(range(65,91)))) # 26 chars ascii_lc = ''.join(map(chr,list(range(97,123)))) # 26 chars diff --git a/test/pexpect.py b/test/pexpect.py index 80f5eb14..465b0edf 100755 --- a/test/pexpect.py +++ b/test/pexpect.py @@ -24,7 +24,7 @@ import sys,os,time from mmgen.globalvars import g from mmgen.opts import opt from mmgen.util import msg,msg_r,vmsg,vmsg_r,rmsg,red,yellow,green,cyan,die,rdie -from test.common import getrandstr +from test.common import * try: import pexpect diff --git a/test/scrambletest.py b/test/scrambletest.py index ef1f92b3..0725430c 100755 --- a/test/scrambletest.py +++ b/test/scrambletest.py @@ -28,7 +28,7 @@ os.environ['MMGEN_TEST_SUITE'] = '1' # Import this _after_ local path's been added to sys.path from mmgen.common import * -from test.common import init_coverage +from test.common import * opts_data = { 'text': { diff --git a/test/test_py_d/ts_shared.py b/test/test_py_d/ts_shared.py index 206c9031..4e05b3de 100755 --- a/test/test_py_d/ts_shared.py +++ b/test/test_py_d/ts_shared.py @@ -188,13 +188,15 @@ class TestSuiteShared(object): if sid: cmp_or_die(chk,sid) return t - def addrgen(self,wf,pf=None,check_ref=False,ftype='addr',id_str=None,extra_args=[],mmtype=None): - if not mmtype and ftype[:4] != 'pass': + def addrgen(self,wf,pf=None,check_ref=False,ftype='addr',id_str=None,extra_args=[],mmtype=None,stdout=False): + passgen = ftype[:4] == 'pass' + if not mmtype and not passgen: mmtype = self.segwit_mmtype - cmd_pfx = (ftype,'pass')[ftype[:4]=='pass'] + cmd_pfx = (ftype,'pass')[passgen] t = self.spawn('mmgen-{}gen'.format(cmd_pfx), ['-d',self.tmpdir] + extra_args + ([],['--type='+str(mmtype)])[bool(mmtype)] + + ([],['--stdout'])[stdout] + ([],[wf])[bool(wf)] + ([],[id_str])[bool(id_str)] + [getattr(self,'{}_idx_list'.format(cmd_pfx))], @@ -202,15 +204,13 @@ class TestSuiteShared(object): t.license() t.passphrase('MMGen wallet',self.wpasswd) t.expect('Passphrase is OK') - desc = ('address','password')[ftype[:4]=='pass'] + desc = ('address','password')[passgen] chk = t.expect_getend(r'Checksum for {} data .*?: '.format(desc),regex=True) - if ftype[:4] == 'pass': - t.expect('Encrypt password list? (y/N): ','\n') - t.written_to_file('Password list',oo=True) - else: - t.written_to_file('Addresses',oo=True) + if passgen: + t.expect('Encrypt password list? (y/N): ','N') + t.read() if stdout else t.written_to_file(('Addresses','Password list')[passgen]) if check_ref: - chk_ref = (self.chk_data[self.test_name] if ftype[:4] == 'pass' else + chk_ref = (self.chk_data[self.test_name] if passgen else self.chk_data[self.test_name][self.fork][g.testnet]) cmp_or_die(chk,chk_ref,desc='{}list data checksum'.format(ftype)) return t