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

This commit is contained in:
derch28 2022-08-09 11:21:52 -05:00 committed by GitHub
parent 88844b1228
commit 64ac7d01ab
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 26 additions and 2 deletions

View File

@ -191,8 +191,8 @@ impl<T: ArtifactOutput> TempProject<T> {
pragma solidity {};
contract {} {{}}
"#,
version.as_ref(),
name,
version.as_ref()
),
)
}
@ -219,8 +219,8 @@ contract {} {{}}
pragma solidity {};
contract {} {{}}
"#,
version.as_ref(),
name,
version.as_ref()
),
)
}

View File

@ -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());
}