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

chore(test): fix data verification test #285

Merged
merged 2 commits into from
Jan 24, 2025
Merged

Conversation

dtfiedler
Copy link
Collaborator

We need to index the bundle transaction before we can attempting to verify its data root.

We need to index the bundle transaction before we can attempting to verify its data root.
@@ -160,7 +160,7 @@ export class DataRootComputer {
});
}

async computeDataRoot(id: string): Promise<Uint8Array | undefined> {
async computeDataRoot(id: string): Promise<string | undefined> {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@hlolli - the result of this is the toB64Url of the data root, lmk if i'm mistaken on this change. it was causing type warnings in the verifyDataRoot when trying to compare a string to Uint8Array

Copy link
Contributor

Choose a reason for hiding this comment

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

that is correct, initially it was that, but after my changes it's a string

Copy link
Contributor

coderabbitai bot commented Jan 24, 2025

Warning

Rate limit exceeded

@dtfiedler has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 19 minutes and 9 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📥 Commits

Reviewing files that changed from the base of the PR and between fa00d38 and 279394a.

📒 Files selected for processing (4)
  • src/config.ts (1 hunks)
  • src/workers/data-verification.ts (2 hunks)
  • test/end-to-end/data-sources.test.ts (0 hunks)
  • test/end-to-end/indexing.test.ts (3 hunks)
📝 Walkthrough

Walkthrough

This pull request introduces configuration and improvements to the background data verification process. A new configuration constant BACKGROUND_DATA_VERIFICATION_WORKER_COUNT is added to control the number of workers. The computeDataRoot method in the DataRootComputer class now returns a Base64 URL string instead of a Uint8Array. The verifyDataRoot method in DataVerificationWorker includes additional error handling to check for undefined data roots. The end-to-end indexing test suite has been updated with enhanced logging and timing adjustments.

Changes

File Change Summary
src/config.ts Added new constant BACKGROUND_DATA_VERIFICATION_WORKER_COUNT using env.varOrDefault
src/lib/data-root.ts Modified computeDataRoot method to return Promise<string | undefined> instead of Promise<Uint8Array | undefined>
src/workers/data-verification.ts Added error handling in verifyDataRoot to check for undefined dataRoot
test/end-to-end/indexing.test.ts Increased test timeout, updated waitVerification function, reduced verification interval, added transaction and bundle queueing

Sequence Diagram

sequenceDiagram
    participant Config as Configuration
    participant Worker as DataVerificationWorker
    participant DataRoot as DataRootComputer

    Config->>Worker: Set worker count
    Worker->>DataRoot: Compute data root
    alt Data root exists
        DataRoot-->>Worker: Return Base64 URL string
        Worker->>Worker: Verify data root
    else Data root undefined
        Worker-->>Worker: Log warning, return false
    end
Loading

Possibly related PRs

Suggested reviewers

  • djwhitt

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (3)
src/config.ts (1)

305-309: Validate worker count configuration
Using a numeric conversion is fine, but consider edge cases (e.g., negative or extremely large values) that might degrade performance or cause resource exhaustion.

test/end-to-end/indexing.test.ts (2)

866-869: Use a consistent logger
Consider using log.debug or log.info instead of console.log for uniform logging and better filtering by log levels.


883-899: Minor spelling fix and comment clarity
• Line 883 has a small typo: "bundele" → "bundle".
• Hardcoding “79 data items” is fine for test clarity, but consider clarifying that this value may change if the bundle contents evolve.

Apply the following diff for the spelling fix:

- // queue the bundele tx to populate the data root
+ // queue the bundle tx to populate the data root
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 0b02e18 and fa00d38.

📒 Files selected for processing (4)
  • src/config.ts (1 hunks)
  • src/lib/data-root.ts (1 hunks)
  • src/workers/data-verification.ts (1 hunks)
  • test/end-to-end/indexing.test.ts (3 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: test (macos-latest)
  • GitHub Check: test (ubuntu-latest)
🔇 Additional comments (4)
src/workers/data-verification.ts (1)

120-126: Ensure undefined dataRoot early check is appropriate
Returning immediately when dataRoot is missing prevents wasted computation. The log message is clear about re-indexing needs, which is good. Ensure upstream logic properly detects and re-queues unindexed transactions for a seamless flow.

src/lib/data-root.ts (1)

163-163: Confirm proper handling of string return type
Now that computeDataRoot returns a string | undefined, verify all callers appropriately handle the string type (e.g., indexing, logging, comparisons).

test/end-to-end/indexing.test.ts (2)

846-849: Extended test suite timeout
Allowing 120 seconds for background verification tests reduces flakiness in end-to-end environments. This appears practical.


878-878: Frequent verification interval
A 1-second interval helps accelerate tests, but may be too frequent for production. Consider a condition or environment check to differentiate test vs. production intervals.

Copy link

codecov bot commented Jan 24, 2025

Codecov Report

Attention: Patch coverage is 70.00000% with 6 lines in your changes missing coverage. Please review.

Project coverage is 71.83%. Comparing base (0b02e18) to head (279394a).
Report is 2 commits behind head on develop.

Files with missing lines Patch % Lines
src/workers/data-verification.ts 33.33% 6 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           develop     #285      +/-   ##
===========================================
- Coverage    71.85%   71.83%   -0.03%     
===========================================
  Files           39       39              
  Lines         9804     9818      +14     
  Branches       563      564       +1     
===========================================
+ Hits          7045     7053       +8     
- Misses        2755     2761       +6     
  Partials         4        4              

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

…am timeout

These give us flexiblity when setting up integration tests. Not exposing them on docker-compose as data verification is not enabled by default.
@dtfiedler dtfiedler force-pushed the PE-7488-disable-e2e-tests branch from cdf770d to 279394a Compare January 24, 2025 15:46
@@ -65,7 +65,6 @@ describe('DataSources', () => {

localStack = await new LocalstackContainer('localstack/localstack:3')
.withNetwork(network as any)
.withName('localstack')
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

this was causing warnings/errors when attempting to spin up local stack. this will give it a dynamic name for each execution avoiding conflicts

Error: (HTTP code 409) unexpected - Conflict. The container name "/localstack" is already in use by container "420421cdc2b4abb71994d9034928ab0fd352c77cc1e0cc8fe05eff9112297135". You have to remove (or rename) that container to be able to reuse that name. 

@djwhitt djwhitt merged commit ffd0dc8 into develop Jan 24, 2025
6 checks passed
@djwhitt djwhitt deleted the PE-7488-disable-e2e-tests branch January 24, 2025 15:52
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.

3 participants