diff --git a/.github/workflows/verify-correctness-of-vc-content-.yml b/.github/workflows/verify-correctness-of-vc-content.yml similarity index 53% rename from .github/workflows/verify-correctness-of-vc-content-.yml rename to .github/workflows/verify-correctness-of-vc-content.yml index 598138c987..5780606830 100644 --- a/.github/workflows/verify-correctness-of-vc-content-.yml +++ b/.github/workflows/verify-correctness-of-vc-content.yml @@ -4,33 +4,32 @@ on: workflow_dispatch: inputs: docker-tag: - description: "client tag(e.g. p1.2.0-9701-w0.0.1-101)" + description: "an existing docker tag (e.g. v0.9.18)" required: true default: "latest" + schedule: + - cron: '0 12 * * 3,6' # Run every Wednesday and Saturday at 12:00 UTC +env: + DOCKER_TAG: ${{ github.event.inputs.docker-tag || 'latest' }} + jobs: - test-data-provider: + test-vc-correctness: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - - name: Set ENV - run: | - # extracting parachain version and worker version from release tag - echo "PARACHAIN_TAG=$(echo ${{inputs.docker-tag}} | cut -d'-' -f1 | sed 's/p/v/')" >> $GITHUB_ENV - echo "WORKER_TAG=$(echo ${{inputs.docker-tag}} | cut -d'-' -f3 | sed 's/w/v/')" >> $GITHUB_ENV - - name: Pull litentry image optionally run: | docker pull parity/polkadot - docker pull litentry/identity-worker:$WORKER_TAG - docker pull litentry/identity-cli:$WORKER_TAG - docker pull litentry/litentry-parachain:$PARACHAIN_TAG + docker pull litentry/identity-worker:$DOCKER_TAG + docker pull litentry/identity-cli:$DOCKER_TAG + docker pull litentry/litentry-parachain:$DOCKER_TAG - name: Re-tag docker image run: | - docker tag litentry/identity-worker:$WORKER_TAG litentry/identity-worker:latest - docker tag litentry/identity-cli:$WORKER_TAG litentry/identity-cli:latest - docker tag litentry/litentry-parachain:$PARACHAIN_TAG litentry/litentry-parachain:latest + docker tag litentry/identity-worker:$DOCKER_TAG litentry/identity-worker:latest + docker tag litentry/identity-cli:$DOCKER_TAG litentry/identity-cli:latest + docker tag litentry/litentry-parachain:$DOCKER_TAG litentry/litentry-parachain:latest - run: docker images --all @@ -46,15 +45,15 @@ jobs: cd tee-worker/docker docker compose -f litentry-parachain.build.yml build - - name: Run data-provider-test + - name: Run vc correctness tests run: | cd tee-worker/docker - docker compose -f docker-compose.yml -f lit-data-provider-test.yml up --no-build --exit-code-from lit-data-provider-test lit-data-provider-test + docker compose -f docker-compose.yml -f lit-vc-correctness-test.yml up --no-build --exit-code-from lit-vc-correctness-test lit-vc-correctness-test - name: Stop docker containers run: | cd tee-worker/docker - docker compose -f docker-compose.yml -f lit-data-provider-test.yml stop + docker compose -f docker-compose.yml -f lit-vc-correctness-test.yml stop - name: Collect Docker Logs continue-on-error: true @@ -68,6 +67,6 @@ jobs: if: always() uses: actions/upload-artifact@v4 with: - name: logs-lit-data-provider-test + name: logs-lit-vc-correctness-test path: logs if-no-files-found: ignore diff --git a/tee-worker/docker/lit-data-provider-test.yml b/tee-worker/docker/lit-vc-correctness-test.yml similarity index 83% rename from tee-worker/docker/lit-data-provider-test.yml rename to tee-worker/docker/lit-vc-correctness-test.yml index 113babcba2..ea86dba417 100644 --- a/tee-worker/docker/lit-data-provider-test.yml +++ b/tee-worker/docker/lit-vc-correctness-test.yml @@ -1,7 +1,7 @@ services: - lit-data-provider-test: + lit-vc-correctness-test: image: litentry/identity-cli:latest - container_name: litentry-data-provider-test + container_name: litentry-vc-correctness-test volumes: - ../ts-tests:/ts-tests - ../client-api:/client-api @@ -17,7 +17,7 @@ services: condition: service_healthy networks: - litentry-test-network - entrypoint: "bash -c '/usr/local/worker-cli/lit_ts_integration_test.sh data-provider.test.ts 2>&1' " + entrypoint: "bash -c '/usr/local/worker-cli/lit_ts_integration_test.sh vc_correctness.test.ts 2>&1' " restart: "no" networks: litentry-test-network: diff --git a/tee-worker/ts-tests/integration-tests/common/credential-json/achainable.json b/tee-worker/ts-tests/integration-tests/common/credential-json/achainable.json index fe4ba534d7..f6a78dfe07 100644 --- a/tee-worker/ts-tests/integration-tests/common/credential-json/achainable.json +++ b/tee-worker/ts-tests/integration-tests/common/credential-json/achainable.json @@ -8,7 +8,7 @@ "payload": { "Basic": { "name": "BAB token holder", - "chain": "Bsc" + "chain": ["Bsc"] } } }, @@ -27,7 +27,7 @@ "payload": { "Basic": { "name": "Uniswap V2/V3 user", - "chain": "Ethereum" + "chain": ["Ethereum"] } } }, @@ -40,10 +40,10 @@ { "id": "dot-holder", "name": "DOT Holding Time", - "description": "The length of time a user continues to hold DOT token (threshold DOT > 5)", + "description": "The length of time a user continues to hold DOT token (threshold DOT > 1)", "assertion": { "id": "A7", - "payload": "5" + "payload": "1" }, "dataProvider": "achainable", "network": "polkadot", @@ -102,7 +102,7 @@ "payload": { "ClassOfYear": { "name": "Account created between {dates}", - "chain": "Ethereum" + "chain": ["Ethereum"] } } }, @@ -233,19 +233,5 @@ "mockDid": "litentry:substrate:0xc0103c4b56ce752d05b16a88260e3a9e2c44306602a74c5edd1cd4ff56356f7c", "mockWeb3Network": "litentry,polkadot", "expectedCredentialValue": true - }, - { - "id": "token-holding-amount-btcs", - "name": "BTCS Holding Time", - "description": "The number of BTCS tokens you hold > 0", - "assertion": { - "id": "Brc20AmountHolder", - "payload": [] - }, - "dataProvider": "achainable", - "network": "litentry", - "mockDid": "litentry:bitcoin:0x02dbb0aff6e115284ac2ac5795e299588dae74474ad4bd0e580e92163e80837da8", - "mockWeb3Network": "BitcoinP2tr", - "expectedCredentialValue": null } ] diff --git a/tee-worker/ts-tests/integration-tests/common/credential-json/blockchaininfo.json b/tee-worker/ts-tests/integration-tests/common/credential-json/blockchaininfo.json new file mode 100644 index 0000000000..ae3d274e34 --- /dev/null +++ b/tee-worker/ts-tests/integration-tests/common/credential-json/blockchaininfo.json @@ -0,0 +1,16 @@ +[ + { + "id": "token-holding-amount-btc", + "name": "Bitcoin Holding Amount", + "description": "The number of bitcoin tokens you hold > 0", + "assertion": { + "id": "TokenHoldingAmount", + "payload": "BTC" + }, + "dataProvider": "blockchaininfo", + "network": "bitcoin", + "mockDid": "litentry:bitcoin:0x03041ee39c741c35eb55078220dceb477a1e3b1b129977e0b37db6624772b5bda8", + "mockWeb3Network": "BitcoinP2wpkh", + "expectedCredentialValue": true + } +] diff --git a/tee-worker/ts-tests/integration-tests/common/credential-json/geniidata.json b/tee-worker/ts-tests/integration-tests/common/credential-json/geniidata.json new file mode 100644 index 0000000000..79e7a1248f --- /dev/null +++ b/tee-worker/ts-tests/integration-tests/common/credential-json/geniidata.json @@ -0,0 +1,16 @@ +[ + { + "id": "token-holding-amount-btcs", + "name": "BTCS Holding Amount", + "description": "The number of BTCS tokens you hold > 0", + "assertion": { + "id": "Brc20AmountHolder", + "payload": [] + }, + "dataProvider": "geniidata", + "network": "bitcoin", + "mockDid": "litentry:bitcoin:0x0202eb94e79b526f80b9029672f03d7c721da64c99fe742545423cbcc70851727f", + "mockWeb3Network": "BitcoinP2wpkh", + "expectedCredentialValue": true + } +] diff --git a/tee-worker/ts-tests/integration-tests/common/credential-json/index.ts b/tee-worker/ts-tests/integration-tests/common/credential-json/index.ts index 6d7af24221..9432cd57d8 100644 --- a/tee-worker/ts-tests/integration-tests/common/credential-json/index.ts +++ b/tee-worker/ts-tests/integration-tests/common/credential-json/index.ts @@ -11,6 +11,9 @@ import discordJson from './discord.json' assert { type: 'json' }; import litentryJson from './litentry.json' assert { type: 'json' }; import twitterJson from './twitter.json' assert { type: 'json' }; import oneblockJson from './oneblock.json' assert { type: 'json' }; +import geniidataJson from './geniidata.json' assert { type: 'json' }; +import moralisJson from './moralis.json' assert { type: 'json' }; +import blockchaininfoJson from './blockchaininfo.json' assert { type: 'json' }; export const vip3 = vip3Json as unknown as CredentialDefinition[]; export const achainable = achainableJson as unknown as CredentialDefinition[]; export const nodereal = noderealJson as unknown as CredentialDefinition[]; @@ -18,7 +21,21 @@ export const discord = discordJson as unknown as CredentialDefinition[]; export const litentry = litentryJson as unknown as CredentialDefinition[]; export const twitter = twitterJson as unknown as CredentialDefinition[]; export const oneblock = oneblockJson as unknown as CredentialDefinition[]; -export const credentialsJson = [...vip3, ...achainable, ...nodereal, ...litentry, ...twitter, ...oneblock, ...discord]; +export const geniidata = geniidataJson as unknown as CredentialDefinition[]; +export const moralis = moralisJson as unknown as CredentialDefinition[]; +export const blockchaininfo = blockchaininfoJson as unknown as CredentialDefinition[]; +export const credentialsJson = [ + ...nodereal, + ...geniidata, + ...moralis, + ...achainable, + ...litentry, + ...twitter, + ...oneblock, + ...discord, + ...vip3, + ...blockchaininfo, +]; export interface CredentialDefinition { id: string; diff --git a/tee-worker/ts-tests/integration-tests/common/credential-json/moralis.json b/tee-worker/ts-tests/integration-tests/common/credential-json/moralis.json new file mode 100644 index 0000000000..f38e9816c5 --- /dev/null +++ b/tee-worker/ts-tests/integration-tests/common/credential-json/moralis.json @@ -0,0 +1,16 @@ +[ + { + "id": "token-holding-amount-sol", + "name": "SOL Holding Amount", + "description": "The number of SOL tokens you hold > 0", + "assertion": { + "id": "TokenHoldingAmount", + "payload": "SOL" + }, + "dataProvider": "moralis", + "network": "solana", + "mockDid": "litentry:solana:09b36de0a9862cdbfe3eb023959e97e816e17d846a5762b3c1bfe7b75490c23b", + "mockWeb3Network": "solana", + "expectedCredentialValue": true + } +] diff --git a/tee-worker/ts-tests/integration-tests/common/credential-json/nodereal.json b/tee-worker/ts-tests/integration-tests/common/credential-json/nodereal.json index 298a0a7a2c..0c99a8094a 100644 --- a/tee-worker/ts-tests/integration-tests/common/credential-json/nodereal.json +++ b/tee-worker/ts-tests/integration-tests/common/credential-json/nodereal.json @@ -10,35 +10,7 @@ }, "dataProvider": "nodereal", "network": "ethereum", - "mockDid": "litentry:evm:0xf813361F1FADC5c51EFdd0ba5b93e2760a5537EC", - "mockWeb3Network": "bsc,ethereum", - "expectedCredentialValue": true - }, - { - "id": "bnb-999-club-member", - "name": "000-999.bnb Domain Holding Amount", - "description": "You are holding a certain amount of 000-999.bnb domain names", - "assertion": { - "id": "BnbDigitDomainClub", - "payload": "Bnb999ClubMember" - }, - "dataProvider": "nodereal", - "network": "ethereum", - "mockDid": "litentry:evm:0xA6E3d8B20a5DC12c986AF63E496B8D585117aBBd", - "mockWeb3Network": "bsc,ethereum", - "expectedCredentialValue": true - }, - { - "id": "bnb-10k-club-member", - "name": "0000-9999.bnb Holding Amount", - "description": "You are holding a certain amount of 0000-9999.bnb domain names", - "assertion": { - "id": "BnbDigitDomainClub", - "payload": "Bnb10KClubMember" - }, - "dataProvider": "nodereal", - "network": "ethereum", - "mockDid": "litentry:evm:0xD673b52E4c560f5d2BD41fd92e7566Ef445DC5AB", + "mockDid": "litentry:evm:0x6A9c371dB67992444cA55D32eA4219dd264b8DD3", "mockWeb3Network": "bsc,ethereum", "expectedCredentialValue": true }, @@ -52,7 +24,7 @@ }, "dataProvider": "nodereal", "network": "ethereum", - "mockDid": "litentry:evm:0x5029bC78f84Fc7F1568FbA1A7808e753691E6675", + "mockDid": "litentry:evm:0x10EF5b7309Bdc639fbE9597EB87a34b27ecDAF0f", "mockWeb3Network": "bsc,ethereum", "expectedCredentialValue": true }, @@ -66,7 +38,7 @@ }, "dataProvider": "nodereal", "network": "ethereum", - "mockDid": "litentry:evm:0xA5044e67f0c35b31fe82F2Ded6606b0b91545e98", + "mockDid": "litentry:evm:0xF0775DD7A342F123b63826Eab7abb979d109B2DC", "mockWeb3Network": "bsc,ethereum", "expectedCredentialValue": true }, @@ -80,7 +52,7 @@ }, "dataProvider": "nodereal", "network": "ethereum", - "mockDid": "litentry:evm:0xd14A1dB9B2Bfe0cE9cC175C24d6B01a16aB84f42", + "mockDid": "litentry:evm:0x661Be0562b31E9E8DdC2A7c93803005A1C71D749", "mockWeb3Network": "bsc,ethereum", "expectedCredentialValue": true }, @@ -94,7 +66,7 @@ }, "dataProvider": "nodereal", "network": "ethereum", - "mockDid": "litentry:evm:0xAA1582084c4f588eF9BE86F5eA1a919F86A3eE57", + "mockDid": "litentry:evm:0xa1D100a5bf6BFd2736837c97248853D989a9ED84", "mockWeb3Network": "bsc,ethereum", "expectedCredentialValue": true }, @@ -108,7 +80,7 @@ }, "dataProvider": "nodereal", "network": "ethereum", - "mockDid": "litentry:evm:0xe7DAE0cEd7a64d50136D466945257b600e718ACa", + "mockDid": "litentry:evm:0x65f7BA4Ec257AF7c55fd5854E5f6356bBd0fb8EC", "mockWeb3Network": "bsc,ethereum", "expectedCredentialValue": true }, @@ -122,7 +94,7 @@ }, "dataProvider": "nodereal", "network": "ethereum", - "mockDid": "litentry:evm:0x46f80018211D5cBBc988e853A8683501FCA4ee9b", + "mockDid": "litentry:evm:0x7fBC543Cb079bDA8b8013b811B179BcD38a313ce", "mockWeb3Network": "bsc,ethereum", "expectedCredentialValue": true }, @@ -136,7 +108,7 @@ }, "dataProvider": "nodereal", "network": "ethereum", - "mockDid": "litentry:evm:0x310E035d176ccB589511eD16af7aE7BAc4fc7f83", + "mockDid": "litentry:evm:0xbc29937451E4607d21a2444DE4dbFbA1AE8B88b8", "mockWeb3Network": "bsc,ethereum", "expectedCredentialValue": true }, @@ -150,7 +122,7 @@ }, "dataProvider": "nodereal", "network": "ethereum", - "mockDid": "litentry:evm:0x94CFF34005A073911C3179abE89F1677f0D37d42", + "mockDid": "litentry:evm:0x4b516c437c30D8D9d88b1c0463cEDc996e1F23d1", "mockWeb3Network": "bsc,ethereum", "expectedCredentialValue": true }, @@ -164,7 +136,7 @@ }, "dataProvider": "nodereal", "network": "ethereum", - "mockDid": "litentry:evm:0xB4e9275827B5f049196f5337F69533937475A3de", + "mockDid": "litentry:evm:0x04EAb3e8Ab9D6Aaa09953Bf6d4d2f0aa105c6d11", "mockWeb3Network": "bsc,ethereum", "expectedCredentialValue": true }, @@ -178,7 +150,7 @@ }, "dataProvider": "nodereal", "network": "litentry", - "mockDid": "litentry:evm:0xcFD97648df7fB75A545c69106d2049aa3D540334", + "mockDid": "litentry:evm:0x5b2a74B28C271800D743c8d9Cb5EDB145c32e718", "mockWeb3Network": "bsc,ethereum", "expectedCredentialValue": true }, @@ -192,7 +164,7 @@ }, "dataProvider": "nodereal", "network": "ethereum", - "mockDid": "litentry:evm:0x60E4F4bF50204dEeeD8bF4C6216b41BA2e5e453a", + "mockDid": "litentry:evm:0x1DF5DFE74De0Fd7De571bfF235e2f1E7F2F04c71", "mockWeb3Network": "bsc,ethereum", "expectedCredentialValue": true }, @@ -206,7 +178,7 @@ }, "dataProvider": "nodereal", "network": "ethereum", - "mockDid": "litentry:evm:0x8BaE6C9EA994d18e6b05cE33aE3e54Fa6F7FcE82", + "mockDid": "litentry:evm:0x202869cC52285E05B279796C6f379e79d50cDc21", "mockWeb3Network": "bsc,ethereum", "expectedCredentialValue": true }, @@ -220,7 +192,7 @@ }, "dataProvider": "nodereal", "network": "ethereum", - "mockDid": "litentry:evm:0x2d23D597b21F88c55fC6f1E2a84f42b06b7915dF", + "mockDid": "litentry:evm:0x12B1Cd23A925EFE7bc7584E26F6e7f33494755dB", "mockWeb3Network": "bsc,ethereum", "expectedCredentialValue": true }, @@ -234,7 +206,7 @@ }, "dataProvider": "nodereal", "network": "ethereum", - "mockDid": "litentry:evm:0xDebc74120F822C0F0e6Eb69dB5F347F574d2D446", + "mockDid": "litentry:evm:0x221A5d1FCABecA06608eaaA4DF016533b1Ff67CA", "mockWeb3Network": "bsc,ethereum", "expectedCredentialValue": true }, @@ -248,7 +220,7 @@ }, "dataProvider": "nodereal", "network": "ethereum", - "mockDid": "litentry:evm:0x31743a08D895d01a49dB98b8F9c8469D92f63745", + "mockDid": "litentry:evm:0xd28424E9c65F8496456a2387556e621e9Bb066Af", "mockWeb3Network": "bsc,ethereum", "expectedCredentialValue": true }, @@ -262,7 +234,7 @@ }, "dataProvider": "nodereal", "network": "ethereum", - "mockDid": "litentry:evm:0x67aB29354a70732CDC97f372Be81d657ce8822cd", + "mockDid": "litentry:evm:0x8558FE88F8439dDcd7453ccAd6671Dfd90657a32", "mockWeb3Network": "bsc,ethereum", "expectedCredentialValue": true }, @@ -276,35 +248,7 @@ }, "dataProvider": "nodereal", "network": "ethereum", - "mockDid": "litentry:evm:0x3B7BB88dB769923dC2eE1e9e6A83c00A74c407D2", - "mockWeb3Network": "bsc,ethereum", - "expectedCredentialValue": true - }, - { - "id": "token-staking-amount-lit", - "name": "LIT Staking Amount", - "description": "You are staking a certain amount of LIT", - "assertion": { - "id": "LitStaking", - "payload": [] - }, - "dataProvider": "nodereal", - "network": "litentry", - "mockDid": "litentry:substrate:0xfc7a9dd32be14db4695555aa9a2abd240a8c2160f84ccb403a985701dd13fe50", - "mockWeb3Network": "litentry,polkadot", - "expectedCredentialValue": true - }, - { - "id": "weirdo-ghost-gang-holder", - "name": "WeirdoGhostGang Holder", - "description": "You are WeirdoGhostGang NFT holder", - "assertion": { - "id": "WeirdoGhostGangHolder", - "payload": [] - }, - "dataProvider": "nodereal", - "network": "ethereum", - "mockDid": "litentry:evm:0xCaA18Cd73E2756c680859F0A97E2C4846D50f71B", + "mockDid": "litentry:evm:0xDe8A35e0e8859ceD282103Fd15d8dD72Fd6Bb862", "mockWeb3Network": "bsc,ethereum", "expectedCredentialValue": true } diff --git a/tee-worker/ts-tests/integration-tests/package.json b/tee-worker/ts-tests/integration-tests/package.json index 280181ebfa..95c89e0b5e 100644 --- a/tee-worker/ts-tests/integration-tests/package.json +++ b/tee-worker/ts-tests/integration-tests/package.json @@ -46,7 +46,8 @@ "tweetnacl": "^1.0.3", "websocket-as-promised": "^2.0.1", "ws": "^8.17.1", - "zx": "^7.2.3" + "zx": "^7.2.3", + "@litentry/chaindata": "^0.2.0" }, "devDependencies": { "@ethersproject/providers": "^5.7.2", diff --git a/tee-worker/ts-tests/integration-tests/data-provider.test.ts b/tee-worker/ts-tests/integration-tests/vc_correctness.test.ts similarity index 50% rename from tee-worker/ts-tests/integration-tests/data-provider.test.ts rename to tee-worker/ts-tests/integration-tests/vc_correctness.test.ts index 6e0ce9dfa1..1abe11fc06 100644 --- a/tee-worker/ts-tests/integration-tests/data-provider.test.ts +++ b/tee-worker/ts-tests/integration-tests/vc_correctness.test.ts @@ -18,6 +18,10 @@ import { subscribeToEventsWithExtHash } from './common/transactions'; import { KeyringPair } from '@polkadot/keyring/types'; import { u8aToHex } from '@polkadot/util'; import { CredentialDefinition, credentialsJson } from './common/credential-json'; +import { byId } from '@litentry/chaindata'; + +// Change this to the environment you want to test +const chain = byId['litentry-dev']; describe('Test Vc (direct invocation)', function () { let context: IntegrationTestContext = undefined as any; @@ -29,9 +33,17 @@ describe('Test Vc (direct invocation)', function () { const keyringPairs: KeyringPair[] = []; let argvId = ''; + const nodeEndpoint: string = chain.rpcs[0].url; + const enclaveEndpoint: string = chain.enclaveRpcs[0].url; + console.log(`[node] ${nodeEndpoint}`); + console.log(`[worker] ${enclaveEndpoint}`); + + const teeDevNodePort = 443; + const teeDevWorkerPort = 443; + const errorArray: { id: string; index: number; assertion: any; error: any }[] = []; this.timeout(6000000); before(async () => { - context = await initIntegrationTestContext(process.env.WORKER_ENDPOINT!, process.env.NODE_ENDPOINT!); + context = await initIntegrationTestContext(enclaveEndpoint, nodeEndpoint); teeShieldingKey = await getTeeShieldingKey(context); }); @@ -40,12 +52,8 @@ describe('Test Vc (direct invocation)', function () { // `pnpm run test-data-providers:local` for all tests const idIndex = process.argv.indexOf('--id'); argvId = process.argv[idIndex + 1]; - const { - protocol: workerProtocal, - hostname: workerHostname, - port: workerPort, - } = new URL(process.env.WORKER_ENDPOINT!); - const { protocol: nodeProtocal, hostname: nodeHostname, port: nodePort } = new URL(process.env.NODE_ENDPOINT!); + const { protocol: workerProtocal, hostname: workerHostname } = new URL(enclaveEndpoint); + const { protocol: nodeProtocal, hostname: nodeHostname } = new URL(nodeEndpoint); async function linkIdentityViaCli(id: string) { const credentialDefinitions = credentialsJson.find((item) => item.id === id) as CredentialDefinition; @@ -59,7 +67,7 @@ describe('Test Vc (direct invocation)', function () { const eventsPromise = subscribeToEventsWithExtHash(reqExtHash, context); try { // CLIENT = "$CLIENT_BIN -p $NPORT -P $WORKER1PORT -u $NODEURL -U $WORKER1URL" - const commandPromise = zx`${clientDir} -p ${nodePort} -P ${workerPort} -u ${ + const commandPromise = zx`${clientDir} -p ${teeDevNodePort} -P ${teeDevWorkerPort} -u ${ nodeProtocal + nodeHostname } -U ${workerProtocal + workerHostname}\ trusted -d link-identity did:litentry:substrate:${formatAddress}\ @@ -78,42 +86,55 @@ describe('Test Vc (direct invocation)', function () { } async function requestVc(id: string, index: number) { - const credentialDefinitions = credentialsJson.find((item) => item.id === id) as CredentialDefinition; - const assertion = { - [credentialDefinitions.assertion.id]: credentialDefinitions.assertion.payload, - }; - console.log('vc description: ', credentialDefinitions.description); - - console.log('assertion: ', assertion); - - let currentNonce = (await getSidechainNonce(context, substrateIdentities[index])).toNumber(); - const getNextNonce = () => currentNonce++; - const nonce = getNextNonce(); - - const requestIdentifier = `0x${randomBytes(32).toString('hex')}`; - const requestVcCall = await createSignedTrustedCallRequestVc( - context.api, - context.mrEnclave, - context.api.createType('Index', nonce), - new PolkadotSigner(keyringPairs[index]), - substrateIdentities[index], - context.api.createType('Assertion', assertion).toHex(), - context.api.createType('Option', aesKey).toHex(), - requestIdentifier - ); - const res = await sendRequestFromTrustedCall(context, teeShieldingKey, requestVcCall); - await assertIsInSidechainBlock(`${Object.keys(assertion)[0]} requestVcCall`, res); - - const vcResults = context.api.createType('RequestVCResult', res.value); - const decryptVcPayload = decryptWithAes(aesKey, vcResults.vc_payload, 'utf-8').replace('0x', ''); - const vcPayloadJson = JSON.parse(decryptVcPayload); - console.log('vcPayload: ', vcPayloadJson); - - assert.equal( - vcPayloadJson.credentialSubject.values[0], - credentialDefinitions.expectedCredentialValue, - "credential value doesn't match, please check the credential json expectedCredentialValue" - ); + try { + const credentialDefinitions = credentialsJson.find((item) => item.id === id) as CredentialDefinition; + const assertion = { + [credentialDefinitions.assertion.id]: credentialDefinitions.assertion.payload, + }; + console.log('vc description: ', credentialDefinitions.description); + + console.log('assertion: ', assertion); + + let currentNonce = (await getSidechainNonce(context, substrateIdentities[index])).toNumber(); + const getNextNonce = () => currentNonce++; + const nonce = getNextNonce(); + + const requestIdentifier = `0x${randomBytes(32).toString('hex')}`; + const requestVcCall = await createSignedTrustedCallRequestVc( + context.api, + context.mrEnclave, + context.api.createType('Index', nonce), + new PolkadotSigner(keyringPairs[index]), + substrateIdentities[index], + context.api.createType('Assertion', assertion).toHex(), + context.api.createType('Option', aesKey).toHex(), + requestIdentifier + ); + const res = await sendRequestFromTrustedCall(context, teeShieldingKey, requestVcCall); + await assertIsInSidechainBlock(`${Object.keys(assertion)[0]} requestVcCall`, res); + + const vcResults = context.api.createType('RequestVCResult', res.value); + const decryptVcPayload = decryptWithAes(aesKey, vcResults.vc_payload, 'utf-8').replace('0x', ''); + const vcPayloadJson = JSON.parse(decryptVcPayload); + console.log('vcPayload: ', vcPayloadJson); + + assert.equal( + vcPayloadJson.credentialSubject.values[0], + credentialDefinitions.expectedCredentialValue, + "credential value doesn't match, please check the credential json expectedCredentialValue" + ); + } catch (error) { + // Sometimes unstable dataprovider can cause interruptions in the testing process. We expect errors in the test to be stored and specific error information to be thrown out after the end. + const credentialDefinitions = credentialsJson.find((item) => item.id === id) as CredentialDefinition; + + errorArray.push({ + id: id, + index: index, + assertion: credentialDefinitions.assertion.payload, + error: error, + }); + console.error(`Error in requestVc for id ${id} at index ${index}:`, error); + } } if (argvId && credentialsJson.find((item) => item.id === argvId)) { @@ -129,4 +150,10 @@ describe('Test Vc (direct invocation)', function () { }); }); } + after(async function () { + if (errorArray.length > 0) { + console.log('errorArray:', errorArray); + throw new Error(`${errorArray.length} tests failed. See above for details.`); + } + }); }); diff --git a/tee-worker/ts-tests/pnpm-lock.yaml b/tee-worker/ts-tests/pnpm-lock.yaml index c0d5b94fa2..4f1484b81c 100644 --- a/tee-worker/ts-tests/pnpm-lock.yaml +++ b/tee-worker/ts-tests/pnpm-lock.yaml @@ -10,6 +10,9 @@ importers: integration-tests: dependencies: + '@litentry/chaindata': + specifier: ^0.2.0 + version: 0.2.0 '@litentry/vc-schema-validator': specifier: ^0.0.1 version: 0.0.1(ajv-formats@2.1.1)(ajv@8.12.0)(fast-glob@3.3.2)(tslib@2.6.2)