@@ -510,6 +510,41 @@ fn opted_in_epoch_configuration_and_interrupt_conflict_keep_legacy_rules() {
510510 assert_eq ! ( observations. lock( ) . unwrap( ) . calls, 1 ) ;
511511}
512512
513+ #[ test]
514+ fn malformed_vmbc_keeps_wire_error_type_in_all_ordinary_cli_routes ( ) {
515+ let scratch = Scratch :: new ( ) ;
516+ let path = scratch. 0 . join ( "malformed.vmbc" ) ;
517+ std:: fs:: write ( & path, b"invalid VMBC bytes" ) . unwrap ( ) ;
518+ let expected = crate :: decode_program ( & std:: fs:: read ( & path) . unwrap ( ) )
519+ . unwrap_err ( )
520+ . to_string ( ) ;
521+ for selected in [
522+ CliHostServices :: default ( ) ,
523+ CliHostServices :: default ( ) . with_capture_certification ( ) ,
524+ services ( Arc :: new ( Mutex :: new ( Observations :: default ( ) ) ) ) ,
525+ services ( Arc :: new ( Mutex :: new ( Observations :: default ( ) ) ) ) . with_capture_certification ( ) ,
526+ ] {
527+ for emit in [ false , true ] {
528+ let mut args = Vec :: new ( ) ;
529+ if emit {
530+ args. extend ( [
531+ "--emit-vmbc" . to_owned ( ) ,
532+ scratch. 0 . join ( "rejected.vmbc" ) . display ( ) . to_string ( ) ,
533+ ] ) ;
534+ }
535+ args. push ( path. display ( ) . to_string ( ) ) ;
536+ let error = run_with_args ( & CliRuntime :: default ( ) , & args, & selected) . unwrap_err ( ) ;
537+ assert_eq ! ( error. to_string( ) , expected) ;
538+ assert ! (
539+ error. downcast_ref:: <crate :: WireError >( ) . is_some( ) ,
540+ "WireError was wrapped: {error:?}"
541+ ) ;
542+ assert ! ( error. downcast_ref:: <io:: Error >( ) . is_none( ) ) ;
543+ assert ! ( !scratch. 0 . join( "rejected.vmbc" ) . exists( ) ) ;
544+ }
545+ }
546+ }
547+
513548#[ test]
514549fn default_services_remain_uncertified_with_actual_owner_candidate ( ) {
515550 let scratch = Scratch :: new ( ) ;
0 commit comments