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

Commit 1038349

Browse files
authored
test(solc): ensure trigger rebuild on settings change (#1591)
1 parent 6f8dc93 commit 1038349

File tree

1 file changed

+49
-0
lines changed

1 file changed

+49
-0
lines changed

Diff for: ethers-solc/tests/project.rs

+49
Original file line numberDiff line numberDiff line change
@@ -2138,6 +2138,55 @@ fn can_checkout_repo() {
21382138
let _artifacts = project.artifacts_snapshot().unwrap();
21392139
}
21402140

2141+
#[test]
2142+
fn can_detect_config_changes() {
2143+
let mut project = TempProject::<ConfigurableArtifacts>::dapptools().unwrap();
2144+
2145+
let remapping = project.paths().libraries[0].join("remapping");
2146+
project
2147+
.paths_mut()
2148+
.remappings
2149+
.push(Remapping::from_str(&format!("remapping/={}/", remapping.display())).unwrap());
2150+
2151+
project
2152+
.add_source(
2153+
"Foo",
2154+
r#"
2155+
pragma solidity ^0.8.10;
2156+
import "remapping/Bar.sol";
2157+
2158+
contract Foo {}
2159+
"#,
2160+
)
2161+
.unwrap();
2162+
project
2163+
.add_lib(
2164+
"remapping/Bar",
2165+
r#"
2166+
pragma solidity ^0.8.10;
2167+
2168+
contract Bar {}
2169+
"#,
2170+
)
2171+
.unwrap();
2172+
2173+
let compiled = project.compile().unwrap();
2174+
assert!(!compiled.has_compiler_errors());
2175+
2176+
let cache = SolFilesCache::read(&project.paths().cache).unwrap();
2177+
assert_eq!(cache.files.len(), 2);
2178+
2179+
// nothing to compile
2180+
let compiled = project.compile().unwrap();
2181+
assert!(compiled.is_unchanged());
2182+
2183+
project.project_mut().solc_config.settings.optimizer.enabled = Some(true);
2184+
2185+
let compiled = project.compile().unwrap();
2186+
assert!(!compiled.has_compiler_errors());
2187+
assert!(!compiled.is_unchanged());
2188+
}
2189+
21412190
#[test]
21422191
fn can_add_basic_contract_and_library() {
21432192
let mut project = TempProject::<ConfigurableArtifacts>::dapptools().unwrap();

0 commit comments

Comments
 (0)