Skip to content

Commit d938bda

Browse files
committed
feat: adapt unit tests to pectra
1 parent 3a94a4a commit d938bda

6 files changed

+6950
-3779
lines changed

justfile

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ _default:
22
@just --list --unsorted
33

44
# Run unit tests
5-
test:
6-
uv run pytest --exitfirst
5+
test specific_test='':
6+
uv run pytest --exitfirst -v -k '{{ specific_test }}' --tb=short
77

88
# Run linter
99
lint:

tests/assets/cassettes/test_sepolia.yaml

+6,868-3,745
Large diffs are not rendered by default.

tests/assets/config.sepolia.yaml

+4-9
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,10 @@
1-
beacon_url: http://localhost:3500/
2-
beacon_timeout_sec: 90
1+
beacon_url: http://localhost:3500
2+
beacon_timeout_sec: 720
33
network: sepolia
44
metrics_port: 8000
55

6-
# We have data for:
7-
#
8-
# - slot 5493884: 1721660208
9-
# - slot 5493975: 1721661324
10-
11-
replay_start_at_ts: 1721660208
12-
replay_end_at_ts: 1721661324
6+
replay_start_at_ts: 1744096730
7+
replay_end_at_ts: 1744097880
138

149
watched_keys:
1510
- public_key: '989fa046d04b41fc95a04dabb7ab8b64e84afaa85c0aa49e1c6878d7b2814094402d62ae42dfbf3ac72e6770ee0926a8'

tests/assets/config.sepolia_replay_2_slots.yaml

+2-7
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,8 @@ beacon_timeout_sec: 90
33
network: sepolia
44
metrics_port: 8000
55

6-
# We have data for:
7-
#
8-
# - slot 5493884: 1721660208
9-
# - slot 6356780: 1721661324
10-
11-
replay_start_at_ts: 1721660207
12-
replay_end_at_ts: 1721660225
6+
replay_start_at_ts: 1744096730
7+
replay_end_at_ts: 1744096760
138

149
watched_keys:
1510
- public_key: '989fa046d04b41fc95a04dabb7ab8b64e84afaa85c0aa49e1c6878d7b2814094402d62ae42dfbf3ac72e6770ee0926a8'

tests/assets/config.sepolia_replay_5_slots.yaml

+2-7
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,8 @@ beacon_timeout_sec: 90
33
network: sepolia
44
metrics_port: 8000
55

6-
# We have data for:
7-
#
8-
# - slot 5493884: 1721660208
9-
# - slot 6356780: 1721661324
10-
11-
replay_start_at_ts: 1721660207
12-
replay_end_at_ts: 1721660261
6+
replay_start_at_ts: 17440967030
7+
replay_end_at_ts: 1744096785
138

149
watched_keys:
1510
- public_key: '989fa046d04b41fc95a04dabb7ab8b64e84afaa85c0aa49e1c6878d7b2814094402d62ae42dfbf3ac72e6770ee0926a8'

tests/test_sepolia.py

+72-9
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ def test_sepolia_metric_epoch(self, slot: int):
109109
def test_sepolia_validator_status(self, slot: int):
110110
"""Verifies the validator statuses are exposed by scopes.
111111
"""
112-
if slot != 5493883:
112+
if slot != 7363592:
113113
return
114114

