mirror of
https://github.com/ethereum/consensus-specs.git
synced 2026-02-02 01:25:16 -05:00
set RNG for test case for consistent test outputs
This commit is contained in:
@@ -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)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user