From b59e244da3a1a7bf9dfc831499abaffb1ceccabc Mon Sep 17 00:00:00 2001 From: Byron Hambly Date: Fri, 1 Sep 2023 16:04:39 +0200 Subject: [PATCH] lint: fix issues from lint-python.sh --- test/functional/feature_block.py | 2 +- test/functional/feature_rbf.py | 1 - test/functional/feature_taproot.py | 4 ++-- test/functional/interface_zmq.py | 1 - test/functional/mempool_package_limits.py | 1 - test/functional/mining_basic.py | 3 ++- test/functional/p2p_ibd_txrelay.py | 2 +- test/functional/p2p_invalid_block.py | 2 +- test/functional/rpc_fundrawtransaction.py | 10 +++++----- test/functional/rpc_rawtransaction.py | 1 - test/functional/wallet_send.py | 2 +- 11 files changed, 13 insertions(+), 16 deletions(-) diff --git a/test/functional/feature_block.py b/test/functional/feature_block.py index 5aa4293e71..f906f29250 100755 --- a/test/functional/feature_block.py +++ b/test/functional/feature_block.py @@ -24,7 +24,7 @@ from test_framework.messages import ( CTxOut, MAX_BLOCK_WEIGHT, SEQUENCE_FINAL, - uint256_from_compact, + # uint256_from_compact, uint256_from_str, ) from test_framework.p2p import P2PDataStore diff --git a/test/functional/feature_rbf.py b/test/functional/feature_rbf.py index a2b721265d..a6fbf370fb 100755 --- a/test/functional/feature_rbf.py +++ b/test/functional/feature_rbf.py @@ -4,7 +4,6 @@ # file COPYING or http://www.opensource.org/licenses/mit-license.php. """Test the RBF code.""" -from copy import deepcopy from decimal import Decimal from test_framework.messages import ( diff --git a/test/functional/feature_taproot.py b/test/functional/feature_taproot.py index 5828aaea5b..06dcf56926 100755 --- a/test/functional/feature_taproot.py +++ b/test/functional/feature_taproot.py @@ -101,7 +101,7 @@ from test_framework import util from test_framework.key import generate_privkey, compute_xonly_pubkey, sign_schnorr, tweak_add_privkey, ECKey from test_framework.address import ( hash160, - program_to_witness + # program_to_witness ) from collections import OrderedDict, namedtuple from enum import Enum @@ -1594,7 +1594,7 @@ class TaprootTest(BitcoinTestFramework): # Require one negated and one non-negated in taps 5 and 6. # assert taps[5].negflag != taps[6].negflag - cblks = [{leaf: get({**DEFAULT_CONTEXT, 'tap': taps[i], 'leaf': leaf}, 'controlblock') for leaf in taps[i].leaves} for i in range(7)] + # cblks = [{leaf: get({**DEFAULT_CONTEXT, 'tap': taps[i], 'leaf': leaf}, 'controlblock') for leaf in taps[i].leaves} for i in range(7)] # Require one swapped and one unswapped in taps 3 and 4. #assert (cblks[3]['0'][33:65] < cblks[3]['1'][33:65]) != (cblks[4]['0'][33:65] < cblks[4]['1'][33:65]) # Require one swapped and one unswapped in taps 5 and 6, both at the top and child level. diff --git a/test/functional/interface_zmq.py b/test/functional/interface_zmq.py index bffe60b4c9..f4be083e8b 100755 --- a/test/functional/interface_zmq.py +++ b/test/functional/interface_zmq.py @@ -19,7 +19,6 @@ from test_framework.messages import ( CTransaction, hash256, ) -from test_framework import util from test_framework.util import ( assert_equal, assert_raises_rpc_error, diff --git a/test/functional/mempool_package_limits.py b/test/functional/mempool_package_limits.py index ea093b5fa6..14317a4502 100755 --- a/test/functional/mempool_package_limits.py +++ b/test/functional/mempool_package_limits.py @@ -26,7 +26,6 @@ from test_framework.wallet import ( bulk_transaction, create_child_with_parents, make_chain, - DEFAULT_FEE, ) class MempoolPackageLimitsTest(BitcoinTestFramework): diff --git a/test/functional/mining_basic.py b/test/functional/mining_basic.py index 8d8b02eb56..e88a5a266c 100755 --- a/test/functional/mining_basic.py +++ b/test/functional/mining_basic.py @@ -97,12 +97,13 @@ class MiningTest(BitcoinTestFramework): # Check that default_witness_commitment is present. assert 'default_witness_commitment' in tmpl - witness_commitment = tmpl['default_witness_commitment'] + # witness_commitment = tmpl['default_witness_commitment'] # Check that default_witness_commitment is correct. witness_root = CBlock.get_merkle_root([ser_uint256(0), ser_uint256(txid)]) script = get_witness_script(witness_root, 0) + assert_equal(script.hex(), "6a24aa21a9ed3160175963f85aa4d48b96b0b1c16eb02693d2ee908f73391e78a73747722e72") # ELEMENTS: use `script` to placate linter # ELEMENTS: The following assertion fails because # (1) Elements appears to use a different merkle tree computation than Bitcoin here diff --git a/test/functional/p2p_ibd_txrelay.py b/test/functional/p2p_ibd_txrelay.py index 3b752278cd..4df1d486fa 100755 --- a/test/functional/p2p_ibd_txrelay.py +++ b/test/functional/p2p_ibd_txrelay.py @@ -88,7 +88,7 @@ class P2PIBDTxRelayTest(BitcoinTestFramework): peer_txer = self.nodes[0].add_p2p_connection(P2PInterface()) # ELEMENTS FIXME: # with self.nodes[0].assert_debug_log(expected_msgs=["was not accepted"]): - #peer_txer.send_and_ping(msg_tx(tx)) + # peer_txer.send_and_ping(msg_tx(tx)) if __name__ == '__main__': P2PIBDTxRelayTest().main() diff --git a/test/functional/p2p_invalid_block.py b/test/functional/p2p_invalid_block.py index ac9371a4ae..e0a0a67dc7 100755 --- a/test/functional/p2p_invalid_block.py +++ b/test/functional/p2p_invalid_block.py @@ -21,7 +21,7 @@ from test_framework.blocktools import ( create_coinbase, create_tx_with_script, ) -from test_framework.messages import COIN, CTxOutValue +from test_framework.messages import COIN from test_framework.p2p import P2PDataStore from test_framework.script import OP_TRUE from test_framework.test_framework import BitcoinTestFramework diff --git a/test/functional/rpc_fundrawtransaction.py b/test/functional/rpc_fundrawtransaction.py index ceeaba0b57..1862f665b1 100755 --- a/test/functional/rpc_fundrawtransaction.py +++ b/test/functional/rpc_fundrawtransaction.py @@ -7,7 +7,7 @@ from decimal import Decimal from itertools import product -from math import ceil +# from math import ceil from test_framework.descriptors import descsum_create from test_framework.key import ECKey @@ -1136,10 +1136,10 @@ class RawTransactionsTest(BitcoinTestFramework): funded_tx3 = ext_fund.fundrawtransaction(raw_tx, {"solving_data": {"descriptors": [desc]}, "input_weights": [{"txid": ext_utxo["txid"], "vout": ext_utxo["vout"], "weight": high_input_weight}]}) assert_equal(funded_tx2["fee"], funded_tx3["fee"]) # The feerate should be met - funded_tx4 = ext_fund.fundrawtransaction(raw_tx, {"input_weights": [{"txid": ext_utxo["txid"], "vout": ext_utxo["vout"], "weight": high_input_weight}], "fee_rate": 10}) - input_add_weight = high_input_weight - (41 * 4) - tx4_weight = ext_fund.decoderawtransaction(funded_tx4["hex"])["weight"] + input_add_weight - tx4_vsize = int(ceil(tx4_weight / 4)) + # funded_tx4 = ext_fund.fundrawtransaction(raw_tx, {"input_weights": [{"txid": ext_utxo["txid"], "vout": ext_utxo["vout"], "weight": high_input_weight}], "fee_rate": 10}) + # input_add_weight = high_input_weight - (41 * 4) + # tx4_weight = ext_fund.decoderawtransaction(funded_tx4["hex"])["weight"] + input_add_weight + # tx4_vsize = int(ceil(tx4_weight / 4)) # assert_fee_amount(funded_tx4["fee"], tx4_vsize, Decimal(0.0001)) Fee is different in Elements # Funding with weight at csuint boundaries should not cause problems diff --git a/test/functional/rpc_rawtransaction.py b/test/functional/rpc_rawtransaction.py index 4ca4b1248b..6f584a10a4 100755 --- a/test/functional/rpc_rawtransaction.py +++ b/test/functional/rpc_rawtransaction.py @@ -325,7 +325,6 @@ class RawTransactionsTest(BitcoinTestFramework): self.sync_all() inputs = [{"txid": txId, "vout": vout['n']}] - txout = self.nodes[0].gettxout(txId, vout['n']) # Fee 10,000 satoshis, (1 - (10000 sat * 0.00000001 BTC/sat)) = 0.9999 outputs = [{self.nodes[0].getnewaddress(): Decimal("0.99990000")}, {"fee": 0.0001}] rawTx = self.nodes[2].createrawtransaction(inputs, outputs) diff --git a/test/functional/wallet_send.py b/test/functional/wallet_send.py index 7e28bb9026..d65eb2dc51 100755 --- a/test/functional/wallet_send.py +++ b/test/functional/wallet_send.py @@ -16,7 +16,7 @@ from test_framework.util import ( # assert_fee_amount, assert_greater_than, assert_raises_rpc_error, - count_bytes, + # count_bytes, ) from test_framework.wallet_util import bytes_to_wif