Thanks to visit codestin.com
Credit goes to github.com

Skip to content
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
Prev Previous commit
Next Next commit
refactor(artillery): update command scripts to include logging option…
…s and remove module type; add TypeScript configuration
  • Loading branch information
Ansonhkg committed Sep 15, 2025
commit d6028298f219b656442310f47839ccbc9ba3c789
94 changes: 41 additions & 53 deletions packages/e2e/artillery/README.md
Original file line number Diff line number Diff line change
@@ -1,84 +1,72 @@
# 🚀 Run Artillery tests
# @lit-protocol/artillery

Standalone Artillery load-testing package for Lit Protocol. Moved from `packages/e2e/artillery`.

Usage via root scripts remains the same, now pointing to `packages/artillery`.

# Run Artillery tests

- LOG_LEVEL= `debug` | `info` | `silent` | `debug2` (raw console.log)
- NETWORK= `naga-dev` | `naga-staging`

### Basic functionality verification
## Setup Commands

**⭐️ Purpose**: Basic sanity check
### Initialise Artillery

- **Users**: 3 people max, 1 new user every minute
- **Duration**: 30 seconds
- **Tests**: All main functions once
- **When to use**: Before releasing code, quick health check, "did I break anything?"
**⭐️ Purpose**: Sets up accounts, balances, and authentication for testing

```jsx
LOG_LEVEL=silent NETWORK=naga-dev bun run artillery:smoke
```bash
nx run artillery:init
```

### Normal traffic simulation

**⭐️ Purpose**: Simulates typical everyday usage
### Check Balance Status

- **Users**: 30 people max, 10 new users per second during peak
- **Duration**: 5 minutes total (1min ramp up, 3min steady, 1min ramp down)
- **Tests**: All functions with realistic ratios (40% signing, 30% encryption, 20% JS execution, 10% viewing)
- **When to use**: "Will this handle our normal traffic?"
**⭐️ Purpose**: Check account balances before running tests

```jsx
LOG_LEVEL=silent NETWORK=naga-dev bun run artillery:load
```bash
nx run artillery:balance-status
```

### Find breaking points
## Load Testing Commands

**⭐️ Purpose**: Pushes system beyond normal limits to find where it breaks
### PKP Sign Focused

- **Users**: 200 people max, up to 50 new users per second
- **Duration**: 11 minutes of gradually increasing pressure
- **Tests**: Same mix as load test but much more intense
- **When to use**: "How much traffic can we handle before things go wrong?"
**⭐️ Purpose**: Tests PKP signing functionality specifically

```jsx
LOG_LEVEL=silent NETWORK=naga-dev bun run artillery:stress
```bash
nx run artillery:pkp-sign
```

### Test traffic spikes

**⭐️ Purpose**: Sudden traffic bursts (like when your app goes viral)
### Encrypt-Decrypt Focused

- **Users**: 400 people max during spikes, jumps from 2 to 150 users/second instantly
- **Duration**: 6 minutes with two sudden traffic spikes
- **Tests**: Focuses on signing and encryption (most critical functions)
- **When to use**: "What happens if we suddenly get 100x more traffic?"
**⭐️ Purpose**: Tests encryption/decryption functionality

```jsx
LOG_LEVEL=silent NETWORK=naga-dev bun run artillery:spike
```bash
nx run artillery:encrypt-decrypt
```

### PKP Sign Focused

**⭐️ Purpose**: Hammers the PKP signing functionality specifically
### Execute Actions

- **Users**: 50 people max, 15 new users per second during peak
- **Duration**: 7 minutes with sustained high signing load
- **Tests**: ONLY PKP signing with different authentication methods
- **When to use**: "Is our signing service robust enough for heavy use?"
**⭐️ Purpose**: Tests Lit Action execution functionality

```jsx
LOG_LEVEL=silent NETWORK=naga-dev bun run artillery:pkp-sign
```bash
nx run artillery:execute
```

### Encrypt-Decrypt Focused
### Mixed Workload

**⭐️ Purpose**: Hammers encryption/decryption functionality specifically
**⭐️ Purpose**: Tests a combination of different Lit Protocol operations

- **Users**: 30 people max, 8 new users per second during peak
- **Duration**: 6 minutes of sustained encryption/decryption
- **Tests**: ONLY encryption and decryption functions
- **When to use**: "Can our encryption handle lots of data processing?"
```bash
nx run artillery:mix
```

```jsx
LOG_LEVEL=silent NETWORK=naga-dev bun run artillery:encrypt-decrypt
### Sign Session Key

**⭐️ Purpose**: Tests session key signing functionality

```bash
nx run artillery:sign-session-key
```

## (Optional) Generating a report
Expand All @@ -87,4 +75,4 @@ Generating a report required an API key, you can add that to the root `.env` fil

```jsx
ARTILLERY_KEY = xxx;
```
```
19 changes: 8 additions & 11 deletions packages/e2e/artillery/src/init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,11 @@ import {
} from '@lit-protocol/auth';
import * as StateManager from './StateManager';
import { createLitClient } from '@lit-protocol/lit-client';
import { getOrCreatePkp } from '../../../e2e/src/helper/pkp-utils';
import * as NetworkManager from '../../../e2e/src/helper/NetworkManager';
import {
getOrCreatePkp,
getLitNetworkModule,
getViemPublicClient,
} from '@lit-protocol/e2e';
import * as AccountManager from '../src/AccountManager';

const _network = process.env['NETWORK'];
Expand All @@ -21,8 +24,8 @@ const LEDGER_MINIMUM_BALANCE = 20000;
console.log('\x1b[90m✅ Initialising Artillery...\x1b[0m');

// 1. Setup network and chain client
const networkModule = await NetworkManager.getLitNetworkModule();
const publicClient = await NetworkManager.getViemPublicClient({
const networkModule = await getLitNetworkModule();
const publicClient = await getViemPublicClient({
networkModule,
});
const litClient = await createLitClient({ network: networkModule });
Expand Down Expand Up @@ -89,13 +92,7 @@ const LEDGER_MINIMUM_BALANCE = 20000;
// 5. get or mint a PKP for the master account
const masterAccountPkp = await StateManager.getOrUpdate(
'masterAccount.pkp',
await getOrCreatePkp(
litClient,
masterAccountAuthData,
masterAccount,
'./artillery-pkp-tokens',
`${_network}-artillery`
)
await getOrCreatePkp(litClient, masterAccountAuthData, masterAccount)
);

console.log('✅ Master Account PKP:', masterAccountPkp);
Expand Down
22 changes: 22 additions & 0 deletions packages/e2e/artillery/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"extends": "../../tsconfig.base.json",
"compilerOptions": {
"module": "commonjs",
"forceConsistentCasingInFileNames": true,
"strict": true,
"noImplicitOverride": true,
"noPropertyAccessFromIndexSignature": true,
"noImplicitReturns": true,
"noFallthroughCasesInSwitch": true
},
"files": [],
"include": [],
"references": [
{
"path": "./tsconfig.lib.json"
},
{
"path": "./tsconfig.spec.json"
}
]
}