Skip to content

Commit

Permalink
Fix tests with nodes (#76)
Browse files Browse the repository at this point in the history
  • Loading branch information
fhenneke authored Oct 9, 2024
1 parent f5cc889 commit da9ff65
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 35 deletions.
1 change: 1 addition & 0 deletions .github/workflows/pull_request.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,4 @@ jobs:
run: pytest tests/e2e/test_blockchain_data.py tests/e2e/test_imbalances_script.py
env:
NODE_URL: ${{ secrets.NODE_URL }}
CHAIN_SLEEP_TIME: 1
21 changes: 3 additions & 18 deletions tests/e2e/test_blockchain_data.py
Original file line number Diff line number Diff line change
@@ -1,26 +1,11 @@
from os import getenv, environ
from unittest.mock import patch
from os import getenv

import pytest
from web3 import Web3

from src.helpers.blockchain_data import BlockchainData

@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

def tests_get_tx_hashes_blocks():
web3 = Web3(Web3.HTTPProvider(getenv("NODE_URL")))
blockchain = BlockchainData(web3)
start_block = 20892118
Expand Down
20 changes: 3 additions & 17 deletions tests/e2e/test_imbalances_script.py
Original file line number Diff line number Diff line change
@@ -1,25 +1,11 @@
from os import getenv, environ
from unittest.mock import Mock, patch
from os import getenv

import pytest
from web3 import Web3

from src.imbalances_script import RawTokenImbalances

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


def tests_process_single_transaction(set_env_variables):
# import has to happen after patching environment variable
from src.imbalances_script import RawTokenImbalances

def tests_process_single_transaction():
web3 = Web3(Web3.HTTPProvider(getenv("NODE_URL")))
raw_imbalances = RawTokenImbalances(web3, "mainnet")
imbalances = raw_imbalances.compute_imbalances(
Expand Down

0 comments on commit da9ff65

Please sign in to comment.