Skip to content

Commit

Permalink
increase cc
Browse files Browse the repository at this point in the history
  • Loading branch information
kgarbacinski committed Feb 20, 2024
1 parent 07f7dd9 commit 1420926
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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"])
Expand Down Expand Up @@ -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
4 changes: 2 additions & 2 deletions backend/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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):
Expand Down
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 1420926

Please sign in to comment.