Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(test): brownie bug no longer breaks tests #290

Merged
merged 1 commit into from
Nov 18, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 10 additions & 14 deletions tests/test_dank_mids.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,20 +29,13 @@
]


def _get_controller():
brownie_version = tuple(int(x) for x in importlib.metadata.version("eth-brownie").split("."))
if brownie_version >= (1, 20):
# Not sure why but 1.20 creates 2 instances
return instances[chain.id][1]
return instances[chain.id][0]


@pytest.mark.asyncio_cooperative
async def test_dank_middleware():
await asyncio.gather(*BIG_WORK)
cid = _get_controller().call_uid.latest
mid = _get_controller().multicall_uid.latest
rid = _get_controller().request_uid.latest
controller = instances[chain.id][0]
cid = controller.call_uid.latest
mid = controller.multicall_uid.latest
rid = controller.request_uid.latest
assert cid, "The DankMiddlewareController did not process any calls."
if sys.version_info < (3, 10):
# Not sure why this assert fails above 3.10
Expand Down Expand Up @@ -92,7 +85,8 @@ def test_next_cid():
This test ensures that the call ID generator correctly increments
and provides unique IDs for each call.
"""
assert _get_controller().call_uid.next + 1 == _get_controller().call_uid.next
controller = instances[chain.id][0]
assert controller.call_uid.next + 1 == controller.call_uid.next


def test_next_mid():
Expand All @@ -102,7 +96,8 @@ def test_next_mid():
This test verifies that the request ID generator correctly increments
and provides unique IDs for each request.
"""
assert _get_controller().request_uid.next + 1 == _get_controller().request_uid.next
controller = instances[chain.id][0]
assert controller.request_uid.next + 1 == controller.request_uid.next


def test_next_bid():
Expand All @@ -112,7 +107,8 @@ def test_next_bid():
This test checks that the multicall ID generator correctly increments
and provides unique IDs for each multicall.
"""
assert _get_controller().multicall_uid.next + 1 == _get_controller().multicall_uid.next
controller = instances[chain.id][0]
assert controller.multicall_uid.next + 1 == controller.multicall_uid.next


@pytest.mark.asyncio_cooperative
Expand Down
Loading