@@ -191,85 +191,86 @@ def _get_genesis_header(self) -> dict:
191
191
return to_json (self .fixture .genesis )
192
192
193
193
194
- class ReorgClient (ClientWrapper ):
194
+ class MultiTestClient (ClientWrapper ):
195
195
"""
196
- Client wrapper for the reorg simulator where clients are shared across tests.
196
+ Client wrapper for multi-test execution where clients are used across tests.
197
197
198
198
This class manages clients that are reused across multiple tests in the same
199
- pre-allocation group, using blockchain reorganization to reset state between tests .
199
+ pre-allocation group.
200
200
"""
201
201
202
202
def __init__ (
203
203
self ,
204
204
pre_hash : str ,
205
205
client_type : ClientType ,
206
- shared_pre_state : PreAllocGroup ,
206
+ pre_alloc_group : PreAllocGroup ,
207
207
):
208
208
"""
209
- Initialize a reorg client wrapper.
209
+ Initialize a multi-test client wrapper.
210
210
211
211
Args:
212
212
pre_hash: The hash identifying the pre-allocation group
213
213
client_type: The type of client to manage
214
- shared_pre_state : The shared pre-state data for this group
214
+ pre_alloc_group : The pre-allocation group data for this group
215
215
216
216
"""
217
217
super ().__init__ (client_type )
218
218
self .pre_hash = pre_hash
219
- self .shared_pre_state = shared_pre_state
219
+ self .pre_alloc_group = pre_alloc_group
220
220
221
221
def _get_fork (self ) -> Fork :
222
- """Get the fork from the shared pre-state ."""
223
- return self .shared_pre_state .fork
222
+ """Get the fork from the pre-allocation group ."""
223
+ return self .pre_alloc_group .fork
224
224
225
225
def _get_chain_id (self ) -> int :
226
- """Get the chain ID from the shared pre-state environment."""
226
+ """Get the chain ID from the pre-allocation group environment."""
227
227
# TODO: Environment doesn't have chain_id field - see work_in_progress.md
228
228
return 1
229
229
230
230
def _get_pre_alloc (self ) -> dict :
231
- """Get the pre-allocation from the shared pre-state ."""
232
- return to_json (self .shared_pre_state .pre )
231
+ """Get the pre-allocation from the pre-allocation group ."""
232
+ return to_json (self .pre_alloc_group .pre )
233
233
234
234
def _get_genesis_header (self ) -> dict :
235
- """Get the genesis header from the shared pre-state ."""
236
- return self .shared_pre_state .genesis ().model_dump (by_alias = True )
235
+ """Get the genesis header from the pre-allocation group ."""
236
+ return self .pre_alloc_group .genesis ().model_dump (by_alias = True )
237
237
238
238
def set_client (self , client : Client ) -> None :
239
239
"""Override to log with pre_hash information."""
240
240
if self ._is_started :
241
- raise RuntimeError (f"Client for preHash { self .pre_hash } is already set" )
241
+ raise RuntimeError (f"Client for pre-allocation group { self .pre_hash } is already set" )
242
242
243
243
self .client = client
244
244
self ._is_started = True
245
245
logger .info (
246
- f"Reorg client ({ self .client_type .name } ) registered for preHash { self .pre_hash } "
246
+ f"Multi-test client ({ self .client_type .name } ) registered for pre-allocation group "
247
+ f"{ self .pre_hash } "
247
248
)
248
249
249
250
def stop (self ) -> None :
250
251
"""Override to log with pre_hash information."""
251
252
if self ._is_started :
252
253
logger .info (
253
- f"Marking reorg client ({ self .client_type .name } ) for preHash { self . pre_hash } "
254
- f"as stopped after { self .test_count } tests"
254
+ f"Marking multi-test client ({ self .client_type .name } ) for pre-allocation group "
255
+ f"{ self . pre_hash } as stopped after { self .test_count } tests"
255
256
)
256
257
self .client = None
257
258
self ._is_started = False
258
259
259
260
260
- class ReorgClientManager :
261
+ class MultiTestClientManager :
261
262
"""
262
- Singleton manager for coordinating reorg clients across test execution.
263
+ Singleton manager for coordinating multi-test clients across test execution.
263
264
264
- This class tracks all reorg clients by their preHash and ensures proper
265
+ This class tracks all multi-test clients by their preHash and ensures proper
265
266
lifecycle management including cleanup at session end.
266
267
"""
267
268
268
- _instance : Optional ["ReorgClientManager " ] = None
269
+ _instance : Optional ["MultiTestClientManager " ] = None
269
270
_initialized : bool
270
271
271
- def __new__ (cls ) -> "ReorgClientManager " :
272
- """Ensure only one instance of ReorgClientManager exists."""
272
+ def __new__ (cls ) -> "MultiTestClientManager " :
273
+ """Ensure only one instance of MultiTestClientManager exists."""
273
274
if cls ._instance is None :
274
275
cls ._instance = super ().__new__ (cls )
275
276
cls ._instance ._initialized = False
@@ -280,10 +281,10 @@ def __init__(self) -> None:
280
281
if hasattr (self , "_initialized" ) and self ._initialized :
281
282
return
282
283
283
- self .reorg_clients : Dict [str , ReorgClient ] = {}
284
+ self .multi_test_clients : Dict [str , MultiTestClient ] = {}
284
285
self .pre_alloc_path : Optional [Path ] = None
285
286
self ._initialized = True
286
- logger .info ("ReorgClientManager initialized" )
287
+ logger .info ("MultiTestClientManager initialized" )
287
288
288
289
def set_pre_alloc_path (self , path : Path ) -> None :
289
290
"""
@@ -296,9 +297,9 @@ def set_pre_alloc_path(self, path: Path) -> None:
296
297
self .pre_alloc_path = path
297
298
logger .debug (f"Pre-alloc path set to: { path } " )
298
299
299
- def load_shared_pre_state (self , pre_hash : str ) -> PreAllocGroup :
300
+ def load_pre_alloc_group (self , pre_hash : str ) -> PreAllocGroup :
300
301
"""
301
- Load the shared pre-state for a given preHash.
302
+ Load the pre-allocation group for a given preHash.
302
303
303
304
Args:
304
305
pre_hash: The hash identifying the pre-allocation group
@@ -312,63 +313,65 @@ def load_shared_pre_state(self, pre_hash: str) -> PreAllocGroup:
312
313
313
314
"""
314
315
if self .pre_alloc_path is None :
315
- raise RuntimeError ("Pre-alloc path not set in ReorgClientManager " )
316
+ raise RuntimeError ("Pre-alloc path not set in MultiTestClientManager " )
316
317
317
318
pre_alloc_file = self .pre_alloc_path / f"{ pre_hash } .json"
318
319
if not pre_alloc_file .exists ():
319
320
raise FileNotFoundError (f"Pre-allocation file not found: { pre_alloc_file } " )
320
321
321
322
return PreAllocGroup .model_validate_json (pre_alloc_file .read_text ())
322
323
323
- def get_or_create_reorg_client (
324
+ def get_or_create_multi_test_client (
324
325
self ,
325
326
pre_hash : str ,
326
327
client_type : ClientType ,
327
- ) -> ReorgClient :
328
+ ) -> MultiTestClient :
328
329
"""
329
- Get an existing ReorgClient or create a new one for the given preHash.
330
+ Get an existing MultiTestClient or create a new one for the given preHash.
330
331
331
332
This method doesn't start the actual client - that's done by HiveTestSuite.
332
- It just manages the ReorgClient wrapper objects.
333
+ It just manages the MultiTestClient wrapper objects.
333
334
334
335
Args:
335
336
pre_hash: The hash identifying the pre-allocation group
336
337
client_type: The type of client that will be started
337
338
338
339
Returns:
339
- The ReorgClient wrapper instance
340
+ The MultiTestClient wrapper instance
340
341
341
342
"""
342
- # Check if we already have a ReorgClient for this preHash
343
- if pre_hash in self .reorg_clients :
344
- reorg_client = self .reorg_clients [pre_hash ]
345
- if reorg_client .is_running :
346
- logger .debug (f"Found existing ReorgClient for preHash { pre_hash } " )
347
- return reorg_client
343
+ # Check if we already have a MultiTestClient for this preHash
344
+ if pre_hash in self .multi_test_clients :
345
+ multi_test_client = self .multi_test_clients [pre_hash ]
346
+ if multi_test_client .is_running :
347
+ logger .debug (f"Found existing MultiTestClient for pre-allocation group { pre_hash } " )
348
+ return multi_test_client
348
349
else :
349
- # ReorgClient exists but isn't running, remove it
350
- logger .warning (f"Found stopped ReorgClient for preHash { pre_hash } , removing" )
351
- del self .reorg_clients [pre_hash ]
350
+ # MultiTestClient exists but isn't running, remove it
351
+ logger .warning (
352
+ f"Found stopped MultiTestClient for pre-allocation group { pre_hash } , removing"
353
+ )
354
+ del self .multi_test_clients [pre_hash ]
352
355
353
- # Load the shared pre-state for this group
354
- shared_pre_state = self .load_shared_pre_state (pre_hash )
356
+ # Load the pre-allocation group for this group
357
+ pre_alloc_group = self .load_pre_alloc_group (pre_hash )
355
358
356
- # Create new ReorgClient wrapper
357
- reorg_client = ReorgClient (
359
+ # Create new MultiTestClient wrapper
360
+ multi_test_client = MultiTestClient (
358
361
pre_hash = pre_hash ,
359
362
client_type = client_type ,
360
- shared_pre_state = shared_pre_state ,
363
+ pre_alloc_group = pre_alloc_group ,
361
364
)
362
365
363
- # Track the ReorgClient
364
- self .reorg_clients [pre_hash ] = reorg_client
366
+ # Track the MultiTestClient
367
+ self .multi_test_clients [pre_hash ] = multi_test_client
365
368
366
369
logger .info (
367
- f"Created new ReorgClient wrapper for preHash { pre_hash } "
368
- f"(total tracked clients: { len (self .reorg_clients )} )"
370
+ f"Created new MultiTestClient wrapper for pre-allocation group { pre_hash } "
371
+ f"(total tracked clients: { len (self .multi_test_clients )} )"
369
372
)
370
373
371
- return reorg_client
374
+ return multi_test_client
372
375
373
376
def get_client_for_test (self , pre_hash : str ) -> Optional [Client ]:
374
377
"""
@@ -381,38 +384,42 @@ def get_client_for_test(self, pre_hash: str) -> Optional[Client]:
381
384
The client instance if available, None otherwise
382
385
383
386
"""
384
- if pre_hash in self .reorg_clients :
385
- reorg_client = self .reorg_clients [pre_hash ]
386
- if reorg_client .is_running :
387
- reorg_client .increment_test_count ()
388
- return reorg_client .client
387
+ if pre_hash in self .multi_test_clients :
388
+ multi_test_client = self .multi_test_clients [pre_hash ]
389
+ if multi_test_client .is_running :
390
+ multi_test_client .increment_test_count ()
391
+ return multi_test_client .client
389
392
return None
390
393
391
394
def stop_all_clients (self ) -> None :
392
- """Mark all reorg clients as stopped."""
393
- logger .info (f"Marking all { len (self .reorg_clients )} reorg clients as stopped" )
395
+ """Mark all multi-test clients as stopped."""
396
+ logger .info (f"Marking all { len (self .multi_test_clients )} multi-test clients as stopped" )
394
397
395
- for pre_hash , reorg_client in list (self .reorg_clients .items ()):
398
+ for pre_hash , multi_test_client in list (self .multi_test_clients .items ()):
396
399
try :
397
- reorg_client .stop ()
400
+ multi_test_client .stop ()
398
401
except Exception as e :
399
- logger .error (f"Error stopping ReorgClient for preHash { pre_hash } : { e } " )
402
+ logger .error (
403
+ f"Error stopping MultiTestClient for pre-allocation group { pre_hash } : { e } "
404
+ )
400
405
finally :
401
- del self .reorg_clients [pre_hash ]
406
+ del self .multi_test_clients [pre_hash ]
402
407
403
- logger .info ("All ReorgClient wrappers cleared" )
408
+ logger .info ("All MultiTestClient wrappers cleared" )
404
409
405
410
def get_client_count (self ) -> int :
406
- """Get the number of tracked reorg clients."""
407
- return len (self .reorg_clients )
411
+ """Get the number of tracked multi-test clients."""
412
+ return len (self .multi_test_clients )
408
413
409
414
def get_test_counts (self ) -> Dict [str , int ]:
410
- """Get test counts for each reorg client."""
411
- return {pre_hash : client .test_count for pre_hash , client in self .reorg_clients .items ()}
415
+ """Get test counts for each multi-test client."""
416
+ return {
417
+ pre_hash : client .test_count for pre_hash , client in self .multi_test_clients .items ()
418
+ }
412
419
413
420
def reset (self ) -> None :
414
421
"""Reset the manager, clearing all state."""
415
422
self .stop_all_clients ()
416
- self .reorg_clients .clear ()
423
+ self .multi_test_clients .clear ()
417
424
self .pre_alloc_path = None
418
- logger .info ("ReorgClientManager reset" )
425
+ logger .info ("MultiTestClientManager reset" )
0 commit comments