test/test.py,scripts/test-release.py: minor changes

This commit is contained in:
The MMGen Project 2018-07-25 12:34:50 +00:00
commit e978b759d8
Signed by: mmgen
GPG key ID: 3F8B1861E32B7DA2
3 changed files with 17 additions and 12 deletions

View file

@ -79,8 +79,6 @@ REFDIR='test/ref'
if uname -a | grep -qi mingw; then SUDO='' MINGW=1; else SUDO='sudo' MINGW=''; fi if uname -a | grep -qi mingw; then SUDO='' MINGW=1; else SUDO='sudo' MINGW=''; fi
[ "$MINGW" ] || RED="\e[31;1m" GREEN="\e[32;1m" YELLOW="\e[33;1m" RESET="\e[0m" [ "$MINGW" ] || RED="\e[31;1m" GREEN="\e[32;1m" YELLOW="\e[33;1m" RESET="\e[0m"
set -e
[ "$NO_INSTALL" ] || { [ "$NO_INSTALL" ] || {
BRANCH=$1; shift BRANCH=$1; shift
BRANCHES=$(git branch) BRANCHES=$(git branch)
@ -88,6 +86,8 @@ set -e
[ "$FOUND_BRANCH" ] || { echo "Branch '$BRANCH' not found!"; exit; } [ "$FOUND_BRANCH" ] || { echo "Branch '$BRANCH' not found!"; exit; }
} }
set -e
check() { check() {
[ "$BRANCH" ] || { echo 'No branch specified. Exiting'; exit; } [ "$BRANCH" ] || { echo 'No branch specified. Exiting'; exit; }
[ "$(git diff $BRANCH)" == "" ] || { [ "$(git diff $BRANCH)" == "" ] || {

View file

@ -96,7 +96,8 @@ class MMGenPexpect(object):
atexit.register(lambda: os.system('stty sane')) atexit.register(lambda: os.system('stty sane'))
NL = '\n' NL = '\n'
def __init__(self,name,mmgen_cmd,cmd_args,desc,no_output=False,passthru_args=[],msg_only=False,no_msg=False): def __init__(self,name,mmgen_cmd,cmd_args,desc,
no_output=False,passthru_args=[],msg_only=False,no_msg=False,log_fd=None):
cmd_args = ['--{}{}'.format(k.replace('_','-'), cmd_args = ['--{}{}'.format(k.replace('_','-'),
'='+getattr(opt,k) if getattr(opt,k) != True else '' '='+getattr(opt,k) if getattr(opt,k) != True else ''
) for k in passthru_args if getattr(opt,k)] \ ) for k in passthru_args if getattr(opt,k)] \
@ -120,7 +121,7 @@ class MMGenPexpect(object):
cmd_str = fs.format(*init_coverage(),c=cmd_str) cmd_str = fs.format(*init_coverage(),c=cmd_str)
if opt.log: if opt.log:
log_fd.write(cmd_str+'\n') log_fd.write(cmd_str.encode('utf8')+'\n')
if not no_msg: if not no_msg:
if opt.verbose or opt.print_cmdline or opt.exact_output: if opt.verbose or opt.print_cmdline or opt.exact_output:

View file

@ -1053,6 +1053,8 @@ del cmd_group
if opt.profile: opt.names = True if opt.profile: opt.names = True
if opt.resume: opt.skip_deps = True if opt.resume: opt.skip_deps = True
log_fd = None
if opt.log: if opt.log:
log_fd = open(log_file,'a') log_fd = open(log_file,'a')
log_fd.write('\nLog started: {}\n'.format(make_timestr())) log_fd.write('\nLog started: {}\n'.format(make_timestr()))
@ -1193,7 +1195,8 @@ class MMGenExpect(MMGenPexpect):
no_output=no_output, no_output=no_output,
passthru_args=passthru_args, passthru_args=passthru_args,
msg_only=msg_only, msg_only=msg_only,
no_msg=no_msg) no_msg=no_msg,
log_fd=log_fd)
def create_fake_unspent_entry(coinaddr,al_id=None,idx=None,lbl=None,non_mmgen=False,segwit=False): def create_fake_unspent_entry(coinaddr,al_id=None,idx=None,lbl=None,non_mmgen=False,segwit=False):
if 'S' not in g.proto.mmtypes: segwit = False if 'S' not in g.proto.mmtypes: segwit = False
@ -1739,7 +1742,7 @@ class MMGenTestSuite(object):
def txsign_ui_common(self,t,name, view='t',add_comment='', def txsign_ui_common(self,t,name, view='t',add_comment='',
ni=False,save=True,do_passwd=False, ni=False,save=True,do_passwd=False,
file_desc='Signed transaction',no_ok=False): file_desc='Signed transaction',no_ok=False,has_label=False):
txdo = name[:4] == 'txdo' txdo = name[:4] == 'txdo'
if do_passwd: if do_passwd:
@ -1747,7 +1750,7 @@ class MMGenTestSuite(object):
if not ni and not txdo: if not ni and not txdo:
t.view_tx(view) t.view_tx(view)
t.do_comment(add_comment) t.do_comment(add_comment,has_label=has_label)
t.expect('(Y/n): ',('n','y')[save]) t.expect('(Y/n): ',('n','y')[save])
t.written_to_file(file_desc) t.written_to_file(file_desc)
@ -1761,13 +1764,13 @@ class MMGenTestSuite(object):
def txsend_ui_common(self,t,name, view='n',add_comment='', def txsend_ui_common(self,t,name, view='n',add_comment='',
confirm_send=True,bogus_send=True,quiet=False, confirm_send=True,bogus_send=True,quiet=False,
file_desc='Sent transaction',no_ok=False): file_desc='Sent transaction',no_ok=False,has_label=False):
txdo = name[:4] == 'txdo' txdo = name[:4] == 'txdo'
if not txdo: if not txdo:
t.license() # MMGEN_NO_LICENSE is set, so does nothing t.license() # MMGEN_NO_LICENSE is set, so does nothing
t.view_tx(view) t.view_tx(view)
t.do_comment(add_comment) t.do_comment(add_comment,has_label=has_label)
self.do_confirm_send(t,quiet=quiet,confirm_send=confirm_send) self.do_confirm_send(t,quiet=quiet,confirm_send=confirm_send)
@ -3148,21 +3151,22 @@ class MMGenTestSuite(object):
input_sels_prompt='to spend from', input_sels_prompt='to spend from',
inputs=acct,file_desc='Ethereum transaction', inputs=acct,file_desc='Ethereum transaction',
bad_input_sels=True,non_mmgen_inputs=non_mmgen_inputs, bad_input_sels=True,non_mmgen_inputs=non_mmgen_inputs,
interactive_fee=interactive_fee,fee_res=fee_res,fee_desc=fee_desc) interactive_fee=interactive_fee,fee_res=fee_res,fee_desc=fee_desc,
add_comment=ref_tx_label_jp)
def ethdev_txsign(self,name,ni=False,ext='.rawtx',add_args=[]): def ethdev_txsign(self,name,ni=False,ext='.rawtx',add_args=[]):
key_fn = get_tmpfile_fn(cfg,cfg['parity_keyfile']) key_fn = get_tmpfile_fn(cfg,cfg['parity_keyfile'])
write_to_tmpfile(cfg,cfg['parity_keyfile'],eth_key+'\n') write_to_tmpfile(cfg,cfg['parity_keyfile'],eth_key+'\n')
tx_fn = get_file_with_ext(ext,cfg['tmpdir'],no_dot=True) tx_fn = get_file_with_ext(ext,cfg['tmpdir'],no_dot=True)
t = MMGenExpect(name,'mmgen-txsign',eth_args+add_args + ([],['--yes'])[ni] + ['-k',key_fn,tx_fn,dfl_words]) t = MMGenExpect(name,'mmgen-txsign',eth_args+add_args + ([],['--yes'])[ni] + ['-k',key_fn,tx_fn,dfl_words])
self.txsign_ui_common(t,name,ni=ni) self.txsign_ui_common(t,name,ni=ni,has_label=True)
def ethdev_txsend(self,name,ni=False,bogus_send=False,ext='.sigtx',add_args=[]): def ethdev_txsend(self,name,ni=False,bogus_send=False,ext='.sigtx',add_args=[]):
tx_fn = get_file_with_ext(ext,cfg['tmpdir'],no_dot=True) tx_fn = get_file_with_ext(ext,cfg['tmpdir'],no_dot=True)
if not bogus_send: os.environ['MMGEN_BOGUS_SEND'] = '' if not bogus_send: os.environ['MMGEN_BOGUS_SEND'] = ''
t = MMGenExpect(name,'mmgen-txsend', eth_args+add_args + [tx_fn]) t = MMGenExpect(name,'mmgen-txsend', eth_args+add_args + [tx_fn])
if not bogus_send: os.environ['MMGEN_BOGUS_SEND'] = '1' if not bogus_send: os.environ['MMGEN_BOGUS_SEND'] = '1'
self.txsend_ui_common(t,name,quiet=True,bogus_send=bogus_send) self.txsend_ui_common(t,name,quiet=True,bogus_send=bogus_send,has_label=True)
def ethdev_txcreate1(self,name): def ethdev_txcreate1(self,name):
menu = ['a','d','A','r','M','D','e','m','m'] menu = ['a','d','A','r','M','D','e','m','m']