@@ -34,6 +34,7 @@ def cronos_staking_cache(tmp_path_factory):
3434 26650 ,
3535 Path (__file__ ).parent / "configs/staking_cache.jsonnet" ,
3636 )
37+
3738
3839def get_delegator_address (cli , account_name ):
3940 """Get delegator address for a specific account."""
@@ -442,14 +443,16 @@ def test_staking_cache_unbonding_validator(cronos_staking_cache):
442443 test_val = v
443444 break
444445
445- if test_val :
446- print (
447- f"Node { node_idx } (cache-size={ cache_size } ): "
448- f"Status={ test_val .get ('status' , 'unknown' )} , "
449- f"Tokens={ test_val .get ('tokens' , '0' )} "
450- )
451- else :
452- print (f"Node { node_idx } (cache-size={ cache_size } ): Validator not found" )
446+ assert test_val is not None , (
447+ f"Node { node_idx } (cache-size={ cache_size } ): "
448+ f"Validator { val_addr } not found in initial status check"
449+ )
450+
451+ print (
452+ f"Node { node_idx } (cache-size={ cache_size } ): "
453+ f"Status={ test_val .get ('status' , 'unknown' )} , "
454+ f"Tokens={ test_val .get ('tokens' , '0' )} "
455+ )
453456
454457 # Get current self-delegation amount
455458 delegations = cli .get_delegated_amount (val_account )
@@ -491,21 +494,20 @@ def test_staking_cache_unbonding_validator(cronos_staking_cache):
491494 cache_size = [- 1 , 0 , 1 , 2 , 3 ][node_idx ]
492495 validator = node_cli .validator (val_addr )
493496
494- if validator and "validator" in validator :
495- val_info = validator ["validator" ]
496- status = val_info .get ("status" , "unknown" )
497- tokens = val_info .get ("tokens" , "0" )
498- jailed = val_info .get ("jailed" , False )
499- unbonding_statuses .append (status )
500- print (
501- f"Node { node_idx } (cache-size={ cache_size } ): "
502- f"Status={ status } , Tokens={ tokens } , Jailed={ jailed } "
503- )
504- else :
505- print (
506- f"Node { node_idx } (cache-size={ cache_size } ): "
507- f"Validator not found"
508- )
497+ assert validator and "validator" in validator , (
498+ f"Node { node_idx } (cache-size={ cache_size } ): "
499+ f"Failed to query validator { val_addr } after unbonding"
500+ )
501+
502+ val_info = validator ["validator" ]
503+ status = val_info .get ("status" , "unknown" )
504+ tokens = val_info .get ("tokens" , "0" )
505+ jailed = val_info .get ("jailed" , False )
506+ unbonding_statuses .append (status )
507+ print (
508+ f"Node { node_idx } (cache-size={ cache_size } ): "
509+ f"Status={ status } , Tokens={ tokens } , Jailed={ jailed } "
510+ )
509511
510512 # Assert validator is in BOND_STATUS_UNBONDING on all nodes
511513 assert len (set (unbonding_statuses )) == 1 , (
@@ -773,13 +775,15 @@ def test_staking_cache_consistency(cronos_staking_cache):
773775 cache_size = [- 1 , 0 , 1 , 2 , 3 ][node_idx ]
774776 validator = node_cli .validator (val_addr )
775777
776- if validator and "validator" in validator :
777- val_info = validator ["validator" ]
778- status = val_info .get ("status" , "unknown" )
779- unbonding_statuses .append (status )
780- print (f" Node { node_idx } (cache-size={ cache_size } ): Status={ status } " )
781- else :
782- print (f" Node { node_idx } (cache-size={ cache_size } ): Validator not found" )
778+ assert validator and "validator" in validator , (
779+ f"Node { node_idx } (cache-size={ cache_size } ): "
780+ f"Failed to query validator { val_addr } after unbonding"
781+ )
782+
783+ val_info = validator ["validator" ]
784+ status = val_info .get ("status" , "unknown" )
785+ unbonding_statuses .append (status )
786+ print (f" Node { node_idx } (cache-size={ cache_size } ): Status={ status } " )
783787
784788 assert (
785789 len (set (unbonding_statuses )) == 1
0 commit comments