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 issue with missing topics #69

Merged
merged 5 commits into from
Oct 6, 2024
Merged
Show file tree
Hide file tree
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
2 changes: 2 additions & 0 deletions .github/workflows/pull_request.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,5 @@ jobs:
black --check ./
- name: Type Check (mypy)
run: mypy src
- name: Tests
run: pytest tests/e2e/test_blockchain_data.py
1 change: 1 addition & 0 deletions src/helpers/blockchain_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ def get_tx_hashes_blocks(
if any(
log.topics[0].to_0x_hex() == INVALIDATED_ORDER_TOPIC
for log in receipt.logs # type: ignore[attr-defined]
if log.topics # type: ignore[attr-defined]
):
continue
# status = 0 indicates a reverted tx, status = 1 is successful tx
Expand Down
32 changes: 32 additions & 0 deletions tests/e2e/test_blockchain_data.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
from os import getenv, environ
from unittest.mock import patch

import pytest
from web3 import Web3


@pytest.fixture()
def set_env_variables(monkeypatch):
with patch.dict(environ, clear=True):
envvars = {
"CHAIN_SLEEP_TIME": "1",
"NODE_URL": "https://rpc.mevblocker.io",
}
for k, v in envvars.items():
monkeypatch.setenv(k, v)
yield # This is the magical bit which restore the environment after


def tests_get_tx_hashes_blocks(set_env_variables):
# import has to happen after patching environment variable
from src.helpers.blockchain_data import BlockchainData

web3 = Web3(Web3.HTTPProvider(getenv("NODE_URL")))
blockchain = BlockchainData(web3)
start_block = 20892118
end_block = start_block
res = blockchain.get_tx_hashes_blocks(start_block, end_block)
assert res[0] == (
"0xb75e03b63d4f06c56549effd503e1e37f3ccfc3c00e6985a5aacc9b0534d7c5c",
20892118,
)
Loading