fix(solc): strip .sol suffix (#1583)

This commit is contained in:
Matthias Seitz 2022-08-09 23:49:17 +02:00 committed by GitHub
parent 2f0dbad1fd
commit 47d3333195
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 3 deletions

View File

@ -185,6 +185,7 @@ impl<T: ArtifactOutput> TempProject<T> {
version: impl AsRef<str>, version: impl AsRef<str>,
) -> Result<PathBuf> { ) -> Result<PathBuf> {
let name = name.as_ref(); let name = name.as_ref();
let name = name.strip_suffix(".sol").unwrap_or(name);
self.add_lib( self.add_lib(
name, name,
format!( format!(
@ -213,6 +214,7 @@ contract {} {{}}
version: impl AsRef<str>, version: impl AsRef<str>,
) -> Result<PathBuf> { ) -> Result<PathBuf> {
let name = name.as_ref(); let name = name.as_ref();
let name = name.strip_suffix(".sol").unwrap_or(name);
self.add_source( self.add_source(
name, name,
format!( format!(

View File

@ -2150,14 +2150,15 @@ fn can_add_basic_contract_and_library() {
let src = project.add_basic_source("Foo.sol", "^0.8.0").unwrap(); let src = project.add_basic_source("Foo.sol", "^0.8.0").unwrap();
let lib = project.add_basic_source("Bar.sol", "^0.8.0").unwrap(); let lib = project.add_basic_source("Bar", "^0.8.0").unwrap();
let graph = Graph::resolve(project.paths()).unwrap(); let graph = Graph::resolve(project.paths()).unwrap();
assert_eq!(graph.files().len(), 2); assert_eq!(graph.files().len(), 2);
assert_eq!(graph.files().clone(), HashMap::from([(src, 0), (lib, 1),])); assert!(graph.files().contains_key(&src));
assert!(graph.files().contains_key(&lib));
let compiled = project.compile().unwrap(); let compiled = project.compile().unwrap();
assert!(!compiled.has_compiler_errors());
assert!(compiled.find_first("Foo").is_some()); assert!(compiled.find_first("Foo").is_some());
assert!(compiled.find_first("Bar").is_some()); assert!(compiled.find_first("Bar").is_some());
assert!(!compiled.has_compiler_errors());
} }