Skip to content

Commit da90a5b

Browse files
committed
fix: clean up e2e tests implementation
Use a less hard to reason about PRNG randomness source
1 parent fd370b3 commit da90a5b

1 file changed

Lines changed: 6 additions & 12 deletions

File tree

‎tests/rtc/test_e2e_data_streams.py‎

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,11 @@
1717

1818
import asyncio
1919
import os
20+
import random
21+
import string
2022
import time
2123
import uuid
22-
from typing import Any, List, Optional, Tuple
24+
from typing import Any, Optional, Tuple
2325

2426
import pytest
2527

@@ -49,22 +51,14 @@ def unique_room_name(base: str) -> str:
4951

5052

5153
def pseudo_random_text(length: int, seed: int = 0x5EED) -> str:
52-
"""Deterministic pseudo-random lowercase text (mulberry32 PRNG).
54+
"""Deterministic pseudo-random lowercase text.
5355
5456
Random lowercase carries ~4.7 bits of entropy per 8-bit byte, so deflate
5557
compresses it well under its raw size — exercising the chunked-compressed
5658
wire path.
5759
"""
58-
a = seed & 0xFFFFFFFF
59-
chars: List[str] = []
60-
for _ in range(length):
61-
a = (a + 0x6D2B79F5) & 0xFFFFFFFF
62-
t = a
63-
t = (t ^ (t >> 15)) * (t | 1) & 0xFFFFFFFF
64-
t = (t + ((t ^ (t >> 7)) * (t | 61) & 0xFFFFFFFF)) & 0xFFFFFFFF
65-
t = t ^ (t >> 14)
66-
chars.append(chr(97 + t % 26))
67-
return "".join(chars)
60+
rng = random.Random(seed)
61+
return "".join(rng.choices(string.ascii_lowercase, k=length))
6862

6963

7064
async def connect_rooms(

0 commit comments

Comments
 (0)