Skip to content

Remove From and Into test impls and create test-specific function for converting between Rust primitives and U256#3612

Merged
apoelstra merged 1 commit intorust-bitcoin:masterfrom
shinghim:3160-remove-from-into
Nov 14, 2024
Merged

Remove From and Into test impls and create test-specific function for converting between Rust primitives and U256#3612
apoelstra merged 1 commit intorust-bitcoin:masterfrom
shinghim:3160-remove-from-into

Conversation

@shinghim
Copy link
Copy Markdown
Contributor

Created a new test-utils module for these functions since it needs to be visible for tests in the block module that were also using the previous From and Into impls.

Fixes #3160

@github-actions github-actions bot added the C-bitcoin PRs modifying the bitcoin crate label Nov 13, 2024
@coveralls
Copy link
Copy Markdown

coveralls commented Nov 13, 2024

Pull Request Test Coverage Report for Build 11826412804

Details

  • 14 of 14 (100.0%) changed or added relevant lines in 2 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.007%) to 82.477%

Totals Coverage Status
Change from base Build 11822813449: 0.007%
Covered Lines: 19782
Relevant Lines: 23985

💛 - Coveralls

@shinghim shinghim force-pushed the 3160-remove-from-into branch from 1f26364 to 7507836 Compare November 13, 2024 15:29
@shinghim shinghim marked this pull request as ready for review November 13, 2024 16:05
apoelstra
apoelstra previously approved these changes Nov 13, 2024
Copy link
Copy Markdown
Member

@apoelstra apoelstra left a comment

Choose a reason for hiding this comment

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

ACK 750783604c05d7e4ce404e48ddb7a67886a51273; successfully ran local tests

Copy link
Copy Markdown
Member

@tcharding tcharding left a comment

Choose a reason for hiding this comment

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

Thanks man, a few naming suggestions but looks good apart from that.

One small thing, can you make the commit brief log less than or equal to 54 charactars please. Long lines cause grief for other tools.

Remove From and Into test impls

blah blah create test-specific function blah blah

Comment on lines 1085 to 1086
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Perhaps call the module convert and the the functions u64_to_work, then at the call sites use convert::u64_to_work, and import with use crate::pow::convert.

Just an idea.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

That would look nicer. I do think that having something about testing in the module name would make it immediately clear that these are meant for testing only though, instead of having to look at the declaration and seeing the test flag. Any reason we shouldn't limit it to just testing-related code?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Definitely only test code, and fair point about having 'test' in the name. Lets stick with your original module name (even though we try not to use 'util'). Perhaps drop the convert_.

The removed impls have been replaced with test-specific functions for
converting between Rust primitives and U256
@shinghim shinghim force-pushed the 3160-remove-from-into branch from 48b32bc to 33b9d69 Compare November 13, 2024 21:49
Copy link
Copy Markdown
Member

@apoelstra apoelstra left a comment

Choose a reason for hiding this comment

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

ACK 33b9d69; successfully ran local tests

Copy link
Copy Markdown
Member

@tcharding tcharding left a comment

Choose a reason for hiding this comment

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

ACK 33b9d69

@apoelstra apoelstra merged commit 431581a into rust-bitcoin:master Nov 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

C-bitcoin PRs modifying the bitcoin crate

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Remove From<T> for Target from pow unit tests module

5 participants