test(solc): ensure trigger rebuild on settings change (#1591)

This commit is contained in:
Matthias Seitz 2022-08-12 01:43:35 +02:00 committed by GitHub
parent 6f8dc93fc6
commit 1038349510
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 49 additions and 0 deletions

View File

@ -2138,6 +2138,55 @@ fn can_checkout_repo() {
let _artifacts = project.artifacts_snapshot().unwrap();
}
#[test]
fn can_detect_config_changes() {
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());
project
.add_source(
"Foo",
r#"
pragma solidity ^0.8.10;
import "remapping/Bar.sol";
contract Foo {}
"#,
)
.unwrap();
project
.add_lib(
"remapping/Bar",
r#"
pragma solidity ^0.8.10;
contract Bar {}
"#,
)
.unwrap();
let compiled = project.compile().unwrap();
assert!(!compiled.has_compiler_errors());
let cache = SolFilesCache::read(&project.paths().cache).unwrap();
assert_eq!(cache.files.len(), 2);
// nothing to compile
let compiled = project.compile().unwrap();
assert!(compiled.is_unchanged());
project.project_mut().solc_config.settings.optimizer.enabled = Some(true);
let compiled = project.compile().unwrap();
assert!(!compiled.has_compiler_errors());
assert!(!compiled.is_unchanged());
}
#[test]
fn can_add_basic_contract_and_library() {
let mut project = TempProject::<ConfigurableArtifacts>::dapptools().unwrap();