Skip to content

test: makes timeout a forced named argument in tests methods that use it - #29750

Merged
fanquake merged 1 commit into
bitcoin:masterfrom
sr-gi:202403-test-forced-timeout
Apr 2, 2024
Merged

fanquake merged 1 commit into
bitcoin:masterfrom
sr-gi:202403-test-forced-timeout

Conversation

@sr-gi

@sr-gi sr-gi commented Mar 27, 2024 •

Copy link
Copy Markdown
Member

This makes calls to such methods more explicit and less error-prone.

Motivated by #29736 (comment)

@DrahtBot

DrahtBot commented Mar 27, 2024 •

Copy link
Copy Markdown
Contributor

The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

Code Coverage

For detailed information about the code coverage, see the test coverage report.

Reviews

See the guideline for information on the review process.

Type Reviewers
ACK maflcko, brunoerg, BrandonOdiwuor, AngusP, stratospher
Concept ACK kevkevinpal

If your review is incorrectly listed, please react with 👎 to this comment and the bot will ignore it on the next update.

Conflicts

Reviewers, this pull request conflicts with the following ones:

  • #29748 (test: Cleans some manual checks/drops when using wait_for_getdata by sr-gi)
  • #29736 (test: Extends wait_for_getheaders so a specific block hash can be checked by sr-gi)

If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first.

@kevkevinpal

Copy link
Copy Markdown
Contributor

Concept ACK 985d4d4

This makes calls to such methods more explicit and less error prone
@sr-gi
sr-gi force-pushed the 202403-test-forced-timeout branch from 985d4d4 to 61560d5 Compare March 27, 2024 14:33
@maflcko

maflcko commented Mar 27, 2024

Copy link
Copy Markdown
Member

lgtm ACK 61560d5

@brunoerg brunoerg left a comment

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.

ACK 61560d5

@BrandonOdiwuor BrandonOdiwuor left a comment

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.

crACK 61560d5

@AngusP AngusP left a comment

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.

ACK 61560d5

Comment on lines +201 to +203
self.wait_for_getheaders(timeout=timeout)
self.send_message(msg)
self.wait_for_getdata([block.sha256])
self.wait_for_getdata([block.sha256], timeout=timeout)

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.

Nit: default timeout=60, but that's 60 secs for each inner function that takes a timeout, so the total timeout for announce_block_and_wait_for_getdata is 120 in this case.

Probably fine, but potentially confusing, i.e. announce_block_and_wait_for_getdata(..., timeout=60) can actually run for ~120 seconds. An alternative would be something like timeout=timeout//2 on wait_for_getheaders and wait_for_getdata but that doesn't seem much better to me. More complex could be to subtract 'already spent time' from timeout after each inner wait_* call?

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.

Also nit: should timeout on announce_block_and_wait_for_getdata also be kwargs only?

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.

Nit: default timeout=60, but that's 60 secs for each inner function that takes a timeout, so the total timeout for announce_block_and_wait_for_getdata is 120 in this case.

the first 60 second timeout would cause the test to crash and we wouldn't wait around for the next crash to happen :)

Also nit: should timeout on announce_block_and_wait_for_getdata also be kwargs only?

don't think it's worth it since it's only a local function used in 1 file.

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.

the first 60 second timeout would cause the test to crash and we wouldn't wait around for the next crash to happen :)

I meant if the first took say 59s to succeed then the second another 59s, but yeah it's not really an issue

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Nit: default timeout=60, but that's 60 secs for each inner function that takes a timeout, so the total timeout for announce_block_and_wait_for_getdata is 120 in this case.

the first 60 second timeout would cause the test to crash and we wouldn't wait around for the next crash to happen :)

Also nit: should timeout on announce_block_and_wait_for_getdata also be kwargs only?

don't think it's worth it since it's only a local function used in 1 file.

Yeah, this was my intuition too. The same applies to the total timeout, I think it'd be worth if this was used outside the context of this file, but it is actually only used in a single test

@stratospher stratospher left a comment

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.

tested ACK 61560d5.

Comment on lines +201 to +203
self.wait_for_getheaders(timeout=timeout)
self.send_message(msg)
self.wait_for_getdata([block.sha256])
self.wait_for_getdata([block.sha256], timeout=timeout)

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.

Nit: default timeout=60, but that's 60 secs for each inner function that takes a timeout, so the total timeout for announce_block_and_wait_for_getdata is 120 in this case.

the first 60 second timeout would cause the test to crash and we wouldn't wait around for the next crash to happen :)

Also nit: should timeout on announce_block_and_wait_for_getdata also be kwargs only?

don't think it's worth it since it's only a local function used in 1 file.

@maflcko

maflcko commented Apr 2, 2024

Copy link
Copy Markdown
Member

rfm?

@fanquake
fanquake merged commit 1d8a5f0 into bitcoin:master Apr 2, 2024
Pttn added a commit to Pttn/Bitcoin that referenced this pull request Jan 10, 2025
@bitcoin bitcoin locked and limited conversation to collaborators Apr 2, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

9 participants