115115
def test_for_label(
@@ -136,8 +136,45 @@ def test_for_label(
136136
self.assertEqual(self.metrics[f'eth_validator_status_count{{network="sepolia",scope="{label}",status="withdrawal_done"}}'], float(withdrawal_done))
137137

138138
test_for_label("scope:watched", active_ongoing=100)
139-
test_for_label("scope:all-network", active_ongoing=1771, withdrawal_possible=200, withdrawal_done=2)
140-
test_for_label("scope:network", active_ongoing=1671, withdrawal_possible=200, withdrawal_done=2)
139+
test_for_label("scope:all-network", active_ongoing=1781, withdrawal_possible=200, withdrawal_done=6)
140+
test_for_label("scope:network", active_ongoing=1681, withdrawal_possible=200, withdrawal_done=6)
141+
test_for_label("operator:kiln", active_ongoing=100)
142+
test_for_label("vc:prysm-validator-1", active_ongoing=50)
143+
test_for_label("vc:teku-validator-1", active_ongoing=50)
144+
145+
@sepolia_test("config.sepolia_replay_2_slots.yaml")
146+
def test_sepolia_validator_scaled_status(self, slot: int):
147+
"""Verifies the validator statuses are exposed by scopes.
148+
"""
149+
if slot != 7363592:
150+
return
151+
152+
def test_for_label(
153+
label: str,
154+
pending_initialized: int = 0,
155+
pending_queued: int = 0,
156+
active_ongoing: int = 0,
157+
active_exiting: int = 0,
158+
active_slashed: int = 0,
159+
exited_unslashed: int = 0,
160+
exited_slashed: int = 0,
161+
withdrawal_possible: int = 0,
162+
withdrawal_done: int = 0,
163+
) -> None:
164+
165+
self.assertEqual(self.metrics[f'eth_validator_status_scaled_count{{network="sepolia",scope="{label}",status="pending_initialized"}}'], float(pending_initialized))
166+
self.assertEqual(self.metrics[f'eth_validator_status_scaled_count{{network="sepolia",scope="{label}",status="pending_queued"}}'], float(pending_queued))
167+
self.assertEqual(self.metrics[f'eth_validator_status_scaled_count{{network="sepolia",scope="{label}",status="active_ongoing"}}'], float(active_ongoing))
168+
self.assertEqual(self.metrics[f'eth_validator_status_scaled_count{{network="sepolia",scope="{label}",status="active_exiting"}}'], float(active_exiting))
169+
self.assertEqual(self.metrics[f'eth_validator_status_scaled_count{{network="sepolia",scope="{label}",status="active_slashed"}}'], float(active_slashed))
170+
self.assertEqual(self.metrics[f'eth_validator_status_scaled_count{{network="sepolia",scope="{label}",status="exited_unslashed"}}'], float(exited_unslashed))
171+
self.assertEqual(self.metrics[f'eth_validator_status_scaled_count{{network="sepolia",scope="{label}",status="exited_slashed"}}'], float(exited_slashed))
172+
self.assertEqual(self.metrics[f'eth_validator_status_scaled_count{{network="sepolia",scope="{label}",status="withdrawal_possible"}}'], float(withdrawal_possible))
173+
self.assertEqual(self.metrics[f'eth_validator_status_scaled_count{{network="sepolia",scope="{label}",status="withdrawal_done"}}'], float(withdrawal_done))
174+
175+
test_for_label("scope:watched", active_ongoing=100)
176+
test_for_label("scope:all-network", active_ongoing=1785.09375, withdrawal_possible=150, withdrawal_done=0)
177+
test_for_label("scope:network", active_ongoing=1685.09375, withdrawal_possible=150, withdrawal_done=0)
141178
test_for_label("operator:kiln", active_ongoing=100)
142179
test_for_label("vc:prysm-validator-1", active_ongoing=50)
143180
test_for_label("vc:teku-validator-1", active_ongoing=50)
@@ -146,28 +183,54 @@ def test_for_label(
146183
def test_sepolia_missed_attestation(self, slot: int):
147184
"""Verifies attestation misses
148185
"""
149-
if slot != 5493883:
186+
if slot != 7363592:
150187
return
151188

152189
self.assertEqual(self.metrics['eth_missed_attestations{network="sepolia",scope="operator:kiln"}'], 0.0)
153190
self.assertEqual(self.metrics['eth_missed_attestations{network="sepolia",scope="vc:prysm-validator-1"}'], 0.0)
154191
self.assertEqual(self.metrics['eth_missed_attestations{network="sepolia",scope="vc:teku-validator-1"}'], 0.0)
155192
self.assertEqual(self.metrics['eth_missed_attestations{network="sepolia",scope="scope:watched"}'], 0.0)
156-
self.assertEqual(self.metrics['eth_missed_attestations{network="sepolia",scope="scope:all-network"}'], 350.0)
157-
self.assertEqual(self.metrics['eth_missed_attestations{network="sepolia",scope="scope:network"}'], 350.0)
193+
self.assertEqual(self.metrics['eth_missed_attestations{network="sepolia",scope="scope:all-network"}'], 101.0)
194+
self.assertEqual(self.metrics['eth_missed_attestations{network="sepolia",scope="scope:network"}'], 101.0)
195+
196+
self.assertEqual(self.metrics['eth_missed_attestations_scaled{network="sepolia",scope="operator:kiln"}'], 0.0)
197+
self.assertEqual(self.metrics['eth_missed_attestations_scaled{network="sepolia",scope="vc:prysm-validator-1"}'], 0.0)
198+
self.assertEqual(self.metrics['eth_missed_attestations_scaled{network="sepolia",scope="vc:teku-validator-1"}'], 0.0)
199+
self.assertEqual(self.metrics['eth_missed_attestations_scaled{network="sepolia",scope="scope:watched"}'], 0.0)
200+
self.assertEqual(self.metrics['eth_missed_attestations_scaled{network="sepolia",scope="scope:all-network"}'], 100.9375)
201+
self.assertEqual(self.metrics['eth_missed_attestations_scaled{network="sepolia",scope="scope:network"}'], 100.9375)
202+
203+
@sepolia_test("config.sepolia.yaml")
204+
def test_sepolia_missed_consecutive_attestation(self, slot: int):
205+
"""Verifies consecutive attestation misses
206+
"""
207+
if slot != 7363686:
208+
return
209+
210+
self.assertEqual(self.metrics['eth_missed_consecutive_attestations{network="sepolia",scope="operator:kiln"}'], 0.0)
211+
self.assertEqual(self.metrics['eth_missed_consecutive_attestations{network="sepolia",scope="vc:prysm-validator-1"}'], 0.0)
212+
self.assertEqual(self.metrics['eth_missed_consecutive_attestations{network="sepolia",scope="vc:teku-validator-1"}'], 0.0)
213+
self.assertEqual(self.metrics['eth_missed_consecutive_attestations{network="sepolia",scope="scope:watched"}'], 0.0)
214+
self.assertEqual(self.metrics['eth_missed_consecutive_attestations{network="sepolia",scope="scope:all-network"}'], 101.0)
215+
self.assertEqual(self.metrics['eth_missed_consecutive_attestations{network="sepolia",scope="scope:network"}'], 101.0)
158216

159217
@sepolia_test("config.sepolia.yaml")
160218
def test_sepolia_blocks(self, slot: int):
161219
"""Verifies block proposals and misses.
162220
"""
163-
if slot != 5493975:
221+
if slot != 7363612:
164222
return
165223

166-
self.assertEqual(self.metrics['eth_block_proposals_head_total{network="sepolia",scope="operator:kiln"}'], 6.0)
224+
self.assertEqual(self.metrics['eth_block_proposals_head_total{network="sepolia",scope="operator:kiln"}'], 2.0)
167225
self.assertEqual(self.metrics['eth_missed_block_proposals_head_total{network="sepolia",scope="operator:kiln"}'], 0.0)
168-
self.assertEqual(self.metrics['eth_block_proposals_finalized_total{network="sepolia",scope="operator:kiln"}'], 2.0)
226+
self.assertEqual(self.metrics['eth_block_proposals_finalized_total{network="sepolia",scope="operator:kiln"}'], 0.0)
169227
self.assertEqual(self.metrics['eth_missed_block_proposals_finalized_total{network="sepolia",scope="operator:kiln"}'], 0.0)
170228

229+
self.assertEqual(self.metrics['eth_block_proposals_head_total{network="sepolia",scope="scope:all-network"}'], 20.0)
230+
self.assertEqual(self.metrics['eth_missed_block_proposals_head_total{network="sepolia",scope="scope:all-network"}'], 1.0)
231+
self.assertEqual(self.metrics['eth_block_proposals_finalized_total{network="sepolia",scope="scope:all-network"}'], 0.0)
232+
self.assertEqual(self.metrics['eth_missed_block_proposals_finalized_total{network="sepolia",scope="scope:all-network"}'], 0.0)
233+
171234
@sepolia_test("config.sepolia.yaml")
172235
def test_sepolia_full(self, slot: int):
173236
"""Runs a complete iteration of the watcher over two epochs.

0 commit comments

Comments
 (0)