scripted-diff: test: Use py3.5 bytes::hex() method
-BEGIN VERIFY SCRIPT- sed -i -e "s/def bytes_to_hex_str/def b_2_x/g" $(git grep -l bytes_to_hex_str) export RE_B_0="[^()]*" # match no bracket export RE_B_1="${RE_B_0}\(${RE_B_0}\)${RE_B_0}" # match exactly one () export RE_B_2="${RE_B_0}\(${RE_B_1}\)${RE_B_0}" # match wrapped (()) export RE_M="(b2x|bytes_to_hex_str)\(((${RE_B_0}|${RE_B_1}|${RE_B_2})*)\)" sed -i --regexp-extended -e "s/${RE_M}/\2.hex()/g" $(git grep -l -E '(b2x|bytes_to_hex_str)') sed -i --regexp-extended -e "/ +bytes_to_hex_str( as b2x)?,/d" $(git grep -l bytes_to_hex_str) sed -i --regexp-extended -e "s/ +bytes_to_hex_str( as b2x)?,//g" $(git grep -l bytes_to_hex_str) sed -i --regexp-extended -e "s/, bytes_to_hex_str( as b2x)?//g" $(git grep -l bytes_to_hex_str) export RE_M="(binascii\.)?hexlify\(((${RE_B_0}|${RE_B_1}|${RE_B_2})*)\).decode\(${RE_B_0}\)" sed -i --regexp-extended -e "s/${RE_M}/\2.hex()/g" $(git grep -l hexlify -- ':(exclude)share') sed -i --regexp-extended -e "/from binascii import hexlify$/d" $(git grep -l hexlify -- ':(exclude)share') sed -i --regexp-extended -e "s/(from binascii import) .*hexlify/\1 unhexlify/g" $(git grep -l hexlify -- ':(exclude)share') sed -i -e 's/ignore-names "/ignore-names "b_2_x,/g' ./test/lint/lint-python-dead-code.sh -END VERIFY SCRIPT-
This commit is contained in:
parent
9e3122de05
commit
fa6bf21f5e
26 changed files with 134 additions and 146 deletions
test/functional/test_framework
|
@ -28,7 +28,7 @@ import struct
|
|||
import time
|
||||
|
||||
from test_framework.siphash import siphash256
|
||||
from test_framework.util import hex_str_to_bytes, bytes_to_hex_str, assert_equal
|
||||
from test_framework.util import hex_str_to_bytes, assert_equal
|
||||
|
||||
MIN_VERSION_SUPPORTED = 60001
|
||||
MY_VERSION = 70014 # past bip-31 for ping/pong
|
||||
|
@ -181,7 +181,7 @@ def FromHex(obj, hex_string):
|
|||
|
||||
# Convert a binary-serializable object to hex (eg for submission via RPC)
|
||||
def ToHex(obj):
|
||||
return bytes_to_hex_str(obj.serialize())
|
||||
return obj.serialize().hex()
|
||||
|
||||
# Objects that map to bitcoind objects, which can be serialized/deserialized
|
||||
|
||||
|
@ -319,7 +319,7 @@ class CTxIn:
|
|||
|
||||
def __repr__(self):
|
||||
return "CTxIn(prevout=%s scriptSig=%s nSequence=%i)" \
|
||||
% (repr(self.prevout), bytes_to_hex_str(self.scriptSig),
|
||||
% (repr(self.prevout), self.scriptSig.hex(),
|
||||
self.nSequence)
|
||||
|
||||
|
||||
|
@ -343,7 +343,7 @@ class CTxOut:
|
|||
def __repr__(self):
|
||||
return "CTxOut(nValue=%i.%08i scriptPubKey=%s)" \
|
||||
% (self.nValue // COIN, self.nValue % COIN,
|
||||
bytes_to_hex_str(self.scriptPubKey))
|
||||
self.scriptPubKey.hex())
|
||||
|
||||
|
||||
class CScriptWitness:
|
||||
|
@ -355,7 +355,7 @@ class CScriptWitness:
|
|||
|
||||
def __repr__(self):
|
||||
return "CScriptWitness(%s)" % \
|
||||
(",".join([bytes_to_hex_str(x) for x in self.stack]))
|
||||
(",".join([x.hex() for x in self.stack]))
|
||||
|
||||
def is_null(self):
|
||||
if self.stack:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue