Skip to content

Commit

Permalink
add resolver test
Browse files Browse the repository at this point in the history
  • Loading branch information
kayhhh committed Oct 21, 2024
1 parent 000f829 commit 11db604
Show file tree
Hide file tree
Showing 3 changed files with 108 additions and 0 deletions.
89 changes: 89 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions crates/xdid/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,6 @@ did-web = ["dep:xdid-method-web"]
xdid-core = { path = "../xdid-core" }
xdid-method-key = { path = "../xdid-method-key", optional = true }
xdid-method-web = { path = "../xdid-method-web", optional = true }

[dev-dependencies]
tokio = { version = "1.40.0", features = ["macros", "rt"] }
16 changes: 16 additions & 0 deletions crates/xdid/src/resolver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,19 @@ impl DidResolver {
Err(ResolutionError::UnsupportedMethod)
}
}

#[cfg(test)]
mod tests {
use xdid_method_key::{keys::p256::P256KeyPair, DidKey};

use super::*;

#[tokio::test]
async fn test_resolve_did_key() {
let did = DidKey::new(P256KeyPair::generate().unwrap().to_public()).to_did();

let resolver = DidResolver::default();
let document = resolver.resolve(&did).await.unwrap();
assert_eq!(document.id, did);
}
}

0 comments on commit 11db604

Please sign in to comment.