-
Notifications
You must be signed in to change notification settings - Fork 65
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
addrman_tests #177
addrman_tests #177
Conversation
v7.17.3 digibyte/src/policy/feerate.cpp Line 13 in 258afac
|
Thanks for doing this! A couple of quick questions, other than the fact it was using Chat GPT summary is helpful to understand why:
Please let me know if I am missing something else with this, but I think BTC devs made the change for cross platform consistency. |
I saw a problem in test/amount_tests.cpp. The size of DigiByte MAX_MONEY was 21e17. Bitcoin MAX_MONEY is 21e15.
digibyte/src/test/amount_tests.cpp Line 88 in dd95b35
Then i saw in policy/feerate.h and policy/feerate.cpp uint32_t. And changed it just to be sure. saw the same at Litecoin and DigiByte 7. Here num_bytes is converted immediately to int64_t digibyte/src/policy/feerate.cpp Lines 12 to 14 in dd95b35
But of course i have changed it back to uint32_t. uint32_t is better. Thank you!! |
in src/test/amount_tests.cpp i also change int64_t to uint32_t. |
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.
I left some comments for @JaredTate and @Jongjan88 to review.
src/test/amount_tests.cpp
Outdated
@@ -85,7 +85,7 @@ BOOST_AUTO_TEST_CASE(GetFeeTest) | |||
BOOST_CHECK(CFeeRate(CAmount(26), 789) == CFeeRate(32)); | |||
BOOST_CHECK(CFeeRate(CAmount(27), 789) == CFeeRate(34)); | |||
// Maximum size in bytes, should not crash | |||
CFeeRate(MAX_MONEY, std::numeric_limits<uint32_t>::max()).GetFeePerK(); | |||
CFeeRate(MAX_MONEY <= uint32_t(std::numeric_limits<uint32_t>::max())).GetFeePerK(); |
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.
@Jongjan88 and @JaredTate, I am concerned about this change. Normally, I would not expect changes to our test code but rather the underlying code being tested for the respective tests to pass.
The proposed change, however, alters the test to use a boolean expression result (either 0 or 1) as the first argument to CFeeRate. This means the test no longer checks the behavior of CFeeRate with large numerical values but rather with the smallest possible non-negative values (0 or 1).
This shift in testing could potentially miss issues or behaviors that only manifest with larger values. Changing a test is unusual unless the underlying code or the specifications have changed.
@Jongjan88, can you provide some more detail on this change?
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.
I think you are right. We should not change the test if possible.
When i do this. The code is working.
size_t = MAX_MONEY2
MAX_MONEY2 = MAX_MONEY / 1000;
CFeeRate(MAX_MONEY2, std::numeric_limits<uint32_t>::max()).GetFeePerK();
Update
I remove this line CFeeRate(MAX_MONEY <= uint32_t(std::numeric_limits<uint32_t>::max())).GetFeePerK();
@Jongjan88 Are these all the correct changes and should other devs be reviewing this? |
Yes. |
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.
cACK.
This looks good now @Jongjan88 , but I do have a question about placing the assertions in feerate.cpp
. While this does make this code more guarded, I wonder what the performance impact will be? I will have to defer to @JaredTate . Conceptually, this PR looks ok though.
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.
cACK. I agree with @gto90 that we need to get a further review from @JaredTate.
That is correct @JaredTate ! I believe they were reverted because they were changes to the test code which obfuscated underlying issues we are actually having in the code. |
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.
@Jongjan88 I see that we use 12024 still in a couple of files, should they also be changed?
- nodes_main.txt
- windows-setup.md
- chainparams.cpp
- netbase.h
- net.cpp
- net_tests.cpp
- netbase_tests.cpp
@Jongjan88 , we do not necessarily have to change them in this PR to be clear. But we should make sure that our ports are consistent across the code base. |
I saw them. I think some need to be changed. chainparams.cpp not ofc. #178 (comment) @gto90 |
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
Thank you @Jongjan88
No worries on this, so now it's just port changes correct? I am trying to free up a couple of full days to really dive in on this. I have had other commitments to finish over this past week. I should free up the next few days. |
Nice. Yes after this port change in addrman_tests. addrman_tests will not give 3 errors. And pass successful. |
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.
ACK. Make sense, thanks for doing this. It compiles & runs good. On to the next!
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.
cACK. Thanks for your efforts folks!
src/test/addrman_tests.cpp
//after changing ports back from 12024 to 8333 addrman_tests pass successful.
On the screenshot you can see it pass addrman_tests.cpp