api/rootfingerprint: add unit tests
@@ -28,3 +28,37 @@ pub fn process() -> Result<Response, Error> {
fingerprint: fingerprint.to_vec(),
}))
}
+
+#[cfg(test)]
+mod tests {
+ use super::*;
+
+ use bitbox02::keystore::lock;
+ use bitbox02::testing::mock_unlocked_using_mnemonic;
+
+ #[test]
+ fn test_process() {
+ lock();
+ assert_eq!(process(), Err(Error::Generic));
+
+ mock_unlocked_using_mnemonic(
+ "purity concert above invest pigeon category peace tuition hazard vivid latin since legal speak nation session onion library travel spell region blast estate stay"
+ );
+ assert_eq!(
+ process(),
+ Ok(Response::Fingerprint(pb::RootFingerprintResponse {
+ fingerprint: vec![0x02, 0x40, 0xe9, 0x2a],
+ }))
+ );
+
+ mock_unlocked_using_mnemonic(
+ "small agent wife animal marine cloth exit thank stool idea steel frame",
+ );
+ assert_eq!(
+ process(),
+ Ok(Response::Fingerprint(pb::RootFingerprintResponse {
+ fingerprint: vec![0xf4, 0x0b, 0x46, 0x9a],
+ }))
+ );
+ }
+}
