diff options
author | Sebastian Falbesoner <sebastian.falbesoner@gmail.com> | 2023-04-01 14:10:01 +0200 |
---|---|---|
committer | Sebastian Falbesoner <sebastian.falbesoner@gmail.com> | 2023-04-01 14:15:17 +0200 |
commit | f842ed9a40c0db656b86f85e84dd4978865cc0a0 (patch) | |
tree | 2b0f7ea480ae7d9af0db9649fb77bde4d57381c3 /test/functional/interface_zmq.py | |
parent | a0d37d1d230b837ebb0ec8f609885ab89280936c (diff) | |
download | bitcoin-f842ed9a40c0db656b86f85e84dd4978865cc0a0.tar.xz |
test: refactor: replace unnecessary `BytesIO` uses
Rather than needing to create intermediate stream variables, we can use
helper functions like `tx_from_hex` instead or access the result
directly, leading both to increased readability and less code.
Diffstat (limited to 'test/functional/interface_zmq.py')
-rwxr-xr-x | test/functional/interface_zmq.py | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/test/functional/interface_zmq.py b/test/functional/interface_zmq.py index 2f41f9aa53..2358dd4387 100755 --- a/test/functional/interface_zmq.py +++ b/test/functional/interface_zmq.py @@ -4,6 +4,7 @@ # file COPYING or http://www.opensource.org/licenses/mit-license.php. """Test the ZMQ notification interface.""" import struct +from time import sleep from test_framework.address import ( ADDRESS_BCRT1_P2WSH_OP_TRUE, @@ -16,8 +17,8 @@ from test_framework.blocktools import ( ) from test_framework.test_framework import BitcoinTestFramework from test_framework.messages import ( - CTransaction, hash256, + tx_from_hex, ) from test_framework.util import ( assert_equal, @@ -28,8 +29,7 @@ from test_framework.wallet import ( MiniWallet, ) from test_framework.netutil import test_ipv6_local -from io import BytesIO -from time import sleep + # Test may be skipped and not have zmq installed try: @@ -198,9 +198,7 @@ class ZMQTest (BitcoinTestFramework): txid = hashtx.receive() # Should receive the coinbase raw transaction. - hex = rawtx.receive() - tx = CTransaction() - tx.deserialize(BytesIO(hex)) + tx = tx_from_hex(rawtx.receive().hex()) tx.calc_sha256() assert_equal(tx.hash, txid.hex()) |