Skip to content

Conversation

@NorrinRadd
Copy link

@NorrinRadd NorrinRadd commented Oct 20, 2022

ref #23119: Updated a subset of the test cases to get approach feedback before making a large amount of changes that may need to change again.

Approach:

  • assert_equal is preferred over assert where possible.
  • A matching assert_not_equal function has been added also.
  • Where assert_equal is not possible, the built-in assert function will be used.

Rationale:
This has been discussed in a few PRs / Issue. The most recent consensus is that a minimal approach is best.

@NorrinRadd NorrinRadd changed the title test: Use a consistent assert functions: ref #23119 test: Use a consistent assert functions Oct 20, 2022
@NorrinRadd NorrinRadd changed the title test: Use a consistent assert functions test: Use consistent assert functions Oct 20, 2022
@DrahtBot DrahtBot added the Tests label Oct 20, 2022
@DrahtBot
Copy link
Contributor

DrahtBot commented Oct 20, 2022

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

Reviews

See the guideline for information on the review process.

Type Reviewers
Concept ACK shaavan

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:

  • #26257 (script, test: python linter fixups and updates by jonatack)
  • #23502 (wallet: Avoid underpaying transaction fees when signing taproot spends by achow101)

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.

Copy link
Contributor

@shaavan shaavan left a comment

Choose a reason for hiding this comment

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

Concept ACK on using the consistent assert function.

However, I am skeptical of this statement.

Other variations of assert will be removed.

There are many variations of assert in test/test_framework/util.py, and all serve different purposes. For example, assert_is_hex_string will be used in the case of verifying hex strings.
If we eliminate all variants other than assert_equal and assert_not_equal, it will increase the verbosity of the assert code on the usage side, making maintaining and debugging code a challenge.

IMO, I would rather have a bunch of variations of assert statements based on a different case, maintained in the same file, and used consistently throughout the codebase than have only a minimal amount of functions implemented and use them to write custom code on the usage side.

@NorrinRadd
Copy link
Author

That is an important distinction. assert and assert_equal will be used where possible.

Concept ACK on using the consistent assert function.

However, I am skeptical of this statement.

Other variations of assert will be removed.

There are many variations of assert in test/test_framework/util.py, and all serve different purposes. For example, assert_is_hex_string will be used in the case of verifying hex strings. If we eliminate all variants other than assert_equal and assert_not_equal, it will increase the verbosity of the assert code on the usage side, making maintaining and debugging code a challenge.

IMO, I would rather have a bunch of variations of assert statements based on a different case, maintained in the same file, and used consistently throughout the codebase than have only a minimal amount of functions implemented and use them to write custom code on the usage side.

Yes, that's an important point. I'll update the summary accordingly and also revert some of the removals of assert_greater_than, as I can see in previous PRs that function was acceptable.

Updated a subset of the test cases to get approach feedback.

assert_equal is preferred over assert where possible.
A matching assert_not_equal function has been added also.
Where assert_equal is not possible, the built-in assert function will be used.
@NorrinRadd
Copy link
Author

Any more issues? Is this good to merge? Once accepted I can make these changes to the other TC files and hopefully close out #23119

Co-authored-by: Shashwat Vangani <[email protected]>
Copy link
Contributor

@aureleoules aureleoules left a comment

Choose a reason for hiding this comment

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

LGTM. I think you should squash the commits.

Comment on lines -259 to +260
assert_greater_than_or_equal(tmpl['sizelimit'], 3999577) # actual maximum size is lower due to minimum mandatory non-witness data
assert_greater_than_or_equal(tmpl['sizelimit'], 3999577) # actual maximum size is lower due to minimum mandatory non-witness data
Copy link
Contributor

@aureleoules aureleoules Nov 21, 2022

Choose a reason for hiding this comment

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

this can be removed (useless change)

@DrahtBot
Copy link
Contributor

DrahtBot commented Dec 9, 2022

🐙 This pull request conflicts with the target branch and needs rebase.

@fanquake fanquake marked this pull request as draft February 6, 2023 15:07
@fanquake
Copy link
Member

fanquake commented Feb 6, 2023

Moved to draft for now. Seems like there could be agreement on making this change, but it needs rebasing (2 months), changes need squashing, needs review comments addressing.

@fanquake
Copy link
Member

Closing for now. Looks like the user has also disspeared off GitHub.

@fanquake fanquake closed this Mar 20, 2023
@bitcoin bitcoin locked and limited conversation to collaborators Mar 19, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants