Skip to content

Commit ed44607

Browse files
committed
docs: add runner to ADDING_SIGNERS.md and CLAUDE.md
1 parent ad5d81f commit ed44607

File tree

2 files changed

+110
-91
lines changed

2 files changed

+110
-91
lines changed

CLAUDE.md

Lines changed: 55 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -76,10 +76,7 @@ make lint-fix-all
7676
# Run unit tests
7777
make test
7878

79-
# Setup test environment (for integration tests)
80-
make setup-test-env
81-
82-
# Run integration tests
79+
# Run integration tests (automatically handles environment setup)
8380
make test-integration
8481

8582
# Run all tests
@@ -88,7 +85,7 @@ cargo test --workspace
8885

8986
#### Integration Test Environment Setup
9087

91-
Integration tests are fully automated using a makefile-based approach that handles sequential test execution:
88+
Integration tests are fully automated using a Rust test runner binary that handles sequential test execution:
9289

9390
**Quick Start:**
9491
```bash
@@ -100,24 +97,28 @@ make test-integration
10097
2. **Test Environment Setup**: Creates test accounts, tokens, and ATAs
10198
3. **Sequential Test Phases**: Runs 3 test suites with different configurations
10299

103-
**Test Phases (Auto-managed):**
100+
**Test Phases (Configured in `tests/src/test_runner/test_cases.toml`):**
104101

105-
**Phase 1: Regular integration tests (26 tests)**
102+
**Regular Tests**
106103
- Config: `tests/src/common/fixtures/kora-test.toml` (no auth)
107-
- Server: Standard Kora RPC server
108104
- Tests: Core RPC functionality, token operations, compute budget
109105

110-
**Phase 2: Auth integration tests (4 tests)**
106+
**Auth Tests**
111107
- Config: `tests/src/common/fixtures/auth-test.toml` (auth enabled)
112-
- Server: Restart with auth middleware
113108
- Tests: API key and HMAC authentication validation
114109

115-
**Phase 3: Payment address tests (2 tests)**
110+
**Payment Address Tests**
116111
- Config: `tests/src/common/fixtures/paymaster-address-test.toml` (payment address)
117-
- Server: Restart with payment address configuration
118112
- **CLI ATA Initialization**: Automatically runs `kora rpc initialize-atas` before tests
119113
- Tests: Payment address validation and wrong destination rejection
120114

115+
**Multi-Signer Tests**
116+
- Config: `tests/src/common/fixtures/multi-signers.toml`
117+
- Tests: Multiple signer configurations
118+
119+
**TypeScript Tests**
120+
- Tests: TypeScript SDK integration tests
121+
121122
**File Structure:**
122123
```
123124
tests/
@@ -132,55 +133,48 @@ tests/
132133
│ │ │ ├── payment-local.json # Payment address keypair
133134
│ │ │ ├── sender-local.json # Sender keypair
134135
│ │ │ └── usdc-mint-local.json # USDC mint keypair
135-
│ │ └── setup_test_env.rs # Test environment setup
136+
│ │ └── setup.rs # Test environment setup
137+
│ ├── test_runner/ # Test runner modules
138+
│ │ ├── accounts.rs # Account management
139+
│ │ ├── commands.rs # Test command execution
140+
│ │ ├── config.rs # Test configuration
141+
│ │ ├── kora.rs # Kora server management
142+
│ │ ├── output.rs # Output handling
143+
│ │ ├── test_cases.toml # Test phase configurations
144+
│ │ └── validator.rs # Solana validator management
136145
│ └── bin/
137-
│ └── setup_test_env.rs # Binary wrapper for setup
146+
│ └── test_runner.rs # Main test runner binary
138147
├── integration/ # Regular integration tests
139148
├── auth/ # Authentication tests
140149
└── payment-address/ # Payment address tests
141150
```
142151

143-
**Manual Test Commands (if needed):**
152+
**Test Runner Commands:**
144153
```bash
145-
# Setup test environment only
146-
make setup-test-env
154+
# Run all integration tests (default)
155+
make test-integration
156+
157+
# Run with verbose output
158+
make test-integration-verbose
147159

148-
# Clean up test environment
149-
make clean-test-env
160+
# Force refresh test accounts (ignore cached)
161+
make test-integration-fresh
150162

