Example #1
0
	def __init__(self,name,mmgen_cmd,cmd_args,desc,no_output=False,passthru_args=[],msg_only=False,no_msg=False):
		cmd_args = ['--{}{}'.format(k.replace('_','-'),
			'='+getattr(opt,k) if getattr(opt,k) != True else ''
			) for k in passthru_args if getattr(opt,k)] \
			+ ['--data-dir='+data_dir] + cmd_args

		if g.platform == 'win': cmd,args = 'python',[mmgen_cmd]+cmd_args
		else:                   cmd,args = mmgen_cmd,cmd_args

		for i in args:
			if type(i) not in (str,unicode):
				m1 = 'Error: missing input files in cmd line?:'
				m2 = '\nName: {}\nCmd: {}\nCmd args: {}'
				die(2,(m1+m2).format(name,cmd,args))

		if opt.popen_spawn:
			args = [u'{q}{}{q}'.format(a,q="'" if ' ' in a else '') for a in args]

		cmd_str = u'{} {}'.format(cmd,u' '.join(args)).replace('\\','/')
		if opt.coverage:
			fs = 'python -m trace --count --coverdir={} --file={} {c}'
			cmd_str = fs.format(*init_coverage(),c=cmd_str)

		if opt.log:
			log_fd.write(cmd_str+'\n')

		if not no_msg:
			if opt.verbose or opt.print_cmdline or opt.exact_output:
				clr1,clr2,eol = ((green,cyan,'\n'),(nocolor,nocolor,' '))[bool(opt.print_cmdline)]
				sys.stderr.write(green('Testing: {}\n'.format(desc)))
				if not msg_only:
					s = repr(cmd_str) if g.platform == 'win' else cmd_str
					sys.stderr.write(clr1(u'Executing {}{}'.format(clr2(s),eol)))
			else:
				m = 'Testing {}: '.format(desc)
				msg_r(m)

		if msg_only: return

		if opt.direct_exec:
			msg('')
			from subprocess import call,check_output
			f = (call,check_output)[bool(no_output)]
			ret = f([cmd] + args)
			if f == call and ret != 0:
				die(1,red('ERROR: process returned a non-zero exit status ({})'.format(ret)))
		else:
			if opt.traceback:
				cmd,args = g.traceback_cmd,[cmd]+args
				cmd_str = g.traceback_cmd + ' ' + cmd_str
#			Msg('\ncmd_str: {}'.format(cmd_str))
			if opt.popen_spawn:
				# PopenSpawn() requires cmd string to be bytes.  However, it autoconverts unicode
				# input to bytes, though this behavior seems to be undocumented.  Setting 'encoding'
				# to 'UTF-8' will cause pexpect to reject non-unicode string input.
				self.p = PopenSpawn(cmd_str.encode('utf8'))
			else:
				self.p = pexpect.spawn(cmd,args)
			if opt.exact_output: self.p.logfile = sys.stdout
Example #2
0
             'EU4L6x2b5QUb2gRQsBAAuB8TuPEwUxCNZU')),
    ('zec', ('0bf9b5b20af7b5a0', 'zec:legacy', '-ZEC', 'ZEC',
             't1URz8BHxV38v3gsaN6oHQNKC16s35R9WkY')),
    ('zec_zcash_z',
     ('b15570d033df9b1a', 'zec:zcash_z', '-ZEC-Z', 'ZEC:ZCASH_Z',
      'zcLMMsnzfFYZWU4avRBnuc83yh4jTtJXbtP32uWrs3ickzu1krMU4ppZCQPTwwfE9hLnRuFDSYF8VFW13aT9eeQK8aov3Ge'
      )),
    ('xmr',
     ('c76af3b088da3364', 'xmr:monero', '-XMR-M', 'XMR:MONERO',
      '41tmwZd2CdXEGtWqGY9fH9FVtQM8VxZASYPQ3VJQhFjtGWYzQFuidD21vJYTi2yy3tXRYXTNXBTaYVLav62rwUUpFFyicZU'
      )),
])

cmd_base = 'python{} cmds/mmgen-addrgen -qS'.format(
    ' -m trace --count --coverdir={} --file={}'.format(
        *init_coverage()) if opt.coverage else '')


