Skip to content
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

test: improve processor test organization and readability #1220

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

Odomey
Copy link

@Odomey Odomey commented Dec 22, 2024

Description

Improved Test Organization and Error Handling in Processor Tests

Changes Made

Added Test Setup Infrastructure

  • Introduced TestMain(m *testing.M) for centralized test configuration
  • Added setup() function to initialize Heimdall configuration consistently across tests
  • Set up essential configuration values like Tendermint node and log level

Enhanced Test Structure

  • Refactored TestBroadcastWhenTxInMempool to use table-driven tests
  • Added clear test case categories:
    • Unique message handling
    • Duplicate message detection
    • Different transaction hash processing
    • Different log index handling

Improved Error Handling

  • Replaced basic error checks with require.NoError for critical assertions
  • Added descriptive error messages for better debugging
  • Implemented proper cleanup after test execution

Test Performance

  • Added t.Parallel() for concurrent test execution
  • Improved test isolation with proper variable scoping in subtests

Better Test Documentation

  • Added descriptive names for each test case
  • Included detailed descriptions of expected behavior
  • Improved code readability with consistent formatting

Impact

These improvements make the tests:

  • More maintainable
  • Easier to debug
  • More reliable
  • Faster to execute
  • Better documented

No production code was modified in this PR, only test improvements were made.

Changes

  • Bugfix (non-breaking change that solves an issue)
  • Hotfix (change that solves an urgent issue, and requires immediate attention)
  • New feature (non-breaking change that adds functionality)
  • Breaking change (change that is not backwards-compatible and/or changes current functionality)
  • Changes only for a subset of nodes

Checklist

  • I have added at least 2 reviewer or the whole pos-v1 team
  • I have added sufficient documentation in code
  • I will be resolving comments - if any - by pushing each fix in a separate commit and linking the commit hash in the comment reply

Cross repository changes

  • This PR requires changes to bor
    • In case link the PR here:
  • This PR requires changes to matic-cli
    • In case link the PR here:

Testing

  • I have added unit tests
  • I have added tests to CI
  • I have tested this code manually on local environment
  • I have tested this code manually on remote devnet using express-cli
  • I have tested this code manually on mumbai or amoy
  • I have created new e2e tests into express-cli

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.

1 participant