From 4ad929d56ec9aab924a2b7d3485822b32da3f26b Mon Sep 17 00:00:00 2001 From: Giovanni_Torrisi_ChainSecurity Date: Thu, 5 Jun 2025 16:40:51 +0200 Subject: [PATCH 01/11] Fix assert_eq_files --- tests/test_end_to_end.rs | 35 +++++++++++++++++++---------------- 1 file changed, 19 insertions(+), 16 deletions(-) diff --git a/tests/test_end_to_end.rs b/tests/test_end_to_end.rs index 0f84a922..905884ee 100644 --- a/tests/test_end_to_end.rs +++ b/tests/test_end_to_end.rs @@ -227,26 +227,29 @@ mod tests { let line2 = line2?; // Code hashes and deployment txs can be different + if line1.contains("\"codehash\"") || line1.contains("\"deployment_tx\"") { + continue; + } - if !line1.contains("\"codehash\"") && !line1.contains("\"deployment_tx\"") { - // Chain ID is different for geth - if LocalClientType::Geth == l - && !(line1.contains("\"chain_id\":") - || line1.contains("\"deployment_block_num\":")) - { - // don't compare codehash to avoid metadata mis-matches - assert_eq!( - line1, - line2, - "Line {}: \nFile1: {}\nFile2: {}", - line_number + 1, - line1, - line2 - ); - } + // Chain ID and deployment block are different for geth + if LocalClientType::Geth == l + && (line1.contains("\"chain_id\":") || line1.contains("\"deployment_block_num\":")) + { + continue; } + + // Otherwise, the lines should be identical + assert_eq!( + line1, + line2, + "Line {}: \nFile1: {}\nFile2: {}", + line_number + 1, + line1, + line2 + ); } + // Check that the number of lines is the same let reader1 = BufReader::new(file1); let reader2 = BufReader::new(file2); From ff7e6d1e86533bba79c9a4ce715a3e49b860c451 Mon Sep 17 00:00:00 2001 From: Giovanni_Torrisi_ChainSecurity Date: Thu, 5 Jun 2025 18:38:32 +0200 Subject: [PATCH 02/11] Implement DVF object and file comparison --- lib/dvf/parse.rs | 24 ++++++++++ tests/test_end_to_end.rs | 94 +++++----------------------------------- 2 files changed, 36 insertions(+), 82 deletions(-) diff --git a/lib/dvf/parse.rs b/lib/dvf/parse.rs index 9f0d32b1..e83d0a3c 100644 --- a/lib/dvf/parse.rs +++ b/lib/dvf/parse.rs @@ -671,4 +671,28 @@ impl CompleteDVF { fn get_version(&self) -> &Version { &self.version } + + pub fn equals(&self, other: &Self, ignore_testing_chain: bool) -> bool { + let mut json1 = serde_json::to_value(self).expect("Serialization failed"); + let mut json2 = serde_json::to_value(other).expect("Serialization failed"); + + // Keys to always ignore + let mut ignored_keys = vec!["id", "codehash", "deployment_tx"]; + + if ignore_testing_chain { + ignored_keys.extend(&["chain_id", "deployment_block_num"]); + } + + for key in ignored_keys { + json1.as_object_mut().unwrap().remove(key); + json2.as_object_mut().unwrap().remove(key); + } + + // After removing ignored keys, ensure number of keys matches + if json1.as_object().iter().len() != json2.as_object().iter().len() { + return false; + } + + json1 == json2 + } } diff --git a/tests/test_end_to_end.rs b/tests/test_end_to_end.rs index 905884ee..f623983d 100644 --- a/tests/test_end_to_end.rs +++ b/tests/test_end_to_end.rs @@ -9,7 +9,6 @@ mod tests { use std::fs::File; use std::fs::OpenOptions; use std::io::{self, Write}; - use std::io::{BufRead, BufReader}; use std::panic; use std::path::Path; use std::process::{Child, Command as SimpleCommand, Stdio}; @@ -215,49 +214,13 @@ mod tests { } } - fn assert_eq_files>(path1: P, path2: P, l: LocalClientType) -> io::Result<()> { - let file1 = File::open(path1)?; - let file2 = File::open(path2)?; + fn assert_eq_files>(path1: P, path2: P) -> io::Result<()> { + let dvf1 = + CompleteDVF::from_path(path1.as_ref()).expect("File1 cannot be parsed into a DVF"); + let dvf2 = + CompleteDVF::from_path(path2.as_ref()).expect("File2 cannot be parsed into a DVF"); - let reader1 = BufReader::new(&file1); - let reader2 = BufReader::new(&file2); - - for (line_number, (line1, line2)) in reader1.lines().zip(reader2.lines()).enumerate() { - let line1 = line1?; - let line2 = line2?; - - // Code hashes and deployment txs can be different - if line1.contains("\"codehash\"") || line1.contains("\"deployment_tx\"") { - continue; - } - - // Chain ID and deployment block are different for geth - if LocalClientType::Geth == l - && (line1.contains("\"chain_id\":") || line1.contains("\"deployment_block_num\":")) - { - continue; - } - - // Otherwise, the lines should be identical - assert_eq!( - line1, - line2, - "Line {}: \nFile1: {}\nFile2: {}", - line_number + 1, - line1, - line2 - ); - } - - // Check that the number of lines is the same - let reader1 = BufReader::new(file1); - let reader2 = BufReader::new(file2); - - assert_eq!( - reader1.lines().count(), - reader2.lines().count(), - "Differently many lines." - ); + assert!(dvf1.equals(&dvf2, true), "DVF files do not match"); Ok(()) } @@ -400,12 +363,7 @@ mod tests { // Uncomment to regenerate expected files // std::fs::copy(outfile.path(), Path::new(&testcase.expected)).unwrap(); - assert_eq_files( - &outfile.path(), - &Path::new(&testcase.expected), - client_type.clone(), - ) - .unwrap(); + assert_eq_files(&outfile.path(), &Path::new(&testcase.expected)).unwrap(); // Sign let mut dvf_cmd = Command::cargo_bin("dv").unwrap(); @@ -455,12 +413,7 @@ mod tests { // Uncomment to regenerate expected files // std::fs::copy(Path::new(&updated_path), Path::new(&testcase.updated)).unwrap(); - assert_eq_files( - &Path::new(&updated_path), - &Path::new(&testcase.updated), - client_type.clone(), - ) - .unwrap(); + assert_eq_files(&Path::new(&updated_path), &Path::new(&testcase.updated)).unwrap(); // Sign let mut dvf_cmd = Command::cargo_bin("dv").unwrap(); @@ -565,7 +518,6 @@ mod tests { assert_eq_files( &factory_outfile.path(), &Path::new("tests/expected_dvfs/PullPayment.dvf.json"), - client_type.clone(), ) .unwrap(); @@ -665,7 +617,6 @@ mod tests { assert_eq_files( &outfile.path(), &Path::new("tests/expected_dvfs/MyToken.dvf.json"), - client_type.clone(), ) .unwrap(); @@ -727,7 +678,6 @@ mod tests { assert_eq_files( &proxy_outfile.path(), &Path::new("tests/expected_dvfs/TransparentUpgradeableProxy.dvf.json"), - client_type.clone(), ) .unwrap(); @@ -900,12 +850,7 @@ mod tests { // Uncomment to regenerate expected files // std::fs::copy(outfile.path(), Path::new(&testcase.expected)).unwrap(); - assert_eq_files( - &outfile.path(), - &Path::new(&testcase.expected), - client_type.clone(), - ) - .unwrap(); + assert_eq_files(&outfile.path(), &Path::new(&testcase.expected)).unwrap(); // Sign let mut dvf_cmd = Command::cargo_bin("dv").unwrap(); @@ -1173,12 +1118,7 @@ mod tests { // Uncomment to regenerate expected files // std::fs::copy(child_outfile.path(), Path::new(new_fname)).unwrap(); - assert_eq_files( - &child_outfile.path(), - &Path::new(new_fname), - client_type.clone(), - ) - .unwrap(); + assert_eq_files(&child_outfile.path(), &Path::new(new_fname)).unwrap(); // Sign let mut dvf_cmd = Command::cargo_bin("dv").unwrap(); @@ -1290,12 +1230,7 @@ mod tests { // Uncomment to regenerate expected files // std::fs::copy(factory_outfile.path(), Path::new(dvf_path)).unwrap(); - assert_eq_files( - &factory_outfile.path(), - &Path::new(dvf_path), - client_type.clone(), - ) - .unwrap(); + assert_eq_files(&factory_outfile.path(), &Path::new(dvf_path)).unwrap(); // Sign let mut dvf_cmd = Command::cargo_bin("dv").unwrap(); @@ -1598,12 +1533,7 @@ mod tests { // Uncomment to regenerate expected files // std::fs::copy(outfile.path(), Path::new(&testcase.expected)).unwrap(); - assert_eq_files( - &outfile.path(), - &Path::new(&testcase.expected), - client_type.clone(), - ) - .unwrap(); + assert_eq_files(&outfile.path(), &Path::new(&testcase.expected)).unwrap(); drop(local_client); // this will kill the instance } From d02d566c2688caa593f073d09d13c20e616a02c7 Mon Sep 17 00:00:00 2001 From: Giovanni_Torrisi_ChainSecurity Date: Fri, 6 Jun 2025 11:27:10 +0200 Subject: [PATCH 03/11] Print DVFs differences on failed comparisons --- lib/dvf/parse.rs | 32 ++++++++++++++++++++++++++++++-- tests/test_end_to_end.rs | 7 ++++++- 2 files changed, 36 insertions(+), 3 deletions(-) diff --git a/lib/dvf/parse.rs b/lib/dvf/parse.rs index e83d0a3c..59f60360 100644 --- a/lib/dvf/parse.rs +++ b/lib/dvf/parse.rs @@ -677,7 +677,7 @@ impl CompleteDVF { let mut json2 = serde_json::to_value(other).expect("Serialization failed"); // Keys to always ignore - let mut ignored_keys = vec!["id", "codehash", "deployment_tx"]; + let mut ignored_keys = vec!["id", "codehash", "deployment_tx", "unvalidated_metadata"]; if ignore_testing_chain { ignored_keys.extend(&["chain_id", "deployment_block_num"]); @@ -690,9 +690,37 @@ impl CompleteDVF { // After removing ignored keys, ensure number of keys matches if json1.as_object().iter().len() != json2.as_object().iter().len() { + println!("DVF number of keys do not match"); return false; } - json1 == json2 + let json1_obj = json1.as_object().unwrap(); + let json2_obj = json2.as_object().unwrap(); + + let mut differences = Vec::new(); + + for (key, value1) in json1_obj { + if let Some(value2) = json2_obj.get(key) { + if value1 != value2 { + // Key of json1 found in json2, but value differ + differences.push((key, value1.clone(), value2.clone())); + break; + } + } else { + // Key of json1 not found in json2 + differences.push((key, value1.clone(), Value::Null)); + break; + } + } + + if !differences.is_empty() { + println!("DVFs differ!"); + for (key, value1, value2) in differences { + println!("Key: {}\nValue1: {:?}\nValue2: {:?}", key, value1, value2); + } + return false; + } + + true } } diff --git a/tests/test_end_to_end.rs b/tests/test_end_to_end.rs index f623983d..857fa6fe 100644 --- a/tests/test_end_to_end.rs +++ b/tests/test_end_to_end.rs @@ -220,7 +220,12 @@ mod tests { let dvf2 = CompleteDVF::from_path(path2.as_ref()).expect("File2 cannot be parsed into a DVF"); - assert!(dvf1.equals(&dvf2, true), "DVF files do not match"); + assert!( + dvf1.equals(&dvf2, true), + "DVF {:?} does not match DVF {:?}", + path1.as_ref(), + path2.as_ref() + ); Ok(()) } From 71f4706a57b5546516e21d1566c49387363dfe19 Mon Sep 17 00:00:00 2001 From: Hubert Ritzdorf Date: Fri, 6 Jun 2025 14:07:42 +0200 Subject: [PATCH 04/11] Fix Tests, make sure block numbers are consistent --- lib/web3.rs | 8 ++------ tests/test_end_to_end.rs | 16 ++++++++++++++++ 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/lib/web3.rs b/lib/web3.rs index 73ad22d9..fbd212c7 100644 --- a/lib/web3.rs +++ b/lib/web3.rs @@ -747,13 +747,9 @@ pub fn get_deployment( Box::new(move || { let config = unsafe { &*config_ptr }; let address = unsafe { &*address_ptr }; - debug!("No deployment tx found in etherscan or blockscout, searching traces. "); let current_block_num = get_eth_block_number(config)?; - let start_block_num = if current_block_num > 10 { - get_deployment_block_from_binary_search(config, address, current_block_num)? - } else { - 1 - }; + let start_block_num = get_deployment_block_from_binary_search(config, address, current_block_num).map_or(1, |v| v); + debug!("No deployment tx found in etherscan or blockscout, searching traces from {start_block_num}."); match get_deployment_from_parity_trace( config, address, diff --git a/tests/test_end_to_end.rs b/tests/test_end_to_end.rs index 857fa6fe..a08eb56d 100644 --- a/tests/test_end_to_end.rs +++ b/tests/test_end_to_end.rs @@ -92,6 +92,22 @@ mod tests { println!("Waiting for anvil config: {:?}", e); sleep(Duration::from_millis(100)); } + // Waste one block to be consistent with geth + // forge script script/WasteBlock.s.sol --rpc-url "http://127.0.0.1:8546" --broadcast --slow + let mut forge_cmd = Command::new("forge"); + forge_cmd.current_dir("tests/Contracts"); + forge_cmd + .args(&[ + "script", + "script/Waste1Block.s.sol", + "--rpc-url", + &anvil.endpoint(), + "--broadcast", + "--slow", + ]) + .assert() + .success(); + LocalClient::Anvil(anvil) } _ => { From 2d8ef2cff95326e40c3057a6addfe45f5e2eace0 Mon Sep 17 00:00:00 2001 From: Hubert Ritzdorf Date: Fri, 6 Jun 2025 14:09:10 +0200 Subject: [PATCH 05/11] fmt --- lib/web3.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/web3.rs b/lib/web3.rs index fbd212c7..a07b04e9 100644 --- a/lib/web3.rs +++ b/lib/web3.rs @@ -748,7 +748,9 @@ pub fn get_deployment( let config = unsafe { &*config_ptr }; let address = unsafe { &*address_ptr }; let current_block_num = get_eth_block_number(config)?; - let start_block_num = get_deployment_block_from_binary_search(config, address, current_block_num).map_or(1, |v| v); + let start_block_num = + get_deployment_block_from_binary_search(config, address, current_block_num) + .map_or(1, |v| v); debug!("No deployment tx found in etherscan or blockscout, searching traces from {start_block_num}."); match get_deployment_from_parity_trace( config, From d4cd0526a6c5f8c134c1172c39a9223b5ff7f6e3 Mon Sep 17 00:00:00 2001 From: Hubert Ritzdorf Date: Fri, 6 Jun 2025 14:34:31 +0200 Subject: [PATCH 06/11] Forgot to add the new file --- tests/Contracts/script/Waste1Block.s.sol | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 tests/Contracts/script/Waste1Block.s.sol diff --git a/tests/Contracts/script/Waste1Block.s.sol b/tests/Contracts/script/Waste1Block.s.sol new file mode 100644 index 00000000..29a8ff18 --- /dev/null +++ b/tests/Contracts/script/Waste1Block.s.sol @@ -0,0 +1,20 @@ +pragma solidity ^0.8.12; + +import "forge-std/Script.sol"; +import "../src/BytesMapping.sol"; + +contract S is Script { + uint256 x; + uint256 y; + + function run() external { + uint256 anvilSecondKey = 0x59c6995e998f97a5a0044966f0945389dc9e86dae88c7a8412f4603b6b78690d; + //uint256 ganacheDefaultKey = 0x0cc0c2de7e8c30525b4ca3b9e0b9703fb29569060d403261055481df7014f7fa; + vm.startBroadcast(anvilSecondKey); + address payable recipient = payable(0x1234567890AbcdEF1234567890aBcdef12345678); + + // Send exactly 1 wei + (bool success, ) = recipient.call{ value: 1 wei }(""); + vm.stopBroadcast(); + } +} From 5fcab02042e5cba72a894b8076da9fc3077c1a9b Mon Sep 17 00:00:00 2001 From: Hubert Ritzdorf Date: Fri, 6 Jun 2025 14:38:36 +0200 Subject: [PATCH 07/11] More precise difference --- lib/dvf/parse.rs | 96 ++++++++++++++++++++++++++++------------ tests/test_end_to_end.rs | 2 +- 2 files changed, 68 insertions(+), 30 deletions(-) diff --git a/lib/dvf/parse.rs b/lib/dvf/parse.rs index 59f60360..dcc37aeb 100644 --- a/lib/dvf/parse.rs +++ b/lib/dvf/parse.rs @@ -1,3 +1,4 @@ +use std::collections::HashSet; use std::env::VarError; use std::fmt; use std::fs::File; @@ -672,15 +673,15 @@ impl CompleteDVF { &self.version } - pub fn equals(&self, other: &Self, ignore_testing_chain: bool) -> bool { + pub fn critical_fields_equal(&self, other: &Self, ignore_chain_id: bool) -> bool { let mut json1 = serde_json::to_value(self).expect("Serialization failed"); let mut json2 = serde_json::to_value(other).expect("Serialization failed"); // Keys to always ignore - let mut ignored_keys = vec!["id", "codehash", "deployment_tx", "unvalidated_metadata"]; + let mut ignored_keys = vec!["id", "deployment_tx", "unvalidated_metadata"]; - if ignore_testing_chain { - ignored_keys.extend(&["chain_id", "deployment_block_num"]); + if ignore_chain_id { + ignored_keys.extend(&["chain_id"]); } for key in ignored_keys { @@ -688,39 +689,76 @@ impl CompleteDVF { json2.as_object_mut().unwrap().remove(key); } - // After removing ignored keys, ensure number of keys matches - if json1.as_object().iter().len() != json2.as_object().iter().len() { - println!("DVF number of keys do not match"); - return false; - } + let has_diff = diff_json(&json1, &json2, "dvf".to_string()); + + !has_diff + } +} - let json1_obj = json1.as_object().unwrap(); - let json2_obj = json2.as_object().unwrap(); +// Returns true when there is a difference +fn diff_json(v1: &Value, v2: &Value, path: String) -> bool { + let mut has_diff = false; - let mut differences = Vec::new(); + match (v1, v2) { + (Value::Object(map1), Value::Object(map2)) => { + // Compare the keys of both objects + let keys1: HashSet<_> = map1.keys().collect(); + let keys2: HashSet<_> = map2.keys().collect(); + + // Find keys that are in one object but not the other + let diff_keys1 = keys1.difference(&keys2); + let diff_keys2 = keys2.difference(&keys1); + + for key in diff_keys1 { + println!( + "Different key at {}: key present in first but not second: {}", + path, key + ); + has_diff = true; + } + for key in diff_keys2 { + println!( + "Different key at {}: key present in second but not first: {}", + path, key + ); + has_diff = true; + } - for (key, value1) in json1_obj { - if let Some(value2) = json2_obj.get(key) { - if value1 != value2 { - // Key of json1 found in json2, but value differ - differences.push((key, value1.clone(), value2.clone())); - break; + // Recursively compare the values associated with each key + for key in keys1.intersection(&keys2) { + if diff_json(&map1[*key], &map2[*key], format!("{}/{}", path, key)) { + has_diff = true; } - } else { - // Key of json1 not found in json2 - differences.push((key, value1.clone(), Value::Null)); - break; } } + (Value::Array(arr1), Value::Array(arr2)) => { + // Compare the lengths of both arrays + if arr1.len() != arr2.len() { + println!( + "Different array lengths at {}: {} != {}", + path, + arr1.len(), + arr2.len() + ); + has_diff = true; + } - if !differences.is_empty() { - println!("DVFs differ!"); - for (key, value1, value2) in differences { - println!("Key: {}\nValue1: {:?}\nValue2: {:?}", key, value1, value2); + // Compare each element in the array + for (i, (e1, e2)) in arr1.iter().zip(arr2.iter()).enumerate() { + if diff_json(e1, e2, format!("{}/{}", path, i)) { + has_diff = true; + } + } + } + _ => { + // If values are different, print the difference and return true + if v1 != v2 { + println!("Difference at {}: {} != {}", path, v1, v2); + has_diff = true; } - return false; } - - true } + + // Return true if any difference is found, else false + has_diff } diff --git a/tests/test_end_to_end.rs b/tests/test_end_to_end.rs index a08eb56d..0f8cfb57 100644 --- a/tests/test_end_to_end.rs +++ b/tests/test_end_to_end.rs @@ -237,7 +237,7 @@ mod tests { CompleteDVF::from_path(path2.as_ref()).expect("File2 cannot be parsed into a DVF"); assert!( - dvf1.equals(&dvf2, true), + dvf1.critical_fields_equal(&dvf2, true), "DVF {:?} does not match DVF {:?}", path1.as_ref(), path2.as_ref() From 052b857dfa3bb43e6f5b10e8e476052adbd07b05 Mon Sep 17 00:00:00 2001 From: Hubert Ritzdorf Date: Fri, 6 Jun 2025 14:47:36 +0200 Subject: [PATCH 08/11] add a negative test and remove useless return --- tests/test_end_to_end.rs | 35 +++++++++++++++++++---------------- 1 file changed, 19 insertions(+), 16 deletions(-) diff --git a/tests/test_end_to_end.rs b/tests/test_end_to_end.rs index 0f8cfb57..c623d61d 100644 --- a/tests/test_end_to_end.rs +++ b/tests/test_end_to_end.rs @@ -8,7 +8,7 @@ mod tests { use std::fs::metadata; use std::fs::File; use std::fs::OpenOptions; - use std::io::{self, Write}; + use std::io::Write; use std::panic; use std::path::Path; use std::process::{Child, Command as SimpleCommand, Stdio}; @@ -230,7 +230,15 @@ mod tests { } } - fn assert_eq_files>(path1: P, path2: P) -> io::Result<()> { + #[test] + #[should_panic] + fn test_file_diff() { + let p1 = &Path::new("tests/expected_dvfs/Deploy_0_b1.dvf.json"); + let p2 = &Path::new("tests/expected_dvfs/Deploy_0_updated.dvf.json"); + assert_eq_files(p1, p2); + } + + fn assert_eq_files>(path1: P, path2: P) { let dvf1 = CompleteDVF::from_path(path1.as_ref()).expect("File1 cannot be parsed into a DVF"); let dvf2 = @@ -242,8 +250,6 @@ mod tests { path1.as_ref(), path2.as_ref() ); - - Ok(()) } #[test] @@ -384,7 +390,7 @@ mod tests { // Uncomment to regenerate expected files // std::fs::copy(outfile.path(), Path::new(&testcase.expected)).unwrap(); - assert_eq_files(&outfile.path(), &Path::new(&testcase.expected)).unwrap(); + assert_eq_files(&outfile.path(), &Path::new(&testcase.expected)); // Sign let mut dvf_cmd = Command::cargo_bin("dv").unwrap(); @@ -434,7 +440,7 @@ mod tests { // Uncomment to regenerate expected files // std::fs::copy(Path::new(&updated_path), Path::new(&testcase.updated)).unwrap(); - assert_eq_files(&Path::new(&updated_path), &Path::new(&testcase.updated)).unwrap(); + assert_eq_files(&Path::new(&updated_path), &Path::new(&testcase.updated)); // Sign let mut dvf_cmd = Command::cargo_bin("dv").unwrap(); @@ -539,8 +545,7 @@ mod tests { assert_eq_files( &factory_outfile.path(), &Path::new("tests/expected_dvfs/PullPayment.dvf.json"), - ) - .unwrap(); + ); // Sign let mut dvf_cmd = Command::cargo_bin("dv").unwrap(); @@ -638,8 +643,7 @@ mod tests { assert_eq_files( &outfile.path(), &Path::new("tests/expected_dvfs/MyToken.dvf.json"), - ) - .unwrap(); + ); // Sign let mut dvf_cmd = Command::cargo_bin("dv").unwrap(); @@ -699,8 +703,7 @@ mod tests { assert_eq_files( &proxy_outfile.path(), &Path::new("tests/expected_dvfs/TransparentUpgradeableProxy.dvf.json"), - ) - .unwrap(); + ); let mut dvf_cmd = Command::cargo_bin("dv").unwrap(); dvf_cmd @@ -871,7 +874,7 @@ mod tests { // Uncomment to regenerate expected files // std::fs::copy(outfile.path(), Path::new(&testcase.expected)).unwrap(); - assert_eq_files(&outfile.path(), &Path::new(&testcase.expected)).unwrap(); + assert_eq_files(&outfile.path(), &Path::new(&testcase.expected)); // Sign let mut dvf_cmd = Command::cargo_bin("dv").unwrap(); @@ -1139,7 +1142,7 @@ mod tests { // Uncomment to regenerate expected files // std::fs::copy(child_outfile.path(), Path::new(new_fname)).unwrap(); - assert_eq_files(&child_outfile.path(), &Path::new(new_fname)).unwrap(); + assert_eq_files(&child_outfile.path(), &Path::new(new_fname)); // Sign let mut dvf_cmd = Command::cargo_bin("dv").unwrap(); @@ -1251,7 +1254,7 @@ mod tests { // Uncomment to regenerate expected files // std::fs::copy(factory_outfile.path(), Path::new(dvf_path)).unwrap(); - assert_eq_files(&factory_outfile.path(), &Path::new(dvf_path)).unwrap(); + assert_eq_files(&factory_outfile.path(), &Path::new(dvf_path)); // Sign let mut dvf_cmd = Command::cargo_bin("dv").unwrap(); @@ -1554,7 +1557,7 @@ mod tests { // Uncomment to regenerate expected files // std::fs::copy(outfile.path(), Path::new(&testcase.expected)).unwrap(); - assert_eq_files(&outfile.path(), &Path::new(&testcase.expected)).unwrap(); + assert_eq_files(&outfile.path(), &Path::new(&testcase.expected)); drop(local_client); // this will kill the instance } From 1149177774bf6586cc6fde3e8d1686aad237918a Mon Sep 17 00:00:00 2001 From: Hubert Ritzdorf Date: Fri, 6 Jun 2025 14:48:54 +0200 Subject: [PATCH 09/11] forge fmt --- tests/Contracts/script/Waste1Block.s.sol | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/Contracts/script/Waste1Block.s.sol b/tests/Contracts/script/Waste1Block.s.sol index 29a8ff18..ed810c3f 100644 --- a/tests/Contracts/script/Waste1Block.s.sol +++ b/tests/Contracts/script/Waste1Block.s.sol @@ -14,7 +14,7 @@ contract S is Script { address payable recipient = payable(0x1234567890AbcdEF1234567890aBcdef12345678); // Send exactly 1 wei - (bool success, ) = recipient.call{ value: 1 wei }(""); + (bool success,) = recipient.call{value: 1 wei}(""); vm.stopBroadcast(); } } From 2052b38eccdc877d33dc39a856796fdeb7c1f7a6 Mon Sep 17 00:00:00 2001 From: Hubert Ritzdorf Date: Fri, 6 Jun 2025 15:17:40 +0200 Subject: [PATCH 10/11] fix test case --- tests/expected_dvfs/Lib.dvf.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/expected_dvfs/Lib.dvf.json b/tests/expected_dvfs/Lib.dvf.json index c41fa165..54701116 100644 --- a/tests/expected_dvfs/Lib.dvf.json +++ b/tests/expected_dvfs/Lib.dvf.json @@ -1,10 +1,10 @@ { "version": "0.9.1", - "id": "0xdb26661b8d95e1e02f9331fc20ac3e28635fa9895083c1366c7918a59963312d", + "id": "0x721fa24eea7458a12242c6cc73ac0f2c511b3c04da155445f2fd60e9632168a9", "contract_name": "Lib", "address": "0x8627e5da250bd67817177c77ed8432e8528d2bc9", "chain_id": 31337, - "deployment_block_num": 1, + "deployment_block_num": 2, "init_block_num": 4, "deployment_tx": "0xc46bb378f0ae75fbf0c0c65d9536df3854c9147ebb0d8adec1cd65355cfe36bc", "codehash": "0xacdec87e06ce0e6478a315ee1ceccbd69f4b0e9bb3ee92c4ea70b8a757818512", From 1fef01de9ad71c7d77b5e2bf43458246807282ea Mon Sep 17 00:00:00 2001 From: Hubert Ritzdorf Date: Fri, 6 Jun 2025 15:54:00 +0200 Subject: [PATCH 11/11] fix one more test --- tests/expected_dvfs/AllValueTypes_operators_Anvil.dvf.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/expected_dvfs/AllValueTypes_operators_Anvil.dvf.json b/tests/expected_dvfs/AllValueTypes_operators_Anvil.dvf.json index 51a69ee1..769de238 100644 --- a/tests/expected_dvfs/AllValueTypes_operators_Anvil.dvf.json +++ b/tests/expected_dvfs/AllValueTypes_operators_Anvil.dvf.json @@ -3,7 +3,7 @@ "contract_name": "AllValueTypes", "address": "0x5fbdb2315678afecb367f032d93f642f64180aa3", "chain_id": 31337, - "deployment_block_num": 1, + "deployment_block_num": 2, "init_block_num": 4, "deployment_tx": "0x4c0eda23fa858c9ec88a7004c80c78a606561025d2d8b2c85f825957cab8fc9b", "codehash": "0xc5f9a009f6b4fe853fa6d949876dedd2594d797a7aa57fcf9c58031f7911dfe5",