mirror of
https://github.com/logos-blockchain/logos-blockchain-e2e-tests.git
synced 2026-01-07 23:53:07 +00:00
fix: reduce fixture repetition
- improve comment
This commit is contained in:
parent
b55fb83e5f
commit
f66a5bd394
@ -42,7 +42,7 @@ def to_app_id(n: int) -> list:
|
|||||||
|
|
||||||
def random_divide_k(n, k):
|
def random_divide_k(n, k):
|
||||||
if n < k:
|
if n < k:
|
||||||
raise ValueError("n must be at least k to split into k parts.")
|
raise ValueError(f"n={n} must be at least k={k} to split into {k} parts")
|
||||||
cuts = sorted(random.sample(range(1, n), k - 1))
|
cuts = sorted(random.sample(range(1, n), k - 1))
|
||||||
parts = [cuts[0]] + [cuts[i] - cuts[i - 1] for i in range(1, len(cuts))] + [n - cuts[-1]]
|
parts = [cuts[0]] + [cuts[i] - cuts[i - 1] for i in range(1, len(cuts))] + [n - cuts[-1]]
|
||||||
return parts
|
return parts
|
||||||
|
|||||||
@ -9,10 +9,10 @@ from src.test_data import DATA_TO_DISPERSE
|
|||||||
logger = get_custom_logger(__name__)
|
logger = get_custom_logger(__name__)
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.usefixtures("setup_2_node_cluster")
|
||||||
class TestSpamProtection(StepsDataAvailability):
|
class TestSpamProtection(StepsDataAvailability):
|
||||||
main_nodes = []
|
main_nodes = []
|
||||||
|
|
||||||
@pytest.mark.usefixtures("setup_2_node_cluster")
|
|
||||||
def test_spam_protection_valid_uploads(self):
|
def test_spam_protection_valid_uploads(self):
|
||||||
num_samples = len(DATA_TO_DISPERSE)
|
num_samples = len(DATA_TO_DISPERSE)
|
||||||
missing_dispersals = num_samples
|
missing_dispersals = num_samples
|
||||||
@ -28,7 +28,6 @@ class TestSpamProtection(StepsDataAvailability):
|
|||||||
|
|
||||||
assert missing_dispersals == 0, f"{missing_dispersals} dispersals were not successful"
|
assert missing_dispersals == 0, f"{missing_dispersals} dispersals were not successful"
|
||||||
|
|
||||||
@pytest.mark.usefixtures("setup_2_node_cluster")
|
|
||||||
def test_spam_protection_single_burst(self):
|
def test_spam_protection_single_burst(self):
|
||||||
rate_limit = 1000
|
rate_limit = 1000
|
||||||
spam_per_burst = rate_limit + 10
|
spam_per_burst = rate_limit + 10
|
||||||
@ -45,7 +44,6 @@ class TestSpamProtection(StepsDataAvailability):
|
|||||||
|
|
||||||
assert successful_dispersals <= rate_limit, "All consecutive dispersals were successful without any constraint"
|
assert successful_dispersals <= rate_limit, "All consecutive dispersals were successful without any constraint"
|
||||||
|
|
||||||
@pytest.mark.usefixtures("setup_2_node_cluster")
|
|
||||||
def test_spam_protection_random_bytes_single_burst(self):
|
def test_spam_protection_random_bytes_single_burst(self):
|
||||||
rate_limit = 1000
|
rate_limit = 1000
|
||||||
spam_per_burst = rate_limit + 10
|
spam_per_burst = rate_limit + 10
|
||||||
@ -66,7 +64,6 @@ class TestSpamProtection(StepsDataAvailability):
|
|||||||
|
|
||||||
assert successful_dispersals <= rate_limit, "All consecutive dispersals were successful without any constraint"
|
assert successful_dispersals <= rate_limit, "All consecutive dispersals were successful without any constraint"
|
||||||
|
|
||||||
@pytest.mark.usefixtures("setup_2_node_cluster")
|
|
||||||
def test_spam_protection_multiple_bursts(self):
|
def test_spam_protection_multiple_bursts(self):
|
||||||
time_interval = 60
|
time_interval = 60
|
||||||
rate_limit = 1000
|
rate_limit = 1000
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user