Skip to content

test: Wallet Service Facade initial tests#949

Merged
tuliomir merged 43 commits intomasterfrom
test/not-websocket
Dec 12, 2025
Merged

test: Wallet Service Facade initial tests#949
tuliomir merged 43 commits intomasterfrom
test/not-websocket

Conversation

@tuliomir
Copy link
Copy Markdown
Contributor

@tuliomir tuliomir commented Oct 1, 2025

This PR is the immediate sequence to #909 , where the infrastructure to test the Wallet Service Facade was implemented.

Acceptance Criteria

  • Kickstart the Wallet Service facade suite with enough coverage for a good smoke test
  • Implement a solution for frequent socket hang up errors while requesting the serverless-offline environment

Notes

  • Nano Contracts were not tested in this PR
  • WebSockets were also not tested and are still lacking coverage
  • The tests here are not complete because the priority for now is test: Shared integration test code between facades #947
  • Various improvements of code style will also be implemented by 947. Those improvements require Typescript typing that demands a larger scope of refactoring than this PR would accomodate.
  • We tried removing the --forceExit from the integration tests as it was expected that it would have been solved by feat: do not start background tasks during tests #934 , but the CI didn't pass without it, so we just moved this flag to the Jest configs instead.

Security Checklist

  • Make sure you do not include new dependencies in the project unless strictly necessary and do not include dev-dependencies as production ones. More dependencies increase the possibility of one of them being hijacked and affecting us.

@tuliomir tuliomir self-assigned this Oct 1, 2025
@tuliomir tuliomir added the tests label Oct 1, 2025
@tuliomir tuliomir moved this from Todo to In Progress (WIP) in Hathor Network Oct 1, 2025
@codecov
Copy link
Copy Markdown

codecov bot commented Oct 1, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 86.62%. Comparing base (21ba6c1) to head (293a581).
⚠️ Report is 1 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #949      +/-   ##
==========================================
+ Coverage   85.00%   86.62%   +1.62%     
==========================================
  Files         113      113              
  Lines        8389     8396       +7     
  Branches     1832     1834       +2     
==========================================
+ Hits         7131     7273     +142     
+ Misses       1229     1096     -133     
+ Partials       29       27       -2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 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.

@tuliomir tuliomir force-pushed the test/not-websocket branch from 1b39152 to c728b35 Compare October 6, 2025 23:44
@tuliomir tuliomir moved this from In Progress (WIP) to In Progress (Done) in Hathor Network Oct 7, 2025
@tuliomir tuliomir moved this from In Progress (Done) to In Progress (WIP) in Hathor Network Oct 7, 2025
@tuliomir tuliomir moved this from In Progress (WIP) to In Progress (Done) in Hathor Network Oct 7, 2025
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 10 out of 10 changed files in this pull request and generated 12 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +240 to +244
this.retryConfig = {
maxRetries: retryConfig.maxRetries,
delayBaseMs: retryConfig.delayBaseMs,
delayMaxMs: retryConfig.delayMaxMs,
};
Copy link

Copilot AI Dec 10, 2025

Choose a reason for hiding this comment

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

The retry configuration is being copied property by property rather than using object spread or a more concise approach. This creates unnecessary code repetition. Consider simplifying to this.retryConfig = { ...retryConfig }; which achieves the same result with less code and is more maintainable.

Suggested change
this.retryConfig = {
maxRetries: retryConfig.maxRetries,
delayBaseMs: retryConfig.delayBaseMs,
delayMaxMs: retryConfig.delayMaxMs,
};
this.retryConfig = { ...retryConfig };

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

For now we'd rather have this property being copied item by item, but this is a good improvement once we settle on a definitive design for this retryConfig.

Comment on lines +781 to +788
// @ts-expect-error - tokenOutput must exist
expect(tokenOutput).toStrictEqual(
expect.objectContaining({
value: tokenAmount,
tokenData: 1,
script: expect.any(Buffer),
})
);
Copy link

Copilot AI Dec 10, 2025

Choose a reason for hiding this comment

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

Using @ts-expect-error to suppress type errors for variables that "must exist" indicates a type safety gap. Consider using non-null assertion (tokenOutput!) or restructuring the code to properly handle the case where these outputs might not be found, either with explicit null checks and error throws, or by using find() with proper type guards.

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

These issues will be solved soon, with the Shared Tests PR.
For now we'll have to rely on those typescript adjustments.

import HathorWalletServiceWallet from '../wallet';
import { WalletRequestError, TxNotFoundError } from '../../errors';
import { parseSchema } from '../../utils/bigint';
import helpers from '../../utils/helpers';
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

unused

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Thanks, removed on 64f43d0

// we pass the response data to the guard for additional validations.
if (response.status === 404 && response.data) {
walletApi._txNotFoundGuard(response.data);
throw new WalletRequestError('Error getting transaction by its id.', {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Remove this throw? We already have it down there?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Good catch, this was an obsolete validation. Removed on 64f43d0

Comment on lines +1180 to +1182
try {
const sign = this.signMessage(privKey, timestamp, this.walletId);
const data = await walletApi.createAuthToken(this, timestamp, privKey.xpubkey, sign);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I don't get it... Is this a fix? Why are you try/catching it? Maybe add a log?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yes, it's a fix!
We were having errors without any relation to whatever was being tested because this function runs asynchronously and crashes when the original caller context had already been fully finished.

Added a console on 9b045be

andreabadesso
andreabadesso previously approved these changes Dec 12, 2025
@tuliomir tuliomir merged commit c832bb3 into master Dec 12, 2025
5 checks passed
@github-project-automation github-project-automation bot moved this from In Review (WIP) to Waiting to be deployed in Hathor Network Dec 12, 2025
@tuliomir tuliomir deleted the test/not-websocket branch December 12, 2025 18:53
@tuliomir tuliomir moved this from Waiting to be deployed to Done in Hathor Network Jan 26, 2026
@tuliomir tuliomir mentioned this pull request Mar 9, 2026
1 task
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

4 participants