aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xtest/functional/p2p_invalid_messages.py3
-rw-r--r--test/functional/test_framework/script.py4
-rwxr-xr-xtest/functional/wallet_balance.py5
3 files changed, 5 insertions, 7 deletions
diff --git a/test/functional/p2p_invalid_messages.py b/test/functional/p2p_invalid_messages.py
index 40a69936bc..adcbb4fd05 100755
--- a/test/functional/p2p_invalid_messages.py
+++ b/test/functional/p2p_invalid_messages.py
@@ -5,7 +5,6 @@
"""Test node responses to invalid network messages."""
import random
-import struct
import time
from test_framework.messages import (
@@ -233,7 +232,7 @@ class InvalidMessagesTest(BitcoinTestFramework):
'208d')) # port
def test_addrv2_unrecognized_network(self):
- now_hex = struct.pack('<I', int(time.time())).hex()
+ now_hex = int(time.time()).to_bytes(4, "little").hex()
self.test_addrv2('unrecognized network',
[
'received: addrv2 (25 bytes)',
diff --git a/test/functional/test_framework/script.py b/test/functional/test_framework/script.py
index ee3c3a0efd..5d6f65b83d 100644
--- a/test/functional/test_framework/script.py
+++ b/test/functional/test_framework/script.py
@@ -800,13 +800,13 @@ def BIP341_sha_prevouts(txTo):
return sha256(b"".join(i.prevout.serialize() for i in txTo.vin))
def BIP341_sha_amounts(spent_utxos):
- return sha256(b"".join(struct.pack("<q", u.nValue) for u in spent_utxos))
+ return sha256(b"".join(u.nValue.to_bytes(8, "little", signed=True) for u in spent_utxos))
def BIP341_sha_scriptpubkeys(spent_utxos):
return sha256(b"".join(ser_string(u.scriptPubKey) for u in spent_utxos))
def BIP341_sha_sequences(txTo):
- return sha256(b"".join(struct.pack("<I", i.nSequence) for i in txTo.vin))
+ return sha256(b"".join(i.nSequence.to_bytes(4, "little") for i in txTo.vin))
def BIP341_sha_outputs(txTo):
return sha256(b"".join(o.serialize() for o in txTo.vout))
diff --git a/test/functional/wallet_balance.py b/test/functional/wallet_balance.py
index c322ae52c1..2c85773bf3 100755
--- a/test/functional/wallet_balance.py
+++ b/test/functional/wallet_balance.py
@@ -4,7 +4,6 @@
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
"""Test the wallet balance RPC methods."""
from decimal import Decimal
-import struct
from test_framework.address import ADDRESS_BCRT1_UNSPENDABLE as ADDRESS_WATCHONLY
from test_framework.blocktools import COINBASE_MATURITY
@@ -266,8 +265,8 @@ class WalletTest(BitcoinTestFramework):
tx_orig = self.nodes[0].gettransaction(txid)['hex']
# Increase fee by 1 coin
tx_replace = tx_orig.replace(
- struct.pack("<q", 99 * 10**8).hex(),
- struct.pack("<q", 98 * 10**8).hex(),
+ (99 * 10**8).to_bytes(8, "little", signed=True).hex(),
+ (98 * 10**8).to_bytes(8, "little", signed=True).hex(),
)
tx_replace = self.nodes[0].signrawtransactionwithwallet(tx_replace)['hex']
# Total balance is given by the sum of outputs of the tx