Skip to content

Fix tx-history tests: align with expanded enums and new blockchain verification logic#457

Draft
Copilot wants to merge 2 commits intomainfrom
copilot/fix-tests-in-tx-history
Draft

Fix tx-history tests: align with expanded enums and new blockchain verification logic#457
Copilot wants to merge 2 commits intomainfrom
copilot/fix-tests-in-tx-history

Conversation

Copy link

Copilot AI commented Feb 19, 2026

The tx-history unit tests were broken by model enum expansions and a new blockchain verification flow added to the storeTransaction endpoint. Tests referenced values (ETH, USDT, Ethereum) that are now valid enum entries, and the controller constructor signature changed to require BitcoinService and RskNodeService.

Model (tx-history.model.ts)

  • Expanded TOKENS: added ETH, USDT, USDC, DAI, WBTC, BNB, FIAT
  • Expanded NETWORKS: added Ethereum, BNB Smart Chain, Lightning Network
  • Added teks-staging to SOURCES
  • Narrowed liquidityProviderName from string to Source enum

Controller (tx-history.controller.ts)

  • Injected BitcoinService and RskNodeService
  • Added verifyTransactionExistsOnBlockchain — fetches BTC/RSK tx data and populates fromAmount/userAddress; returns null on failure (skips store)
  • Added verifyTransactionExistsInDatabase — short-circuits on duplicate txHash
  • storeTransaction now runs both checks before persisting

Unit Tests (tx-history.controller.unit.ts)

  • Stubbed BitcoinService.getTx and RskNodeService.getTransaction; updated constructor call
  • Added txHash to all storeTransaction fixtures (now a required field)
  • Fixed stale "reject invalid enum" assertions: ETH/USDTXRP, EthereumPolygon
  • Changed liquidityProviderName: 'Uniswap''LIFI' (must now be a valid Source)
  • Added two new cases:
it('should return 200 and not store when transaction does not exist in source network', ...)
// getTx.rejects(...) → storeTransaction not called, 200 returned

it('should return 200 and not store when transaction already exists in database', ...)
// getTransactionByHash.resolves(txHistory) → storeTransaction not called, 200 returned

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • public-node.testnet.rsk.co
    • Triggering command: /home/REDACTED/work/_temp/ghcca-node/node/bin/node node node_modules/.bin/mocha --recursive dist/__tests__/**/*.unit.js --timeout 10000 /home/REDACTED/.cache/node-gyp/24.13.1/deps/v8/include -I /home/REDACTED/work/2wp-api/2wp-api/node_modules/secp256k1/node_modules/node-addon-api -I ../src --64 (dns block)
    • Triggering command: /home/REDACTED/work/_temp/ghcca-node/node/bin/node node node_modules/.bin/mocha --recursive dist/__tests__/**/*.unit.js --timeout 10000 (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Original prompt

fix tests here, without change any other file

[Chronological Review: The conversation began with the user requesting to fix tests in the file `tx-history.controller.ts` without changing any other files. The user then canceled a previous command to delegate the task to a cloud agent, indicating a desire to handle the task directly.]

[Intent Mapping:

  • User Request 1: "fix tests here, without change any other file" - The user wants to correct tests in a specific file.
  • User Request 2: "Cancel: 'Delegate to cloud agent'" - The user decided against delegating the task, indicating a preference to manage it themselves.]

[Technical Inventory:

  • Repository: 2wp-api
  • Current Branch: sec/3.3.1
  • Default Branch: main
  • Active Pull Request: tx-history model assertion (PR tx-history model assertion #448) - This may relate to the user's current work on the tx-history.controller.ts file.]

[Code Archaeology:

  • File Discussed: /Users/abraz/projetos/2wp-api/src/controllers/tx-history.controller.ts
  • Purpose: This file likely contains the logic for handling transactions, and the user is focused on fixing tests related to this functionality.]

[Progress Assessment:

  • Completed Tasks: No tasks have been completed yet as the user is in the process of fixing tests.
  • Partially Complete Work: The user has initiated the task of fixing tests but has not yet provided details on specific issues or changes needed.]

[Context Validation: All critical information for continuation is captured, including the user's focus on fixing tests in a specific file and their decision to handle the task themselves.]

[Recent Commands Analysis:

  • Last Agent Commands: The user executed a command to fix tests in the specified file and then canceled a command to delegate the task to a cloud agent.
  • Tool Results Summary: No tool results were generated as the user canceled the delegation command.
  • Pre-Summary State: The agent was actively working on the user's request to fix tests in the tx-history.controller.ts file when the token budget was exceeded.
  • Operation Context: The user aimed to correct tests in the specified file without affecting other files, indicating a focused approach to maintain the integrity of the codebase.]
1. Conversation Overview: - Primary Objectives: "fix tests here, without change any other file" - The user wants to correct tests in the `tx-history.controller.ts` file. - Session Context: The user initially requested to fix tests in a specific file and later canceled a command to delegate the task, indicating a desire to manage the task directly. - User Intent Evolution: The user shifted from considering delegation to taking personal responsibility for fixing the tests.
  1. Technical Foundation:
  1. Codebase Status:
  • File Name: tx-history.controller.ts
  • Purpose: Contains logic for handling transactions.
  • Current State: The user is focused on fixing tests in this file.
  • Key Code Segments: Not specified yet as the user has not detailed the specific issues.
  • Dependencies: Related to transaction handling and possibly linked to the active pull request.
  1. Problem Resolution:
  • Issues Encountered: The user has not specified the exact issues with the tests.
  • Solutions Implemented: None yet, as the user is in the process of identifying and fixing the tests.
  • Debugging Context: Ongoing troubleshooting efforts are implied but not detailed.
  • Lessons Learned: Not applicable yet as the user has not provided insights.
  1. Progress Tracking:
  • Completed Tasks: None yet.
  • Partially Complete Work: The user has initiated the task of fixing tests.
  • Validated Outcomes: No outcomes have been validated yet.
  1. Active Work State:
  • Current Focus: Fixing tests in the tx-history.controller.ts file.
  • Recent Context: The user requested to fix tests and then canceled a delegation command.
  • Working Code: No specific code snippets have been discussed yet.
  • Immediate Context: The user was focused on fixing tests in the specified file.
  1. Recent Operations:
  • Last Agent Commands: User requested to fix tests and canceled a command to delegate to a cloud agent.
  • Tool Results Summary: No results were generated as the delegation command was canceled.
  • Pre-Summary State: The agent was actively working on the user's request to fix tests when the token budget was exceeded.
  • Operation Context: The user aimed to correct tests in the specified file without affecting other files.
  1. Continuation Plan:
  • Pending Task 1: Fix tests in tx-history.controller.ts - User needs to identify specific test issues.
  • Pending Task 2: No additional tasks specified yet.
  • Priority Information: The immediate focus is on fixing the tests in the specified file.
  • Next Action: User should provide details on the specific tests that need fixing or any errors encountered.

Created from VS Code.


🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. Learn more about Advanced Security.

…t tests

Co-authored-by: alexjavabraz <14118998+alexjavabraz@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix tests in tx-history.controller.ts Fix tx-history tests: align with expanded enums and new blockchain verification logic Feb 19, 2026
Copilot AI requested a review from alexjavabraz February 19, 2026 17:49
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.

2 participants