-
Notifications
You must be signed in to change notification settings - Fork 83
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: George Mulhearn <[email protected]>
- Loading branch information
1 parent
96d74e9
commit a98803a
Showing
3 changed files
with
109 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,85 @@ | ||
use did_cheqd::resolution::resolver::{DidCheqdResolver, DidCheqdResolverConfiguration}; | ||
use serde_json::json; | ||
|
||
#[tokio::test] | ||
async fn test_resolve_known_mainnet_vector() { | ||
// sample from https://dev.uniresolver.io/ | ||
let did = "did:cheqd:mainnet:Ps1ysXP2Ae6GBfxNhNQNKN".parse().unwrap(); | ||
// NOTE: modifications from uni-resolver: | ||
// *remove contexts, | ||
// make serviceEndpoints into single item (not array) | ||
let expected_doc = json!({ | ||
"@context": [], | ||
"id": "did:cheqd:mainnet:Ps1ysXP2Ae6GBfxNhNQNKN", | ||
"verificationMethod": [ | ||
{ | ||
"id": "did:cheqd:mainnet:Ps1ysXP2Ae6GBfxNhNQNKN#key1", | ||
"type": "Ed25519VerificationKey2020", | ||
"controller": "did:cheqd:mainnet:Ps1ysXP2Ae6GBfxNhNQNKN", | ||
"publicKeyMultibase": "z6Mkta7joRuvDh7UnoESdgpr9dDUMh5LvdoECDi3WGrJoscA" | ||
} | ||
], | ||
"authentication": [ | ||
"did:cheqd:mainnet:Ps1ysXP2Ae6GBfxNhNQNKN#key1" | ||
], | ||
"service": [ | ||
{ | ||
"id": "did:cheqd:mainnet:Ps1ysXP2Ae6GBfxNhNQNKN#website", | ||
"type": "LinkedDomains", | ||
"serviceEndpoint": "https://www.cheqd.io/" | ||
}, | ||
{ | ||
"id": "did:cheqd:mainnet:Ps1ysXP2Ae6GBfxNhNQNKN#non-fungible-image", | ||
"type": "LinkedDomains", | ||
"serviceEndpoint": "https://gateway.ipfs.io/ipfs/bafybeihetj2ng3d74k7t754atv2s5dk76pcqtvxls6dntef3xa6rax25xe" | ||
}, | ||
{ | ||
"id": "did:cheqd:mainnet:Ps1ysXP2Ae6GBfxNhNQNKN#twitter", | ||
"type": "LinkedDomains", | ||
"serviceEndpoint": "https://twitter.com/cheqd_io" | ||
}, | ||
{ | ||
"id": "did:cheqd:mainnet:Ps1ysXP2Ae6GBfxNhNQNKN#linkedin", | ||
"type": "LinkedDomains", | ||
"serviceEndpoint": "https://www.linkedin.com/company/cheqd-identity/" | ||
} | ||
] | ||
}); | ||
|
||
let resolver = DidCheqdResolver::new(DidCheqdResolverConfiguration::default()); | ||
let doc = resolver.resolve_did(&did).await.unwrap(); | ||
assert_eq!(serde_json::to_value(doc.clone()).unwrap(), expected_doc); | ||
assert_eq!(doc, serde_json::from_value(expected_doc).unwrap()); | ||
} | ||
|
||
#[tokio::test] | ||
async fn test_resolve_known_testnet_vector() { | ||
// let did = "did:cheqd:testnet:BttdoaxtC5JkYJoLeGV8ny".parse().unwrap(); | ||
let did = "did:cheqd:mainnet:e536be60-880a-4d10-bd95-e84d13d7db6d" | ||
// sample from https://dev.uniresolver.io/ | ||
let did = "did:cheqd:testnet:55dbc8bf-fba3-4117-855c-1e0dc1d3bb47" | ||
.parse() | ||
.unwrap(); | ||
dbg!(&did); | ||
// NOTE: modifications from uni-resolver: | ||
// * remove contexts, | ||
// * made controller a single item | ||
let expected_doc = json!({ | ||
"@context": [], | ||
"id": "did:cheqd:testnet:55dbc8bf-fba3-4117-855c-1e0dc1d3bb47", | ||
"controller": "did:cheqd:testnet:55dbc8bf-fba3-4117-855c-1e0dc1d3bb47", | ||
"verificationMethod": [ | ||
{ | ||
"id": "did:cheqd:testnet:55dbc8bf-fba3-4117-855c-1e0dc1d3bb47#key-1", | ||
"type": "Ed25519VerificationKey2020", | ||
"controller": "did:cheqd:testnet:55dbc8bf-fba3-4117-855c-1e0dc1d3bb47", | ||
"publicKeyMultibase": "z6MkkVbyHJLLjdjU5B62DaJ4mkdMdUkttf9UqySSkA9bVTeZ" | ||
} | ||
], | ||
"authentication": [ | ||
"did:cheqd:testnet:55dbc8bf-fba3-4117-855c-1e0dc1d3bb47#key-1" | ||
] | ||
}); | ||
|
||
let resolver = DidCheqdResolver::new(DidCheqdResolverConfiguration::default()); | ||
let doc = resolver.resolve_did(&did).await.unwrap(); | ||
dbg!(doc); | ||
assert_eq!(serde_json::to_value(doc.clone()).unwrap(), expected_doc); | ||
assert_eq!(doc, serde_json::from_value(expected_doc).unwrap()); | ||
} |