Skip to content

Commit d602829

Browse files
committed
refactor(artillery): update command scripts to include logging options and remove module type; add TypeScript configuration
1 parent 151df69 commit d602829

File tree

3 files changed

+71
-64
lines changed

3 files changed

+71
-64
lines changed

packages/e2e/artillery/README.md

Lines changed: 41 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -1,84 +1,72 @@
1-
# 🚀 Run Artillery tests
1+
# @lit-protocol/artillery
2+
3+
Standalone Artillery load-testing package for Lit Protocol. Moved from `packages/e2e/artillery`.
4+
5+
Usage via root scripts remains the same, now pointing to `packages/artillery`.
6+
7+
# Run Artillery tests
28

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

6-
### Basic functionality verification
12+
## Setup Commands
713

8-
**⭐️ Purpose**: Basic sanity check
14+
### Initialise Artillery
915

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

15-
```jsx
16-
LOG_LEVEL=silent NETWORK=naga-dev bun run artillery:smoke
18+
```bash
19+
nx run artillery:init
1720
```
1821

19-
### Normal traffic simulation
20-
21-
**⭐️ Purpose**: Simulates typical everyday usage
22+
### Check Balance Status
2223

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

28-
```jsx
29-
LOG_LEVEL=silent NETWORK=naga-dev bun run artillery:load
26+
```bash
27+
nx run artillery:balance-status
3028
```
3129

32-
### Find breaking points
30+
## Load Testing Commands
3331

34-
**⭐️ Purpose**: Pushes system beyond normal limits to find where it breaks
32+
### PKP Sign Focused
3533

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

41-
```jsx
42-
LOG_LEVEL=silent NETWORK=naga-dev bun run artillery:stress
36+
```bash
37+
nx run artillery:pkp-sign
4338
```
4439

45-
### Test traffic spikes
46-
47-
**⭐️ Purpose**: Sudden traffic bursts (like when your app goes viral)
40+
### Encrypt-Decrypt Focused
4841

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

54-
```jsx
55-
LOG_LEVEL=silent NETWORK=naga-dev bun run artillery:spike
44+
```bash
45+
nx run artillery:encrypt-decrypt
5646
```
5747

58-
### PKP Sign Focused
59-
60-
**⭐️ Purpose**: Hammers the PKP signing functionality specifically
48+
### Execute Actions
6149

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

67-
```jsx
68-
LOG_LEVEL=silent NETWORK=naga-dev bun run artillery:pkp-sign
52+
```bash
53+
nx run artillery:execute
6954
```
7055

71-
### Encrypt-Decrypt Focused
56+
### Mixed Workload
7257

73-
**⭐️ Purpose**: Hammers encryption/decryption functionality specifically
58+
**⭐️ Purpose**: Tests a combination of different Lit Protocol operations
7459

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

80-
```jsx
81-
LOG_LEVEL=silent NETWORK=naga-dev bun run artillery:encrypt-decrypt
64+
### Sign Session Key
65+
66+
**⭐️ Purpose**: Tests session key signing functionality
67+
68+
```bash
69+
nx run artillery:sign-session-key
8270
```
8371

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

8876
```jsx
8977
ARTILLERY_KEY = xxx;
90-
```
78+
```

packages/e2e/artillery/src/init.ts

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,11 @@ import {
66
} from '@lit-protocol/auth';
77
import * as StateManager from './StateManager';
88
import { createLitClient } from '@lit-protocol/lit-client';
9-
import { getOrCreatePkp } from '../../../e2e/src/helper/pkp-utils';
10-
import * as NetworkManager from '../../../e2e/src/helper/NetworkManager';
9+
import {
10+
getOrCreatePkp,
11+
getLitNetworkModule,
12+
getViemPublicClient,
13+
} from '@lit-protocol/e2e';
1114
import * as AccountManager from '../src/AccountManager';
1215

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

2326
// 1. Setup network and chain client
24-
const networkModule = await NetworkManager.getLitNetworkModule();
25-
const publicClient = await NetworkManager.getViemPublicClient({
27+
const networkModule = await getLitNetworkModule();
28+
const publicClient = await getViemPublicClient({
2629
networkModule,
2730
});
2831
const litClient = await createLitClient({ network: networkModule });
@@ -89,13 +92,7 @@ const LEDGER_MINIMUM_BALANCE = 20000;
8992
// 5. get or mint a PKP for the master account
9093
const masterAccountPkp = await StateManager.getOrUpdate(
9194
'masterAccount.pkp',
92-
await getOrCreatePkp(
93-
litClient,
94-
masterAccountAuthData,
95-
masterAccount,
96-
'./artillery-pkp-tokens',
97-
`${_network}-artillery`
98-
)
95+
await getOrCreatePkp(litClient, masterAccountAuthData, masterAccount)
9996
);
10097

10198
console.log('✅ Master Account PKP:', masterAccountPkp);
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
{
2+
"extends": "../../tsconfig.base.json",
3+
"compilerOptions": {
4+
"module": "commonjs",
5+
"forceConsistentCasingInFileNames": true,
6+
"strict": true,
7+
"noImplicitOverride": true,
8+
"noPropertyAccessFromIndexSignature": true,
9+
"noImplicitReturns": true,
10+
"noFallthroughCasesInSwitch": true
11+
},
12+
"files": [],
13+
"include": [],
14+
"references": [
15+
{
16+
"path": "./tsconfig.lib.json"
17+
},
18+
{
19+
"path": "./tsconfig.spec.json"
20+
}
21+
]
22+
}

0 commit comments

Comments
 (0)