Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: P-1044 merge all identity tests into one #3113

Merged
merged 2 commits into from
Oct 10, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 2 additions & 10 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -709,15 +709,10 @@ jobs:
fail-fast: false
matrix:
include:
- test_name: lit-di-substrate-identity-test
- test_name: lit-di-evm-identity-test
- test_name: lit-di-bitcoin-identity-test
- test_name: lit-di-solana-identity-test
- test_name: lit-di-identity-test
- test_name: lit-dr-vc-test
- test_name: lit-parentchain-nonce
- test_name: lit-test-failed-parentchain-extrinsic
- test_name: lit-twitter-identity-test
- test_name: lit-discord-identity-test
name: ${{ matrix.test_name }}
steps:
- uses: actions/checkout@v4
Expand Down Expand Up @@ -785,10 +780,7 @@ jobs:
fail-fast: false
matrix:
include:
- test_name: lit-di-bitcoin-identity-multiworker-test
- test_name: lit-di-evm-identity-multiworker-test
- test_name: lit-di-solana-identity-multiworker-test
- test_name: lit-di-substrate-identity-multiworker-test
- test_name: lit-di-identity-multiworker-test
- test_name: lit-dr-vc-multiworker-test
- test_name: lit-resume-worker
name: ${{ matrix.test_name }}
Expand Down
2 changes: 1 addition & 1 deletion tee-worker/identity/build.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@
LABEL maintainer="Trust Computing GmbH <[email protected]>"

# set environment variables
ENV SGX_SDK /opt/sgxsdk

Check warning on line 25 in tee-worker/identity/build.Dockerfile

View workflow job for this annotation

GitHub Actions / identity-build

Legacy key/value format with whitespace separator should not be used

LegacyKeyValueFormat: "ENV key=value" should be used instead of legacy "ENV key value" format More info: https://docs.docker.com/go/dockerfile/rule/legacy-key-value-format/
ENV PATH "$PATH:${SGX_SDK}/bin:${SGX_SDK}/bin/x64:/opt/rust/bin"

Check warning on line 26 in tee-worker/identity/build.Dockerfile

View workflow job for this annotation

GitHub Actions / identity-build

Legacy key/value format with whitespace separator should not be used

LegacyKeyValueFormat: "ENV key=value" should be used instead of legacy "ENV key value" format More info: https://docs.docker.com/go/dockerfile/rule/legacy-key-value-format/
ENV PKG_CONFIG_PATH "${PKG_CONFIG_PATH}:${SGX_SDK}/pkgconfig"

Check warning on line 27 in tee-worker/identity/build.Dockerfile

View workflow job for this annotation

GitHub Actions / identity-build

Legacy key/value format with whitespace separator should not be used

LegacyKeyValueFormat: "ENV key=value" should be used instead of legacy "ENV key value" format More info: https://docs.docker.com/go/dockerfile/rule/legacy-key-value-format/
ENV LD_LIBRARY_PATH "${LD_LIBRARY_PATH}:${SGX_SDK}/sdk_libs"

Check warning on line 28 in tee-worker/identity/build.Dockerfile

View workflow job for this annotation

GitHub Actions / identity-build

Legacy key/value format with whitespace separator should not be used

LegacyKeyValueFormat: "ENV key=value" should be used instead of legacy "ENV key value" format More info: https://docs.docker.com/go/dockerfile/rule/legacy-key-value-format/
ENV CARGO_NET_GIT_FETCH_WITH_CLI true

Check warning on line 29 in tee-worker/identity/build.Dockerfile

View workflow job for this annotation

GitHub Actions / identity-build

Legacy key/value format with whitespace separator should not be used

LegacyKeyValueFormat: "ENV key=value" should be used instead of legacy "ENV key value" format More info: https://docs.docker.com/go/dockerfile/rule/legacy-key-value-format/

ENV SCCACHE_CACHE_SIZE="20G"
ENV SCCACHE_DIR="/opt/rust/sccache"
Expand Down Expand Up @@ -58,8 +58,8 @@

ARG FINGERPRINT=none

ARG SGX_COMMERCIAL_KEY

Check warning on line 61 in tee-worker/identity/build.Dockerfile

