@@ -19,13 +19,35 @@ pub fn load_sync_test(path: impl AsRef<Path>) -> anyhow::Result<TestFixture<Sync
1919
2020/// Run a single sync test case (currently the only operation is `verify_checkpoint`)
2121pub fn run_sync_test ( test_name : & str , test : & SyncTest ) -> anyhow:: Result < ( ) > {
22- info ! (
23- "Running sync test: {test_name} (operation={})" ,
24- test. operation
25- ) ;
22+ // devnet4: operation is a plain string, params in output
23+ // devnet5: operation is an object with kind + params
24+ let ( operation_kind, num_validators, expected_anchor_slot) =
25+ if let Some ( kind) = test. operation . as_str ( ) {
26+ let num_validators = test
27+ . output
28+ . validator_count
29+ . ok_or_else ( || anyhow ! ( "devnet4 format requires output.validatorCount" ) ) ?;
30+ let anchor_slot = test
31+ . output
32+ . anchor_slot
33+ . ok_or_else ( || anyhow ! ( "devnet4 format requires output.anchorSlot" ) ) ?;
34+ ( kind. to_string ( ) , num_validators, anchor_slot)
35+ } else {
36+ let kind = test. operation [ "kind" ]
37+ . as_str ( )
38+ . ok_or_else ( || anyhow ! ( "Missing operation.kind" ) ) ?
39+ . to_string ( ) ;
40+ let num_validators = test. operation [ "numValidators" ]
41+ . as_u64 ( )
42+ . ok_or_else ( || anyhow ! ( "Missing operation.numValidators" ) ) ?;
43+ let anchor_slot = test. operation [ "anchorSlot" ] . as_u64 ( ) . unwrap_or ( 0 ) ;
44+ ( kind, num_validators, anchor_slot)
45+ } ;
46+
47+ info ! ( "Running sync test: {test_name} (operation={operation_kind})" ) ;
2648
27- if test . operation != "verify_checkpoint" {
28- bail ! ( "Unknown sync operation: {}" , test . operation ) ;
49+ if operation_kind != "verify_checkpoint" {
50+ bail ! ( "Unknown sync operation: {operation_kind}" ) ;
2951 }
3052
3153 let state_bytes = hex:: decode ( test. output . state_bytes . trim_start_matches ( "0x" ) )
@@ -39,14 +61,12 @@ pub fn run_sync_test(test_name: &str, test: &SyncTest) -> anyhow::Result<()> {
3961 let actually_valid = actual_validator_count > 0 ;
4062
4163 ensure ! (
42- actual_validator_count == test. output. validator_count,
43- "validatorCount mismatch: expected {}, got {actual_validator_count}" ,
44- test. output. validator_count,
64+ actual_validator_count == num_validators,
65+ "validatorCount mismatch: expected {num_validators}, got {actual_validator_count}" ,
4566 ) ;
4667 ensure ! (
47- actual_slot == test. output. anchor_slot,
48- "anchorSlot mismatch: expected {}, got {actual_slot}" ,
49- test. output. anchor_slot,
68+ actual_slot == expected_anchor_slot,
69+ "anchorSlot mismatch: expected {expected_anchor_slot}, got {actual_slot}" ,
5070 ) ;
5171 ensure ! (
5272 actually_valid == test. output. valid,
0 commit comments