mirror of
https://github.com/pezkuwichain/revive-differential-tests.git
synced 2026-04-26 03:58:00 +00:00
Compile all contracts for a test file
This commit is contained in:
@@ -69,14 +69,27 @@ where
|
||||
anyhow::bail!("unsupported solc version: {:?}", &mode.solc_version);
|
||||
};
|
||||
|
||||
let mut compiler = Compiler::<T::Compiler>::new()
|
||||
let compiler = Compiler::<T::Compiler>::new()
|
||||
.base_path(metadata.directory()?.display().to_string())
|
||||
.allow_path(metadata.directory()?.display().to_string())
|
||||
.solc_optimizer(mode.solc_optimize());
|
||||
|
||||
for (file, _contract) in metadata.contract_sources()?.values() {
|
||||
tracing::debug!("contract source {}", file.display());
|
||||
compiler = compiler.with_source(file)?;
|
||||
}
|
||||
let compiler = std::fs::read_dir(metadata.directory()?)?
|
||||
.flat_map(|entry| match entry {
|
||||
Ok(entry) => {
|
||||
if entry
|
||||
.path()
|
||||
.extension()
|
||||
.is_some_and(|ext| ext.eq_ignore_ascii_case("sol"))
|
||||
{
|
||||
Some(entry.path())
|
||||
} else {
|
||||
None
|
||||
}
|
||||
}
|
||||
Err(_) => None,
|
||||
})
|
||||
.try_fold(compiler, |compiler, path| compiler.with_source(&path))?;
|
||||
|
||||
let mut task = CompilationTask {
|
||||
json_input: compiler.input(),
|
||||
@@ -180,12 +193,15 @@ where
|
||||
}
|
||||
|
||||
pub fn deploy_contracts(&mut self, input: &Input, node: &T::Blockchain) -> anyhow::Result<()> {
|
||||
tracing::debug!(
|
||||
"Deploying contracts {}, having address {} on node: {}",
|
||||
&input.instance,
|
||||
&input.caller,
|
||||
std::any::type_name::<T>()
|
||||
let tracing_span = tracing::debug_span!(
|
||||
"Deploying contracts",
|
||||
?input,
|
||||
node = std::any::type_name::<T>()
|
||||
);
|
||||
let _guard = tracing_span.enter();
|
||||
|
||||
tracing::debug!(number_of_contracts_to_deploy = self.contracts.len());
|
||||
|
||||
for output in self.contracts.values() {
|
||||
let Some(contract_map) = &output.contracts else {
|
||||
tracing::debug!(
|
||||
|
||||
@@ -123,9 +123,14 @@ impl Input {
|
||||
return Ok(Bytes::default()); // fallback or deployer — no input
|
||||
};
|
||||
|
||||
let abi = deployed_abis
|
||||
.get(&self.instance)
|
||||
.ok_or_else(|| anyhow::anyhow!("ABI for instance '{}' not found", &self.instance))?;
|
||||
let Some(abi) = deployed_abis.get(&self.instance) else {
|
||||
tracing::error!(
|
||||
contract_name = self.instance,
|
||||
available_abis = ?deployed_abis.keys().collect::<Vec<_>>(),
|
||||
"Attempted to lookup ABI of contract but it wasn't found"
|
||||
);
|
||||
anyhow::bail!("ABI for instance '{}' not found", &self.instance);
|
||||
};
|
||||
|
||||
tracing::trace!("ABI found for instance: {}", &self.instance);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user