Creates unittests for addrman, makes addrman more testable. #6720

Merged
merged 1 commit into from Oct 7, 2015

Conversation

Projects
None yet
6 participants
@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

@jonasschnelli

View changes

src/addrman.h
@@ -567,6 +569,14 @@ class CAddrMan
Check();
}
}
+
+
+ #ifdef __ADDRMAN_TEST__

This comment has been minimized.

@jonasschnelli

jonasschnelli Sep 24, 2015

Member

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

@jonasschnelli

jonasschnelli Sep 24, 2015

Member

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

@eth0

This comment has been minimized.

Show comment
Hide comment
@eth0

eth0 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.

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

This comment has been minimized.

Show comment
Hide comment
@jonasschnelli

jonasschnelli Sep 24, 2015

Member

@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.

Member

jonasschnelli commented Sep 24, 2015

@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.

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.
@eth0

This comment has been minimized.

Show comment
Hide comment
@eth0

eth0 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.

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

This comment has been minimized.

Show comment
Hide comment
@dcousens

dcousens Sep 25, 2015

Contributor

concept ACK, non test-code utACK

Contributor

dcousens commented Sep 25, 2015

concept ACK, non test-code utACK

@EthanHeilman

This comment has been minimized.

Show comment
Hide comment
@EthanHeilman

EthanHeilman Sep 30, 2015

Contributor

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

Contributor

EthanHeilman commented Sep 30, 2015

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

@jgarzik

This comment has been minimized.

Show comment
Hide comment
@jgarzik

jgarzik Oct 1, 2015

Contributor

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

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

1 check passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details

laanwj added a commit that referenced this pull request Oct 7, 2015

Merge pull request #6720
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

This comment has been minimized.

Show comment
Hide comment
@laanwj

laanwj Oct 7, 2015

Member

utACK

Member

laanwj commented Oct 7, 2015

utACK

luke-jr added a commit to luke-jr/bitcoin that referenced this pull request Jan 9, 2016

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.

Github-Pull: #6720
Rebased-From: 1534d9a
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment