From eecf8acd0d8ece32be7b046e80964cb84a5a0931 Mon Sep 17 00:00:00 2001 From: The MMGen Project Date: Tue, 28 Mar 2023 18:16:33 +0000 Subject: [PATCH] minor fixes and cleanups --- mmgen_node_tools/PeerBlocks.py | 1 + mmgen_node_tools/main_txfind.py | 1 + test/test_py_d/ts_misc.py | 2 +- test/test_py_d/ts_regtest.py | 13 +++++++------ test/unit_tests_d/ut_BlocksInfo.py | 8 +++++--- 5 files changed, 15 insertions(+), 10 deletions(-) diff --git a/mmgen_node_tools/PeerBlocks.py b/mmgen_node_tools/PeerBlocks.py index 899f962..6df9894 100755 --- a/mmgen_node_tools/PeerBlocks.py +++ b/mmgen_node_tools/PeerBlocks.py @@ -31,6 +31,7 @@ class Display(PollDisplay): poll_secs = 2 def __init__(self): + super().__init__() global term,term_width diff --git a/mmgen_node_tools/main_txfind.py b/mmgen_node_tools/main_txfind.py index 2672a11..d0a04e2 100755 --- a/mmgen_node_tools/main_txfind.py +++ b/mmgen_node_tools/main_txfind.py @@ -86,6 +86,7 @@ async def main(txid): return exitval cmd_args = opts.init(opts_data) + msgs = msg_data['quiet' if opt.quiet else 'normal'] if len(cmd_args) != 1: diff --git a/test/test_py_d/ts_misc.py b/test/test_py_d/ts_misc.py index ee41377..cc4c22d 100755 --- a/test/test_py_d/ts_misc.py +++ b/test/test_py_d/ts_misc.py @@ -9,7 +9,7 @@ # https://gitlab.com/mmgen/mmgen-node-tools """ -ts_misc.py: Miscellaneous test groups for the test.py test suite +test.test_py_d.ts_misc: Miscellaneous test groups for the test.py test suite """ import shutil diff --git a/test/test_py_d/ts_regtest.py b/test/test_py_d/ts_regtest.py index 2501160..fd19099 100755 --- a/test/test_py_d/ts_regtest.py +++ b/test/test_py_d/ts_regtest.py @@ -9,7 +9,7 @@ # https://gitlab.com/mmgen/mmgen-node-tools """ -ts_regtest.py: Regtest tests for the test.py test suite +test.test_py_d.ts_regtest: Regtest tests for the test.py test suite """ import os @@ -273,7 +273,7 @@ class TestSuiteRegtest(TestSuiteBase): wp = namedtuple('wifaddrpair',['wif','addr']) def gen(): - for n in range(1,nPairs+1): + for n in range(0xfaceface,nPairs+0xfaceface): wif = t.hex2wif(f'{n:064x}') yield wp( wif, t.wif2addr(wif) ) @@ -299,11 +299,12 @@ class TestSuiteRegtest(TestSuiteBase): async def do_tx1(): us = await r.rpc_call('listunspent',wallet='miner') + tx_input = us[7] # 25 BTC in coinbase -- us[0] could have < 25 BTC fee = self.proto.coin_amt('0.001') outputs = {p.addr:tx1_amt for p in pairs[:nTxs]} - outputs.update({burn_addr: us[0]['amount'] - (tx1_amt*nTxs) - fee}) + outputs.update({burn_addr: tx_input['amount'] - (tx1_amt*nTxs) - fee}) return await do_tx( - [{ 'txid': us[0]['txid'], 'vout': 0 }], + [{ 'txid': tx_input['txid'], 'vout': 0 }], outputs, r.miner_wif ) @@ -326,8 +327,8 @@ class TestSuiteRegtest(TestSuiteBase): r = self.regtest nPairs = 100 nTxs = 25 - tx1_amt = self.proto.coin_amt('{:0.4f}'.format(24 / (nTxs+1))) # 25 BTC subsidy - tx2_amt = self.proto.coin_amt('0.0001') + tx1_amt = self.proto.coin_amt('{:0.4f}'.format(24 / nTxs)) # 25 BTC subsidy, leave extra for fee + tx2_amt = self.proto.coin_amt('0.00005') # make this as small as possible imsg(f'Creating {nPairs} key-address pairs') pairs = create_pairs(nPairs+1) diff --git a/test/unit_tests_d/ut_BlocksInfo.py b/test/unit_tests_d/ut_BlocksInfo.py index e83cca0..ab09882 100755 --- a/test/unit_tests_d/ut_BlocksInfo.py +++ b/test/unit_tests_d/ut_BlocksInfo.py @@ -1,7 +1,6 @@ #!/usr/bin/env python3 """ -test.unit_tests_d.nt_BlocksInfo: - BlocksInfo unit test for the MMGen Node Tools suite +test.unit_tests_d.nt_BlocksInfo: BlocksInfo unit test for the MMGen Node Tools suite """ from mmgen.common import * @@ -108,7 +107,10 @@ class unit_tests: def parse_cmd_args(self,name,ut): def test(spec,foo,chk): - b = BlocksInfo(spec if type(spec) == tuple else [spec],dummyOpt(),dummyRPC()) + b = BlocksInfo( + spec if type(spec) == tuple else [spec], + dummyOpt(), + dummyRPC() ) ret = (b.first,b.last,b.block_list) vmsg('{:13} => {}'.format( (repr(spec) if type(spec) == tuple else spec),