def run_tests():
    for test in test_data:
        if test == 'zec_zcash_z' and g.platform == 'win':
            msg("Skipping 'zec_zcash_z' test for Windows platform")
            continue
        try:
            coin, mmtype = test.split('_', 1)
        except:
            coin, mmtype = test, None
        type_arg = ' --type=' + mmtype if mmtype else ''
        cmd = '{} --coin={}{} test/ref/98831F3A.mmwords 1'.format(
            cmd_base, coin, type_arg)
        vmsg(green('Executing: {}'.format(cmd)))
Example #3
0
('bch',           ('456d7f5f1c4bfe3b','(none)',         '',    '',          '1MU7EdgqYy9JX35L25hR6CmXXcSEBDAwyv')),
('bch_compressed',('bf98a4af5464a4ef','compressed',     '-C',  'COMPRESSED','1F97Jd89wwmu4ELadesAdGDzg3d8Y6j5iP')),
('ltc',           ('b11f16632e63ba92','ltc:legacy',     '-LTC','LTC',       'LMxB474SVfxeYdqxNrM1WZDZMnifteSMv1')),
('ltc_compressed',('7ccf465d466ee7d3','ltc:compressed', '-LTC-C','LTC:COMPRESSED', 'LdkebBKVXSs6NNoPJWGM8KciDnL8LhXXjb')),
('ltc_segwit',    ('9460f5ba15e82768','ltc:segwit',     '-LTC-S','LTC:SEGWIT',     'MQrY3vEbqKMBgegXrSaR93R2HoTDE5bKrY')),
('eth',           ('213ed116869b19f2','eth',          '-ETH',  'ETH', 'e704b6cfd9f0edb2e6cfbd0c913438d37ede7b35')),
('etc',           ('909def37096f5ab8','etc',          '-ETC',  'ETC', '1a6acbef8c38f52f20d04ecded2992b04d8608d7')),
('dash',          ('1319d347b021f952','dash:legacy',  '-DASH', 'DASH','XoK491fppGNZQUUS9uEFkT6L9u8xxVFJNJ')),
('emc',           ('7e1a29853d2db875','emc:legacy',   '-EMC',  'EMC', 'EU4L6x2b5QUb2gRQsBAAuB8TuPEwUxCNZU')),
('zec',           ('0bf9b5b20af7b5a0','zec:legacy',   '-ZEC',  'ZEC', 't1URz8BHxV38v3gsaN6oHQNKC16s35R9WkY')),
('zec_zcash_z',   ('b15570d033df9b1a','zec:zcash_z',  '-ZEC-Z','ZEC:ZCASH_Z','zcLMMsnzfFYZWU4avRBnuc83yh4jTtJXbtP32uWrs3ickzu1krMU4ppZCQPTwwfE9hLnRuFDSYF8VFW13aT9eeQK8aov3Ge')),
('xmr',           ('c76af3b088da3364','xmr:monero',   '-XMR-M','XMR:MONERO','41tmwZd2CdXEGtWqGY9fH9FVtQM8VxZASYPQ3VJQhFjtGWYzQFuidD21vJYTi2yy3tXRYXTNXBTaYVLav62rwUUpFFyicZU')),
])

cmd_base = 'python{} cmds/mmgen-addrgen -qS'.format(
	' -m trace --count --coverdir={} --file={}'.format(*init_coverage()) if opt.coverage else '')

def run_tests():
	for test in test_data:
		if test == 'zec_zcash_z' and g.platform == 'win':
			msg("Skipping 'zec_zcash_z' test for Windows platform")
			continue
		try:    coin,mmtype = test.split('_',1)
		except: coin,mmtype = test,None
		type_arg = ' --type='+mmtype if mmtype else ''
		cmd = '{} --coin={}{} test/ref/98831F3A.mmwords 1'.format(cmd_base,coin,type_arg)
		vmsg(green('Executing: {}'.format(cmd)))
		msg_r('Testing: --coin {:4} {:22}'.format(coin.upper(),type_arg))
		p = subprocess.Popen(cmd.split(),stdout=subprocess.PIPE,stderr=subprocess.PIPE)
		o = p.stdout.read()
		vmsg(o)