Skip to content

Conversation

maflcko
Copy link
Member

@maflcko maflcko commented Apr 15, 2024

Seems odd to have the assert in the deprecated function, but not in the other.

Fix this by adding it to the other, and by inlining the deprecated one.

Also, use chrono type for the global mocktime variable.

@DrahtBot
Copy link
Contributor

DrahtBot commented Apr 15, 2024

The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

Code Coverage

For detailed information about the code coverage, see the test coverage report.

Reviews

See the guideline for information on the review process.

Type Reviewers
ACK stickies-v, davidgumberg

If your review is incorrectly listed, please react with 👎 to this comment and the bot will ignore it on the next update.

@DrahtBot DrahtBot changed the title test: Add missing Assert(mock_time_in >= 0s) to SetMockTime test: Add missing Assert(mock_time_in >= 0s) to SetMockTime Apr 15, 2024
@DrahtBot DrahtBot added the Tests label Apr 15, 2024
@DrahtBot
Copy link
Contributor

🚧 At least one of the CI tasks failed. Make sure to run all tests locally, according to the
documentation.

Possibly this is due to a silent merge conflict (the changes in this pull request being
incompatible with the current code in the target branch). If so, make sure to rebase on the latest
commit of the target branch.

Leave a comment here, if you need help tracking down a confusing failure.

Debug: https://github.com/bitcoin/bitcoin/runs/23822732364

MarcoFalke added 2 commits April 15, 2024 13:34
Also, inline the deprecated alias to avoid having the two go out of sync
again in the future.
This avoids verbose casts in the lines where the symbol is used.
Copy link
Contributor

@stickies-v stickies-v left a comment

Choose a reason for hiding this comment

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

ACK fae0db5

void SetMockTime(std::chrono::seconds mock_time_in)
{
nMockTime.store(mock_time_in.count(), std::memory_order_relaxed);
Assert(mock_time_in >= 0s);
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: any reason to not just use assert?

Copy link
Member Author

Choose a reason for hiding this comment

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

Both can be used. In this context they are exactly the same.

nMockTime.store(nMockTimeIn, std::memory_order_relaxed);
}

void SetMockTime(int64_t nMockTimeIn) { SetMockTime(std::chrono::seconds{nMockTimeIn}); }
Copy link
Contributor

Choose a reason for hiding this comment

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

nit:

Suggested change
void SetMockTime(int64_t nMockTimeIn) { SetMockTime(std::chrono::seconds{nMockTimeIn}); }
void SetMockTime(int64_t mock_time_in) { SetMockTime(std::chrono::seconds{mock_time_in}); }

Copy link
Member Author

Choose a reason for hiding this comment

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

I think I'd also have to touch the header to address this, so I'll leave it as-is for now. Also, once could consider to remove this legacy interface function completely.

@davidgumberg
Copy link
Contributor

davidgumberg commented Apr 27, 2024

crACK fae0db5

