Skip to content

Commit

Permalink
fix: withdrawal test
Browse files Browse the repository at this point in the history
  • Loading branch information
krogla committed Feb 2, 2024
1 parent 4c509c9 commit c5b0303
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
10 changes: 6 additions & 4 deletions tests/regression/test_all_round_happy_path.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ def test_all_round_happy_path(accounts, stranger, steth_holder, eth_whale):
# stake new ether to increase buffer
contracts.lido.submit(ZERO_ADDRESS, {"from": eth_whale.address, "value": ETH(10000)})

# get accidentally unaccounted stETH shares on WQ contract
uncounted_steth_shares = contracts.lido.sharesOf(contracts.withdrawal_queue)

contracts.lido.approve(contracts.withdrawal_queue.address, 1000, {"from": steth_holder})
contracts.withdrawal_queue.requestWithdrawals([1000], steth_holder, {"from": steth_holder})

Expand Down Expand Up @@ -98,9 +101,11 @@ def test_all_round_happy_path(accounts, stranger, steth_holder, eth_whale):
buffered_ether_after_deposit = contracts.lido.getBufferedEther()

unbuffered_event_nor = deposit_tx_nor.events["Unbuffered"]
deposit_validators_changed_event_nor = deposit_tx_nor.events["DepositedValidatorsChanged"]
# deposit_validators_changed_event_nor = deposit_tx_nor.events["DepositedValidatorsChanged"]

unbuffered_event_sdvt = deposit_tx_sdvt.events["Unbuffered"]

# we need just last one event
deposit_validators_changed_event_sdvt = deposit_tx_sdvt.events["DepositedValidatorsChanged"]

deposits_count = math.floor(unbuffered_event_nor["amount"] / ETH(32)) + math.floor(
Expand Down Expand Up @@ -228,9 +233,6 @@ def test_all_round_happy_path(accounts, stranger, steth_holder, eth_whale):

last_request_id_before = contracts.withdrawal_queue.getLastRequestId()

# get accidentally unaccounted stETH shares on WQ contract
uncounted_steth_shares = contracts.lido.sharesOf(contracts.withdrawal_queue)

withdrawal_request_tx = contracts.withdrawal_queue.requestWithdrawals(
[amount_with_rewards], stranger, {"from": stranger}
)
Expand Down
5 changes: 4 additions & 1 deletion tests/regression/test_withdrawal_happy_path.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ def test_withdraw(steth_holder, eth_whale):
# stake new ether to increase buffer
contracts.lido.submit(ZERO_ADDRESS, {"from": eth_whale.address, "value": ETH(10000)})

# get accidentally unaccounted stETH shares on WQ contract
uncounted_steth_shares = contracts.lido.sharesOf(contracts.withdrawal_queue)

""" pre request """
no_requests = contracts.withdrawal_queue.getWithdrawalRequests(steth_holder, {"from": steth_holder})
assert len(no_requests) == 0
Expand All @@ -43,7 +46,7 @@ def test_withdraw(steth_holder, eth_whale):
)
steth_balance_after = steth_balance(steth_holder)

shares_to_burn = contracts.lido.sharesOf(contracts.withdrawal_queue)
shares_to_burn = contracts.lido.sharesOf(contracts.withdrawal_queue) - uncounted_steth_shares
# post request checks

assert almostEqWithDiff(steth_balance_before - steth_balance_after, REQUESTS_SUM, 2 * REQUESTS_COUNT)
Expand Down

0 comments on commit c5b0303

Please sign in to comment.