Skip to content

test: add unit tests for Deprecated class covering constructor and active methods #451

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

Open
wants to merge 1 commit into
base: mainnet-launch
Choose a base branch
from

Conversation

abdulazeem-tk4vr
Copy link
Member

@abdulazeem-tk4vr abdulazeem-tk4vr commented Mar 28, 2025

PR Type

Tests


Description

  • Add unit tests for Deprecated class constructor.

  • Test purgeTransactionData method functionality.

  • Test purgeStateTableData method functionality.

  • Mock dependencies for isolated testing.


Changes walkthrough 📝

Relevant files
Tests
Deprecated.test.ts
Add unit tests for `Deprecated` class methods                       

test/unit/src/state-manager/Deprecated.test.ts

  • Added unit tests for Deprecated class.
  • Tested constructor initialization with dependencies.
  • Tested purgeTransactionData and purgeStateTableData methods.
  • Mocked necessary dependencies for testing.
  • +157/-0 

    Need help?
  • Type /help how to ... in the comments thread for any questions about PR-Agent usage.
  • Check out the documentation for more information.
  • Copy link

    PR Reviewer Guide 🔍

    Here are some key observations to aid the review process:

    ⏱️ Estimated effort to review: 2 🔵🔵⚪⚪⚪
    🏅 Score: 95
    🧪 PR contains tests
    🔒 No security concerns identified
    ⚡ No major issues detected

    Comment on lines 130 to 166
    it('should handle errors during purge', async () => {
    // Setup
    mockStorage.getKeys.mockRejectedValue(new Error('Database error'))

    // Execute & Verify
    await expect(deprecated.purgeTransactionData()).rejects.toThrow('Database error')
    })

    Choose a reason for hiding this comment

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

    Suggestion: Ensure that the error handling test for purgeTransactionData logs the error using the logger to verify that errors are properly logged. [general, importance: 7]

    Suggested change
    it('should handle errors during purge', async () => {
    // Setup
    mockStorage.getKeys.mockRejectedValue(new Error('Database error'))
    // Execute & Verify
    await expect(deprecated.purgeTransactionData()).rejects.toThrow('Database error')
    })
    it('should handle errors during purge', async () => {
    // Setup
    mockStorage.getKeys.mockRejectedValue(new Error('Database error'))
    // Execute & Verify
    await expect(deprecated.purgeTransactionData()).rejects.toThrow('Database error')
    expect(mockMainLogger.error).toHaveBeenCalledWith('Error purging transaction data: Database error')
    })

    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.

    1 participant