Skip to content

Conversation

eth0
Copy link

@eth0 eth0 commented Sep 24, 2015

  • Creates unittests for addrman, while not all addrman behavior is covered by these tests they provide a useful starting place and increase code coverage.
  • Minor modifications to addrman to allow deterministic and effective testing.

@laanwj laanwj added the Tests label Sep 24, 2015
@@ -567,6 +569,14 @@ class CAddrMan
Check();
}
}


#ifdef __ADDRMAN_TEST__
Copy link
Contributor

Choose a reason for hiding this comment

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

Would it make sense to link this to the configure flag --enable-tests?

@eth0
Copy link
Author

eth0 commented Sep 24, 2015

@jonasschnelli What advantages are offered by using the --enable-tests flag?

Also how would one learn the value of --enable-tests at the level necessary to change code behavior? I suppose you could move the MakeDeterministic method into its own source file and then only include that source when building tests but that is a bit complicated.

I could also remove the ifdef ADDRMAN_TEST check completely.

@jonasschnelli
Copy link
Contributor

@eth0: maybe remote the #ifdef __ADDRMAN_TEST__ completely or export the ENABLE_TESTS over AC_DEFINE_UNQUOTED() in configure.ac and use this define to determine if you compile the MakeDeterministic() function?

Is the newOnly related to the new unit-tests?

Nice work!
Concept ACK.

Adds several unittests for addrman to verify it works as expected.
Makes small modifications to addrman to allow deterministic and targeted tests.
@eth0
Copy link
Author

eth0 commented Sep 24, 2015

@jonasschnelli
I removed the macro completely.

newOnly is related to the unit-tests since I need a way to test if an addr is in the new or tried tables.

I am developing some non-unittest code which builds on the newOnly functionality but it is independent of this pull-request.

@dcousens
Copy link
Contributor

concept ACK, non test-code utACK

@EthanHeilman
Copy link
Contributor

@dcousens Anything I can do to move this along?
I've tested this code in the Bitcoin client and the unittests all pass.

@jgarzik
Copy link
Contributor

jgarzik commented Oct 1, 2015

ut ACK - doesn't test very much, but what it does test, looks correct based on quick review :)

@laanwj laanwj merged commit 1534d9a into bitcoin:master Oct 7, 2015
laanwj added a commit that referenced this pull request Oct 7, 2015
1534d9a Creates unittests for addrman, makes addrman testable. Adds several unittests for addrman to verify it works as expected. Makes small modifications to addrman to allow deterministic and targeted tests. (EthanHeilman)
@laanwj
Copy link
Member

laanwj commented Oct 7, 2015

utACK

luke-jr pushed a commit to luke-jr/bitcoin that referenced this pull request Jan 9, 2016
Adds several unittests for addrman to verify it works as expected.
Makes small modifications to addrman to allow deterministic and targeted tests.

Github-Pull: bitcoin#6720
Rebased-From: 1534d9a
@bitcoin bitcoin locked as resolved and limited conversation to collaborators Sep 8, 2021
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.

6 participants