Skip to content

Commit

Permalink
test: add test for state override json (#3586)
Browse files Browse the repository at this point in the history
  • Loading branch information
mattsse authored Jul 5, 2023
1 parent d4f505c commit ceb4e35
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions crates/rpc/rpc-types/src/eth/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,22 @@ pub struct AccountOverride {
#[serde(default, skip_serializing_if = "Option::is_none")]
pub state_diff: Option<HashMap<H256, H256>>,
}

#[cfg(test)]
mod tests {
use super::*;

#[test]
fn test_state_override() {
let s = r#"{
"0x0000000000000000000000000000000000000124": {
"code": "0x6080604052348015600e575f80fd5b50600436106026575f3560e01c80632096525514602a575b5f80fd5b60306044565b604051901515815260200160405180910390f35b5f604e600242605e565b5f0360595750600190565b505f90565b5f82607757634e487b7160e01b5f52601260045260245ffd5b50069056fea2646970667358221220287f77a4262e88659e3fb402138d2ee6a7ff9ba86bae487a95aa28156367d09c64736f6c63430008140033"
}
}"#;
let state_override: StateOverride = serde_json::from_str(s).unwrap();
let acc = state_override
.get(&"0x0000000000000000000000000000000000000124".parse().unwrap())
.unwrap();
assert!(acc.code.is_some());
}
}

0 comments on commit ceb4e35

Please sign in to comment.