From 1420926bde33eaa7e8acc4003fe139b0799e92ff Mon Sep 17 00:00:00 2001 From: "kacper.golem" Date: Tue, 20 Feb 2024 21:34:15 +0100 Subject: [PATCH] increase cc --- .../external_api/bitquery/blocks_reward.py | 4 ++-- backend/tests/conftest.py | 4 ++-- .../external_api/bitquery/test_acc_blocks_reward.py | 13 +++++++++++++ 3 files changed, 17 insertions(+), 4 deletions(-) create mode 100644 backend/tests/infrastracture/external_api/bitquery/test_acc_blocks_reward.py diff --git a/backend/app/infrastructure/external_api/bitquery/blocks_reward.py b/backend/app/infrastructure/external_api/bitquery/blocks_reward.py index 505f5136cc..49b38d1641 100644 --- a/backend/app/infrastructure/external_api/bitquery/blocks_reward.py +++ b/backend/app/infrastructure/external_api/bitquery/blocks_reward.py @@ -11,7 +11,7 @@ ) -def accumulate_blocks_reward(blocks: list) -> int: +def accumulate_blocks_reward_wei(blocks: list) -> int: blocks_reward_gwei = 0.0 for block in blocks: blocks_reward_gwei += float(block["reward"]) @@ -39,5 +39,5 @@ def get_blocks_reward(address: str, start_time: str, end_time: str) -> int: raise ExternalApiException(api_url, e, 500) blocks = json_response.json()["data"]["ethereum"]["blocks"] - blocks_reward = accumulate_blocks_reward(blocks) + blocks_reward = accumulate_blocks_reward_wei(blocks) return blocks_reward diff --git a/backend/tests/conftest.py b/backend/tests/conftest.py index 4fa3dfaf18..eb928b44d0 100644 --- a/backend/tests/conftest.py +++ b/backend/tests/conftest.py @@ -23,7 +23,7 @@ from app.infrastructure.contracts.proposals import Proposals from app.infrastructure.contracts.vault import Vault from app.infrastructure.external_api.bitquery.blocks_reward import ( - accumulate_blocks_reward, + accumulate_blocks_reward_wei, ) from app.legacy.controllers.allocations import allocate, deserialize_payload from app.legacy.core.allocations import Allocation, AllocationRequest @@ -135,7 +135,7 @@ def mock_bitquery_api_get_blocks_reward(*args, **kwargs): } blocks = example_resp_json["data"]["ethereum"]["blocks"] - return accumulate_blocks_reward(blocks) + return accumulate_blocks_reward_wei(blocks) def pytest_addoption(parser): diff --git a/backend/tests/infrastracture/external_api/bitquery/test_acc_blocks_reward.py b/backend/tests/infrastracture/external_api/bitquery/test_acc_blocks_reward.py new file mode 100644 index 0000000000..b290d62b76 --- /dev/null +++ b/backend/tests/infrastracture/external_api/bitquery/test_acc_blocks_reward.py @@ -0,0 +1,13 @@ +import pytest +from app.infrastructure.external_api.bitquery.blocks_reward import ( + accumulate_blocks_reward_wei, +) + + +@pytest.mark.parametrize( + "blocks, result", + [([{"reward": 0.024473700594149782}, {"reward": 0.05342909432569912}], 77902794)], +) +def test_accumulate_blocks_reward_wei(blocks, result): + actual_result = accumulate_blocks_reward_wei(blocks) + assert actual_result == result