diff --git a/qa/pull-tester/rpc-tests.py b/qa/pull-tester/rpc-tests.py index d78ffefdd..07ebf587b 100755 --- a/qa/pull-tester/rpc-tests.py +++ b/qa/pull-tester/rpc-tests.py @@ -32,13 +32,13 @@ import re from tests_config import * #If imported values are not defined then set to zero (or disabled) -if not vars().has_key('ENABLE_WALLET'): +if 'ENABLE_WALLET' not in vars(): ENABLE_WALLET=0 -if not vars().has_key('ENABLE_BITCOIND'): +if 'ENABLE_BITCOIND' not in vars(): ENABLE_BITCOIND=0 -if not vars().has_key('ENABLE_UTILS'): +if 'ENABLE_UTILS' not in vars(): ENABLE_UTILS=0 -if not vars().has_key('ENABLE_ZMQ'): +if 'ENABLE_ZMQ' not in vars(): ENABLE_ZMQ=0 # python-zmq may not be installed. Handle this gracefully and with some helpful info diff --git a/qa/rpc-tests/bipdersig-p2p.py b/qa/rpc-tests/bipdersig-p2p.py index b25872982..cca3aefd1 100755 --- a/qa/rpc-tests/bipdersig-p2p.py +++ b/qa/rpc-tests/bipdersig-p2p.py @@ -11,7 +11,7 @@ from test_framework.blocktools import create_coinbase, create_block from test_framework.comptool import TestInstance, TestManager from test_framework.script import CScript from binascii import unhexlify -import io +from io import BytesIO ''' @@ -47,7 +47,7 @@ class BIP66Test(ComparisonTestFramework): rawtx = node.createrawtransaction(inputs, outputs) signresult = node.signrawtransaction(rawtx) tx = CTransaction() - f = io.BytesIO(unhexlify(signresult['hex'])) + f = BytesIO(unhexlify(signresult['hex'])) tx.deserialize(f) return tx diff --git a/qa/rpc-tests/fundrawtransaction.py b/qa/rpc-tests/fundrawtransaction.py index 4445d0ed7..938cb0041 100755 --- a/qa/rpc-tests/fundrawtransaction.py +++ b/qa/rpc-tests/fundrawtransaction.py @@ -210,7 +210,7 @@ class RawTransactionsTest(BitcoinTestFramework): matchingOuts = 0 for i, out in enumerate(dec_tx['vout']): totalOut += out['value'] - if out['scriptPubKey']['addresses'][0] in outputs : + if out['scriptPubKey']['addresses'][0] in outputs: matchingOuts+=1 else: assert_equal(i, rawtxfund['changepos']) diff --git a/qa/rpc-tests/rest.py b/qa/rpc-tests/rest.py index acc5d943f..f09eda0b9 100755 --- a/qa/rpc-tests/rest.py +++ b/qa/rpc-tests/rest.py @@ -14,7 +14,7 @@ from test_framework.util import assert_equal, assert_greater_than, \ import struct import binascii import json -import io +from io import BytesIO from codecs import encode from decimal import Decimal @@ -145,7 +145,7 @@ class RESTTest (BitcoinTestFramework): binaryRequest += struct.pack("i", 0); bin_response = http_post_call(url.hostname, url.port, '/rest/getutxos'+self.FORMAT_SEPARATOR+'bin', binaryRequest) - output = io.BytesIO() + output = BytesIO() output.write(bin_response) output.seek(0) chainHeight = struct.unpack("i", output.read(4))[0] diff --git a/qa/rpc-tests/smartfees.py b/qa/rpc-tests/smartfees.py index 8caab8808..3f632696d 100755 --- a/qa/rpc-tests/smartfees.py +++ b/qa/rpc-tests/smartfees.py @@ -112,7 +112,7 @@ def check_estimates(node, fees_seen, max_invalid, print_estimates = True): print([str(all_estimates[e-1]) for e in [1,2,3,6,15,25]]) delta = 1.0e-6 # account for rounding error last_e = max(fees_seen) - for e in filter(lambda x: x >= 0, all_estimates): + for e in [x for x in all_estimates if x >= 0]: # Estimates should be within the bounds of what transactions fees actually were: if float(e)+delta < min(fees_seen) or float(e)-delta > max(fees_seen): raise AssertionError("Estimated fee (%f) out of range (%f,%f)" diff --git a/qa/rpc-tests/test_framework/blockstore.py b/qa/rpc-tests/test_framework/blockstore.py index 1288521e9..7e8dd2a5a 100644 --- a/qa/rpc-tests/test_framework/blockstore.py +++ b/qa/rpc-tests/test_framework/blockstore.py @@ -6,7 +6,7 @@ from .mininode import CBlock, CBlockHeader, CBlockLocator, CTransaction, msg_block, msg_headers, msg_tx import sys -import io +from io import BytesIO import dbm.dumb as dbm class BlockStore(): @@ -24,7 +24,7 @@ class BlockStore(): serialized_block = self.blockDB[repr(blockhash)] except KeyError: return None - f = io.BytesIO(serialized_block) + f = BytesIO(serialized_block) ret = CBlock() ret.deserialize(f) ret.calc_sha256() @@ -118,7 +118,7 @@ class TxStore(object): serialized_tx = self.txDB[repr(txhash)] except KeyError: return None - f = io.BytesIO(serialized_tx) + f = BytesIO(serialized_tx) ret = CTransaction() ret.deserialize(f) ret.calc_sha256() diff --git a/qa/rpc-tests/test_framework/mininode.py b/qa/rpc-tests/test_framework/mininode.py index 04a7ef773..36f31e431 100755 --- a/qa/rpc-tests/test_framework/mininode.py +++ b/qa/rpc-tests/test_framework/mininode.py @@ -757,9 +757,8 @@ class CTransaction(object): self.calc_sha256() def calc_sha256(self): - serialized = self.serialize() if self.sha256 is None: - self.sha256 = uint256_from_str(hash256(serialized)) + self.sha256 = uint256_from_str(hash256(self.serialize())) self.hash = hash256(self.serialize())[::-1].hex() def is_valid(self):