test: refactor: remove hex_str_to_bytes helper

Use the built-in class method bytes.fromhex() instead,
which is available since Python 3.0.
This commit is contained in:
Sebastian Falbesoner
2021-07-31 21:23:16 +02:00
parent f2e41d1109
commit ca6c154ef1
15 changed files with 40 additions and 57 deletions

View File

@@ -28,7 +28,6 @@ from test_framework.p2p import (
from test_framework.test_framework import BitcoinTestFramework
from test_framework.util import (
assert_equal,
hex_str_to_bytes,
)
VALID_DATA_LIMIT = MAX_PROTOCOL_MESSAGE_LENGTH - 5 # Account for the 5-byte length prefix
@@ -187,7 +186,7 @@ class InvalidMessagesTest(BitcoinTestFramework):
[
'received: addrv2 (1 bytes)',
],
hex_str_to_bytes('00'))
bytes.fromhex('00'))
def test_addrv2_too_long_address(self):
self.test_addrv2('too long address',
@@ -196,7 +195,7 @@ class InvalidMessagesTest(BitcoinTestFramework):
'ProcessMessages(addrv2, 525 bytes): Exception',
'Address too long: 513 > 512',
],
hex_str_to_bytes(
bytes.fromhex(
'01' + # number of entries
'61bc6649' + # time, Fri Jan 9 02:54:25 UTC 2009
'00' + # service flags, COMPACTSIZE(NODE_NONE)
@@ -213,7 +212,7 @@ class InvalidMessagesTest(BitcoinTestFramework):
'IP 9.9.9.9 mapped',
'Added 1 addresses',
],
hex_str_to_bytes(
bytes.fromhex(
'02' + # number of entries
# this should be ignored without impeding acceptance of subsequent ones
now_hex + # time