Merge bitcoin/bitcoin#28727: test: replace random_bytes with random.randbytes

fe3ac3700d test: replace random_bytes with randbytes #28720 (ns-xvrn)

Pull request description:

  With Python upgraded to 3.9 replaced the `random_bytes` function in util of functional tests and replaced it's usage with `random.randbytes`.

  Closes #28720.

ACKs for top commit:
  maflcko:
    lgtm ACK fe3ac3700d
  BrandonOdiwuor:
    ACK fe3ac3700d
  stickies-v:
    ACK fe3ac3700d, thanks for picking this up
  kristapsk:
    utACK fe3ac3700d

Tree-SHA512: f65a75e73ebd840c2936eb133d42bccd552f25b717c8ca25c18d06e0593e12f292389cfcc0a0b0759004b67a46ea0c8ac237973ef90f246139778230be1e64e1
This commit is contained in:
fanquake
2023-10-29 10:11:24 +01:00
5 changed files with 35 additions and 44 deletions

View File

@ -6,6 +6,7 @@
"""
from decimal import Decimal
from itertools import product
from random import randbytes
from test_framework.descriptors import descsum_create
from test_framework.key import H_POINT
@ -39,7 +40,6 @@ from test_framework.util import (
assert_greater_than_or_equal,
assert_raises_rpc_error,
find_vout_for_address,
random_bytes,
)
from test_framework.wallet_util import (
generate_keypair,
@ -885,10 +885,10 @@ class PSBTTest(BitcoinTestFramework):
self.log.info("Test decoding PSBT with per-input preimage types")
# note that the decodepsbt RPC doesn't check whether preimages and hashes match
hash_ripemd160, preimage_ripemd160 = random_bytes(20), random_bytes(50)
hash_sha256, preimage_sha256 = random_bytes(32), random_bytes(50)
hash_hash160, preimage_hash160 = random_bytes(20), random_bytes(50)
hash_hash256, preimage_hash256 = random_bytes(32), random_bytes(50)
hash_ripemd160, preimage_ripemd160 = randbytes(20), randbytes(50)
hash_sha256, preimage_sha256 = randbytes(32), randbytes(50)
hash_hash160, preimage_hash160 = randbytes(20), randbytes(50)
hash_hash256, preimage_hash256 = randbytes(32), randbytes(50)
tx = CTransaction()
tx.vin = [CTxIn(outpoint=COutPoint(hash=int('aa' * 32, 16), n=0), scriptSig=b""),