set RNG for test case for consistent test outputs

This commit is contained in:
protolambda 2021-05-19 19:07:24 +02:00
parent 76cc964a37
commit c080324e08
No known key found for this signature in database
GPG Key ID: EC89FDBB2B4C7623

View File

@ -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)