mirror of
https://github.com/pezkuwichain/revive-differential-tests.git
synced 2026-06-11 22:21:11 +00:00
Compare commits
12 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| adc0c44cde | |||
| 811e17136b | |||
| ba32bad6b3 | |||
| bb754cba4f | |||
| c858bbe66d | |||
| 906878f06a | |||
| 9a71369e8a | |||
| 84ab873b46 | |||
| 2ef6f7ba63 | |||
| 38e6140a7c | |||
| ca6c5529e2 | |||
| 038a2db53c |
@@ -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.signature().starts_with(function_name))
|
.find(|function| function.name.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,53 +434,6 @@ 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