SetMockTime(std::chrono::seconds mock_time_in should have the Assert added here, and inlining the deprecated function is an improvement.

nMockTime->g_mock_time more closely conforms to the project's naming conventions

@maflcko
Copy link
Member Author

maflcko commented Apr 29, 2024

Anything left to be done here?

@fanquake fanquake merged commit 0c45d73 into bitcoin:master Apr 29, 2024
@maflcko maflcko deleted the 2404-mocktime- branch April 29, 2024 14:32
PastaPastaPasta pushed a commit to PastaPastaPasta/dash that referenced this pull request Oct 25, 2024
…SetMockTime

fae0db5 refactor: Use chrono type for g_mock_time (MarcoFalke)
fa382d3 test: Add missing Assert(mock_time_in >= 0s) to SetMockTime (MarcoFalke)

Pull request description:

  Seems odd to have the assert in the *deprecated* function, but not in the other.

  Fix this by adding it to the other, and by inlining the deprecated one.

  Also, use chrono type for the global mocktime variable.

ACKs for top commit:
  davidgumberg:
    crACK bitcoin@fae0db5
  stickies-v:
    ACK fae0db5

Tree-SHA512: 630c2917422ff2a7fa307114f95f22ad3c205429ffe36e67f0b2650733e40c876289c1aecebe882a9123d3106db7606bd6eff067ed6e2ecb95765984d3fe8612
PastaPastaPasta pushed a commit to PastaPastaPasta/dash that referenced this pull request Oct 26, 2024
…SetMockTime

fae0db5 refactor: Use chrono type for g_mock_time (MarcoFalke)
fa382d3 test: Add missing Assert(mock_time_in >= 0s) to SetMockTime (MarcoFalke)

Pull request description:

  Seems odd to have the assert in the *deprecated* function, but not in the other.

  Fix this by adding it to the other, and by inlining the deprecated one.

  Also, use chrono type for the global mocktime variable.

ACKs for top commit:
  davidgumberg:
    crACK bitcoin@fae0db5
  stickies-v:
    ACK fae0db5

Tree-SHA512: 630c2917422ff2a7fa307114f95f22ad3c205429ffe36e67f0b2650733e40c876289c1aecebe882a9123d3106db7606bd6eff067ed6e2ecb95765984d3fe8612
PastaPastaPasta added a commit to dashpay/dash that referenced this pull request Oct 27, 2024
700b8c5 Merge bitcoin#29658: Bugfix: GUI: Help messages already have a trailing newline, so don't add an extra one (merge-script)
a0cd305 Merge bitcoin#29948: test: add missing comparison of node1's mempool in MempoolPackagesTest (Ava Chow)
f1907ea Merge bitcoin#29984: net: Replace ifname check with IFF_LOOPBACK in Discover (merge-script)
daa6eee Merge bitcoin#29960: depends: pass verbose through to cmake based makefiles (merge-script)
61a5832 Merge bitcoin#29907: test: Fix `test/streams_tests.cpp` compilation on SunOS / illumos (merge-script)
23f25a9 Merge bitcoin#29872: test: Add missing Assert(mock_time_in >= 0s) to SetMockTime (merge-script)
a7daee7 Merge bitcoin#29689: lint: scripted-diff verification also requires GNU grep (Ava Chow)
3df1ca1 Merge bitcoin#29953: doc: Bash is needed in gen_id and is not installed on FreeBSD by default (merge-script)
b53b854 Merge bitcoin#29850: net: Decrease nMaxIPs when learning from DNS seeds (Ava Chow)
c4a147c Merge bitcoin#28340: security: restrict abis in bitcoind.service (Ryan Ofsky)
acfdf9e Merge bitcoin#28373: doc: Add example of mixing private and public keys in descriptors (Ava Chow)
51bc8bd Merge bitcoin#29859: build: Fix false positive `CHECK_ATOMIC` test (merge-script)
bb4102c Merge bitcoin#29893: test: fix intermittent failure in p2p_compactblocks_hb.py (glozow)
4ecb761 Merge bitcoin#29786: Drop Windows Socket dependency for `randomenv.cpp` (fanquake)
1a8e805 Merge bitcoin#29498: test: Update --tmpdir doc string to say directory must not exist (fanquake)
81ca71c Merge bitcoin#29781: depends: add new LLVM debug macro (fanquake)
5ce92ca Merge bitcoin#29527: depends: add -g to DEBUG=1 flags (fanquake)

Pull request description:

  ## Issue being fixed or feature implemented
  Trivial backports

  ## What was done?

  ## How Has This Been Tested?
  built locally

  ## Breaking Changes

  ## Checklist:
    _Go over all the following points, and put an `x` in all the boxes that apply._
  - [ ] I have performed a self-review of my own code
  - [ ] I have commented my code, particularly in hard-to-understand areas
  - [ ] I have added or updated relevant unit/integration/functional/e2e tests
  - [ ] I have made corresponding changes to the documentation
  - [x] I have assigned this pull request to a milestone _(for repository code-owners and collaborators only)_

ACKs for top commit:
  UdjinM6:
    utACK 700b8c5 but pls confirm Guix is happy now before merging
  kwvg:
    utACK 700b8c5

Tree-SHA512: 9722979c4f0589cb02bfeaf39373713372a4aa1c8c5a55aa5b4d33388f73ef19231de3963b80ffaad25fbe0db90a133de5080baac691daed41b86a762b867b2d
@bitcoin bitcoin locked and limited conversation to collaborators Apr 29, 2025
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.

5 participants