Skip to content

Commit

Permalink
test: add test for _mock_balance_check
Browse files Browse the repository at this point in the history
  • Loading branch information
Adamantios authored and cyberosa committed Jun 24, 2024
1 parent 4e817ec commit a27eb32
Showing 1 changed file with 16 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,22 @@ def test_collateral_amount_info(self, amount: int, benchmarking_mode_enabled: bo
else:
assert result == f"{amount} WEI of the collateral token with address {collateral_token}"

@given(st.integers(), st.integers())
def test_mock_balance_check(self, collateral_balance: int, native_balance: int) -> None:
"""Test the `_mock_balance_check` method."""
# use `BlacklistingBehaviour` because it overrides the `DecisionMakerBaseBehaviour`.
self.ffw(BlacklistingBehaviour)
behaviour = cast(BlacklistingBehaviour, self.behaviour.current_behaviour)
assert behaviour.behaviour_id == BlacklistingBehaviour.auto_behaviour_id()

behaviour.benchmarking_mode.collateral_balance = collateral_balance
behaviour.benchmarking_mode.native_balance = native_balance
with mock.patch.object(behaviour, "_report_balance") as mock_report_balance:
behaviour._mock_balance_check()
mock_report_balance.assert_called_once()
assert behaviour.token_balance == collateral_balance
assert behaviour.wallet_balance == native_balance

@pytest.mark.parametrize(
"mocked_result, expected_result",
(
Expand Down

0 comments on commit a27eb32

Please sign in to comment.