Skip to content

Commit

Permalink
add tests for key deserialization
Browse files Browse the repository at this point in the history
  • Loading branch information
segfault-magnet committed Nov 19, 2024
1 parent 12982b2 commit efadde7
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 0 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions packages/eth/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ alloy = { workspace = true, features = [
"node-bindings",
"json-rpc",
] }
serde_json = { workspace = true }
mockall = { workspace = true }
ports = { workspace = true, features = ["l1", "test-helpers"] }
pretty_assertions = { workspace = true, features = ["default"] }
Expand Down
31 changes: 31 additions & 0 deletions packages/eth/src/websocket.rs
Original file line number Diff line number Diff line change
Expand Up @@ -275,3 +275,34 @@ impl RegistersMetrics for WebsocketClient {
self.inner.metrics()
}
}

#[cfg(test)]
mod test {
use pretty_assertions::assert_eq;

use super::L1Key;

#[test]
fn can_deserialize_private_key() {
// given
let val = r#""Private(0x1234)""#;

// when
let key: L1Key = serde_json::from_str(val).unwrap();

// then
assert_eq!(key, L1Key::Private("0x1234".to_owned()));
}

#[test]
fn can_deserialize_kms_key() {
// given
let val = r#""Kms(0x1234)""#;

// when
let key: L1Key = serde_json::from_str(val).unwrap();

// then
assert_eq!(key, L1Key::Kms("0x1234".to_owned()));
}
}

0 comments on commit efadde7

Please sign in to comment.