Skip to content

Commit 3df9f4b

Browse files
committed
Use OS entropy for seeds
1 parent 184aa67 commit 3df9f4b

File tree

1 file changed

+1
-23
lines changed

1 file changed

+1
-23
lines changed

test/integration/helpers.py

Lines changed: 1 addition & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -17,17 +17,14 @@
1717
import platform
1818
import random
1919
import re
20-
import secrets
2120
import shutil
2221
import string
2322
import subprocess
2423
import sys
2524
import threading
26-
import time
2725
import warnings
2826
from dataclasses import dataclass
2927
from datetime import datetime, timedelta
30-
from hashlib import sha256
3128
from os import environ, linesep
3229
from pathlib import Path
3330
from tempfile import mkdtemp, mktemp
@@ -72,26 +69,7 @@
7269
NODE_DESCRIPTION = f'{platform.node()}: {platform.platform()} {platform.python_version()}'
7370

7471

75-
def get_seed() -> str:
76-
"""
77-
Get seed for random number generator.
78-
79-
The `WORKFLOW_ID` variable has to be set in the CI to uniquely identify
80-
the current workflow (including the attempt)
81-
"""
82-
seed = ''.join(
83-
(
84-
secrets.token_hex(),
85-
str(time.time_ns()),
86-
os.getenv('WORKFLOW_ID', ''),
87-
NODE_DESCRIPTION,
88-
os.getenv('PYTEST_XDIST_WORKER', 'gw0'),
89-
)
90-
)
91-
return sha256(seed.encode()).hexdigest()[:32] # 32 is the default entropy in python secrets module - 256 bits
92-
93-
94-
RNG_SEED = get_seed()
72+
RNG_SEED = os.urandom(32).hex()
9573
RNG = random.Random(RNG_SEED)
9674
RNG_COUNTER = 0
9775

0 commit comments

Comments
 (0)