mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-11-26 05:48:20 +01:00
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:
@@ -152,7 +152,7 @@ class RESTTest (BitcoinTestFramework):
|
||||
bin_response = self.test_rest_request("/getutxos", http_method='POST', req_type=ReqType.BIN, body=bin_request, ret_type=RetType.BYTES)
|
||||
output = BytesIO(bin_response)
|
||||
chain_height, = unpack("i", output.read(4))
|
||||
response_hash = binascii.hexlify(output.read(32)[::-1]).decode('ascii')
|
||||
response_hash = output.read(32)[::-1].hex()
|
||||
|
||||
assert_equal(bb_hash, response_hash) # check if getutxo's chaintip during calculation was fine
|
||||
assert_equal(chain_height, 102) # chain height must be 102
|
||||
@@ -252,7 +252,7 @@ class RESTTest (BitcoinTestFramework):
|
||||
resp_hex = self.test_rest_request("/blockhashbyheight/{}".format(block_json_obj['height']), req_type=ReqType.HEX, ret_type=RetType.OBJ)
|
||||
assert_equal(resp_hex.read().decode('utf-8').rstrip(), bb_hash)
|
||||
resp_bytes = self.test_rest_request("/blockhashbyheight/{}".format(block_json_obj['height']), req_type=ReqType.BIN, ret_type=RetType.BYTES)
|
||||
blockhash = binascii.hexlify(resp_bytes[::-1]).decode('utf-8')
|
||||
blockhash = resp_bytes[::-1].hex()
|
||||
assert_equal(blockhash, bb_hash)
|
||||
|
||||
# Check invalid blockhashbyheight requests
|
||||
|
||||
Reference in New Issue
Block a user