diff --git a/crates/settlement-clients/ethereum/src/conversion.rs b/crates/settlement-clients/ethereum/src/conversion.rs index 509a8493..04543c27 100644 --- a/crates/settlement-clients/ethereum/src/conversion.rs +++ b/crates/settlement-clients/ethereum/src/conversion.rs @@ -142,15 +142,10 @@ mod tests { #[case::maximum(&[0xFF; 32], U256::MAX)] #[case::short(&[0xFF; 16], U256::from_be_slice(&[0xFF; 16]))] #[case::empty(&[], U256::ZERO)] - fn slice_u8_to_u256_works(#[case] slice: &[u8], #[case] expected: U256) { - assert_eq!(slice_u8_to_u256(slice).expect("slice_u8_to_u256 failed"), expected) - } - - #[rstest] #[should_panic(expected = "could not convert &[u8] to U256")] - #[case::over(&[0xFF; 33])] - fn slice_u8_to_u256_panics(#[case] slice: &[u8]) { - let _ = slice_u8_to_u256(slice).unwrap(); + #[case::over(&[0xFF; 33],U256::from_be_slice(&[0xFF;32]))] + fn slice_u8_to_u256_all_working_and_failing_cases(#[case] slice: &[u8], #[case] expected: U256) { + assert_eq!(slice_u8_to_u256(slice).expect("slice_u8_to_u256 failed"), expected) } #[rstest] @@ -198,17 +193,11 @@ mod tests { #[case::empty(&[], "0".repeat(64))] #[case::typical(&[0xFF,0xFF,0xFF,0xFF], format!("{}{}", "ff".repeat(4), "0".repeat(56)))] #[case::big(&[0xFF; 32], format!("{}", "ff".repeat(32)))] - fn to_hex_string_works(#[case] slice: &[u8], #[case] expected: String) { - let result = to_padded_hex(slice); - assert_eq!(result, expected); - assert!(expected.len() == 64); - } - - #[rstest] #[should_panic(expected = "Slice length must not exceed 32")] #[case::exceeding(&[0xFF; 40], format!("{}", "ff".repeat(32)))] - fn to_hex_string_panics(#[case] slice: &[u8], #[case] expected: String) { - let _ = to_padded_hex(slice); + fn to_hex_string_working_and_failing_cases(#[case] slice: &[u8], #[case] expected: String) { + let result = to_padded_hex(slice); + assert_eq!(result, expected); assert!(expected.len() == 64); } @@ -250,6 +239,8 @@ mod tests { // block_no here are Ethereum(mainnet) blocks, we are creating sidecar and validating // the function by matching pre-existing commitments against computed. + // https://etherscan.io/tx/0x4e012b119391bdc192653bfee9758c432ea6f35ff23f8af60a7dca4664383dfc + // https://etherscan.io/tx/0x96470b890833c5ae51622bd6efca98d8eec3b4a66402c34be3cdcacf006eb9a0 #[rstest] #[case("20462788")] #[case("20462818")] diff --git a/crates/settlement-clients/ethereum/src/lib.rs b/crates/settlement-clients/ethereum/src/lib.rs index 374ef8f2..8978b6f7 100644 --- a/crates/settlement-clients/ethereum/src/lib.rs +++ b/crates/settlement-clients/ethereum/src/lib.rs @@ -42,7 +42,7 @@ pub mod conversion; // IMPORTANT to understand #[cfg(test)], #[cfg(not(test))] and SHOULD_IMPERSONATE_ACCOUNT // Two tests : `update_state_blob_with_dummy_contract_works` & `update_state_blob_with_impersonation_works` use a env var `TEST_IMPERSONATE_OPERATOR` to inform the function `update_state_with_blobs` about the kind of testing, // `TEST_IMPERSONATE_OPERATOR` can have any of "0" or "1" value : -// - if "0" then : Testing against Dummy Contract. +// - if "0" then : Testing via default Anvil address. // - if "1" then : Testing via impersonating `Starknet Operator Address`. // Note : changing between "0" and "1" is handled automatically by each test function, `no` manual change in `env.test` is needed. diff --git a/crates/settlement-clients/ethereum/src/test_data/ABI/starknet_core_contract.json b/crates/settlement-clients/ethereum/src/test_data/contract_abi/starknet_core_contract.json similarity index 100% rename from crates/settlement-clients/ethereum/src/test_data/ABI/starknet_core_contract.json rename to crates/settlement-clients/ethereum/src/test_data/contract_abi/starknet_core_contract.json diff --git a/crates/settlement-clients/ethereum/src/tests/mod.rs b/crates/settlement-clients/ethereum/src/tests/mod.rs index 274967c0..68c081b3 100644 --- a/crates/settlement-clients/ethereum/src/tests/mod.rs +++ b/crates/settlement-clients/ethereum/src/tests/mod.rs @@ -62,7 +62,7 @@ sol!( #[allow(missing_docs)] #[sol(rpc)] STARKNET_CORE_CONTRACT, - "src/test_data/ABI/starknet_core_contract.json" + "src/test_data/contract_abi/starknet_core_contract.json" ); sol! {