diff options
author | Sebastian Falbesoner <sebastian.falbesoner@gmail.com> | 2022-07-19 17:41:16 +0200 |
---|---|---|
committer | Sebastian Falbesoner <sebastian.falbesoner@gmail.com> | 2022-07-19 17:42:35 +0200 |
commit | faf43378e223c563b0741c28a4b5406f471c1332 (patch) | |
tree | e50fcfa9f55e36744914f8679f33f2efe0930431 /test/functional/test_framework/util.py | |
parent | fdc1ca389646a55c4d9cb2a79feaa69f90b18c67 (diff) |
refactor: move helper `random_bytes` to util library
Can be easily reviewed with `--color-moved=dimmed-zebra`.
Diffstat (limited to 'test/functional/test_framework/util.py')
-rw-r--r-- | test/functional/test_framework/util.py | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/test/functional/test_framework/util.py b/test/functional/test_framework/util.py index 58528b7858..fe61ff95f8 100644 --- a/test/functional/test_framework/util.py +++ b/test/functional/test_framework/util.py @@ -12,6 +12,7 @@ import inspect import json import logging import os +import random import re import time import unittest @@ -286,6 +287,13 @@ def sha256sum_file(filename): d = f.read(4096) return h.digest() + +# TODO: Remove and use random.randbytes(n) instead, available in Python 3.9 +def random_bytes(n): + """Return a random bytes object of length n.""" + return bytes(random.getrandbits(8) for i in range(n)) + + # RPC/P2P connection constants and functions ############################################ |