From e879b7e54825b14ae393c0b5b66a03f2a8d3d229 Mon Sep 17 00:00:00 2001 From: MMGen Date: Mon, 20 May 2019 15:43:01 +0000 Subject: [PATCH] minor fixes --- mmgen/main_txbump.py | 12 ++++++++++-- mmgen/main_txdo.py | 12 ++++++++++-- test/gentest.py | 9 +++++++-- test/test_py_d/ts_autosign.py | 2 +- test/test_py_d/ts_main.py | 3 ++- test/unit_tests_d/ut_tx_deserialize.py | 19 ++++++++++++++----- 6 files changed, 44 insertions(+), 13 deletions(-) diff --git a/mmgen/main_txbump.py b/mmgen/main_txbump.py index a10e6ea3..b701a7ba 100755 --- a/mmgen/main_txbump.py +++ b/mmgen/main_txbump.py @@ -22,6 +22,7 @@ mmgen-txbump: Increase the fee on a replaceable (replace-by-fee) MMGen """ from mmgen.common import * +from mmgen.seed import SeedSource opts_data = { 'sets': [('yes', True, 'quiet', True)], @@ -71,7 +72,13 @@ opts_data = { -y, --yes Answer 'yes' to prompts, suppress non-essential output -z, --show-hash-presets Show information on available hash presets """, - 'notes': '\n{}{}' + 'notes': """ +{}{} +Seed source files must have the canonical extensions listed in the 'FileExt' +column below: + + {f} +""" }, 'code': { 'options': lambda s: s.format( @@ -82,7 +89,8 @@ opts_data = { cu=g.coin), 'notes': lambda s: s.format( help_notes('fee'), - help_notes('txsign')) + help_notes('txsign'), + f='\n '.join(SeedSource.format_fmt_codes().splitlines())) } } diff --git a/mmgen/main_txdo.py b/mmgen/main_txdo.py index fbee840d..8ecec17a 100755 --- a/mmgen/main_txdo.py +++ b/mmgen/main_txdo.py @@ -21,6 +21,7 @@ mmgen-txdo: Create, sign and broadcast an online MMGen transaction """ from mmgen.common import * +from mmgen.seed import SeedSource from mmgen.obj import SubSeedIdxRange opts_data = { @@ -80,7 +81,13 @@ opts_data = { -y, --yes Answer 'yes' to prompts, suppress non-essential output -z, --show-hash-presets Show information on available hash presets """, - 'notes': '\n{}{}{}', + 'notes': """ +{}{}{} +Seed source files must have the canonical extensions listed in the 'FileExt' +column below: + + {f} +""" }, 'code': { 'options': lambda s: s.format( @@ -94,7 +101,8 @@ opts_data = { 'notes': lambda s: s.format( help_notes('txcreate'), help_notes('fee'), - help_notes('txsign')) + help_notes('txsign'), + f='\n '.join(SeedSource.format_fmt_codes().splitlines())) } } diff --git a/test/gentest.py b/test/gentest.py index 6aac8937..47b1c810 100755 --- a/test/gentest.py +++ b/test/gentest.py @@ -168,7 +168,7 @@ def match_error(sec,wif,a_addr,b_addr,a,b): def compare_test(): for k in ('segwit','compressed'): - if addr_type.name == k and g.coin not in ci.external_tests_segwit_compressed[k]: + if b == 'ext' and addr_type.name == k and g.coin not in ci.external_tests_segwit_compressed[k]: m = 'skipping - external program does not support {} for coin {}' msg(m.format(addr_type.name.capitalize(),g.coin)) return @@ -178,7 +178,12 @@ def compare_test(): return m = "Comparing address generators '{}' and '{}' for coin {}" last_t = time.time() - qmsg(green(m.format(kg_a.desc,(ext_lib if b == 'ext' else kg_b.desc),g.coin))) + A = kg_a.desc + B = ext_lib if b == 'ext' else kg_b.desc + if A == B: + msg('skipping - generation methods A and B are the same ({})'.format(A)) + return + qmsg(green(m.format(A,B,g.coin))) for i in range(rounds): if opt.verbose or time.time() - last_t >= 0.1: diff --git a/test/test_py_d/ts_autosign.py b/test/test_py_d/ts_autosign.py index a7abf9fb..9cbc2968 100755 --- a/test/test_py_d/ts_autosign.py +++ b/test/test_py_d/ts_autosign.py @@ -54,7 +54,7 @@ class TestSuiteAutosign(TestSuiteBase): txcount=12, live=False): - if self.skip_for_win(): return + if self.skip_for_win(): return 'skip' def make_wallet(opts): t = self.spawn('mmgen-autosign',opts+['gen_key'],extra_desc='(gen_key)') diff --git a/test/test_py_d/ts_main.py b/test/test_py_d/ts_main.py index f8042ed7..7320906c 100755 --- a/test/test_py_d/ts_main.py +++ b/test/test_py_d/ts_main.py @@ -142,7 +142,8 @@ class TestSuiteMain(TestSuiteBase,TestSuiteShared): ) def __init__(self,trunner,cfgs,spawn): - self.lbl_id = ('account','label')[g.coin=='BTC'] # update as other coins adopt Core's label API + rpc_init() + self.lbl_id = ('account','label')['label_api' in g.rpch.caps] if g.coin in ('BTC','BCH','LTC'): self.tx_fee = {'btc':'0.0001','bch':'0.001','ltc':'0.01'}[g.coin.lower()] self.txbump_fee = {'btc':'123s','bch':'567s','ltc':'12345s'}[g.coin.lower()] diff --git a/test/unit_tests_d/ut_tx_deserialize.py b/test/unit_tests_d/ut_tx_deserialize.py index 5e1c5448..45a2c82f 100755 --- a/test/unit_tests_d/ut_tx_deserialize.py +++ b/test/unit_tests_d/ut_tx_deserialize.py @@ -57,11 +57,20 @@ class tx_deserialize(object): # outputs a,b = d['vout'],dt['txouts'] for i in range(len(a)): - assert a[i]['scriptPubKey']['addresses'][0] == b[i]['address'],( - 'address of ouput {} does not match'.format(i)) - assert a[i]['value'] == b[i]['amount'],'value of ouput {} does not match'.format(i) - assert a[i]['scriptPubKey']['hex'] == b[i]['scriptPubKey'],( - 'scriptPubKey of ouput {} does not match'.format(i)) + A = a[i]['scriptPubKey']['addresses'][0] + B = b[i]['address'] + fs = 'address of output {} does not match\nA: {}\nB: {}' + assert A == B, fs.format(i,A,B) + + A = a[i]['value'] + B = b[i]['amount'] + fs = 'value of output {} does not match\nA: {}\nB: {}' + assert A == B, fs.format(i,A,B) + + A = a[i]['scriptPubKey']['hex'] + B = b[i]['scriptPubKey'] + fs = 'scriptPubKey of output {} does not match\nA: {}\nB: {}' + assert A == B, fs.format(i,A,B) return True