151-
# Run specific test phase
152-
cargo test -p tests --test integration
153-
cargo test -p tests --test auth
154-
cargo test -p tests --test payment-address
163+
# Run specific test
164+
cargo run -p tests --bin test_runner -- --filter regular
165+
cargo run -p tests --bin test_runner -- --filter auth
166+
cargo run -p tests --bin test_runner -- --filter payment_address
167+
cargo run -p tests --bin test_runner -- --filter multi_signer
168+
cargo run -p tests --bin test_runner -- --filter typescript_basic
169+
cargo run -p tests --bin test_runner -- --filter typescript_auth
155170
```
156171

157172
#### Customize Test Environment
158173

159-
The test suite uses environment variables for configuration (checked before falling back to defaults):
160-
161-
| Variable | Description | Default |
162-
|----------|-------------|---------|
163-
| `RPC_URL` | Solana RPC endpoint | `http://127.0.0.1:8899` |
164-
| `TEST_SERVER_URL` | Kora RPC server URL | `http://127.0.0.1:8080` |
165-
| `TEST_SENDER_KEYPAIR` | Base58 encoded test sender keypair | Built-in test keypair |
166-
| `TEST_RECIPIENT_PUBKEY` | Test recipient public key | Built-in test pubkey |
167-
| `KORA_PRIVATE_KEY` | Kora fee payer private key | Built-in test keypair |
168-
| `TEST_USDC_MINT_KEYPAIR` | Test USDC mint keypair | Built-in test mint |
169-
| `TEST_USDC_MINT_DECIMALS` | USDC mint decimals | `6` |
174+
The test suite uses environment variables for configuration specified in `tests/src/common/constants.rs`.
170175

171176
Make sure to update the appropriate config file (kora.toml for production, tests/common/fixtures/kora-test.toml for testing) to reflect the public key of TEST_USDC_MINT_KEYPAIR.
172177

173-
**Example with custom test configuration:**
174-
```bash
175-
# Create .env file for custom test setup
176-
echo "RPC_URL=https://api.devnet.solana.com" > .env
177-
echo "TEST_SENDER_KEYPAIR=your_base58_keypair" >> .env
178-
echo "KORA_PRIVATE_KEY=your_fee_payer_keypair" >> .env
179-
180-
# Run tests with custom config
181-
make test-integration
182-
```
183-
184178
### Running Services
185179

