mirror of
https://github.com/pezkuwichain/revive-differential-tests.git
synced 2026-04-22 20:47:58 +00:00
Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 7836461763 | |||
| 0e473e1633 | |||
| c8cef4834f |
@@ -150,7 +150,7 @@ impl Input {
|
|||||||
// https://github.com/matter-labs/era-compiler-tester/blob/1dfa7d07cba0734ca97e24704f12dd57f6990c2c/compiler_tester/src/test/case/input/mod.rs#L158-L190
|
// https://github.com/matter-labs/era-compiler-tester/blob/1dfa7d07cba0734ca97e24704f12dd57f6990c2c/compiler_tester/src/test/case/input/mod.rs#L158-L190
|
||||||
let function = abi
|
let function = abi
|
||||||
.functions()
|
.functions()
|
||||||
.find(|function| function.name.starts_with(function_name))
|
.find(|function| function.signature().starts_with(function_name))
|
||||||
.ok_or_else(|| {
|
.ok_or_else(|| {
|
||||||
anyhow::anyhow!(
|
anyhow::anyhow!(
|
||||||
"Function with name {:?} not found in ABI for the instance {:?}",
|
"Function with name {:?} not found in ABI for the instance {:?}",
|
||||||
@@ -434,6 +434,53 @@ mod tests {
|
|||||||
assert_eq!(decoded.0, 42);
|
assert_eq!(decoded.0, 42);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_encoded_input_address_with_signature() {
|
||||||
|
let raw_abi = r#"[
|
||||||
|
{
|
||||||
|
"inputs": [{"name": "recipient", "type": "address"}],
|
||||||
|
"name": "send",
|
||||||
|
"outputs": [],
|
||||||
|
"stateMutability": "nonpayable",
|
||||||
|
"type": "function"
|
||||||
|
}
|
||||||
|
]"#;
|
||||||
|
|
||||||
|
let parsed_abi: JsonAbi = serde_json::from_str(raw_abi).unwrap();
|
||||||
|
let selector = parsed_abi
|
||||||
|
.function("send")
|
||||||
|
.unwrap()
|
||||||
|
.first()
|
||||||
|
.unwrap()
|
||||||
|
.selector()
|
||||||
|
.0;
|
||||||
|
|
||||||
|
let input: Input = Input {
|
||||||
|
instance: "Contract".to_owned().into(),
|
||||||
|
method: Method::FunctionName("send(address)".to_owned()),
|
||||||
|
calldata: Some(Calldata::Compound(vec![
|
||||||
|
"0x1000000000000000000000000000000000000001".to_string(),
|
||||||
|
])),
|
||||||
|
..Default::default()
|
||||||
|
};
|
||||||
|
|
||||||
|
let mut contracts = HashMap::new();
|
||||||
|
contracts.insert(
|
||||||
|
ContractInstance::new_from("Contract"),
|
||||||
|
(Address::ZERO, parsed_abi),
|
||||||
|
);
|
||||||
|
|
||||||
|
let encoded = input.encoded_input(&contracts, &DummyEthereumNode).unwrap();
|
||||||
|
assert!(encoded.0.starts_with(&selector));
|
||||||
|
|
||||||
|
type T = (alloy_primitives::Address,);
|
||||||
|
let decoded: T = T::abi_decode(&encoded.0[4..]).unwrap();
|
||||||
|
assert_eq!(
|
||||||
|
decoded.0,
|
||||||
|
address!("0x1000000000000000000000000000000000000001")
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_encoded_input_address() {
|
fn test_encoded_input_address() {
|
||||||
let raw_abi = r#"[
|
let raw_abi = r#"[
|
||||||
|
|||||||
Reference in New Issue
Block a user