diff options
author | Vasil Dimov <vd@FreeBSD.org> | 2021-01-18 14:27:00 +0100 |
---|---|---|
committer | Vasil Dimov <vd@FreeBSD.org> | 2022-03-02 15:40:30 +0100 |
commit | 60da1eaa1113e7318e273144e7ef9c8895d7ed54 (patch) | |
tree | 6d9b7096cf9f87344fe14c27f87f008f0a94d21f /src/test | |
parent | 08bcfa27675da5c65e4c9eab7e7764eab0599298 (diff) | |
download | bitcoin-60da1eaa1113e7318e273144e7ef9c8895d7ed54.tar.xz |
timedata: make it possible to reset the state
Add a new function `TestOnlyResetTimeData()` which would reset the
internal state used by `GetTimeOffset()`, `GetAdjustedTime()` and
`AddTimeData()`.
This is needed so that unit tests that call `AddTimeData()` can restore
the state in order not to confuse other tests that rely on it.
Currently `timedata_tests/addtimedata` is the only test that modifies
the state (via `AddTimeData()`) and also the only test that relies on
that state.
Diffstat (limited to 'src/test')
-rw-r--r-- | src/test/timedata_tests.cpp | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/src/test/timedata_tests.cpp b/src/test/timedata_tests.cpp index 1dcee23bbb..478d61d5e2 100644 --- a/src/test/timedata_tests.cpp +++ b/src/test/timedata_tests.cpp @@ -96,9 +96,10 @@ BOOST_AUTO_TEST_CASE(addtimedata) // not to fix this because it prevents possible attacks. See the comment in AddTimeData() or issue #4521 // for a more detailed explanation. MultiAddTimeData(2, 100); // filter median is 100 now, but nTimeOffset will not change + // We want this test to end with nTimeOffset==0, otherwise subsequent tests of the suite will fail. BOOST_CHECK_EQUAL(GetTimeOffset(), 0); - // We want this test to end with nTimeOffset==0, otherwise subsequent tests of the suite will fail. + TestOnlyResetTimeData(); } BOOST_AUTO_TEST_SUITE_END() |