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

Commit

Permalink
solc: fix bug in basic lib and basic contract generation (#1580)
Browse files Browse the repository at this point in the history
  • Loading branch information
danielrachi1 authored Aug 9, 2022
1 parent 88844b1 commit 64ac7d0
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 2 deletions.
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());
}

0 comments on commit 64ac7d0

Please sign in to comment.