Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
vmidyllic committed Sep 9, 2024
1 parent 8d785d2 commit 74e4c41
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 34 deletions.
7 changes: 3 additions & 4 deletions src/identity/identity-wallet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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);
}
Expand Down Expand Up @@ -718,7 +718,6 @@ export class IdentityWallet implements IIdentityWallet {
rhsUrl: opts.revocationOpts.id,
onChain: opts.revocationOpts.onChain
});

}

await this._credentialWallet.save(credential);
Expand Down Expand Up @@ -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 ?? [],
{
Expand Down
54 changes: 24 additions & 30 deletions tests/identity/id.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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,
Expand All @@ -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);

});
});

0 comments on commit 74e4c41

Please sign in to comment.