Skip to content

Conversation

@knst
Copy link
Collaborator

@knst knst commented Jun 3, 2025

Issue being fixed or feature implemented

#6694

2025-06-03T12:14:23.400000Z TestFramework (ERROR): Assertion failed
Traceback (most recent call last):
  File "DASH/test/functional/test_framework/test_framework.py", line 162, in main
    self.run_test()
  File "DASH/test/functional/p2p_invalid_block.py", line 142, in run_test
    peer.send_blocks_and_test([block], node, force_send=True, success=False, reject_reason='time-too-new')
  File "DASH/test/functional/test_framework/p2p.py", line 936, in send_blocks_and_test
    self.sync_with_ping()
  File "DASH/test/functional/test_framework/p2p.py", line 744, in sync_with_ping
    self.wait_until(test_function, timeout=timeout)
  File "DASH/test/functional/test_framework/p2p.py", line 625, in wait_until
    wait_until_helper(test_function, timeout=timeout, lock=p2p_lock, timeout_factor=self.timeout_factor)
  File "DASH/test/functional/test_framework/util.py", line 269, in wait_until_helper
    if predicate():
       ^^^^^^^^^^^
  File "DASH/test/functional/test_framework/p2p.py", line 622, in test_function
    assert self.is_connected
           ^^^^^^^^^^^^^^^^^
AssertionError
2025-06-03T12:14:23.902000Z TestFramework (INFO): Stopping nodes

What was done?

Mocktime here is misused here t = int(time.time())
Use instead helper bump_mocktime and current mocktime as self.mocktime

How Has This Been Tested?

Run multiple times locally

Breaking Changes

N/A

Checklist:

  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have added or updated relevant unit/integration/functional/e2e tests
  • I have made corresponding changes to the documentation
  • I have assigned this pull request to a milestone

@knst knst added this to the 23 milestone Jun 3, 2025
@knst knst requested review from PastaPastaPasta and UdjinM6 June 3, 2025 12:33
Mocktime here is misused here `t = int(time.time())`

Functional test p2p_invalid_block.py is changed are adjusted for Dash Core
@coderabbitai
Copy link

coderabbitai bot commented Jun 3, 2025

Walkthrough

The test in test/functional/p2p_invalid_block.py was modified to remove direct use of the time module. Instead of setting the node's mock time to the current real time, the test now uses a stored mock time value (self.mocktime). The node's mock time is initially set to this stored value. Later, the test advances mock time by calling self.bump_mocktime(1) rather than setting it directly. These changes alter how the test simulates time progression to verify block acceptance after an initial rejection due to a future timestamp.

✨ Finishing Touches
  • 📝 Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ 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.
    • Explain this complex logic.
    • 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 explain this code block.
    • @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 explain its main purpose.
    • @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.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

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.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @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

@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 (1)
test/functional/p2p_invalid_block.py (1)

141-141: Fix line length issue.

The line exceeds the 100-character limit (110 characters). Consider breaking it into multiple lines for better readability.

-        peer.send_blocks_and_test([block], node, force_send=True, success=False, reject_reason='time-too-new')
+        peer.send_blocks_and_test([block], node, force_send=True, success=False,
+                                 reject_reason='time-too-new')
🧰 Tools
🪛 Pylint (3.3.7)

[convention] 141-141: Line too long (110/100)

(C0301)

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 4930ee6 and 547fbec.

📒 Files selected for processing (1)
  • test/functional/p2p_invalid_block.py (1 hunks)
🧰 Additional context used
🪛 Pylint (3.3.7)
test/functional/p2p_invalid_block.py

[convention] 141-141: Line too long (110/100)

(C0301)

🔇 Additional comments (2)
test/functional/p2p_invalid_block.py (2)

135-135: Excellent fix for mocktime consistency!

Using self.mocktime instead of int(time.time()) ensures the test uses the controlled mock time rather than real system time, which eliminates the intermittent failures caused by time synchronization issues between the test framework and system clock.


142-142: Proper time advancement using framework helper.

Using self.bump_mocktime(1) is the correct way to advance mock time in the test framework, ensuring consistent time management and avoiding direct manipulation of time variables.

@knst knst force-pushed the fix-p2p_invalid_block branch from 547fbec to c0cb338 Compare June 3, 2025 12:41
Copy link

@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 (1)
test/functional/p2p_invalid_block.py (1)

140-140: Consider breaking the long line for better readability.

The line exceeds the 100-character limit. Consider reformatting for better readability:

-        peer.send_blocks_and_test([block], node, force_send=True, success=False, reject_reason='time-too-new')
+        peer.send_blocks_and_test([block], node, force_send=True, success=False,
+                                  reject_reason='time-too-new')
🧰 Tools
🪛 Pylint (3.3.7)

[convention] 140-140: Line too long (110/100)

(C0301)

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 547fbec and c0cb338.

📒 Files selected for processing (1)
  • test/functional/p2p_invalid_block.py (1 hunks)
🧰 Additional context used
🪛 Pylint (3.3.7)
test/functional/p2p_invalid_block.py

[convention] 140-140: Line too long (110/100)

(C0301)

⏰ Context from checks skipped due to timeout of 90000ms (10)
  • GitHub Check: linux64_tsan-build / Build source
  • GitHub Check: linux64_multiprocess-build / Build source
  • GitHub Check: mac-build / Build source
  • GitHub Check: linux64_sqlite-build / Build source
  • GitHub Check: linux64_ubsan-build / Build source
  • GitHub Check: linux64_fuzz-build / Build source
  • GitHub Check: linux64-build / Build source
  • GitHub Check: linux64_nowallet-build / Build source
  • GitHub Check: win64-build / Build source
  • GitHub Check: arm-linux-build / Build source
🔇 Additional comments (2)
test/functional/p2p_invalid_block.py (2)

134-134: Excellent fix for test determinism!

Replacing int(time.time()) with self.mocktime properly aligns with the test framework's mocktime mechanism. This prevents the intermittent failures that occur when mixing real time with mocktime, ensuring consistent and predictable test behavior.


141-141: Good use of the test framework's time management API.

Using self.bump_mocktime(1) instead of manually setting the mocktime is the recommended approach. This method properly updates all internal state and ensures consistency across the test framework, making the code more maintainable and reliable.

Copy link

@UdjinM6 UdjinM6 left a comment

Choose a reason for hiding this comment

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

makes sense

utACK c0cb338

Copy link
Member

@PastaPastaPasta PastaPastaPasta left a comment

Choose a reason for hiding this comment

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

utACK c0cb338

@PastaPastaPasta PastaPastaPasta merged commit 22023b0 into dashpay:develop Jun 3, 2025
34 checks passed
@knst knst deleted the fix-p2p_invalid_block branch June 3, 2025 21:15
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