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
Increase test coverage for Dash specific code #1608
Increase test coverage for Dash specific code #1608
Conversation
src/netaddress.cpp
Outdated
@@ -221,7 +222,7 @@ bool CNetAddr::IsValid() const | |||
|
|||
bool CNetAddr::IsRoutable() const | |||
{ | |||
return IsValid() && !(IsRFC1918() || IsRFC2544() || IsRFC3927() || IsRFC4862() || IsRFC6598() || IsRFC5737() || (IsRFC4193() && !IsTor()) || IsRFC4843() || IsLocal()); | |||
return IsValid() && (Params().NetworkIDString() == CBaseChainParams::REGTEST || !(IsRFC1918() || IsRFC2544() || IsRFC3927() || IsRFC4862() || IsRFC6598() || IsRFC5737() || (IsRFC4193() && !IsTor()) || IsRFC4843() || IsLocal())); |
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 don't think it's a good idea. We are trying to (slowly) get rid of the logic like that actually. I would rather see it somewhere where IsRoutable()
is avoided specifically, not canceling function logic from the inside. One (preferable) way to do so would be to add smth like protected fRequireRoutable
to CChainParams
, specifying different values for mainnet/testnet/regtest, wrapping access into public function and using it via Params()
. See fMiningRequiresPeers
as as example. But again, this class is a base one and should be kept network agnostic, so rather use Params()
where you want IsRoutable()
to be avoided specifically.
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.
Agree. Actually we can explicitly specify -externalip
in tests and then IsRoutable
should be skipped only at initialization phase: https://github.com/dashpay/dash/pull/1608/files#diff-9a82240fe7dfe86564178691cc57f2f1L207
Is it acceptable solution, what do you think?
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.
Hmmm... let's take a step back actually - what issue exactly are you trying to solve by that?
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.
The issue is that masternodes need to be accessible from the Internet, and local network addresses (like 127..., 192.168..., 172... etc) aren't considered as valid external addresses. So we need to make an exception and allow these addresses for our automatic tests.
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.
Then maybe it's CMasternode::IsValidNetAddr
that have to be fixed/adjusted instead?
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 seems this method is already adjusted and always returns true
for regtest. The issue with masternodes is here:
Line 175 in 91ae0b7
nState = ACTIVE_MASTERNODE_NOT_CAPABLE; |
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.
BTW, this line also seems like workaround for explicitly specified addresses: https://github.com/dashpay/dash/blob/fe491f97868ff36a31646cbee7ad09a284b8beee/src/net.cpp#L210
build fails, looks like |
I have the same idea, but can't reproduce the issue on my local machine in order to verify. |
5bf61b2
to
3ab24b6
Compare
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.
Looks better and passes tests now 👍
Found only few small issues so far, see comments
src/netaddress.cpp
Outdated
@@ -11,6 +11,7 @@ | |||
#include "hash.h" | |||
#include "utilstrencodings.h" | |||
#include "tinyformat.h" | |||
#include "chainparams.h" |
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.
should be removed
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.
removed
src/net.cpp
Outdated
@@ -204,7 +204,8 @@ void AdvertiseLocal(CNode *pnode) | |||
// learn a new local address | |||
bool AddLocal(const CService& addr, int nScore) | |||
{ | |||
if (!addr.IsRoutable()) | |||
// TODO: skip IsRoutable only in regtest mode | |||
if (!addr.IsRoutable() && nScore < LOCAL_MANUAL) |
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.
Should probably use Params().RequireRoutableExternalIP()
here as well if this is still needed for tests to pass.
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.
Surely! I forgot to commit net.cpp
... Thanks.
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.
Hmm.. shouldn't nScore < LOCAL_MANUAL
go away here then? Also, // TODO:
above is not a TODO
anymore I guess ;)
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, I will remove TODO
when tests finished. Actually, with nScore < LOCAL_MANUAL
logic is unchanged even in regtest mode (for other tests without -expernalip
parameter). But I think it can be removed safely...
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.
Hmm... Untouched tests failed. Seems like port 11211 is busy for some reason. Same problem with this port was noticed yesterday.
19b2148
to
b39de49
Compare
…ation tests added
… the condition "explicitly specified address" in `AddLocal` method; other minor changes
b39de49
to
e1fb094
Compare
Could you please write longer and more descriptive commit messages, not one-liners? It would be helpful if commit messages contain more detailed description of what is done here, as well as rationale for the change (why it's needed). |
Also, if you add a new file and then fix a bug in it in subsequent commit. please squash these commits together, to make it look like you've added a new file without any bugs originally. :-) |
e1fb094
to
9e4e259
Compare
4a13a7d
to
c1ac7dd
Compare
@@ -0,0 +1,124 @@ | |||
''' |
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.
There's already a very similar version of this in contrib/testgen/base58.py.
The differences look like mostly format
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. Actually, entire lib folder is taken from sentinel
. We have already discussed this issue with @OlegGirko. Presumably, the best way is to make this dash-specific code as python library with modules (like dash_hash, for example) in order to use it in the sentinel
as well as in rpc-tests
.
So far I'm preparing the wrapper for dash-specific functionality to add it to the BitcoinTestFramework
.
@OlegGirko I don't agree w/this. It hides what is done on the PR and makes inline comments on the PR not make sense if those get superceded by changes. We already are squash-merging via Github, so I think it is ok to push a new commit w/o squashing and changing history on the PR. |
@nmarley: Of course, this applies only for a branch being reviewed, but not merged yet. Once it's merged, it should not be amended. And, BTW, squashing commits when merging PRs is wrong on many levels.
Hence, I vote for normal merging, as other projects do. |
This is changing history, and requires "squashing" or "rebasing" or whatever you want to call it. It's a history change and after a PR has started to get reviewed by other eyes. Now previous commits aren't the same, and the reviewers have to start over completely.
I don't think this is a valid argument, as PRs are temporary and main master/develop branches are all that matters. The commit history in these branches should be clean at any rate.
I assume by normal merging, you mean a merge commit. Github added the "Squash and Merge" and "Rebase and Merge" as options, so there must be something right with those as well. It's up to the developers to commit code, and the repo maintainers to decide how these get merged in. The maintainers have the ability to update the main commit message when they merge it in, thus "clean up" the commit messages. And AFAIK the way that changes get merged into the mainline repo is not up for a vote. |
Since this PR had no reviews/changes for almost 8 months, if @the-schnibble (or anyone willing to take the job) is still interested in merging it, he'd need to address few points IMO:
|
Some changes were partially merged in other PRs, others are pretty much outdated now. Closing. |
CTestLogger
patch to enable test logtest_framework
librarymasternode rate check
andproposal propagation
tests