Skip to content

test: add comprehensive test coverage for transaction scanning refactoring#239

Draft
ulissesferreira wants to merge 3 commits intomainfrom
NEB-475-test-coverage
Draft

test: add comprehensive test coverage for transaction scanning refactoring#239
ulissesferreira wants to merge 3 commits intomainfrom
NEB-475-test-coverage

Conversation

@ulissesferreira
Copy link
Contributor

@ulissesferreira ulissesferreira commented Mar 17, 2026

Explanation

Comprehensive test coverage for the NEB-475 changes. This PR:

  • Adds a full TransactionScanService unit test suite covering: malformed transactions, unsupported contracts, API success/error, analytics tracking, origin replacement, asset diff mapping
  • Updates existing tests for SimulationStatus expectations and assertTransactionStructure references
  • Adds tests for isTransactionWellFormed type consistency validation
  • Adds tests for assertTransactionStructure (valid, multiple contracts, empty contracts)
  • Adds tests for SecurityAlertsApiClient.isContractTypeSupported (all supported + unsupported types)
  • Adds tests for buildTransactionRawData (TransferContract, TriggerSmartContract, round-trip)
  • Extracts shared test fixtures (MOCK_TRANSACTION_RAW_DATA, WELL_FORMED_DESERIALIZED_TRANSACTION)
  • Adjusts coverage thresholds: branches 53.98→58.13, functions 61.78→62.97, lines 70.12→71.61, statements 70.19→71.66

References

  • NEB-475

Checklist

  • I've updated the test suite for new or updated code as appropriate
  • I've updated documentation (JSDoc, Markdown, etc.) for new or updated code as appropriate
  • I've communicated my changes to consumers by updating changelogs for packages I've changed
  • I've introduced breaking changes in this PR and have prepared draft pull requests for clients and consumer packages to resolve them
Open in Web Open in Cursor 

@ulissesferreira ulissesferreira requested a review from a team as a code owner March 17, 2026 14:01
@ulissesferreira ulissesferreira force-pushed the NEB-475-disable-scanning-unsupported-transactions branch from dfb3b46 to 9dad3b7 Compare March 17, 2026 14:36
@ulissesferreira ulissesferreira force-pushed the NEB-475-disable-scanning-unsupported-transactions branch from 9dad3b7 to a1ff63e Compare March 17, 2026 15:37
@ulissesferreira ulissesferreira force-pushed the NEB-475-disable-scanning-unsupported-transactions branch from a1ff63e to 48d2e57 Compare March 17, 2026 15:51
@cursor cursor bot force-pushed the NEB-475-disable-scanning-unsupported-transactions branch from 48d2e57 to b17aa50 Compare March 17, 2026 16:52
@cursor cursor bot force-pushed the NEB-475-test-coverage branch from f13bc68 to 2136255 Compare March 17, 2026 16:55
@cursor cursor bot force-pushed the NEB-475-disable-scanning-unsupported-transactions branch from b17aa50 to 6c584d8 Compare March 17, 2026 17:01
@cursor cursor bot force-pushed the NEB-475-test-coverage branch from 2136255 to df13481 Compare March 17, 2026 17:01
Tron transactions must contain exactly one contract per the protocol
spec. This adds isTransactionWellFormed and assertTransactionStructure
to validate this at every deserialization entry point, rejecting
malformed payloads early with InvalidParamsError.

Uses @metamask/superstruct to define TransactionRawDataStruct with
custom validation logic. The single-contract assumption is now
documented in JSDoc with protocol references.
The Security Alerts API only supports simulation for TransferContract,
CreateSmartContract, and TriggerSmartContract. Previously all
transactions were sent for simulation, causing incorrect alerts that
blocked user flows.

Introduces a SimulationStatus enum (Completed, Skipped, Failed), moves
contract type checking into SecurityAlertsApiClient, refactors the scan
pipeline to accept raw transaction data directly, and updates the UI to
show "unsupported contract for simulation" instead of blocking the user.
…oring

- Add dedicated TransactionScanService unit test suite
- Add tests for isTransactionWellFormed type consistency validation
- Add tests for assertTransactionStructure
- Add tests for SecurityAlertsApiClient.isContractTypeSupported
- Update all render/confirmation tests for SimulationStatus expectations
- Update coverage thresholds
@cursor cursor bot force-pushed the NEB-475-disable-scanning-unsupported-transactions branch from 6c584d8 to 69bbf90 Compare March 18, 2026 13:27
@cursor cursor bot force-pushed the NEB-475-test-coverage branch from df13481 to 9932565 Compare March 18, 2026 13:28
@cursor cursor bot force-pushed the NEB-475-disable-scanning-unsupported-transactions branch from 69bbf90 to e465a02 Compare March 19, 2026 11:01
@ulissesferreira ulissesferreira force-pushed the NEB-475-disable-scanning-unsupported-transactions branch from e465a02 to 1c14162 Compare March 19, 2026 12:48
Base automatically changed from NEB-475-disable-scanning-unsupported-transactions to main March 19, 2026 13:51
@ulissesferreira ulissesferreira marked this pull request as draft March 19, 2026 14:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants