Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(didRegistry): update asset document
- Loading branch information
Showing
2 changed files
with
37 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import { initWithPrivateKeySigner, setCacheConfig } from "../src"; | ||
|
||
const rpcUrl = "https://volta-rpc.energyweb.org"; | ||
const privateKey = ""; | ||
|
||
describe.skip("Cache client", () => { | ||
test("Asset owner should be able to update asset document", async () => { | ||
setCacheConfig(73799, { | ||
url: "https://identitycache-dev.energyweb.org/v1", | ||
cacheServerSupportsAuth: true, | ||
}); | ||
|
||
const metadata = { meterId: "SolarM" }; | ||
|
||
const { connectToCacheServer } = await initWithPrivateKeySigner(privateKey, rpcUrl); | ||
const { connectToDidRegistry, assetsService } = await connectToCacheServer(); | ||
const { claimsService, didRegistry } = await connectToDidRegistry(); | ||
|
||
const assetAddress = await assetsService.registerAsset(); | ||
const assetDid = `did:ethr:volta:${assetAddress}`; | ||
|
||
const claimUrl = await claimsService.createSelfSignedClaim({ | ||
data: metadata, | ||
subject: assetDid, | ||
}); | ||
|
||
await new Promise((r) => setTimeout(r, 30_000)); | ||
|
||
const assetDoc = await didRegistry.getDidDocument({ did: assetDid, includeClaims: true }); | ||
expect( | ||
assetDoc.service.some( | ||
(s) => s.serviceEndpoint === claimUrl && expect(s).toEqual(expect.objectContaining(metadata)), | ||
), | ||
); | ||
}, 120000); | ||
}); |
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