Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(signer-local): add keystore-geth-compat feature #1381

Merged
merged 1 commit into from
Sep 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
1 change: 1 addition & 0 deletions crates/signer-local/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ yubihsm = { version = "0.42", features = ["mockhsm"] }

[features]
keystore = ["dep:eth-keystore", "dep:elliptic-curve"]
keystore-geth-compat = ["keystore", "eth-keystore?/geth-compat"]
mnemonic = ["dep:coins-bip32", "dep:coins-bip39"]
mnemonic-all-languages = ["mnemonic", "coins-bip39?/all-langs"]
yubihsm = ["dep:yubihsm", "dep:elliptic-curve"]
Expand Down
22 changes: 22 additions & 0 deletions crates/signer-local/src/private_key.rs
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,28 @@ mod tests {
test_encrypted_json_keystore(key, &uuid, dir.path());
}

#[test]
#[cfg(feature = "keystore-geth-compat")]
fn test_encrypted_json_keystore_with_address() {
// create and store an encrypted JSON keystore in this directory

use std::fs::File;

use eth_keystore::EthKeystore;
let dir = tempdir().unwrap();
let mut rng = rand::thread_rng();
let (key, uuid) =
LocalSigner::<SigningKey>::new_keystore(&dir, &mut rng, "randpsswd", None).unwrap();

let path = Path::new(dir.path()).join(uuid.clone());
let file = File::open(path).unwrap();
let keystore = serde_json::from_reader::<_, EthKeystore>(file).unwrap();

assert!(!keystore.address.is_zero());

test_encrypted_json_keystore(key, &uuid, dir.path());
}

#[test]
fn signs_msg() {
let message = "Some data";
Expand Down