From 28df48b53067ecff277481af9eb3b29733b1b750 Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Fri, 18 Feb 2022 18:24:02 +0100 Subject: [PATCH] fix(solc): off by one error finding version intersection (#930) * fix: off by one error while finding intersection * test: enable test --- ethers-solc/src/compile/mod.rs | 3 ++- ethers-solc/src/resolver.rs | 2 +- ethers-solc/tests/project.rs | 3 --- 3 files changed, 3 insertions(+), 5 deletions(-) diff --git a/ethers-solc/src/compile/mod.rs b/ethers-solc/src/compile/mod.rs index 11fd3ad0..9841fcc6 100644 --- a/ethers-solc/src/compile/mod.rs +++ b/ethers-solc/src/compile/mod.rs @@ -79,7 +79,8 @@ pub static RELEASES: once_cell::sync::Lazy<(svm::Releases, Vec, bool)> /// A `Solc` version is either installed (available locally) or can be downloaded, from the remote /// endpoint -#[derive(Debug, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)] +#[derive(Debug, Clone, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)] +#[serde(untagged)] pub enum SolcVersion { Installed(Version), Remote(Version), diff --git a/ethers-solc/src/resolver.rs b/ethers-solc/src/resolver.rs index 1d9a515a..16bfbc34 100644 --- a/ethers-solc/src/resolver.rs +++ b/ethers-solc/src/resolver.rs @@ -476,7 +476,7 @@ impl Graph { } let mut result = sets.pop().cloned().expect("not empty; qed.").clone(); - if sets.len() > 1 { + if !sets.is_empty() { result.retain(|item| sets.iter().all(|set| set.contains(item))); } diff --git a/ethers-solc/tests/project.rs b/ethers-solc/tests/project.rs index ac8c01f7..c1afeb4f 100644 --- a/ethers-solc/tests/project.rs +++ b/ethers-solc/tests/project.rs @@ -24,7 +24,6 @@ fn init_tracing() { } #[test] -#[ignore] fn can_get_versioned_linkrefs() { let root = PathBuf::from(env!("CARGO_MANIFEST_DIR")).join("test-data/test-versioned-linkrefs"); let paths = ProjectPathsConfig::builder() @@ -37,8 +36,6 @@ fn can_get_versioned_linkrefs() { let compiled = project.compile().unwrap(); assert!(!compiled.has_compiler_errors()); - - // TODO: } #[test]