Skip to content

Commit

Permalink
fix: skip keyring test in CI
Browse files Browse the repository at this point in the history
  • Loading branch information
marktoda committed Jan 2, 2025
1 parent 35758ef commit 9ab45f8
Showing 1 changed file with 32 additions and 21 deletions.
53 changes: 32 additions & 21 deletions src/key.rs
Original file line number Diff line number Diff line change
Expand Up @@ -276,28 +276,39 @@ mod tests {
let service = "chainz_test";
let username = "test_user";

// First, ensure the test key doesn't exist
if let Ok(entry) = Entry::new(service, username) {
let _ = entry.delete_password();
// Try to create a keyring entry
match Entry::new(service, username) {
Ok(entry) => {
// Clean up any existing test key
let _ = entry.delete_password();

// Attempt to set password
match entry.set_password(TEST_PRIVATE_KEY) {
Ok(_) => {
// If we successfully set the password, run the full test
let key = Key::new(
"test".to_string(),
KeyType::Keyring {
service: service.to_string(),
username: username.to_string(),
},
);

assert_eq!(key.private_key()?, TEST_PRIVATE_KEY);
assert_eq!(key.address()?.to_string(), TEST_ADDRESS);

// Cleanup
let _ = entry.delete_password();
}
Err(e) => {
println!("Skipping keyring test (failed to set password: {})", e);
}
}
}
Err(e) => {
println!("Skipping keyring test (no keyring access: {})", e);
}
}

// Create new keyring entry
let entry = Entry::new(service, username)?;
entry.set_password(TEST_PRIVATE_KEY)?;

let key = Key::new(
"test".to_string(),
KeyType::Keyring {
service: service.to_string(),
username: username.to_string(),
},
);

assert_eq!(key.private_key()?, TEST_PRIVATE_KEY);
assert_eq!(key.address()?.to_string(), TEST_ADDRESS);

// Cleanup
entry.delete_password()?;
Ok(())
}

Expand Down

0 comments on commit 9ab45f8

Please sign in to comment.