Skip to content

Conversation

@lempira
Copy link
Contributor

@lempira lempira commented Nov 13, 2025

Add TestNet HAR Recording Support

This PR enhances the mock server to record HTTP Archive (HAR) files from live TestNet endpoints, enabling comprehensive API response capture for testing.

Key Changes:

Configured the recording script to capture requests from TestNet API (nodely.dev) instead of localhost. Expanded Algod recording to cover over 20 API endpoints, including status and health endpoints, block/transaction/ledger delta queries, and account/application/asset information. Real testnet data is sourced from utils-py tests and Lora object mothers. There are still some TODOs. Those will get defined through integration.

Also added VS Code/Cursor debugging configuration with Bun extension support and workspace file to improve the developer experience.

@lempira lempira requested a review from joe-p November 13, 2025 01:15
@joe-p
Copy link
Contributor

joe-p commented Nov 13, 2025

We'll need to update the server to handle this: https://github.com/algorandfoundation/algokit-polytest/blob/feat/multi_client_server/resources/mock-server/src/server.ts#L47-L50

Currently it's only expecting localnet. We'll probably need to have different servers for localnet and testnet. Alternatively we overwrite the URL when recording HAR files

The tests will also need to be updated (and we should probably add some CI, but that can be a seperate PR)

@lempira
Copy link
Contributor Author

lempira commented Nov 13, 2025

https://github.com/algorandfoundation/algokit-polytest/blob/feat/multi_client_server/resources/mock-server/src/server.ts#L47-L50

I thought we were going to keep this as mock-server as testnet only and configure the client in the native languages test to use localnet. That way we keep the separated.

@joe-p
Copy link
Contributor

joe-p commented Nov 13, 2025

There may be some things that we want to use localnet for down the road, like maybe some contrived app state, but if we just want to switch to test only for now that's probably the easiest path (and we never need localnet)

This enables debugging the recording process and captures real testnet
API responses for mock server playback.

Adds VS Code Bun debugger configuration for server
- Strip transfer-encoding and content-encoding headers in beforeReplay hook to prevent conflicts with content-length and decompression errors
- Replace server tests with replay-focused tests
- Update unrecorded endpoint test to use non-existent account address
- Re-record HAR files with consistent API token format
- Split bin/server.ts (replay-only) and bin/record.ts (recording-only)
- Update startServer() to remove mode parameter, always replays
- Created tests for replay and recording
- Update tests to use new API signatures
- Add debug configurations for both tools
@lempira lempira force-pushed the feature/add-har-file-recordings branch from 61f2919 to 39140fa Compare November 14, 2025 13:17
Removed the bin record file since recording happens on every server start
@lempira lempira requested a review from joe-p November 14, 2025 13:52
@lempira lempira merged commit 4018959 into main Nov 14, 2025
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants