Skip to content

Commit

Permalink
basic test for deser and verification
Browse files Browse the repository at this point in the history
  • Loading branch information
chunningham committed Sep 22, 2023
1 parent 01b82ae commit 9266142
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
3 changes: 3 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,6 @@ siwe-recap = { version = "0.2" }

[dev-dependencies]
async-std = { version = "1.10", features = ["attributes"] }
base64 = "0.13"
serde_ipld_dagcbor = "0.4"
did-method-key = { git = "https://github.com/spruceid/ssi.git", branch = "feat/ucan-0.10" }
14 changes: 14 additions & 0 deletions src/v3/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -257,3 +257,17 @@ where
Ok(RecapCacao::try_from(siwe)?.into())
}
}

#[cfg(test)]
mod test {
use super::*;

#[async_std::test]
async fn basic() {
let encoded = "qmNpc3NYG50aygECAbFNPE9fv7z7mK8tMwAA1JyVuTqnAGNhdWRYVp0a7QE4NstKM22BZAAHaojdiik61NN1l7wVRKwcQJWixAbFHzEjejZNa2lFaExWMmVxOWFqelBRQTZRMkJVU2t6WHdUMm1GYkR2TkdqTXl0VzRTV2g0YXZhMWNhdHSheEtrZXBsZXI6cGtoOmVpcDE1NToxOjB4QjE0ZDNjNEY1RkJGQkNGQjk4YWYyZDMzMDAwMGQ0OWM5NUI5M2FBNzovL2RlZmF1bHQva3alZmt2L2RlbIGgZmt2L2dldIGgZmt2L3B1dIGgZ2t2L2xpc3SBoGtrdi9tZXRhZGF0YYGgY25uY3FVajg5YkdHWmtoNFJKNjY4dmNwcmaAY2lhdBocvbpSY2V4cBsAAAAHda9C0mNmY3SkZWlhdC16ZC41MlplZXhwLXpkLjUyWmZkb21haW5pbG9jYWxob3N0aXJlc291cmNlc4Bhc1hINOcBG5HDAwx4ASjJGspMdIhMu2NX9o06hfQbz1SqCvdAWjwWOpO6aDh56KfReehDpmKEJxYXdQVVLMAmFVq1SZxBIzljSnkc";
let decoded = base64::decode(encoded).unwrap();
let cacao: CommonCacao = serde_ipld_dagcbor::from_slice(&decoded).unwrap();
let verifier = CommonVerifier::new(&did_method_key::DIDKey);
cacao.verify(&verifier).await.unwrap();
}
}

0 comments on commit 9266142

Please sign in to comment.