From 74e4c411094a1cfc75ec8743e60e282abc6da511 Mon Sep 17 00:00:00 2001 From: vmidyllic <74898029+vmidyllic@users.noreply.github.com> Date: Mon, 9 Sep 2024 15:58:22 +0300 Subject: [PATCH] fix --- src/identity/identity-wallet.ts | 7 ++--- tests/identity/id.test.ts | 54 +++++++++++++++------------------ 2 files changed, 27 insertions(+), 34 deletions(-) diff --git a/src/identity/identity-wallet.ts b/src/identity/identity-wallet.ts index 27cd7f47..980cbb57 100644 --- a/src/identity/identity-wallet.ts +++ b/src/identity/identity-wallet.ts @@ -76,7 +76,7 @@ export type IdentityCreationOptions = { /** * Options for creating Auth BJJ credential * seed - seed to generate BJJ key pair - * revocationOpts + * revocationOpts * nonce - explicit revocation nonce to use * onChain - onchain status related option * txCallback - defines how the TransactionReceipt is handled @@ -679,7 +679,7 @@ export class IdentityWallet implements IIdentityWallet { } // otherwise something is already wrong with storage as it has more than 1 credential in it or credential status type of existing credential is different from what user provides - We should remove everything and create new credential. - // in this way credential status of auth credential can be upgraded + // in this way credential status of auth credential can be upgraded for (let i = 0; i < credentials.length; i++) { await this._credentialWallet.remove(credentials[i].id); } @@ -718,7 +718,6 @@ export class IdentityWallet implements IIdentityWallet { rhsUrl: opts.revocationOpts.id, onChain: opts.revocationOpts.onChain }); - } await this._credentialWallet.save(credential); @@ -1270,7 +1269,7 @@ export class IdentityWallet implements IIdentityWallet { let nodes: ProofNode[] = []; - const tree = opts?.treeModel ?? await this.getDIDTreeModel(issuerDID); + const tree = opts?.treeModel ?? (await this.getDIDTreeModel(issuerDID)); nodes = await getNodesRepresentation( opts?.revokedNonces ?? [], { diff --git a/tests/identity/id.test.ts b/tests/identity/id.test.ts index bb3a4ad0..2644c8eb 100644 --- a/tests/identity/id.test.ts +++ b/tests/identity/id.test.ts @@ -36,7 +36,7 @@ import { getRandomBytes } from '@iden3/js-crypto'; import { Blockchain, DidMethod, NetworkId } from '@iden3/js-iden3-core'; import { ZERO_HASH } from '@iden3/js-merkletree'; -describe.only('identity', () => { +describe('identity', () => { let credWallet: ICredentialWallet; let idWallet: IdentityWallet; let dataStorage: IDataStorage; @@ -400,8 +400,7 @@ describe.only('identity', () => { expect(did.string()).to.be.eq(restoredDid.string()); }); - it.only('replace auth bjj credential', async () => { - + it('replace auth bjj credential', async () => { const idRequest: IdentityCreationOptions = { method: DidMethod.Iden3, blockchain: Blockchain.Polygon, @@ -411,48 +410,43 @@ describe.only('identity', () => { type: CredentialStatusType.Iden3ReverseSparseMerkleTreeProof, id: RHS_URL } - } + }; const { did, credential } = await idWallet.createIdentity(idRequest); expect(did.string()).to.equal(expectedDID); - - let credentials = await credWallet.findByQuery( - { - credentialSubject: { - x: { - $eq: credential.credentialSubject['x'], - }, - y: { - $eq: credential.credentialSubject['y'], - } + let credentials = await credWallet.findByQuery({ + credentialSubject: { + x: { + $eq: credential.credentialSubject['x'] + }, + y: { + $eq: credential.credentialSubject['y'] } } - ) + }); expect(credentials.length).to.be.equal(1); idRequest.revocationOpts.type = CredentialStatusType.Iden3OnchainSparseMerkleTreeProof2023; idRequest.revocationOpts.id = RHS_CONTRACT_ADDRESS; idRequest.revocationOpts.genesisPublishingDisabled = true; - const { did: did2, credential: credential2 } = await idWallet.createIdentity(idRequest); expect(did2.string()).to.equal(expectedDID); - expect(credential2.credentialStatus.type).to.be.equal(CredentialStatusType.Iden3OnchainSparseMerkleTreeProof2023); - expect(credential2.credentialStatus.id).to.contain('state') - - credentials = await credWallet.findByQuery( - { - credentialSubject: { - x: { - $eq: credential2.credentialSubject['x'], - }, - y: { - $eq: credential2.credentialSubject['y'], - } + expect(credential2.credentialStatus.type).to.be.equal( + CredentialStatusType.Iden3OnchainSparseMerkleTreeProof2023 + ); + expect(credential2.credentialStatus.id).to.contain('state'); + + credentials = await credWallet.findByQuery({ + credentialSubject: { + x: { + $eq: credential2.credentialSubject['x'] + }, + y: { + $eq: credential2.credentialSubject['y'] } } - ) + }); expect(credentials.length).to.be.equal(1); - }); });