-
Notifications
You must be signed in to change notification settings - Fork 0
Add har file recordings for testnet api calls #7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
7f2dd33
feat: configure testnet recording and bun debugging
lempira bd40c57
fix: updated launch debug file with client arg.
lempira 195168d
fix: changed url for testnet only calling
lempira 1c30305
fix: remove problematic response headers during replay
lempira ec42724
refactor: separate recording and replay into distinct CLI tools
lempira 39140fa
refactor: added recordings back to server start
lempira a4ffe34
refactor: record test to just test the record function
lempira File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -32,3 +32,6 @@ report.[0-9]_.[0-9]_.[0-9]_.[0-9]_.json | |
|
|
||
| # Finder (MacOS) folder config | ||
| .DS_Store | ||
|
|
||
|
|
||
| .tmp/ | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| { | ||
| // Use IntelliSense to learn about possible attributes. | ||
| // Hover to view descriptions of existing attributes. | ||
| // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 | ||
| "version": "0.2.0", | ||
| "configurations": [ | ||
| { | ||
| "type": "bun", | ||
| "request": "launch", | ||
| "name": "Debug Replay Server", | ||
| "program": "${workspaceFolder}/bin/server.ts", | ||
| "args": ["algod"], // Change to: algod, indexer, or kmd | ||
| "cwd": "${workspaceFolder}", | ||
| "stopOnEntry": false, | ||
| "watchMode": false, | ||
| "env": { | ||
| "NODE_ENV": "development", | ||
| "LOG_LEVEL": "debug" | ||
| } | ||
| }, | ||
| { | ||
| "type": "bun", | ||
| "request": "launch", | ||
| "name": "Debug Record", | ||
| "program": "${workspaceFolder}/bin/record.ts", | ||
| "args": ["algod", "record-new"], // Change client: algod, indexer, kmd | mode: record-new, record-overwrite | ||
| "cwd": "${workspaceFolder}", | ||
| "stopOnEntry": false, | ||
| "watchMode": false, | ||
| "env": { | ||
| "NODE_ENV": "development" | ||
| } | ||
| } | ||
| ] | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,51 @@ | ||
| import { describe, it, expect, afterEach } from "vitest"; | ||
| import { record } from "../src/index"; | ||
| import { Algodv2 } from "algosdk"; | ||
| import fs from "fs"; | ||
| import path from "path"; | ||
|
|
||
| const TEST_RECORDINGS_DIR = path.resolve(__dirname, "../recordings-test"); | ||
|
|
||
| describe("Recording Tests", () => { | ||
| afterEach(async () => { | ||
| // Clean up test recordings directory completely | ||
| if (fs.existsSync(TEST_RECORDINGS_DIR)) { | ||
| fs.rmSync(TEST_RECORDINGS_DIR, { recursive: true, force: true }); | ||
| } | ||
| }); | ||
|
|
||
| it("should record in record-new mode", async () => { | ||
| // Create test recordings directory | ||
| fs.mkdirSync(TEST_RECORDINGS_DIR, { recursive: true }); | ||
|
|
||
| // Create recording with record-new using TestNet | ||
| await record( | ||
| "algod", | ||
| async () => { | ||
| const algod = new Algodv2( | ||
| "a".repeat(64), | ||
| "https://testnet-api.4160.nodely.dev", | ||
| 443 | ||
| ); | ||
| await algod.status().do(); | ||
| }, | ||
| "record-new", | ||
| TEST_RECORDINGS_DIR | ||
| ); | ||
|
|
||
| // Verify HAR file was created | ||
| const harFiles = fs.readdirSync(TEST_RECORDINGS_DIR, { recursive: true }); | ||
| const harFileName = harFiles.find((f) => | ||
| f.toString().endsWith("recording.har") | ||
| ); | ||
| expect(harFileName).toBeDefined(); | ||
|
|
||
| const harPath = path.join(TEST_RECORDINGS_DIR, harFileName!.toString()); | ||
| expect(fs.existsSync(harPath)).toBe(true); | ||
|
|
||
| // Verify HAR file has entries | ||
| const content = fs.readFileSync(harPath, "utf-8"); | ||
| const har = JSON.parse(content); | ||
| expect(har.log.entries.length).toBeGreaterThan(0); | ||
| }); | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,7 +1,14 @@ | ||
| import type { Client } from "../src/index.ts"; | ||
| import { startServer } from "../src/server.ts"; | ||
|
|
||
| const client = process.argv[2]; | ||
| const server = await startServer(client as Client); | ||
| const client = process.argv[2] as Client; | ||
| const recordingsDir = process.argv[3]; | ||
|
|
||
| await server.listen; | ||
| console.log(`Starting ${client} mock server in replay mode...`); | ||
| if (recordingsDir) { | ||
| console.log(`Recordings directory: ${recordingsDir}`); | ||
| } | ||
|
|
||
| const server = await startServer(client, recordingsDir); | ||
|
|
||
| console.log(`✓ Server listening on port ${server.port}`); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -5,7 +5,6 @@ | |
| "name": "pollyjs-server", | ||
| "dependencies": { | ||
| "@pollyjs/adapter-fetch": "^6.0.7", | ||
| "@pollyjs/adapter-node-http": "^6.0.6", | ||
| "@pollyjs/core": "^6.0.6", | ||
| "@pollyjs/persister-fs": "^6.0.6", | ||
| "algosdk": "^3.5.2", | ||
|
|
@@ -94,8 +93,6 @@ | |
|
|
||
| "@pollyjs/adapter-fetch": ["@pollyjs/[email protected]", "", { "dependencies": { "@pollyjs/adapter": "^6.0.6", "@pollyjs/utils": "^6.0.6", "to-arraybuffer": "^1.0.1" } }, "sha512-kv44DROx/2qzlcgS71EccGr2/I5nK40Xt92paGNI+1/Kmz290bw/ykt8cvXDg4O4xCc9Fh/jXeAkS7qwGpCx2g=="], | ||
|
|
||
| "@pollyjs/adapter-node-http": ["@pollyjs/[email protected]", "", { "dependencies": { "@pollyjs/adapter": "^6.0.6", "@pollyjs/utils": "^6.0.6", "lodash-es": "^4.17.21", "nock": "^13.2.1" } }, "sha512-jdJG7oncmSHZAtVMmRgOxh5A56b7G8H9ULlk/ZaVJ+jNrlFXhLmPpx8OQoSF4Cuq2ugdiWmwmAjFXHStcpY3Mw=="], | ||
|
|
||
| "@pollyjs/core": ["@pollyjs/[email protected]", "", { "dependencies": { "@pollyjs/utils": "^6.0.6", "@sindresorhus/fnv1a": "^2.0.1", "blueimp-md5": "^2.19.0", "fast-json-stable-stringify": "^2.1.0", "is-absolute-url": "^3.0.3", "lodash-es": "^4.17.21", "loglevel": "^1.8.0", "route-recognizer": "^0.3.4", "slugify": "^1.6.3" } }, "sha512-1ZZcmojW8iSFmvHGeLlvuudM3WiDV842FsVvtPAo3HoAYE6jCNveLHJ+X4qvonL4enj1SyTF3hXA107UkQFQrA=="], | ||
|
|
||
| "@pollyjs/node-server": ["@pollyjs/[email protected]", "", { "dependencies": { "@pollyjs/utils": "^6.0.6", "body-parser": "^1.19.0", "cors": "^2.8.5", "express": "^4.17.1", "fs-extra": "^10.0.0", "http-graceful-shutdown": "^3.1.5", "morgan": "^1.10.0", "nocache": "^3.0.1" } }, "sha512-nkP1+hdNoVOlrRz9R84haXVsaSmo8Xmq7uYK9GeUMSLQy4Fs55ZZ9o2KI6vRA8F6ZqJSbC31xxwwIoTkjyP7Vg=="], | ||
|
|
@@ -352,8 +349,6 @@ | |
|
|
||
| "json-schema-traverse": ["[email protected]", "", {}, "sha512-NM8/P9n3XjXhIZn1lLhkFaACTOURQXjWhV4BA/RnOv8xvgqtqpAX9IO4mRQxSx1Rlo4tqzeqb0sOlruaOy3dug=="], | ||
|
|
||
| "json-stringify-safe": ["[email protected]", "", {}, "sha512-ZClg6AaYvamvYEE82d3Iyd3vSSIjQ+odgjaTzRuO3s7toCdFKczob2i0zCh7JE8kWn17yvAWhUVxvqGwUalsRA=="], | ||
|
|
||
| "jsonfile": ["[email protected]", "", { "dependencies": { "universalify": "^2.0.0" }, "optionalDependencies": { "graceful-fs": "^4.1.6" } }, "sha512-FGuPw30AdOIUTRMC2OMRtQV+jkVj2cfPqSeWXv1NEAJ1qZ5zb1X6z1mFhbfOB/iy3ssJCD+3KuZ8r8C3uVFlAg=="], | ||
|
|
||
| "light-my-request": ["[email protected]", "", { "dependencies": { "cookie": "^1.0.1", "process-warning": "^4.0.0", "set-cookie-parser": "^2.6.0" } }, "sha512-CHYbu8RtboSIoVsHZ6Ye4cj4Aw/yg2oAFimlF7mNvfDV192LR7nDiKtSIfCuLT7KokPSTn/9kfVLm5OGN0A28A=="], | ||
|
|
@@ -390,8 +385,6 @@ | |
|
|
||
| "nocache": ["[email protected]", "", {}, "sha512-WDD0bdg9mbq6F4mRxEYcPWwfA1vxd0mrvKOyxI7Xj/atfRHVeutzuWByG//jfm4uPzp0y4Kj051EORCBSQMycw=="], | ||
|
|
||
| "nock": ["[email protected]", "", { "dependencies": { "debug": "^4.1.0", "json-stringify-safe": "^5.0.1", "propagate": "^2.0.0" } }, "sha512-o2zOYiCpzRqSzPj0Zt/dQ/DqZeYoaQ7TUonc/xUPjCGl9WeHpNbxgVvOquXYAaJzI0M9BXV3HTzG0p8IUAbBTQ=="], | ||
|
|
||
| "object-assign": ["[email protected]", "", {}, "sha512-rJgTQnkUnH1sFw8yT6VSU3zD3sWmu6sZhIseY8VX+GRu3P6F7Fu+JNDoXfklElbLJSnc3FUQHVe4cU5hj+BcUg=="], | ||
|
|
||
| "object-inspect": ["[email protected]", "", {}, "sha512-W67iLl4J2EXEGTbfeHCffrjDfitvLANg0UlX3wFUUSTx92KXRFegMHUVgSqE+wvhAbi4WqjGg9czysTV2Epbew=="], | ||
|
|
@@ -426,8 +419,6 @@ | |
|
|
||
| "process-warning": ["[email protected]", "", {}, "sha512-a39t9ApHNx2L4+HBnQKqxxHNs1r7KF+Intd8Q/g1bUh6q0WIp9voPXJ/x0j+ZL45KF1pJd9+q2jLIRMfvEshkA=="], | ||
|
|
||
| "propagate": ["[email protected]", "", {}, "sha512-vGrhOavPSTz4QVNuBNdcNXePNdNMaO1xj9yBeH1ScQPjk/rhg9sSlCXPhMkFuaNNW/syTvYqsnbIJxMBfRbbag=="], | ||
|
|
||
| "proxy-addr": ["[email protected]", "", { "dependencies": { "forwarded": "0.2.0", "ipaddr.js": "1.9.1" } }, "sha512-llQsMLSUDUPT44jdrU/O37qlnifitDP+ZwrmmZcoSKyLKvtZxpyV0n2/bD/N4tBAAZ/gJEdZU7KMraoK1+XYAg=="], | ||
|
|
||
| "pump": ["[email protected]", "", { "dependencies": { "end-of-stream": "^1.1.0", "once": "^1.3.1" } }, "sha512-todwxLMY7/heScKmntwQG8CXVkWUOdYxIvY2s0VWAAMh/nd8SoYiRaKjlr7+iCs984f2P8zvrfWcDDYVb73NfA=="], | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| { | ||
| "folders": [ | ||
| { | ||
| "name": "mock-server", | ||
| "path": "." | ||
| } | ||
| ], | ||
| // Workspace-specific VS Code settings | ||
| "settings": { | ||
| // Path to the TypeScript language server to use for IntelliSense and type checking | ||
| // Points to the workspace's local typescript package instead of VS Code's built-in version | ||
| "typescript.tsdk": "node_modules/typescript/lib", | ||
|
|
||
| // When true, VS Code will prompt to use the workspace TypeScript version | ||
| // This ensures consistency between CLI builds and editor type checking | ||
| "typescript.enablePromptUseWorkspaceTsdk": true | ||
| } | ||
| } | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.