Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bits in hex for rpc block methods #921

Merged
merged 2 commits into from
Dec 23, 2019
Merged

Conversation

braydonf
Copy link
Contributor

Follow-up of #919

@codecov-io

This comment has been minimized.

@tynes
Copy link
Member

tynes commented Dec 23, 2019

There is prior art for using hex32 to convert the bits Number to a hex string.

bits: hex32(attempt.bits),

In the test, 207fffff is used. This matches the value used to create the genesis block in regtest here:

bits: 545259519,

(545259519).toString(16)
'207fffff'

My only concern is that it couples the test to not mining any blocks beforehand, since the hex string is hardcoded in. Not the largest problem because other tests do the same thing, but I think it would be more ideal to not couple tests to specific blockheights unless they are specifically testing the blockheight.

Looks good to me.

ACK d334051

@braydonf
Copy link
Contributor Author

As these tests become more numerous, I think we'll need to breakout the tests into a few groups based on their expected environments, for example: 1) Basic chain 2) Chain with reorganization. For other cases, it'll probably be necessary to start to use a mocked chain.

@braydonf
Copy link
Contributor Author

The value here matches the bitcoind return value for bits, as from blockToJSON defined in src/rpc/blockchain.cpp:

result.pushKV("bits", strprintf("%08x", block.nBits));

@braydonf
Copy link
Contributor Author

For background, bitcoind has had bits expressed in hex since the field was added in bitcoin/bitcoin#885 after the method was added in bitcoin/bitcoin#727.

braydonf added a commit that referenced this pull request Dec 23, 2019
Bits in hex for rpc block methods
@braydonf braydonf merged commit d334051 into bcoin-org:master Dec 23, 2019
@braydonf braydonf deleted the rpc-bits branch December 23, 2019 22:45
@braydonf braydonf added this to the 2.0.0 milestone Jan 6, 2020
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