@@ -672,6 +672,62 @@ fn candidate_validation_multiple_ambiguous_errors_is_invalid() {
672672 assert_matches ! ( v, ValidationResult :: Invalid ( InvalidCandidate :: ExecutionError ( _) ) ) ;
673673}
674674
675+ // Test that we retry on internal errors.
676+ #[ test]
677+ fn candidate_validation_retry_internal_errors ( ) {
678+ let validation_data = PersistedValidationData { max_pov_size : 1024 , ..Default :: default ( ) } ;
679+
680+ let pov = PoV { block_data : BlockData ( vec ! [ 1 ; 32 ] ) } ;
681+ let validation_code = ValidationCode ( vec ! [ 2 ; 16 ] ) ;
682+
683+ let descriptor = make_valid_candidate_descriptor (
684+ ParaId :: from ( 1_u32 ) ,
685+ dummy_hash ( ) ,
686+ validation_data. hash ( ) ,
687+ pov. hash ( ) ,
688+ validation_code. hash ( ) ,
689+ dummy_hash ( ) ,
690+ dummy_hash ( ) ,
691+ Sr25519Keyring :: Alice ,
692+ ) ;
693+
694+ let check = perform_basic_checks (
695+ & descriptor,
696+ validation_data. max_pov_size ,
697+ & pov,
698+ & validation_code. hash ( ) ,
699+ ) ;
700+ assert ! ( check. is_ok( ) ) ;
701+
702+ let candidate_receipt = CandidateReceipt { descriptor, commitments_hash : Hash :: zero ( ) } ;
703+
704+ let pool = TaskExecutor :: new ( ) ;
705+ let ( mut ctx, ctx_handle) =
706+ test_helpers:: make_subsystem_context :: < AllMessages , _ > ( pool. clone ( ) ) ;
707+ let metrics = Metrics :: default ( ) ;
708+
709+ let v = test_with_executor_params ( ctx_handle, || {
710+ validate_candidate_exhaustive (
711+ ctx. sender ( ) ,
712+ MockValidateCandidateBackend :: with_hardcoded_result_list ( vec ! [
713+ Err ( ValidationError :: InternalError ( "foo" . into( ) ) ) ,
714+ // Throw an AWD error, we should still retry again.
715+ Err ( ValidationError :: InvalidCandidate ( WasmInvalidCandidate :: AmbiguousWorkerDeath ) ) ,
716+ // Throw another internal error.
717+ Err ( ValidationError :: InternalError ( "bar" . into( ) ) ) ,
718+ ] ) ,
719+ validation_data,
720+ validation_code,
721+ candidate_receipt,
722+ Arc :: new ( pov) ,
723+ PvfExecTimeoutKind :: Backing ,
724+ & metrics,
725+ )
726+ } ) ;
727+
728+ assert_matches ! ( v, Err ( ValidationFailed ( s) ) if s == "bar" . to_string( ) ) ;
729+ }
730+
675731#[ test]
676732fn candidate_validation_timeout_is_internal_error ( ) {
677733 let validation_data = PersistedValidationData { max_pov_size : 1024 , ..Default :: default ( ) } ;
0 commit comments