Skip to content

Commit

Permalink
chore: P-1044 merge all identity tests into one (#3113)
Browse files Browse the repository at this point in the history
* chore: P-1044 combine all di identity tests, update ci config to run the combined di identity tests

* removed unused function and clean up

---------

Co-authored-by: higherordertech <higherordertech>
  • Loading branch information
higherordertech authored Oct 10, 2024
1 parent 8daa6bf commit 1189d1a
Show file tree
Hide file tree
Showing 24 changed files with 399 additions and 2,714 deletions.
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 @@ -85,7 +85,7 @@ RUN cargo test --release
##################################################
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 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
27 changes: 21 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
Original file line number Diff line number Diff line change
Expand Up @@ -146,15 +146,15 @@ export async function buildValidations(
signerIdentitity: CorePrimitivesIdentity,
linkIdentity: CorePrimitivesIdentity,
startingSidechainNonce: number,
network: 'ethereum' | 'substrate' | 'bitcoin' | 'solana',
network: 'evm' | 'substrate' | 'bitcoin' | 'solana',
signer?: Signer,
options?: { prettifiedMessage?: boolean }
): Promise<LitentryValidationData> {
const _options = { prettifiedMessage: false, ...options };
const validationNonce = startingSidechainNonce++;

const msg = generateVerificationMessage(context, signerIdentitity, linkIdentity, validationNonce);
if (network === 'ethereum') {
if (network === 'evm') {
const evmValidationData = {
Web3Validation: {
Evm: {
Expand Down
Loading

0 comments on commit 1189d1a

Please sign in to comment.