diff --git a/tests/handlers/auth.test.ts b/tests/handlers/auth.test.ts index bce57c47..3c788a72 100644 --- a/tests/handlers/auth.test.ts +++ b/tests/handlers/auth.test.ts @@ -205,7 +205,7 @@ describe('auth', () => { birthday: 19960424, documentType: 99 }, - expiration: 1693526400, + expiration: 2793526400, revocationOpts: { type: CredentialStatusType.Iden3ReverseSparseMerkleTreeProof, id: rhsUrl @@ -252,12 +252,10 @@ describe('auth', () => { from: issuerId.string() }; - console.log(JSON.stringify(issuerCred)); const msgBytes = byteEncoder.encode(JSON.stringify(authReq)); const authRes = await authHandler.handleAuthorizationRequest(userDID, msgBytes); const tokenStr = authRes.token; - console.log(tokenStr); expect(tokenStr).to.be.a('string'); const token = await Token.parse(tokenStr); expect(token).to.be.a('object'); @@ -297,7 +295,7 @@ describe('auth', () => { birthday: 19960424, documentType: 99 }, - expiration: 1693526400, + expiration: 2793526400, revocationOpts: { type: CredentialStatusType.Iden3ReverseSparseMerkleTreeProof, id: rhsUrl @@ -357,6 +355,5 @@ describe('auth', () => { const resp = await authHandler.handleAuthorizationRequest(authProfileDID, msgBytes); - console.log(resp); }); }); diff --git a/tests/identity/id.test.ts b/tests/identity/id.test.ts index 29c62dd8..02edc7f1 100644 --- a/tests/identity/id.test.ts +++ b/tests/identity/id.test.ts @@ -103,7 +103,6 @@ describe('identity', () => { MerkleTreeType.Claims ); - console.log(JSON.stringify(credential)); expect((await claimsTree.root()).bigInt()).not.to.equal(0); }); it('createProfile', async () => { @@ -129,9 +128,10 @@ describe('identity', () => { ); const dbProfile = await dataStorage.identity.getProfileByVerifier('http://polygonissuer.com/'); - expect(dbProfile.id).to.equal(profileDID.string()); - expect(dbProfile.genesisIdentifier).to.equal(did.string()); - expect(dbProfile.nonce).to.equal(10); + expect(dbProfile).not.to.be.undefined; + expect(dbProfile!.id).to.equal(profileDID.string()); + expect(dbProfile!.genesisIdentifier).to.equal(did.string()); + expect(dbProfile!.nonce).to.equal(10); }); it('sign', async () => { const seedPhrase: Uint8Array = byteEncoder.encode('seedseedseedseedseedseedseedseed'); diff --git a/tests/proofs/mtp-onchain.test.ts b/tests/proofs/mtp-onchain.test.ts index 11b1af72..3d15bda0 100644 --- a/tests/proofs/mtp-onchain.test.ts +++ b/tests/proofs/mtp-onchain.test.ts @@ -21,7 +21,7 @@ import { import { ProofService } from '../../src/proof'; import { CircuitId } from '../../src/circuits'; import { ethers } from 'ethers'; -import { EthStateStorage } from '../../src/storage/blockchain/state'; +import { EthStateStorage, defaultEthConnectionConfig } from '../../src/storage/blockchain/state'; import { RootInfo, StateProof } from '../../src/storage/entities/state'; import path from 'path'; import { CredentialStatusType, W3CCredential } from '../../src/verifiable'; @@ -37,13 +37,15 @@ describe('mtp onchain proofs', () => { let proofService: ProofService; const rhsUrl = process.env.RHS_URL as string; + const rpcUrl = process.env.RPC_URL as string; + const walletKey = process.env.WALLET_KEY as string; const mockStateStorage: IStateStorage = { getLatestStateById: async () => { return { id: 25191641634853875207018381290409317860151551336133597267061715643603096065n, - state: 15316103435703269893947162180693935798669021972402205481551466808302934202991n, + state: 5224437024673068498206105743424598123651101873588696368477339341771571761791n, replacedByState: 0n, createdAtTimestamp: 1672245326n, replacedAtTimestamp: 0n, @@ -97,16 +99,13 @@ describe('mtp onchain proofs', () => { dirname: path.join(__dirname, './testdata') }); - /* - To use ethereum storage - const conf = defaultEthConnectionConfig; - conf.url = infuraUrl; - conf.contractAddress = '0xf6781AD281d9892Df285cf86dF4F6eBec2042d71'; - ethStorage = new EthStateStorage(conf); - dataStorage.states = ethStorage; + // const conf =defaultEthConnectionConfig ; + // conf.url = rpcUrl ; + // conf.contractAddress = '0x134B1BE34911E39A8397ec6289782989729807a4'; + // const ethStorage = new EthStateStorage(conf); + // dataStorage.states = ethStorage; - */ const resolvers = new CredentialStatusResolverRegistry(); resolvers.register( @@ -155,7 +154,7 @@ describe('mtp onchain proofs', () => { birthday: 19960424, documentType: 99 }, - expiration: 1693526400, + expiration: 2793526400, revocationOpts: { type: CredentialStatusType.Iden3ReverseSparseMerkleTreeProof, nonce: 1000, @@ -217,7 +216,6 @@ describe('mtp onchain proofs', () => { challenge: BigInt(2), skipRevocation: false }); - console.log(proof); expect(vp).to.be.undefined; }); }); diff --git a/tests/proofs/mtp.test.ts b/tests/proofs/mtp.test.ts index 422e28f3..e9751e21 100644 --- a/tests/proofs/mtp.test.ts +++ b/tests/proofs/mtp.test.ts @@ -40,7 +40,7 @@ describe('mtp proofs', () => { getLatestStateById: async () => { return { id: 25191641634853875207018381290409317860151551336133597267061715643603096065n, - state: 15316103435703269893947162180693935798669021972402205481551466808302934202991n, + state: 5224437024673068498206105743424598123651101873588696368477339341771571761791n, replacedByState: 0n, createdAtTimestamp: 1672245326n, replacedAtTimestamp: 0n, @@ -151,7 +151,7 @@ describe('mtp proofs', () => { birthday: 19960424, documentType: 99 }, - expiration: 1693526400, + expiration: 2793526400, revocationOpts: { type: CredentialStatusType.Iden3ReverseSparseMerkleTreeProof, nonce: 1000, @@ -212,7 +212,6 @@ describe('mtp proofs', () => { expect(creds.length).to.not.equal(0); const { proof, vp } = await proofService.generateProof(proofReq, userDID); - console.log(proof); expect(vp).to.be.undefined; }); @@ -252,7 +251,7 @@ describe('mtp proofs', () => { birthday: 19960424, documentType: 99 }, - expiration: 1693526400, + expiration: 2793526400, revocationOpts: { type: CredentialStatusType.Iden3ReverseSparseMerkleTreeProof, nonce: 1000, @@ -266,7 +265,6 @@ describe('mtp proofs', () => { const res = await idWallet.addCredentialsToMerkleTree([issuerCred], issuerDID); - // publish to rhs await idWallet.publishStateToRHS(issuerDID, rhsUrl); @@ -320,7 +318,6 @@ describe('mtp proofs', () => { credential: credsForMyUserDID[0], skipRevocation: false }); - console.log(proof); expect(vp).to.be.undefined; }); }); diff --git a/tests/proofs/sig-onchain.test.ts b/tests/proofs/sig-onchain.test.ts index 1a39b6a9..9586aa24 100644 --- a/tests/proofs/sig-onchain.test.ts +++ b/tests/proofs/sig-onchain.test.ts @@ -131,7 +131,7 @@ describe('sig onchain proofs', () => { birthday: 19960424, documentType: 99 }, - expiration: 1693526400, + expiration: 2793526400, revocationOpts: { type: CredentialStatusType.Iden3ReverseSparseMerkleTreeProof, id: rhsUrl @@ -168,7 +168,6 @@ describe('sig onchain proofs', () => { challenge: BigInt(2), skipRevocation: false }); - console.log(proof); expect(vp).to.be.undefined; diff --git a/tests/proofs/sig.test.ts b/tests/proofs/sig.test.ts index 0c1f3814..3a9a0721 100644 --- a/tests/proofs/sig.test.ts +++ b/tests/proofs/sig.test.ts @@ -128,7 +128,7 @@ describe('sig proofs', () => { birthday: 19960424, documentType: 99 }, - expiration: 1693526400, + expiration: 2793526400, revocationOpts: { type: CredentialStatusType.Iden3ReverseSparseMerkleTreeProof, id: rhsUrl @@ -177,7 +177,7 @@ describe('sig proofs', () => { birthday: 19960424, documentType: 99 }, - expiration: 1693526400, + expiration: 2793526400, revocationOpts: { type: CredentialStatusType.Iden3ReverseSparseMerkleTreeProof, id: rhsUrl @@ -229,7 +229,7 @@ describe('sig proofs', () => { birthday: 19960424, documentType: 99 }, - expiration: 1693526400, + expiration: 2793526400, revocationOpts: { type: CredentialStatusType.Iden3ReverseSparseMerkleTreeProof, id: rhsUrl @@ -306,7 +306,7 @@ describe('sig proofs', () => { id: userDID.string(), stringTest: 'test' }, - expiration: 1693526400, + expiration: 2793526400, revocationOpts: { type: CredentialStatusType.Iden3ReverseSparseMerkleTreeProof, id: rhsUrl @@ -380,7 +380,7 @@ describe('sig proofs', () => { }, isPostalProvider: true }, - expiration: 1693526400, + expiration: 2793526400, revocationOpts: { type: CredentialStatusType.Iden3ReverseSparseMerkleTreeProof, id: rhsUrl @@ -418,7 +418,7 @@ describe('sig proofs', () => { price: 15.2, type: 'DeliverAddressMultiTest' }, - expiration: 1693526400, + expiration: 2793526400, revocationOpts: { type: CredentialStatusType.Iden3ReverseSparseMerkleTreeProof, id: rhsUrl diff --git a/tests/rhs/rhs.test.ts b/tests/rhs/rhs.test.ts index 486aa9a2..4a72d582 100644 --- a/tests/rhs/rhs.test.ts +++ b/tests/rhs/rhs.test.ts @@ -63,7 +63,45 @@ describe('rhs', () => { getLatestStateById: async () => { return { id: 25191641634853875207018381290409317860151551336133597267061715643603096065n, - state: 15316103435703269893947162180693935798669021972402205481551466808302934202991n, + state: 9237508920537027525017236505396978200808288762330464571183908763595717964946n, + replacedByState: 0n, + createdAtTimestamp: 1672245326n, + replacedAtTimestamp: 0n, + createdAtBlock: 30258020n, + replacedAtBlock: 0n + }; + }, + publishState: async () => { + return '0xc837f95c984892dbcc3ac41812ecb145fedc26d7003202c50e1b87e226a9b33c'; + }, + getGISTProof: (): Promise => { + return Promise.resolve({ + root: 0n, + existence: false, + siblings: [], + index: 0n, + value: 0n, + auxExistence: false, + auxIndex: 0n, + auxValue: 0n + }); + }, + getGISTRootInfo: (): Promise => { + return Promise.resolve({ + root: 0n, + replacedByRoot: 0n, + createdAtTimestamp: 0n, + replacedAtTimestamp: 0n, + createdAtBlock: 0n, + replacedAtBlock: 0n + }); + } + }; + const mockStateStorageForSecondState: IStateStorage = { + getLatestStateById: async () => { + return { + id: 25191641634853875207018381290409317860151551336133597267061715643603096065n, + state: 6331804583810507588859496367559464513815759967776810588505869388511678144501n, replacedByState: 0n, createdAtTimestamp: 1672245326n, replacedAtTimestamp: 0n, @@ -232,7 +270,7 @@ describe('rhs', () => { birthday: 19960424, documentType: 99 }, - expiration: 1693526400, + expiration: 2793526400, revocationOpts: { nonce: 1000, type: CredentialStatusType.Iden3ReverseSparseMerkleTreeProof, @@ -308,7 +346,7 @@ describe('rhs', () => { birthday: 19960424, documentType: 99 }, - expiration: 1693526400, + expiration: 2793526400, revocationOpts: { type: CredentialStatusType.Iden3ReverseSparseMerkleTreeProof, nonce: 1000, @@ -322,8 +360,6 @@ describe('rhs', () => { await idWallet.addCredentialsToMerkleTree([issuerCred], issuerDID); - // this state is published - // let's add one more credential const claimReq2: CredentialRequest = { @@ -335,7 +371,7 @@ describe('rhs', () => { birthday: 19960523, documentType: 1 }, - expiration: 1693526400, + expiration: 2793526400, revocationOpts: { type: CredentialStatusType.Iden3ReverseSparseMerkleTreeProof, id: rhsUrl, @@ -356,6 +392,7 @@ describe('rhs', () => { await idWallet.publishStateToRHS(issuerDID, rhsUrl, [nonce]); // state is published to blockchain (2) + dataStorage.states = mockStateStorageForSecondState; const rhsResolver = new RHSResolver(dataStorage.states); const rhsStatus = await rhsResolver.resolve(credRHSStatus, { issuerDID });