View workflow job for this annotation

GitHub Actions / identity-build

Sensitive data should not be used in the ARG or ENV commands

SecretsUsedInArgOrEnv: Do not use ARG or ENV instructions for sensitive data (ARG "SGX_COMMERCIAL_KEY") More info: https://docs.docker.com/go/dockerfile/rule/secrets-used-in-arg-or-env/
ENV SGX_COMMERCIAL_KEY=$SGX_COMMERCIAL_KEY

Check warning on line 62 in tee-worker/identity/build.Dockerfile

View workflow job for this annotation

GitHub Actions / identity-build

Sensitive data should not be used in the ARG or ENV commands

SecretsUsedInArgOrEnv: Do not use ARG or ENV instructions for sensitive data (ENV "SGX_COMMERCIAL_KEY") More info: https://docs.docker.com/go/dockerfile/rule/secrets-used-in-arg-or-env/

WORKDIR $HOME/tee-worker/identity
COPY . $HOME
Expand All @@ -85,7 +85,7 @@
##################################################
FROM node:18-bookworm-slim AS runner

RUN apt update && apt install -y libssl-dev iproute2 jq curl protobuf-compiler
RUN apt update && apt install -y libssl-dev iproute2 jq curl protobuf-compiler python3 python-is-python3 build-essential
RUN corepack enable && corepack prepare [email protected] --activate && corepack enable pnpm


Expand All @@ -97,8 +97,8 @@
ARG SCRIPT_DIR=/usr/local/worker-cli
ARG LOG_DIR=/usr/local/log

ENV SCRIPT_DIR ${SCRIPT_DIR}

Check warning on line 100 in tee-worker/identity/build.Dockerfile

View workflow job for this annotation

GitHub Actions / identity-build

Legacy key/value format with whitespace separator should not be used

LegacyKeyValueFormat: "ENV key=value" should be used instead of legacy "ENV key value" format More info: https://docs.docker.com/go/dockerfile/rule/legacy-key-value-format/
ENV LOG_DIR ${LOG_DIR}

Check warning on line 101 in tee-worker/identity/build.Dockerfile

View workflow job for this annotation

GitHub Actions / identity-build

Legacy key/value format with whitespace separator should not be used

LegacyKeyValueFormat: "ENV key=value" should be used instead of legacy "ENV key value" format More info: https://docs.docker.com/go/dockerfile/rule/legacy-key-value-format/

