npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

@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 dev

Test Structure

1. Server Health Check

Validates server is running and responsive before executing tests.

2. Response Structure Validation

Checks that the portfolio endpoint returns:

  • portfolio array field
  • totalValueUsd field
  • 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:131 is 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:

  1. ✅ Update error handler to log actual error details
  2. ⏳ Use real pubkeys instead of fake test data
  3. ⏳ 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

  1. Check server logs for actual validation error
  2. Verify pubkey format matches expected CAIP format
  3. Check that portfolio controller is receiving the request body
  4. Validate request payload structure

Cache not working

  1. Check Redis is running: redis-cli ping
  2. Verify cache TTL configuration
  3. Check cache key generation logic

Slow performance

  1. Check network latency to blockchain nodes
  2. Verify database indexes
  3. Check Redis cache hit rate
  4. Review query optimization