Skip to content

Commit

Permalink
a quick test
Browse files Browse the repository at this point in the history
  • Loading branch information
insipx committed Dec 22, 2023
1 parent e4da0c8 commit 19d0af0
Showing 1 changed file with 16 additions and 20 deletions.
36 changes: 16 additions & 20 deletions src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -134,17 +134,6 @@ pub enum VerificationMethodProperties {
},
}

impl VerificationMethod {
pub fn new(id: DidUrl, controller: DidUrl, verification_type: KeyType) -> Self {
Self {
id,
controller,
verification_type,
verification_properties: None,
}
}
}

/// Represents different types of services associated with a DID.
/// Currently, only [`ServiceType::Messaging`] is directly supported
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq)]
Expand All @@ -156,15 +145,6 @@ pub enum ServiceType {
Other(String),
}

impl<'a> From<&'a str> for ServiceType {
fn from(s: &'a str) -> ServiceType {
match s {
"MessagingService" => Self::Messaging,
other => Self::Other(other.into()),
}
}
}

/// Various cryptographic key types defined in the [DID Specification](https://www.w3.org/TR/did-spec-registries/#verification-method-types)
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub enum KeyType {
Expand Down Expand Up @@ -320,4 +300,20 @@ mod test {
);
assert_eq!(serde_json::to_value(doc).unwrap(), sample_did);
}

#[test]
fn test_keytype_to_str() {
assert_eq!(String::from(KeyType::JsonWebKey2020), "jwk");
assert_eq!(String::from(KeyType::Ed25519VerificationKey2020), "Ed25519");
assert_eq!(
String::from(KeyType::EcdsaSecp256k1RecoveryMethod2020),
"Secp256k1"
);
assert_eq!(
String::from(KeyType::EcdsaSecp256k1VerificationKey2019),
"Secp256k1"
);
assert_eq!(String::from(KeyType::RsaVerificationKey2018), "RSA");
assert_eq!(String::from(KeyType::X25519KeyAgreementKey2019), "X25519");
}
}

0 comments on commit 19d0af0

Please sign in to comment.