COPY --from=local-builder:latest /home/ubuntu/tee-worker/identity/bin/litentry-cli /usr/local/bin
COPY --from=local-builder:latest /home/ubuntu/tee-worker/identity/cli/*.sh /usr/local/worker-cli/
Expand Down Expand Up @@ -130,9 +130,9 @@
RUN ls -al /usr/local/bin

# checks
ENV SGX_SDK /opt/sgxsdk

Check warning on line 133 in tee-worker/identity/build.Dockerfile

View workflow job for this annotation

GitHub Actions / identity-build

Legacy key/value format with whitespace separator should not be used

LegacyKeyValueFormat: "ENV key=value" should be used instead of legacy "ENV key value" format More info: https://docs.docker.com/go/dockerfile/rule/legacy-key-value-format/
ENV SGX_ENCLAVE_SIGNER $SGX_SDK/bin/x64/sgx_sign

Check warning on line 134 in tee-worker/identity/build.Dockerfile

View workflow job for this annotation

GitHub Actions / identity-build

Legacy key/value format with whitespace separator should not be used

LegacyKeyValueFormat: "ENV key=value" should be used instead of legacy "ENV key value" format More info: https://docs.docker.com/go/dockerfile/rule/legacy-key-value-format/
ENV LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/opt/intel/sgx-aesm-service/aesm:$SGX_SDK/sdk_libs

Check warning on line 135 in tee-worker/identity/build.Dockerfile

View workflow job for this annotation

GitHub Actions / identity-build

Variables should be defined before their use

UndefinedVar: Usage of undefined variable '$LD_LIBRARY_PATH' More info: https://docs.docker.com/go/dockerfile/rule/undefined-var/
ENV AESM_PATH=/opt/intel/sgx-aesm-service/aesm

RUN ldd /usr/local/bin/litentry-worker && /usr/local/bin/litentry-worker --version
Expand Down

This file was deleted.

22 changes: 0 additions & 22 deletions tee-worker/identity/docker/lit-di-bitcoin-identity-test.yml

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
services:
lit-di-evm-identity-multiworker-test:
lit-di-identity-multiworker-test:
image: litentry/identity-cli:latest
container_name: litentry-di-evm-identity-test
container_name: litentry-di-identity-test
volumes:
- ../ts-tests:/ts-tests
- ../client-api:/client-api
Expand All @@ -15,7 +15,7 @@ services:
condition: service_healthy
networks:
- litentry-test-network
entrypoint: "bash -c '/usr/local/worker-cli/lit_ts_integration_test.sh di_evm_identity.test.ts 2>&1' "
entrypoint: "bash -c '/usr/local/worker-cli/lit_ts_integration_test.sh di_identity.test.ts 2>&1' "
restart: "no"
networks:
litentry-test-network:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
services:
lit-di-evm-identity-test:
lit-di-identity-test:
image: litentry/identity-cli:latest
container_name: litentry-di-evm-identity-test
container_name: litentry-di-identity-test
volumes:
- ../ts-tests:/ts-tests
- ../client-api:/client-api
Expand All @@ -15,7 +15,7 @@ services:
condition: service_healthy
networks:
- litentry-test-network
entrypoint: "bash -c '/usr/local/worker-cli/lit_ts_integration_test.sh di_evm_identity.test.ts 2>&1' "
entrypoint: "bash -c '/usr/local/worker-cli/lit_ts_integration_test.sh di_identity.test.ts 2>&1' "
restart: "no"
networks:
litentry-test-network:
Expand Down

This file was deleted.

22 changes: 0 additions & 22 deletions tee-worker/identity/docker/lit-di-solana-identity-test.yml

This file was deleted.

This file was deleted.

22 changes: 0 additions & 22 deletions tee-worker/identity/docker/lit-di-substrate-identity-test.yml

This file was deleted.

22 changes: 0 additions & 22 deletions tee-worker/identity/docker/lit-discord-identity-test.yml

This file was deleted.

22 changes: 0 additions & 22 deletions tee-worker/identity/docker/lit-twitter-identity-test.yml

This file was deleted.

12 changes: 3 additions & 9 deletions tee-worker/identity/ts-tests/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,17 +33,11 @@ pnpm install
pnpm --filter integration-tests run test your-testfile.test.ts
```

II identity test: `pnpm --filter integration-tests run test ii_identity.test.ts`
Direct invocation identity test: `pnpm --filter integration-tests run test di_identity.test.ts`

II vc test: `pnpm --filter integration-tests run test ii_vc.test.ts`
Direct invocation vc test: `pnpm --filter integration-tests run test vc_correctness.test.ts`

II batch identity test: `pnpm --filter integration-tests run test ii_batch.test.ts`

Direct invocation substrate identity test: `pnpm --filter integration-tests run test di_substrate_identity.test.ts`

Direct invocation evm identity test: `pnpm --filter integration-tests run test di_evm_identity.test.ts`

Direct invocation vc test: `pnpm --filter integration-tests run test di_vc.test.ts`
Direct requect vc test: `pnpm --filter integration-tests run test dr_vc.test.ts`

## Data-provider test

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { Signer } from './utils/crypto';
// If there are types already defined in the client-api, please avoid redefining these types.
// Instead, make every effort to use the types that have been generated within the client-api.

interface WalletType {
export interface WalletType {
[walletName: string]: Signer;
}
export interface Wallets {
Expand Down
20 changes: 20 additions & 0 deletions tee-worker/identity/ts-tests/integration-tests/common/di-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -347,6 +347,26 @@ export async function createSignedTrustedGetterIdGraph(
return parachainApi.createType('Getter', { trusted: getterSigned });
}

export async function createSignedTrustedCallCleanIDGraphs(
higherordertech marked this conversation as resolved.
Show resolved Hide resolved
parachainApi: ApiPromise,
mrenclave: string,
nonce: Codec,
signer: Signer,
primeIdentity: CorePrimitivesIdentity,
options?: { withWrappedBytes?: boolean; withPrefix?: boolean }
) {
return createSignedTrustedCall(
parachainApi,
['clean_id_graphs', '(LitentryIdentity)'],
signer,
mrenclave,
nonce,
primeIdentity.toHuman(),
options?.withWrappedBytes,
options?.withPrefix
);
}

export const getSidechainNonce = async (
context: IntegrationTestContext,
primeIdentity: CorePrimitivesIdentity
Expand Down
40 changes: 34 additions & 6 deletions tee-worker/identity/ts-tests/integration-tests/common/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,15 @@ import type { KeyringPair } from '@polkadot/keyring/types';
import type { HexString } from '@polkadot/util/types';
import './config';
import { IntegrationTestContext, JsonRpcRequest } from './common-types';
import { createHash, randomBytes } from 'crypto';
import { createHash, randomBytes, type KeyObject } from 'crypto';
import { ECPairFactory, ECPairInterface } from 'ecpair';
import * as ecc from 'tiny-secp256k1';
import { ethers, Wallet } from 'ethers';
import { Keypair } from '@solana/web3.js';
import { EthersSigner, PolkadotSigner, BitcoinSigner, SolanaSigner } from './utils/crypto';
import { EthersSigner, PolkadotSigner, BitcoinSigner, SolanaSigner, Signer } from './utils/crypto';
import { Wallets } from './common-types';
import type { ErrorDetail, StfError } from 'parachain-api';
import { createSignedTrustedCallCleanIDGraphs, getSidechainNonce, sendRequestFromTrustedCall } from './di-utils';

export function blake2128Concat(data: HexString | Uint8Array): Uint8Array {
return u8aConcat(blake2AsU8a(data, 128), u8aToU8a(data));
Expand Down Expand Up @@ -68,6 +69,21 @@ export function genesisSolanaWallet(name: string): Keypair {
return keyPair;
}

export const createWeb3Wallet = (walletType: string, walletName: string): Signer => {
switch (walletType) {
case 'evm':
return new EthersSigner(randomEvmWallet());
case 'substrate':
return new PolkadotSigner(genesisSubstrateWallet(walletName));
case 'bitcoin':
return new BitcoinSigner(randomBitcoinWallet());
case 'solana':
return new SolanaSigner(genesisSolanaWallet(walletName));
default:
throw new Error(`Unsupported wallet type: ${walletType}`);
}
};

export const createWeb3Wallets = (): Wallets => {
const wallets: Wallets = {
evm: {},
Expand All @@ -77,10 +93,9 @@ export const createWeb3Wallets = (): Wallets => {
};
const walletNames = ['Alice', 'Bob', 'Charlie', 'Dave', 'Eve'];
for (const name of walletNames) {
wallets.evm[name] = new EthersSigner(randomEvmWallet());
wallets.substrate[name] = new PolkadotSigner(genesisSubstrateWallet(name));
wallets.bitcoin[name] = new BitcoinSigner(randomBitcoinWallet());
wallets.solana[name] = new SolanaSigner(genesisSolanaWallet(name));
for (const walletType in wallets) {
(wallets as any)[walletType][name] = createWeb3Wallet(walletType, name);
}
}

return wallets;
Expand Down Expand Up @@ -115,3 +130,16 @@ export function stfErrorToString(stfError: StfError): string {

return stfError.type;
}

export async function cleanIDGraphs(context: IntegrationTestContext, teeShieldingKey: KeyObject) {
higherordertech marked this conversation as resolved.
Show resolved Hide resolved
const aliceSubstrateIdentity = await context.web3Wallets.substrate.Alice.getIdentity(context);
const nonce = (await getSidechainNonce(context, aliceSubstrateIdentity)).toNumber();
const CleanIDGraphsCall = await createSignedTrustedCallCleanIDGraphs(
context.api,
context.mrEnclave,
context.api.createType('Index', nonce),
context.web3Wallets.substrate.Alice,
aliceSubstrateIdentity
);
await sendRequestFromTrustedCall(context, teeShieldingKey, CleanIDGraphsCall);
}
Loading