@pioneer-platform/e2e-endpoint-portfolio
v1.0.0
Published
Advanced portfolio endpoint performance testing
Downloads
6
Readme
Portfolio Endpoint Testing Suite
Advanced testing suite for the /api/v1/portfolio endpoint with performance benchmarking and server log diagnostics.
Features
- ✅ Quick failure diagnosis with immediate server log access
- ✅ Cache performance testing (cold vs cached requests)
- ✅ Response structure validation
- ✅ Multi-pubkey testing
- ✅ Server health checking
- ✅ Real-time performance metrics
Usage
# Run the test suite
bun run dev
# Run with custom API URL
API_URL=http://localhost:9001 bun run dev
# Run with real pubkeys (recommended)
ETH_PUBKEY=0x... bun run devTest Structure
1. Server Health Check
Validates server is running and responsive before executing tests.
2. Response Structure Validation
Checks that the portfolio endpoint returns:
portfolioarray fieldtotalValueUsdfield- Proper HTTP status codes
3. Cache Performance Test
Measures performance across 3 requests:
- Cold start: First request (no cache)
- Cached #1: Second request (should be cached)
- Cached #2: Third request (validate cache consistency)
Expected results:
- Cold start: 5-15 seconds (blockchain sync)
- Cached: <100ms (Redis cache)
- Speedup: 50-150x
4. Multi-Pubkey Test
Tests the endpoint with multiple pubkeys simultaneously.
Current Test Results
❌ Issue Found: Validation Error
Status: 400 Bad Request
Error: {"message":"Something went wrong","status":400}
Server Logs Show:
- Error handler at
app.ts:131is catching the error - Query params are empty (expected for POST)
- Actual validation error message is not being logged
Root Cause:
The error handler is swallowing the actual validation error. Need to improve error logging in app.ts to show the actual validation failure reason.
Next Steps:
- ✅ Update error handler to log actual error details
- ⏳ Use real pubkeys instead of fake test data
- ⏳ Verify portfolio data structure with real blockchain data
Log Files
- Server logs:
/Users/highlander/WebstormProjects/keepkey-stack/projects/pioneer/logs/server.log - Discovery logs:
/Users/highlander/WebstormProjects/keepkey-stack/projects/pioneer/logs/discovery.log
Environment Variables
# API server URL
API_URL=http://127.0.0.1:9001
# Test pubkeys (use real pubkeys for actual testing)
ETH_PUBKEY=0x...
BTC_PUBKEY=bc1q...Adding More Test Cases
To add new chain tests, update src/index.ts:
const TEST_PUBKEYS = {
ethereum: {
pubkey: process.env.ETH_PUBKEY || '0x...',
caip: 'eip155:1:' + (process.env.ETH_PUBKEY || '0x...'),
name: 'Ethereum Mainnet'
},
bitcoin: {
pubkey: process.env.BTC_PUBKEY || 'bc1q...',
caip: 'bip122:000000000019d6689c085ae165831e93:' + (process.env.BTC_PUBKEY || 'bc1q...'),
name: 'Bitcoin Mainnet'
}
};Performance Benchmarks
Target performance metrics:
| Metric | Target | Current | |--------|--------|---------| | Cold start | <15s | N/A (validation error) | | Cached request | <100ms | 1ms (cached error) | | Cache speedup | >50x | N/A | | Response time (P95) | <200ms | N/A |
Troubleshooting
Server returns 400 errors
- Check server logs for actual validation error
- Verify pubkey format matches expected CAIP format
- Check that portfolio controller is receiving the request body
- Validate request payload structure
Cache not working
- Check Redis is running:
redis-cli ping - Verify cache TTL configuration
- Check cache key generation logic
Slow performance
- Check network latency to blockchain nodes
- Verify database indexes
- Check Redis cache hit rate
- Review query optimization
