Skip to content

Commit

Permalink
unit test wip
Browse files Browse the repository at this point in the history
  • Loading branch information
thefireskater committed Jul 26, 2023
1 parent 46f2795 commit b9278e1
Show file tree
Hide file tree
Showing 9 changed files with 141 additions and 2 deletions.
5 changes: 4 additions & 1 deletion ssi-dids/src/did_resolve.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1383,7 +1383,7 @@ pub async fn get_verification_methods_for_all(
Error::UnableToResolve(format!("Unable to get verification method ids: {:?}", e))
})?;
for id in vm_ids {
vm_ids_for_purpose.insert(id);
vm_ids_for_purpose.insert(id); // only insert here
}
// Find all verification method maps defined in the resolved DID document.
for vm in doc
Expand All @@ -1404,7 +1404,9 @@ pub async fn get_verification_methods_for_all(
}
}
}

let mut vmms = HashMap::new();

for id in vm_ids_for_purpose {
let vmm = if let Some(vmm) = vmms_by_id.remove(&id) {
vmm
Expand Down Expand Up @@ -1441,6 +1443,7 @@ pub async fn resolve_vm(
if let Some(error) = res_meta.error {
return Err(Error::DIDURLDereference(error));
}
// ah, found the expectedobject, also could've just searched the code base for this error
let vm = match object {
Content::Object(Resource::VerificationMethod(vm)) => vm,
Content::Null => return Err(Error::ResourceNotFound(verification_method.to_string())),
Expand Down
4 changes: 4 additions & 0 deletions ssi-dids/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -918,6 +918,7 @@ impl VerificationMethodMap {
} else {
let resolved_jwk = self.get_jwk()?;
if !resolved_jwk.equals_public(jwk) {
eprintln!("it's getting to this point");
return Err(Error::KeyMismatch);
}
}
Expand Down Expand Up @@ -1367,13 +1368,15 @@ pub mod example {
use async_trait::async_trait;

const DOC_JSON_FOO: &str = include_str!("../tests/did-example-foo.json");
const DOC_JSON_BBS: &str = include_str!("../tests/did-example-bbs.json");
const DOC_JSON_BAR: &str = include_str!("../tests/did-example-bar.json");
const DOC_JSON_12345: &str = include_str!("../tests/did-example-12345.json");
const DOC_JSON_AABB: &str = include_str!("../tests/lds-eip712-issuer.json");

// For vc-test-suite
const DOC_JSON_TEST_ISSUER: &str = include_str!("../tests/did-example-test-issuer.json");
const DOC_JSON_TEST_HOLDER: &str = include_str!("../tests/did-example-test-holder.json");
const BBSPLUS_DID: &str = "did:key:zx4em2CYE3KfT3QFwywcX9ibSjdcFhYkxhjYxbxYS16wXh9CiVzGnsVVsv3s31zw7PAgDBTyVXj2PXkDBphPDRU5FPZxStjsFuhSq7TfkZVYtK2aYBeGWjcrSwvBAeheZfAuqQzQRr5SooEJJ8ctfNkUocBHri1dtZwha1QEH72KitNv4cAKUm7LwQYKEkKbh1AYdKzT59j4fRTyJ3dzLdGcMpdx9XfPgGpYYyzg4ShNhnDqKkzpctU3tXccG5s7ar5jAUuBTxx7kVQxCqJydkzybWP6HG5fc4WmgwCj9EJoaxEzcJjHKQDeDpqpwf7jxndk64maRNJC6gQ35cSRmKAajkoLQ6EzdRPtJM8oSp8CztGPvaoecvLvHbHkNzNRA7yYZ3yVEhgcBWwd3vQK8FGSTozGBPZg6NqAumbPHACXqnacwv9MiTEK4NoRKhyDK8apXkeGFdQ6ECxyYhtyVFmtn3qN8o4rZ2ueMPFEbdm2aLp2CtpDyXUzCNw2Scbf7ucoNMy2cdZAcR4LzQ5Qq3PZRfhjpeoMkUqTwWtS5vvhj5EUkq4oLY7BqmNw3QuUPUd6fALvQxPCb4x812VgAsR8aGLnLx9xvC36nPuTbeJyr8TP9i762r55sLs4kqx5n8PfvqUsafXEiuSDY9FxYVbTLZa3yGQCrQswNEamvKMHrFSpbvV8XE2wfjBAki3DE74Nu4GnN5w9FtrLGwSyHTQJzTSPmL2VfiYyGhcjuQka6z8vUPCrVLvcApJN4i1AdtxvSpLR1Cs41yPiZ5Vwk32X2A4GUjwHG1zQkzq5c7TZHLo2sEEAVWoGBNfVbrry6KMxa4raJBhWZgvWDXdFjgWWoMfQ2GBe7HTNw9bPkBPZ9chaCpCNBaTK51JkqxM9oftoc9BAXdw7BbQUiw1b8Zghqa8wGsf6y6wYR1nmEFoNN54eXDmkuxtFTt6kRx5gsV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fu1Yt7oBV1fvrjXuxQ4KBZMp7qpcGXvHdxY3wVSqUtMarycUFZGRT9QaLKzu88vpoZmdfYh4YtK7B5wV2kerPPAtmYBbKHVk1dEoCynSJopXiDYP5UY8qngxARSLfEYLChA4CUQVFT7dZjaqeeVBybavppMpNgJkA8sqhenE1PUcXfGDETGy44UQMCXT3pga4Vy2sbnpnVrT4d6kHBKrzPhufSeeZCu3v2115QoNkEVb58UeTG1fP57J1TNmHqG9k48q6ejzh7WtBhvc4ioj1wcx1BDyV4HECtwn9GEd1rj9b5gQsgAWm1ReHf6VoTqyQh6dS3Jqr1W6hVYrfThZ72yQHVGjV2NCbfQvByeTpTGfT94Fc9zxhE9if9JSvxazNqKyPyhywyzFZPHNW";

/// An implementation of `did:example`.
///
Expand Down Expand Up @@ -1411,6 +1414,7 @@ pub mod example {
"did:example:12345" => DOC_JSON_12345,
"did:example:ebfeb1f712ebc6f1c276e12ec21" => DOC_JSON_TEST_HOLDER,
"did:example:aaaabbbb" => DOC_JSON_AABB,
BBSPLUS_DID => DOC_JSON_BBS,
_ => return (ResolutionMetadata::from_error(ERROR_NOT_FOUND), None, None),
};
let doc: Document = match serde_json::from_str(doc_str) {
Expand Down
Loading

0 comments on commit b9278e1

Please sign in to comment.