File tree Expand file tree Collapse file tree 1 file changed +12
-0
lines changed Expand file tree Collapse file tree 1 file changed +12
-0
lines changed Original file line number Diff line number Diff line change @@ -147,6 +147,11 @@ impl ContractsByArtifact {
147147    /// Finds a contract which deployed bytecode exactly matches the given code. Accounts for link 
148148/// references and immutables. 
149149pub  fn  find_by_deployed_code_exact ( & self ,  code :  & [ u8 ] )  -> Option < ArtifactWithContractRef < ' _ > >  { 
150+         // Immediately return None if the code is empty. 
151+         if  code. is_empty ( )  { 
152+             return  None ; 
153+         } 
154+ 
150155        self . iter ( ) . find ( |( _,  contract) | { 
151156            let  Some ( deployed_bytecode)  = & contract. deployed_bytecode  else  { 
152157                return  false ; 
@@ -403,4 +408,11 @@ mod tests {
403408        let  a_99 = & b"a" . repeat ( 99 ) [ ..] ; 
404409        assert ! ( bytecode_diff_score( a_100,  a_99)  <= 0.01 ) ; 
405410    } 
411+ 
412+     #[ test]  
413+     fn  find_by_deployed_code_exact_with_empty_deployed ( )  { 
414+         let  contracts = ContractsByArtifact :: new ( vec ! [ ] ) ; 
415+ 
416+         assert ! ( contracts. find_by_deployed_code_exact( & [ ] ) . is_none( ) ) ; 
417+     } 
406418} 
 
 
   
 
     
   
   
          
    
    
     
    
      
     
     
    You can’t perform that action at this time.
  
 
    
  
    
      
        
     
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments