Skip to content

Commit

Permalink
feat(eip5792) add test for wallet_sendCalls request type (#1670)
Browse files Browse the repository at this point in the history
* Update call.rs

* touchup

---------

Co-authored-by: Matthias Seitz <matthias.seitz@outlook.de>
  • Loading branch information
DoTheBestToGetTheBest and mattsse authored Nov 20, 2024
1 parent f10e3ef commit ceb6e50
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions crates/eip5792/src/call.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,38 @@ pub struct CallParams {
#[serde(default, skip_serializing_if = "Option::is_none")]
pub chain_id: Option<ChainId>,
}
#[cfg(test)]
mod tests {
use super::*;
use alloy_primitives::{Address, Bytes, ChainId, U256};

#[test]
fn test_serialization_deserialization() {
let sample_request = SendCallsRequest {
version: "1.0".to_string(),
from: Address::default(),
calls: vec![
CallParams {
to: Some(Address::default()),
data: Some(Bytes::from("d46e8dd67c5d32be8d46e8dd67c5d32be8058bb8eb970870f072445675058bb8eb970870f072445675"
)),
value: Some(U256::from(0x9184e72au64)),
chain_id: Some(ChainId::from(1u64)),
},
CallParams {
to: Some(Address::default()),
data: Some(Bytes::from(
"fbadbaf01"),
),
value: Some(U256::from(0x182183u64)),
chain_id: Some(ChainId::from(1u64)),
},
],
capabilities: None,
};

let serialized = serde_json::to_string(&sample_request).unwrap();
let deserialized: SendCallsRequest = serde_json::from_str(&serialized).unwrap();
assert_eq!(sample_request, deserialized);
}
}

0 comments on commit ceb6e50

Please sign in to comment.