From 59633c7242d81e58197465c26419393083dd29ce Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Mon, 18 Nov 2024 11:34:37 +0100 Subject: [PATCH] chore: use Version::new over .parse (#220) --- crates/artifacts/solc/src/lib.rs | 14 ++++---------- crates/compilers/src/compilers/solc/mod.rs | 2 +- 2 files changed, 5 insertions(+), 11 deletions(-) diff --git a/crates/artifacts/solc/src/lib.rs b/crates/artifacts/solc/src/lib.rs index 218689c0..1ad80da2 100644 --- a/crates/artifacts/solc/src/lib.rs +++ b/crates/artifacts/solc/src/lib.rs @@ -2033,25 +2033,20 @@ mod tests { #[test] fn can_sanitize_byte_code_hash() { - let version: Version = "0.6.0".parse().unwrap(); - let settings = Settings { metadata: Some(BytecodeHash::Ipfs.into()), ..Default::default() }; let input = SolcInput { language: SolcLanguage::Solidity, sources: Default::default(), settings }; - let i = input.clone().sanitized(&version); + let i = input.clone().sanitized(&Version::new(0, 6, 0)); assert_eq!(i.settings.metadata.unwrap().bytecode_hash, Some(BytecodeHash::Ipfs)); - let version: Version = "0.5.17".parse().unwrap(); - let i = input.sanitized(&version); + let i = input.sanitized(&Version::new(0, 5, 17)); assert!(i.settings.metadata.unwrap().bytecode_hash.is_none()); } #[test] fn can_sanitize_cbor_metadata() { - let version: Version = "0.8.18".parse().unwrap(); - let settings = Settings { metadata: Some(SettingsMetadata::new(BytecodeHash::Ipfs, true)), ..Default::default() @@ -2060,7 +2055,7 @@ mod tests { let input = SolcInput { language: SolcLanguage::Solidity, sources: Default::default(), settings }; - let i = input.clone().sanitized(&version); + let i = input.clone().sanitized(&Version::new(0, 8, 18)); assert_eq!(i.settings.metadata.unwrap().cbor_metadata, Some(true)); let i = input.sanitized(&Version::new(0, 8, 0)); @@ -2233,13 +2228,12 @@ mod tests { // #[test] fn can_sanitize_optimizer_inliner() { - let version: Version = "0.8.4".parse().unwrap(); let settings = Settings::default().with_via_ir_minimum_optimization(); let input = SolcInput { language: SolcLanguage::Solidity, sources: Default::default(), settings }; - let i = input.clone().sanitized(&version); + let i = input.clone().sanitized(&Version::new(0, 8, 4)); assert!(i.settings.optimizer.details.unwrap().inliner.is_none()); let i = input.sanitized(&Version::new(0, 8, 5)); diff --git a/crates/compilers/src/compilers/solc/mod.rs b/crates/compilers/src/compilers/solc/mod.rs index 9de98e6a..d3aebcd6 100644 --- a/crates/compilers/src/compilers/solc/mod.rs +++ b/crates/compilers/src/compilers/solc/mod.rs @@ -459,7 +459,7 @@ mod tests { sources: Default::default(), }; - let v: Version = "0.8.12".parse().unwrap(); + let v = Version::new(0, 8, 12); let input = SolcVersionedInput::build( Default::default(), Default::default(),