-
Notifications
You must be signed in to change notification settings - Fork 38.7k
[tests] Add messages.py #11648
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
[tests] Add messages.py #11648
Conversation
|
One travis failure in net.py: |
|
@fanquake looks unrelated, restarted |
|
Thanks for trying to clean things up, but I think we need more categorization here; bitcoin P2P message types are clearly a different kind of primitives than consensus data structures such as CTransaction CTXin etc. Only the second group is called "primitives" in the C++ code. |
|
Maybe just call it something like serialize.py or messages.py. |
738f1da to
46fd472
Compare
mininode.py wildcard imports all names from primitives.py. This is to avoid having to change all test scripts that import from mininode.py.
Mostly move only. Adds a few extra comments.
46fd472 to
1135c79
Compare
I tried splitting this further into If you think it's worth splitting further into consensus primitives and p2p message data structures, I can look at doing that in a future PR. It would end up looking something like https://github.com/jnewbery/bitcoin/tree/pr11648.2. |
|
@jnewbery Thanks. Calling it messages.py is enough. I don't think they need to be split further unless they're used seperately, which they're not. It was just that having two concepts of "primitives" between the tests and code was confusing to me. |
|
utACK 1135c79 |
maflcko
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
utACK 1135c79
Verified that it is indeed move-only and/or fixups due to rename.
I am neutral on the overall change. Some prefer a huge file where it is easy to jump back and forth, others prefer multiple files that bundle into smaller sets of related classes and functions.
I think there is no single true way of organizing the files, but if the refactoring helps some greater goal, I am happy with the changes.
| MAX_INV_SZ = 50000 | ||
| MAX_BLOCK_BASE_SIZE = 1000000 | ||
|
|
||
| COIN = 100000000 # 1 btc in satoshis |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: This is a conversion helper constant not used by any of the primitives or messages.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's used in:
CTxOut.__repr__CTransaction.is_valid
It's arguable where this belongs, the ideal place might be some bitcoin-specific constants header, but for now it makes sense to have it here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are right, I missed those. Looks fine now.
|
utACK 1135c79 |
1135c79 [tests] Tidy up mininode.py module (John Newbery) f9cd9b1 [tests] Move test_framework Bitcoin primitives into separate module (John Newbery) Pull request description: Second part of #11518. Moves the primitive Bitcoin datastructures and message classes into their own module, and tidies up the mininode.py module. - First commit is almost entirely move-only - Second commit is mostly move-only, but also does a little tidying. Tree-SHA512: 5d74802677f1ab788e43188653106a96fffd9ab1fe3aa6a4eb94e5807de5dd5c8ee212296f45e8d16c7e3d95cfc4891677e812b7944bd3ab604e04b3b88aa06e
| return sha256(sha256(s)) | ||
|
|
||
| def ser_compact_size(l): | ||
| r = b"" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unnecessary?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Generally, it is easier to verify move-only-ness when no code changes are made. We've had pull requests in the past that did "all the refactoring" in one go and introduced bugs.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMO both ways are acceptable, as long as the commits that move code are separate from those that make changes.
In any case, moving code around doesn't obligate someone to also fix all the problems it has, in style or other things. Can be done later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, happy to see this fixed up when you touch that function for other reasons. Not sure if this change warrants a pull request on itself.
…arate module I manually recreated this commit, since we have A LOT of conflicts in mininode. However since it is primarily just a move, it was pretty easy to recreate Signed-off-by: Pasta <pasta@dashboost.org>
* [tests] Tidy up mininode.py module Mostly move only. Adds a few extra comments. * bitcoin#11648 [tests] Move test_framework Bitcoin primitives into separate module I manually recreated this commit, since we have A LOT of conflicts in mininode. However since it is primarily just a move, it was pretty easy to recreate Signed-off-by: Pasta <pasta@dashboost.org> * add import to messages.py Signed-off-by: Pasta <pasta@dashboost.org> * move import from mininode.py to messages.py Signed-off-by: Pasta <pasta@dashboost.org> * fix test failure Signed-off-by: Pasta <pasta@dashboost.org> * remove empty line at top of messages.py Signed-off-by: pasta <pasta@dashboost.org> * alphabetize MESSAGEMAP seperated by if it is dash specific or not Signed-off-by: pasta <pasta@dashboost.org> * remove accidentally added feefilter message Signed-off-by: pasta <pasta@dashboost.org> * Add missing getmnlistd/mnlistdiff messages to MESSAGEMAP Co-authored-by: John Newbery <john@johnnewbery.com> Co-authored-by: UdjinM6 <UdjinM6@users.noreply.github.com>
* [tests] Tidy up mininode.py module Mostly move only. Adds a few extra comments. * bitcoin#11648 [tests] Move test_framework Bitcoin primitives into separate module I manually recreated this commit, since we have A LOT of conflicts in mininode. However since it is primarily just a move, it was pretty easy to recreate Signed-off-by: Pasta <pasta@dashboost.org> * add import to messages.py Signed-off-by: Pasta <pasta@dashboost.org> * move import from mininode.py to messages.py Signed-off-by: Pasta <pasta@dashboost.org> * fix test failure Signed-off-by: Pasta <pasta@dashboost.org> * remove empty line at top of messages.py Signed-off-by: pasta <pasta@dashboost.org> * alphabetize MESSAGEMAP seperated by if it is dash specific or not Signed-off-by: pasta <pasta@dashboost.org> * remove accidentally added feefilter message Signed-off-by: pasta <pasta@dashboost.org> * Add missing getmnlistd/mnlistdiff messages to MESSAGEMAP Co-authored-by: John Newbery <john@johnnewbery.com> Co-authored-by: UdjinM6 <UdjinM6@users.noreply.github.com>
Second part of #11518.
Moves the primitive Bitcoin datastructures and message classes into their own module, and tidies up the mininode.py module.