//! # vanify::keys tests use vanify::keys; // Tests for keys module // Should generate a random private key #[test] fn test_generate_private_key() { let private_key = keys::KeyPair::new_from_random_seed(); assert_eq!(private_key.private_key.to_string().len(), 64); } // Should generate a public key from a private key #[test] fn test_generate_public_key() { let private_key = keys::KeyPair::new_from_random_seed(); let public_key = private_key.private_key.derive_public_key(); assert_eq!(public_key.to_string().len(), 40); } // Should generate a key pair from a private key #[test] fn test_generate_key_pair() { let private_key = keys::KeyPair::new_from_random_seed(); let key_pair = keys::KeyPair::new_from_private_key(private_key.private_key); assert_eq!(key_pair.private_key.to_string().len(), 64); assert_eq!(key_pair.public_key.to_string().len(), 40); } // Should convert a private key to a string #[test] fn test_private_key_to_string() { let private_key = keys::KeyPair::new_from_random_seed(); assert_eq!(private_key.private_key.to_string().len(), 64); } // Should convert a public key to a string #[test] fn test_public_key_to_string() { let private_key = keys::KeyPair::new_from_random_seed(); let public_key = private_key.private_key.derive_public_key(); assert_eq!(public_key.to_string().len(), 40); } // Should convert a private key to a u256 and then back to the same private key #[test] fn test_private_key_to_u256() { let private_key = keys::KeyPair::new_from_random_seed(); let u256 = private_key.private_key.to_u256(); let private_key2 = keys::PrivateKey::from_u256(u256); assert_eq!( private_key.private_key.to_string(), private_key2.to_string() ); }