186180
```bash
@@ -562,29 +556,28 @@ Both skip `/liveness` endpoint and can be used simultaneously. Implementation us
562556
- **API tests** - Include example JSON payloads in `tests/examples/`
563557
- **SDK tests** - TypeScript tests in `sdks/*/test/` directories
564558

565-
## Makefile Structure
559+
## Test Runner Architecture
566560

567-
The project uses a modular makefile approach for better organization:
561+
The project uses a Rust-based test runner for integration testing:
568562

569563
```
570-
/Makefile # Main makefile with includes
571-
/makefiles/
572-
├── utils.mk # Common utilities and functions
573-
├── rs.mk # Rust build commands
574-
├── tests_rs.mk # Integration test orchestration
575-
└── docs.mk # Documentation generation
564+
/tests/src/
565+
├── bin/test_runner.rs # Main test runner binary
566+
├── test_runner/ # Test runner modules
567+
│ ├── test_cases.toml # Test phase configurations
568+
│ ├── accounts.rs # Account management & caching
569+
│ ├── commands.rs # Test execution logic
570+
│ ├── kora.rs # Kora server lifecycle
571+
│ └── validator.rs # Solana validator management
572+
└── common/ # Shared test utilities
576573
```
577574

578575
**Key Features:**
579-
- **Sequential Test Execution**: Prevents port conflicts and ensures clean config isolation
580-
- **Server Lifecycle Management**: Automatic start/stop with proper cleanup
581-
- **CLI Integration**: Automated `kora rpc initialize-atas` for payment address tests
582-
- **Parallel Tool Execution**: Optimized for development workflow efficiency
583-
584-
**Core Functions (from utils.mk):**
585-
- `start_solana_validator` / `stop_solana_validator`: Validator lifecycle
586-
- `start_kora_server` / `stop_kora_server`: Server lifecycle with config switching
587-
- `run_integration_phase`: Orchestrates server + CLI + tests for each phase
576+
- **Rust Test Runner**: Single binary manages all test phases
577+
- **TOML Configuration**: Test phases defined in `test_cases.toml`
578+
- **Account Caching**: Reuses test accounts for faster execution
579+
- **Isolated Ports**: Each test phase uses unique ports to avoid conflicts
580+
- **TypeScript Integration**: Seamlessly runs TS SDK tests alongside Rust tests
588581

589582
## Development Guidelines
590583

docs/contributors/ADDING_SIGNERS.md

Lines changed: 55 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -400,48 +400,74 @@ Define a `example-signer.toml` with your signer's configuration and necessary en
400400

401401
### Integration Tests
402402

403-
Testing should utilize the existing `sdks/ts/test/integration.test.ts` file. We manage this with an environment variable `KORA_SIGNER_TYPE` that is set to the signer type you are testing.
404-
405-
Setup:
406-
- `sdks/ts/test/setup.ts`: You will need to add an environment variable to `loadEnvironmentVariables` to set the signer type to your service.
407-
- `sdks/ts/package.json`: You will need to add a new test script that uses the signer type you added to the setup script: `"test:integration:your-service": "KORA_SIGNER_TYPE=your-service pnpm test integration.test.ts"`. When executed, the test will run with the signer type set to your service.
408-
409-
Integration testing requires a local Solana test validator and a local Kora node. We can use the [TypeScript Test Makefile](/makefiles/tests_ts.mk) to start a local Solana test validator and a local Kora node by adding a new script for your signer:
410-
411-
```makefile
412-
# Run TypeScript tests with YourService signer
413-
test-ts-integration-your-service:
414-
@$(call start_solana_validator)
415-
@echo "🚀 Starting Kora node with YourService signer..."
416-
@$(call stop_kora_server)
417-
@cargo run -p kora-cli --bin kora -- --config $(REGULAR_CONFIG) --rpc-url $(TEST_RPC_URL) rpc start --signers-config $(TEST_SIGNERS_YOUR_SERVICE_CONFIG) --port $(TEST_PORT) $(QUIET_OUTPUT) &
418-
@echo $$! > .kora.pid
419-
@echo "⏳ Waiting for server to start..."
420-
@sleep 5
421-
@printf "Running TypeScript SDK tests with YourService signer...\n"
422-
-@cd sdks/ts && pnpm test:integration:your-service
423-
@$(call stop_kora_server)
424-
@$(call stop_solana_validator)
403+
Kora uses a unified test runner (`tests/src/bin/test_runner.rs`) that manages all integration testing phases including TypeScript tests. To add tests for your new signer:
404+
405+
#### 1. Add Test Configuration
406+
407+
Create a new signer configuration file in `tests/src/common/fixtures/` for your service:
408+
409+
```toml
410+
# tests/src/common/fixtures/signers-your-service.toml
411+
[[signers]]
412+
name = "yourservice_main"
413+
type = "your_service"
414+
api_key_env = "YOUR_SERVICE_API_KEY"
415+
api_secret_env = "YOUR_SERVICE_API_SECRET"
416+
wallet_id_env = "YOUR_SERVICE_WALLET_ID"
425417
```
426418

427-
And add your new script to the `test-ts-signers` script:
419+
#### 2. Add Test Phase to Test Runner
420+
421+
Update `tests/src/test_runner/test_cases.toml` to include a test phase for your signer:
428422

429-
```makefile
430-
test-ts-signers: test-ts-integration-your-service # ... test-ts-existing-signer-tests
423+
```toml
424+
[test.your_service]
425+
name = "YourService Signer Tests"
426+
config = "tests/src/common/fixtures/kora-test.toml"
427+
signers = "tests/src/common/fixtures/signers-your-service.toml"
428+
port = "8090" # Use a unique port
429+
tests = ["your_service"]
431430
```
432431

433-
Make sure your local environment is set up:
432+
#### 3. TypeScript SDK Integration
434433

435-
```makefile
434+
For TypeScript SDK testing with your signer:
435+
436+
1. Update `sdks/ts/test/setup.ts` to recognize your signer type:
437+
- Add environment variable handling for `KORA_SIGNER_TYPE=your-service`
438+
439+
2. Add a test script in `sdks/ts/package.json`:
440+
```json
441+
"test:integration:your-service": "KORA_SIGNER_TYPE=your-service pnpm test integration.test.ts"
442+
```
443+
444+
#### 4. Running Tests
445+
446+
Make sure your environment is set up:
447+
448+
```bash
449+
# Install binaries and dependencies
436450
make install
437451
make install-ts-sdk
438452
make build-ts-sdk
453+
454+
# Set environment variables for your service
455+
export YOUR_SERVICE_API_KEY="your_key"
456+
export YOUR_SERVICE_API_SECRET="your_secret"
457+
export YOUR_SERVICE_WALLET_ID="your_wallet"
439458
```
440459

441-
Now you can test your integration by running:
460+
Run tests using the unified test runner:
442461

443462
```bash
444-
make test-ts-integration-your-service
463+
# Run all integration tests (includes your new signer phase)
464+
make test-integration
465+
466+
# Run tests with verbose output
467+
make test-integration-verbose
468+
469+
# Run specific test phase with filter
470+
cargo run -p tests --bin test_runner -- --phases your_service
445471
```
446472

447473

0 commit comments

Comments
 (0)