[qa] Use python2/3 syntax
This commit is contained in:
parent
845b31a760
commit
65a6249d41
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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'])
|
||||
|
|
|
@ -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]
|
||||
|
|
|
@ -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)"
|
||||
|
|
|
@ -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()
|
||||
|
|
|
@ -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):
|
||||
|
|
Loading…
Reference in New Issue