Skip to content

Conversation

@sipa
Copy link
Member

@sipa sipa commented Mar 18, 2020

It seems #17319 introduced an (unobserved) bug in the test framework in bn2vch: a zero padding byte was added for every nonzero number, even when the top byte was <= 0x7F. Fix this.

@sipa
Copy link
Member Author

sipa commented Mar 18, 2020

I'm happy to add a quick test case for this, but I don't see any obvious place to put a test of the test framework itself. Any suggestions?

@sipa sipa force-pushed the 202003_fix_bn2vch branch from 812340c to f65868b Compare March 18, 2020 06:53
@DrahtBot
Copy link
Contributor

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

Conflicts

Reviewers, this pull request conflicts with the following ones:

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.

ext = bytearray()
if v.bit_length() > 0:
have_ext = (v.bit_length() & 0x07) == 0
if v.bit_length() > 0 && (v.bit_length() & 0x07) == 0:
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
if v.bit_length() > 0 && (v.bit_length() & 0x07) == 0:
if v.bit_length() > 0 and (v.bit_length() & 0x07) == 0:

@sipa
Copy link
Member Author

sipa commented Mar 18, 2020

Closing in favor of #18378.

@sipa sipa closed this Mar 18, 2020
laanwj added a commit that referenced this pull request Mar 19, 2020
a733ad5 Add bn2vch test to functional tests (Pieter Wuille)
a3ad645 Simplify bn2vch using int.to_bytes (Pieter Wuille)

Pull request description:

  Alternative to #18374, fixing the incorrect padding added sometimes in `bn2vch`.

  Since we're using Python 3.2+, a much simpler implementation of `bn2vch` is possible using `int.to_bytes`.

  This also adds a "functional" test for bn2vch, in a new "framework_test_script.py", where the "framework_test_" prefix is intended for tests of the framework itself.

ACKs for top commit:
  laanwj:
    nice, ACK a733ad5
  jnewbery:
    Tested ACK a733ad5.

Tree-SHA512: aeacc4e7fd84279023d38e8b4a5175fb16d7b3a7f93c61b9dcb59cd9927547732983c76f28564b62e37088399fc0121b38a514d73b0ea38b3983836539e9ca90
@bitcoin bitcoin locked as resolved and limited conversation to collaborators Feb 15, 2022
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.

5 participants