Skip to content

Conversation

@arianejasuwienas
Copy link
Contributor

@arianejasuwienas arianejasuwienas commented Nov 7, 2025

Description

  1. Added unit tests for createTransactionByType and createTransactionFromLog methods.
  2. Updated the declared interface of TransactionFactory.createTransactionByType to match its actual implementation (numeric values are allowed, other than 2).

Related issue(s)

Fixes #4209

Testing Guide

  1. Run tests
npx lerna run test
  1. check if the coverage for mentioned methods is 100% in packages/relay/coverage/index.html file

Checklist

  • I've assigned an assignee to this PR and related issue(s) (if applicable)
  • I've assigned a label to this PR and related issue(s) (if applicable)
  • I've assigned a milestone to this PR and related issue(s) (if applicable)
  • I've done sufficient testing (unit, integration, etc.)

@arianejasuwienas arianejasuwienas requested review from a team as code owners November 7, 2025 13:04
@arianejasuwienas arianejasuwienas self-assigned this Nov 7, 2025
@arianejasuwienas arianejasuwienas added enhancement New feature or request ArianeLabs Items ArianeLabs is contributing to labels Nov 7, 2025
@arianejasuwienas arianejasuwienas added this to the 0.73.0 milestone Nov 7, 2025
@github-actions
Copy link

github-actions bot commented Nov 7, 2025

Test Results

 20 files  ±0  269 suites  ±0   21m 38s ⏱️ +3s
778 tests ±0  774 ✅ +2  4 💤 ±0  0 ❌  - 2 
794 runs  ±0  790 ✅ +2  4 💤 ±0  0 ❌  - 2 

Results for commit 68afbe1. ± Comparison against base commit 8a7783c.

♻️ This comment has been updated with latest results.


// TransactionFactory is a factory class that creates a Transaction object based on the type of transaction.
export class TransactionFactory {
public static createTransactionByType(type: 2, fields: any): Transaction1559;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i wonder why didn't this result in a failure, if we were passing other types

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@konstantinabl I believe the root cause lies in this line:

https://github.com/hiero-ledger/hiero-json-rpc-relay/pull/4587/files#diff-ddac93377386e734dab4db49925741e7e4ab8056d31d01c4db038d1fcfd1fec2R88

We used any as the type for the contract result, so even though this field could potentially contain any number (which we later pass to createTransactionByType), type checking is effectively disabled there.

(other call to createTransactionByType uses the number 2 explicitly)

accessList: ['should be ignored'],
});

expect(tx).to.not.equal(null);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see a lot of repetitive code asserting tx.type tx.from tx.accessList, can we create some sort of function? Do you think it makes sense?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think these kinds of repetitions aren’t too problematic in tests.I’ve only moved the whole-object comparison into a dedicated function, since that made more sense. And even naming it was easy (what would be the best name for those 3 fields comparison: expectTxTypeFromAndAccessList or expectBasicFields?)

That said, I’m not insisting on my approach ;I can update it if you prefer another way.

@quiet-node
Copy link
Contributor

Actually one nit: Should we follow the Conventional Commits guideline https://www.conventionalcommits.org/en/v1.0.0/ and update the PR title to use an action-oriented phrasing? Starting the title with a verb would help keep it consistent with the rest of the commits in the repository.

@codecov
Copy link

codecov bot commented Nov 10, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.

@@            Coverage Diff             @@
##             main    #4587      +/-   ##
==========================================
- Coverage   95.52%   95.49%   -0.04%     
==========================================
  Files         127      127              
  Lines       20493    20493              
  Branches     1760     1759       -1     
==========================================
- Hits        19576    19569       -7     
- Misses        898      905       +7     
  Partials       19       19              
Flag Coverage Δ
config-service 98.81% <ø> (ø)
relay 90.95% <100.00%> (ø)
server 88.85% <ø> (ø)
ws-server 98.04% <ø> (+1.36%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
...ages/relay/src/lib/factories/transactionFactory.ts 100.00% <100.00%> (ø)

... and 2 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@quiet-node
Copy link
Contributor

quiet-node commented Nov 10, 2025

One more thing: I just helped you update this but in the PR description, please include the word Fixes before the associated ticket, like Fixes #4209. This will:

  • Automatically link the PR to the GitHub issue, making the connection clear on the issue page.
  • Automatically close the ticket when the PR is merged.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ArianeLabs Items ArianeLabs is contributing to enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add test coverage for createTransactionByType and createTransactionFromLog

5 participants