Skip to content

test: Add unit test for AddTimeData#16563

Merged
laanwj merged 1 commit intobitcoin:masterfrom
mzumsande:201908_test_timedata
Aug 14, 2019
Merged

test: Add unit test for AddTimeData#16563
laanwj merged 1 commit intobitcoin:masterfrom
mzumsande:201908_test_timedata

Conversation

@mzumsande
Copy link
Contributor

AddTimeData() has poor test coverage but interesting logic (including a bug turned into a feature). This PR adds a unit test for it.

@DrahtBot DrahtBot added the Tests label Aug 7, 2019
@practicalswift
Copy link
Contributor

Welcome as a contributor @mzumsande!

Would you mind adding a comment describing the bug-turned-feature to give some context to this change? :-)

@maflcko
Copy link
Member

maflcko commented Aug 7, 2019

Maybe this:

@mzumsande
Copy link
Contributor Author

mzumsande commented Aug 7, 2019

Yes, I meant #4521 - there is also a comment about this in the source code of timedata.cpp which I referenced in the test.

Basically, the method of getting offsets from peers will become ineffective after it has reached 200 samples, because it only attempts to change nTimeOffset when it the filter size is odd. So nTimeOffset will never be changed after offsets from 200 peers have been received (unless you restart the node).

@practicalswift
Copy link
Contributor

@mzumsande Could you add a comment to BOOST_AUTO_TEST_CASE(addtimedata) describing the intended behaviour and the rationale behind doing so?

@mzumsande mzumsande force-pushed the 201908_test_timedata branch 2 times, most recently from dbd01a9 to cf02a00 Compare August 7, 2019 18:50
@mzumsande
Copy link
Contributor Author

@practicalswift I added a comment about this and also adjusted the other comments to make it more clear what is tested.

Copy link

@ariard ariard left a comment

Choose a reason for hiding this comment

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

Otherwise, tested ACK cf02a00,

Thanks to give an opportunity to read about AddTimeData!

@mzumsande mzumsande force-pushed the 201908_test_timedata branch from cf02a00 to 50a9f58 Compare August 7, 2019 22:45
@mzumsande
Copy link
Contributor Author

Thanks @ariard for the review, I adressed your comments.

@ariard
Copy link

ariard commented Aug 8, 2019

ACK 50a9f58.

Copy link
Contributor

@promag promag left a comment

Choose a reason for hiding this comment

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

Concept ACK, reviewed the test code and looks good. I'll have to read #4521 before ACK.

Copy link
Contributor

Choose a reason for hiding this comment

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

nit, static function.

Copy link
Contributor

Choose a reason for hiding this comment

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

nit, should #include <string> - iwyu.

Copy link
Contributor

Choose a reason for hiding this comment

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

nit, could avoid warning var by doing GetWarnings("gui").find("...").

@mzumsande mzumsande force-pushed the 201908_test_timedata branch from 50a9f58 to 7cd069d Compare August 13, 2019 15:06
@mzumsande
Copy link
Contributor Author

Addressed nits by @promag.

@laanwj
Copy link
Member

laanwj commented Aug 14, 2019

ACK 7cd069d, thanks for adding a test

@laanwj laanwj merged commit 7cd069d into bitcoin:master Aug 14, 2019
laanwj added a commit that referenced this pull request Aug 14, 2019
7cd069d Add test for AddTimeData (Martin Zumsande)

Pull request description:

  `AddTimeData()` has poor test coverage but interesting logic (including a bug turned into a feature). This PR adds a unit test for it.

ACKs for top commit:
  laanwj:
    ACK 7cd069d, thanks for adding a test

Tree-SHA512: 8228f9027e52ed534411d595c7e45cf4edeee9757f26f5141fbcfae3fc6f598a8cea7f734bb8f55238857a37ad2f2d518e859e1fe8c106c0712da976792ac132
@mzumsande mzumsande deleted the 201908_test_timedata branch August 16, 2019 20:43
deadalnix pushed a commit to Bitcoin-ABC/bitcoin-abc that referenced this pull request Apr 27, 2020
Summary: This is a backport of Core [[bitcoin/bitcoin#16563 | PR16563]]

Test Plan:
  make check

Reviewers: #bitcoin_abc, Fabien

Reviewed By: #bitcoin_abc, Fabien

Differential Revision: https://reviews.bitcoinabc.org/D5844
ftrader pushed a commit to bitcoin-cash-node/bitcoin-cash-node that referenced this pull request Aug 17, 2020
Summary: This is a backport of Core [[bitcoin/bitcoin#16563 | PR16563]]

Test Plan:
  make check

Reviewers: #bitcoin_abc, Fabien

Reviewed By: #bitcoin_abc, Fabien

Differential Revision: https://reviews.bitcoinabc.org/D5844
PastaPastaPasta pushed a commit to PastaPastaPasta/dash that referenced this pull request Nov 3, 2021
7cd069d Add test for AddTimeData (Martin Zumsande)

Pull request description:

  `AddTimeData()` has poor test coverage but interesting logic (including a bug turned into a feature). This PR adds a unit test for it.

ACKs for top commit:
  laanwj:
    ACK 7cd069d, thanks for adding a test

Tree-SHA512: 8228f9027e52ed534411d595c7e45cf4edeee9757f26f5141fbcfae3fc6f598a8cea7f734bb8f55238857a37ad2f2d518e859e1fe8c106c0712da976792ac132
pravblockc pushed a commit to pravblockc/dash that referenced this pull request Nov 18, 2021
7cd069d Add test for AddTimeData (Martin Zumsande)

Pull request description:

  `AddTimeData()` has poor test coverage but interesting logic (including a bug turned into a feature). This PR adds a unit test for it.

ACKs for top commit:
  laanwj:
    ACK 7cd069d, thanks for adding a test

Tree-SHA512: 8228f9027e52ed534411d595c7e45cf4edeee9757f26f5141fbcfae3fc6f598a8cea7f734bb8f55238857a37ad2f2d518e859e1fe8c106c0712da976792ac132
@bitcoin bitcoin locked as resolved and limited conversation to collaborators Dec 16, 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.

7 participants