Skip to content

Commit 176156f

Browse files
committed
fix tests
1 parent 29c2506 commit 176156f

File tree

1 file changed

+6
-16
lines changed

1 file changed

+6
-16
lines changed

src/test_collectors.py

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,8 @@ def test_block_height(self):
6464

6565
def test_finalized_block_height(self):
6666
"""Tests the finalized_block_height function uses the correct call and args to get finalized block height"""
67-
# Mock the response to prevent the actual logic from executing
68-
mock_block_response = {"number": 1715004}
67+
# Mock with hex string, not integer
68+
mock_block_response = {"number": "0x1a2b3c"}
6969
self.mocked_websocket.return_value.query.return_value = mock_block_response
7070

7171
payload = {
@@ -89,27 +89,17 @@ def test_finalized_block_height_return_none_when_no_number_field(self):
8989
result = self.evm_collector.finalized_block_height()
9090
self.assertEqual(None, result)
9191

92-
def test_finalized_block_height_return_int(self):
93-
"""Tests that finalized_block_height returns integer block number correctly"""
92+
def test_finalized_block_height_return(self):
93+
"""Tests that finalized_block_height converts hex block number to integer correctly"""
9494
mock_block_response = {
95-
"number": 1715004, # Already an integer, not hex string
95+
"number": "0x1a2b3c", # Hex string as your code expects
9696
"hash": "0x456def"
9797
}
9898
self.mocked_websocket.return_value.query.return_value = mock_block_response
9999
result = self.evm_collector.finalized_block_height()
100+
# 0x1a2b3c = 1715004 in decimal
100101
self.assertEqual(1715004, result)
101102

102-
def test_finalized_block_height_various_integers(self):
103-
"""Tests that finalized_block_height handles various integer values correctly"""
104-
test_cases = [0, 1, 255, 4096, 1000000]
105-
106-
for expected_int in test_cases:
107-
with self.subTest(block_number=expected_int):
108-
mock_block_response = {"number": expected_int}
109-
self.mocked_websocket.return_value.query.return_value = mock_block_response
110-
result = self.evm_collector.finalized_block_height()
111-
self.assertEqual(expected_int, result)
112-
113103
def test_client_version(self):
114104
"""Tests the client_version function uses the correct call and args to get client version"""
115105
payload = {

0 commit comments

Comments
 (0)