Skip to content
This repository has been archived by the owner on Oct 19, 2024. It is now read-only.

solc: fix bug in basic lib and basic contract generation #1580

Merged
merged 1 commit into from
Aug 9, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions ethers-solc/src/project_util/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -191,8 +191,8 @@ impl<T: ArtifactOutput> TempProject<T> {
pragma solidity {};
contract {} {{}}
"#,
version.as_ref(),
name,
version.as_ref()
),
)
}
Expand All @@ -219,8 +219,8 @@ contract {} {{}}
pragma solidity {};
contract {} {{}}
"#,
version.as_ref(),
name,
version.as_ref()
),
)
}
Expand Down
24 changes: 24 additions & 0 deletions ethers-solc/tests/project.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2128,3 +2128,27 @@ fn can_handle_conflicting_files() {
]
);
}

#[test]
fn can_add_basic_contract_and_library() {
let mut project = TempProject::<ConfigurableArtifacts>::dapptools().unwrap();

let remapping = project.paths().libraries[0].join("remapping");
project
.paths_mut()
.remappings
.push(Remapping::from_str(&format!("remapping/={}/", remapping.display())).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 graph = Graph::resolve(project.paths()).unwrap();
assert_eq!(graph.files().len(), 2);
assert_eq!(graph.files().clone(), HashMap::from([(src, 0), (lib, 1),]));

let compiled = project.compile().unwrap();
assert!(compiled.find_first("Foo").is_some());
assert!(compiled.find_first("Bar").is_some());
assert!(!compiled.has_compiler_errors());
}