Skip to content

Commit

Permalink
fix: tests
Browse files Browse the repository at this point in the history
  • Loading branch information
vgorkavenko committed Jan 22, 2025
1 parent 2a96e6c commit 6881dec
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 4 deletions.
15 changes: 11 additions & 4 deletions tests/modules/accounting/bunker/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,22 @@ def simple_key(pubkey: str) -> LidoKey:


def simple_validator(
index, pubkey, balance, slashed=False, withdrawable_epoch='', exit_epoch='100500', activation_epoch="0"
index,
pubkey,
balance,
slashed=False,
withdrawable_epoch='',
exit_epoch='100500',
activation_epoch="0",
effective_balance=str(32 * 10**9),
) -> Validator:
return Validator(
index=str(index),
balance=str(balance),
validator=ValidatorState(
pubkey=pubkey,
withdrawal_credentials='',
effective_balance=str(balance),
effective_balance=effective_balance,
slashed=slashed,
activation_eligibility_epoch='',
activation_epoch=activation_epoch,
Expand Down Expand Up @@ -203,11 +210,11 @@ def _get_validators(state: ReferenceBlockStamp, _=None):
simple_validator(5, '0x05', (32 * 10**9) + 824112),
],
50: [
simple_validator(4, '0x00', balance=0, activation_epoch=FAR_FUTURE_EPOCH),
simple_validator(4, '0x00', balance=0, effective_balance=0, activation_epoch=FAR_FUTURE_EPOCH),
simple_validator(1, '0x01', 32 * 10**9),
simple_validator(2, '0x02', 32 * 10**9),
simple_validator(3, '0x03', (32 * 10**9) + 333333),
simple_validator(4, '0x04', balance=0, activation_epoch=FAR_FUTURE_EPOCH),
simple_validator(4, '0x04', balance=0, effective_balance=0, activation_epoch=FAR_FUTURE_EPOCH),
simple_validator(5, '0x05', (32 * 10**9) + 824112),
],
1000: [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ def test_is_abnormal_cl_rebase(
rebase_check_nearest_epoch_distance=nearest_epoch_distance,
rebase_check_distant_epoch_distance=far_epoch_distance,
)
abnormal_case.w3.lido_contracts.accounting_oracle.get_consensus_version = Mock(return_value=2)
result = abnormal_case.is_abnormal_cl_rebase(blockstamp, all_validators, lido_validators, frame_cl_rebase)

assert result == expected_is_abnormal
Expand Down Expand Up @@ -112,6 +113,7 @@ def test_calculate_lido_normal_cl_rebase(
abnormal_case.lido_validators = abnormal_case.w3.cc.get_validators(blockstamp)[3:6]
abnormal_case.lido_keys = abnormal_case.w3.kac.get_used_lido_keys(blockstamp)

abnormal_case.w3.lido_contracts.accounting_oracle.get_consensus_version = Mock(return_value=2)
result = abnormal_case._calculate_lido_normal_cl_rebase(blockstamp)

assert result == expected_rebase
Expand Down Expand Up @@ -161,6 +163,7 @@ def test_is_negative_specific_cl_rebase(
rebase_check_nearest_epoch_distance=nearest_epoch_distance,
rebase_check_distant_epoch_distance=far_epoch_distance,
)
abnormal_case.w3.lido_contracts.accounting_oracle.get_consensus_version = Mock(return_value=2)
if isinstance(expected_is_negative, str):
with pytest.raises(ValueError, match=expected_is_negative):
abnormal_case._is_negative_specific_cl_rebase(blockstamp)
Expand Down Expand Up @@ -225,6 +228,7 @@ def test_calculate_cl_rebase_between_blocks(
simple_key('0x04'),
simple_key('0x05'),
]
abnormal_case.w3.lido_contracts.accounting_oracle.get_consensus_version = Mock(return_value=2)
if isinstance(expected_rebase, str):
with pytest.raises(ValueError, match=expected_rebase):
abnormal_case._calculate_cl_rebase_between_blocks(prev_blockstamp, blockstamp)
Expand Down
1 change: 1 addition & 0 deletions tests/modules/accounting/test_accounting_module.py
Original file line number Diff line number Diff line change
Expand Up @@ -452,6 +452,7 @@ def test_simulate_rebase_after_report(
accounting._get_consensus_lido_state_pre_electra = Mock(return_value=(0, 0))
accounting._get_slots_elapsed_from_last_report = Mock(return_value=42)

accounting.w3.lido_contracts.accounting_oracle.get_consensus_version = Mock(return_value=2)
accounting.w3.lido_contracts.lido.handle_oracle_report = Mock(return_value=LidoReportRebaseFactory.build()) # type: ignore

out = accounting.simulate_rebase_after_report(ref_bs, Wei(0))
Expand Down

0 comments on commit 6881dec

Please sign in to comment.