Skip to content

Commit ba49d1b

Browse files
authored
Fix MEV Blocker kickbacks test (#124)
@fhenneke observed that high MEV Blocker refund alerts were missing. Had a look and it turns out that a topic check ``` txs["topics"][0].hex() == "0x3d0ce9bfc3ed7d6862dbb28b2dea94561fe714a1b4d019aa8af39730d1ad7c3d" ``` started failing because the left-hand side didn't have the prefix "0x". Not sure why this stopped working, but in any case, this PR proposes a slightly more robust way of doing the check. Also added a test to demonstrate the fix works. Again, the only meaningful way of running the test is by having it print the logs as well ` python -m pytest --log-cli-level=DEBUG tests/e2e/mev_blocker_kickbacks_test.py`
1 parent 213dd6d commit ba49d1b

File tree

2 files changed

+26
-3
lines changed

2 files changed

+26
-3
lines changed

src/apis/web3api.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -103,9 +103,8 @@ def get_eth_transfers_by_block_range(
103103
return None
104104
total_transfers_in_eth = 0.0
105105
for txs in log_receipts:
106-
if (
107-
txs["topics"][0].hex()
108-
== "0x3d0ce9bfc3ed7d6862dbb28b2dea94561fe714a1b4d019aa8af39730d1ad7c3d"
106+
if txs["topics"][0] == HexBytes(
107+
"0x3d0ce9bfc3ed7d6862dbb28b2dea94561fe714a1b4d019aa8af39730d1ad7c3d"
109108
):
110109
total_transfers_in_eth += int(txs["data"].hex(), 16) / 10**18
111110
return total_transfers_in_eth
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
"""
2+
Test for MEV Blocker kickbacks test.
3+
"""
4+
5+
import unittest
6+
from src.monitoring_tests.mev_blocker_kickbacks_test import (
7+
MEVBlockerRefundsMonitoringTest,
8+
)
9+
10+
11+
class TestMevBlockerRefunds(unittest.TestCase):
12+
def test_mev_blocker_refunds(self) -> None:
13+
mev_blocker_refunds_test = MEVBlockerRefundsMonitoringTest()
14+
# large kickback tx
15+
tx_hash = "0xcbf4677177fb320b7e000ca95b31b5259648c75ebcfa9544014298ddfea94282"
16+
self.assertTrue(mev_blocker_refunds_test.run(tx_hash))
17+
18+
# no kickback tx
19+
tx_hash = "0x3198bc18bc41ec3eb35cc382697d18917ebdaf03528e7dcc5270488d156037c8"
20+
self.assertTrue(mev_blocker_refunds_test.run(tx_hash))
21+
22+
23+
if __name__ == "__main__":
24+
unittest.main()

0 commit comments

Comments
 (0)