mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-05-02 09:48:51 +02: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:
@@ -10,7 +10,6 @@ from test_framework.test_framework import BitcoinTestFramework
|
||||
from test_framework.messages import CTransaction
|
||||
from test_framework.util import (
|
||||
assert_equal,
|
||||
bytes_to_hex_str,
|
||||
hash256,
|
||||
)
|
||||
from io import BytesIO
|
||||
@@ -94,17 +93,17 @@ class ZMQTest (BitcoinTestFramework):
|
||||
tx = CTransaction()
|
||||
tx.deserialize(BytesIO(hex))
|
||||
tx.calc_sha256()
|
||||
assert_equal(tx.hash, bytes_to_hex_str(txid))
|
||||
assert_equal(tx.hash, txid.hex())
|
||||
|
||||
# Should receive the generated block hash.
|
||||
hash = bytes_to_hex_str(self.hashblock.receive())
|
||||
hash = self.hashblock.receive().hex()
|
||||
assert_equal(genhashes[x], hash)
|
||||
# The block should only have the coinbase txid.
|
||||
assert_equal([bytes_to_hex_str(txid)], self.nodes[1].getblock(hash)["tx"])
|
||||
assert_equal([txid.hex()], self.nodes[1].getblock(hash)["tx"])
|
||||
|
||||
# Should receive the generated raw block.
|
||||
block = self.rawblock.receive()
|
||||
assert_equal(genhashes[x], bytes_to_hex_str(hash256(block[:80])))
|
||||
assert_equal(genhashes[x], hash256(block[:80]).hex())
|
||||
|
||||
if self.is_wallet_compiled():
|
||||
self.log.info("Wait for tx from second node")
|
||||
@@ -113,11 +112,11 @@ class ZMQTest (BitcoinTestFramework):
|
||||
|
||||
# Should receive the broadcasted txid.
|
||||
txid = self.hashtx.receive()
|
||||
assert_equal(payment_txid, bytes_to_hex_str(txid))
|
||||
assert_equal(payment_txid, txid.hex())
|
||||
|
||||
# Should receive the broadcasted raw transaction.
|
||||
hex = self.rawtx.receive()
|
||||
assert_equal(payment_txid, bytes_to_hex_str(hash256(hex)))
|
||||
assert_equal(payment_txid, hash256(hex).hex())
|
||||
|
||||
|
||||
self.log.info("Test the getzmqnotifications RPC")
|
||||
|
||||
Reference in New Issue
Block a user