Skip to content
This repository was archived by the owner on Nov 15, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Add test for to_eth_address
  • Loading branch information
conr2d committed Jun 25, 2023
commit a705e6a62f4e51e5d893664822c9b1374dc155f5
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 frame/support/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ serde_json = "1.0.85"
assert_matches = "1.3.0"
pretty_assertions = "1.2.1"
frame-system = { version = "4.0.0-dev", path = "../system" }
array-bytes = "4.1"

[features]
default = ["std"]
Expand Down
16 changes: 16 additions & 0 deletions frame/support/src/crypto/ecdsa.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,3 +47,19 @@ impl ECDSAExt for Public {
})
}
}

#[cfg(test)]
mod tests {
use super::*;
use sp_core::{ecdsa, Pair};

#[test]
fn to_eth_address_works() {
let pair = ecdsa::Pair::from_string("//Alice//password", None).unwrap();
let eth_address = pair.public().to_eth_address().unwrap();
assert_eq!(
array_bytes::bytes2hex("0x", &eth_address),
"0xdc1cce4263956850a3c8eb349dc6fc3f7792cb27"
);
}
}