3838
3939try :
4040 import jsonschema # type: ignore
41- from jsonschema import Draft7Validator # type: ignore
41+ from jsonschema import Draft4Validator # type: ignore
4242except Exception : # pragma: no cover
4343 jsonschema = None # type: ignore
44- Draft7Validator = None # type: ignore
44+ Draft4Validator = None # type: ignore
4545
4646try :
4747 from rich .console import Console # type: ignore
9393# Fields that should be ignored when diffing
9494VOLATILE_FIELDS = {
9595 "metadata" : ["metadata.ttl" ],
96- "preprocess" : ["options.transaction_size" ]
96+ "preprocess" : ["options.transaction_size" ],
9797}
9898
9999# Stats
@@ -276,9 +276,9 @@ def validate_response(
276276 return self ._basic_sanity (instance )
277277 try :
278278 d = self ._deref (schema )
279- if Draft7Validator :
279+ if Draft4Validator :
280280 errs : List [str ] = []
281- for e in Draft7Validator (d ).iter_errors (instance ):
281+ for e in Draft4Validator (d ).iter_errors (instance ):
282282 loc = "." .join ([str (p ) for p in e .path ]) or "<root>"
283283 errs .append (f"{ loc } : { e .message } " )
284284 return errs
@@ -292,24 +292,24 @@ def validate_response(
292292def replace_network_placeholder (payload : Dict [str , Any ]) -> Tuple [Dict [str , Any ], bool ]:
293293 """Replace {{networkId}} placeholders with actual network_id value.
294294 Uses 'preprod' as default if no network_id is provided.
295-
295+
296296 Returns:
297297 Tuple of (modified_payload, has_placeholder)
298298 """
299299 try :
300300 # Convert to JSON string for safe replacement
301301 json_str = json .dumps (payload )
302-
302+
303303 # Check if placeholder exists
304304 has_placeholder = "{{networkId}}" in json_str
305-
305+
306306 if has_placeholder :
307307 # Use provided network_id or default to 'preprod'
308308 network_value = NETWORK_ID if NETWORK_ID is not None else "preprod"
309309 json_str = json_str .replace ("{{networkId}}" , network_value )
310310 # Parse back to dict
311311 return json .loads (json_str ), True
312-
312+
313313 return payload , False
314314 except Exception :
315315 # If anything goes wrong, return original payload
@@ -540,8 +540,9 @@ def validate_file(file_path: Path) -> Dict[str, Any]:
540540 return res
541541 has_ok , has_err = ("expected_response" in test ), ("expected_error" in test )
542542 if not (has_ok or has_err ):
543- skip_reason = test .get ("description" ,
544- "No expected_response or expected_error found" )
543+ skip_reason = test .get (
544+ "description" , "No expected_response or expected_error found"
545+ )
545546 res .update (
546547 {
547548 "status" : "skipped" ,
@@ -812,13 +813,16 @@ def main() -> None:
812813 help = "Show concise schema details per test" ,
813814 )
814815 parser .add_argument (
815- "-j" , "--workers" ,
816+ "-j" ,
817+ "--workers" ,
816818 type = int ,
817819 default = 10 ,
818820 help = "Number of parallel workers for test execution (default: 10)" ,
819821 )
820822 parser .add_argument (
821- "-n" , "--network-id" ,
823+ "-n" ,
824+ "--network-id" ,
825+ default = "preprod" ,
822826 help = "Network ID to replace {{networkId}} placeholders in test files (e.g., 'devkit', 'preprod', 'mainnet')" ,
823827 )
824828 args = parser .parse_args ()
@@ -969,16 +973,18 @@ def main() -> None:
969973 with Live (root , console = RICH_CONSOLE , refresh_per_second = 8 ):
970974 # Process files in parallel, maintain order for display
971975 with ThreadPoolExecutor (max_workers = WORKERS ) as executor :
972- future_to_fp = {executor .submit (validate_file , fp ): fp for fp in gfiles }
976+ future_to_fp = {
977+ executor .submit (validate_file , fp ): fp for fp in gfiles
978+ }
973979 results = []
974980 for future in as_completed (future_to_fp ):
975981 fp = future_to_fp [future ]
976982 r = future .result ()
977983 results .append ((fp , r ))
978-
984+
979985 # Sort results back to original order for consistent display
980986 results .sort (key = lambda x : gfiles .index (x [0 ]))
981-
987+
982988 # Process results in order
983989 for fp , r in results :
984990 stats ["files_tested" ] += 1
@@ -991,7 +997,10 @@ def main() -> None:
991997 ep_failed += 1
992998 (
993999 ep_failures .append (
994- (r ["file" ], (r .get ("differences" ) or ["" ])[0 ])
1000+ (
1001+ r ["file" ],
1002+ (r .get ("differences" ) or ["" ])[0 ],
1003+ )
9951004 )
9961005 if r .get ("differences" )
9971006 else None
@@ -1008,7 +1017,9 @@ def main() -> None:
10081017 ep_error_cases .append (
10091018 (r ["file" ], r .get ("error" ) or "error" )
10101019 )
1011- row = print_result (r , verbose = VERBOSE , rich_collect = True )
1020+ row = print_result (
1021+ r , verbose = VERBOSE , rich_collect = True
1022+ )
10121023 if row is not None :
10131024 rt .add_row (
10141025 fp .name ,
@@ -1068,7 +1079,9 @@ def main() -> None:
10681079 print (f"\n { DIM } [{ name } /{ gname } ]{ RESET } " )
10691080 # Process files in parallel
10701081 with ThreadPoolExecutor (max_workers = WORKERS ) as executor :
1071- future_to_fp = {executor .submit (validate_file , fp ): fp for fp in gfiles }
1082+ future_to_fp = {
1083+ executor .submit (validate_file , fp ): fp for fp in gfiles
1084+ }
10721085 for future in as_completed (future_to_fp ):
10731086 fp = future_to_fp [future ]
10741087 r = future .result ()
@@ -1090,7 +1103,9 @@ def main() -> None:
10901103 elif r ["status" ] == "skipped" :
10911104 stats ["files_skipped" ] += 1
10921105 ep_skipped += 1
1093- ep_skips .append ((r ["file" ], r .get ("error" ) or "skipped" ))
1106+ ep_skips .append (
1107+ (r ["file" ], r .get ("error" ) or "skipped" )
1108+ )
10941109 else :
10951110 stats ["errors_by_endpoint" ][name ] += 1
10961111 ep_errors += 1
@@ -1209,10 +1224,15 @@ def main() -> None:
12091224
12101225 elapsed = time .time () - start_time
12111226 print_summary (elapsed )
1212-
1227+
12131228 # Exit with proper code based on test results
12141229 failed = stats ["files_failed" ]
1215- errors = stats ["files_tested" ] - stats ["files_passed" ] - stats ["files_failed" ] - stats ["files_skipped" ]
1230+ errors = (
1231+ stats ["files_tested" ]
1232+ - stats ["files_passed" ]
1233+ - stats ["files_failed" ]
1234+ - stats ["files_skipped" ]
1235+ )
12161236 if failed > 0 or errors > 0 :
12171237 sys .exit (1 ) # Fail CI when tests fail or have errors
12181238 finally :
0 commit comments