Skip to content

Commit

Permalink
Merge pull request #321 from lidofinance/fix/next-vote-tests
Browse files Browse the repository at this point in the history
Fix tests
  • Loading branch information
iamnp authored Nov 22, 2024
2 parents 80061f9 + b352448 commit c486424
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 7 deletions.
13 changes: 10 additions & 3 deletions tests/acceptance/test_accounting_oracle_negative.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ def test_sender_not_allowed(accounting_oracle: Contract, oracle_version: int, st


def test_submitConsensusReport(accounting_oracle: Contract, hash_consensus: Contract) -> None:
report_if_processing_not_started(accounting_oracle)
last_processing_ref_slot = accounting_oracle.getLastProcessingRefSlot()
far_future = 172191406800

with reverts(
encode_error(
Expand All @@ -68,7 +68,7 @@ def test_submitConsensusReport(accounting_oracle: Contract, hash_consensus: Cont
accounting_oracle.submitConsensusReport(
NON_ZERO_HASH,
last_processing_ref_slot,
far_future,
chain.time(),
{"from": hash_consensus},
)

Expand All @@ -85,12 +85,13 @@ def test_submitConsensusReport(accounting_oracle: Contract, hash_consensus: Cont
accounting_oracle.submitConsensusReport(
ZERO_HASH,
last_processing_ref_slot + 1,
far_future,
chain.time(),
{"from": hash_consensus},
)


def test_discardConsensusReport(accounting_oracle: Contract, hash_consensus: Contract) -> None:
report_if_processing_not_started(accounting_oracle)
last_processing_ref_slot = accounting_oracle.getLastProcessingRefSlot()

with reverts(
Expand Down Expand Up @@ -698,6 +699,12 @@ def wrapped(report: AccountingReport) -> None:
# === Helpers ===


def report_if_processing_not_started(accounting_oracle: Contract) -> None:
(_, _, _, is_processing_started) = accounting_oracle.getConsensusReport()
if not is_processing_started:
oracle_report()


def build_extra_data_item(
index: int,
type_: ItemType,
Expand Down
9 changes: 5 additions & 4 deletions tests/regression/test_validator_exit_bus_happy_path.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ def test_send_validator_to_exit(helpers, web3):
"nodeOperatorId": no_id,
"validatorIndex": unreachable_cl_validator_index,
"validatorPubkey": validator_key,
"timestamp": web3.eth.get_block(web3.eth.block_number).timestamp,
"timestamp": web3.eth.get_block(tx.block_number).timestamp,
},
)

Expand Down Expand Up @@ -192,27 +192,28 @@ def test_send_multiple_validators_to_exit(helpers, web3, stranger):
# Asserts
helpers.assert_single_event_named("ProcessingStarted", tx, {"refSlot": ref_slot, "hash": report_hash_hex})
events = helpers.filter_events_from(tx.receiver, tx.events["ValidatorExitRequest"])
timestamp = web3.eth.get_block(tx.block_number).timestamp
assert len(events) == 3
assert dict(events[0]) == {
"stakingModuleId": first_module_id,
"nodeOperatorId": first_no_id,
"validatorIndex": first_validator_index,
"validatorPubkey": first_validator_key,
"timestamp": web3.eth.get_block(web3.eth.block_number).timestamp,
"timestamp": timestamp,
}
assert dict(events[1]) == {
"stakingModuleId": second_module_id,
"nodeOperatorId": second_no_id,
"validatorIndex": second_validator_index,
"validatorPubkey": second_validator_key,
"timestamp": web3.eth.get_block(web3.eth.block_number).timestamp,
"timestamp": timestamp,
}
assert dict(events[2]) == {
"stakingModuleId": third_module_id,
"nodeOperatorId": third_no_id,
"validatorIndex": third_validator_index,
"validatorPubkey": third_validator_key,
"timestamp": web3.eth.get_block(web3.eth.block_number).timestamp,
"timestamp": timestamp,
}

assert total_requests_after == total_requests_before + 3
Expand Down

0 comments on commit c486424

Please sign in to comment.