From c080324e08779bfbd7a7d89f7050094d77fe5871 Mon Sep 17 00:00:00 2001 From: protolambda Date: Wed, 19 May 2021 19:07:24 +0200 Subject: [PATCH] set RNG for test case for consistent test outputs --- .../block_processing/test_process_attester_slashing.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tests/core/pyspec/eth2spec/test/phase0/block_processing/test_process_attester_slashing.py b/tests/core/pyspec/eth2spec/test/phase0/block_processing/test_process_attester_slashing.py index 4a2c7d61d..940bc47fb 100644 --- a/tests/core/pyspec/eth2spec/test/phase0/block_processing/test_process_attester_slashing.py +++ b/tests/core/pyspec/eth2spec/test/phase0/block_processing/test_process_attester_slashing.py @@ -1,4 +1,4 @@ -import random +from random import Random from eth2spec.test.context import ( spec_state_test, expect_assertion_error, always_bls, with_all_phases, @@ -152,9 +152,10 @@ def test_success_misc_balances(spec, state): @single_phase def test_success_with_effective_balance_disparity(spec, state): # Jitter balances to be different from effective balances + rng = Random(12345) for i in range(len(state.balances)): pre = int(state.balances[i]) - state.balances[i] += random.randrange(max(pre - 5000, 0), pre + 5000) + state.balances[i] += rng.randrange(max(pre - 5000, 0), pre + 5000) attester_slashing = get_valid_attester_slashing(spec, state, signed_1=True, signed_2=True)