Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: Cleanup miner_tests #25073

Merged
merged 4 commits into from
Oct 10, 2022
Merged

Conversation

maflcko
Copy link
Member

@maflcko maflcko commented May 6, 2022

This cleans up the miner tests:

  • Removes duplicate/redundant and thus confusing chainparams object.
  • Uses a fresh mempool for each subtest instead of using the "global" one from the testing setup. This makes it easier to follow the tests in smaller scopes. Also it makes sure the mempool is truly cleared by reconstructing it. Finally, this removes calls to clear, see refactor: Remove unused CTxMemPool::clear() helper #19909

@fanquake fanquake added the Tests label May 6, 2022
@DrahtBot
Copy link
Contributor

DrahtBot commented May 6, 2022

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

Conflicts

Reviewers, this pull request conflicts with the following ones:

  • #24567 (Enforce BIP 68 from genesis by MarcoFalke)
  • #23897 (refactor: Move calculation logic out from CheckSequenceLocksAtTip() by hebasto)

If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first.

@laanwj
Copy link
Member

laanwj commented May 10, 2022

Code review ACK dddd32e

My only criticism is on the last commit: before, it was clear that the CreateNewBlock_validity test was done with the main chain params, after the change it is probably still doing this but implicitly.

@maflcko
Copy link
Member Author

maflcko commented May 10, 2022

Hmm. For reference, 38860f9#diff-b12066a688b85bea440eb38f079fb8ecc1984318470631bca7e3547a98effaa9 is doing the same change. It seems confusing to imply that the chainparams may differ in subsequent calls of the same function.

Happy to add an assert that the "global" chainparams are the main params, if that helps?

@maflcko
Copy link
Member Author

maflcko commented May 27, 2022

Rebased. Should still be trivial to re-ACK with git range-diff bitcoin-core/master dddd32 fabdc1902e.

src/test/miner_tests.cpp Outdated Show resolved Hide resolved
@maflcko
Copy link
Member Author

maflcko commented Jun 22, 2022

Fixed feedback and rebased

Copy link
Member

@glozow glozow 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 to removing unused chainparams. Not sure if I understand why separate mempools that aren't m_node.mempool is beneficial. Seems like clearing would be sufficient, but the goal is to remove clear()?

@dongcarl
Copy link
Contributor

Good idea. I've started something like that in the last commit: The correctness of the changes in this pull are now enforced by valgrind.

Oh nice! I think that's good for this PR, I suppose we could do something like a TestingSetup::ReplaceMempool(std::unique_ptr<CTxMemPool>) in the future, but there's no rush to generalize too early on.

Approach ACK!

Copy link
Contributor

@ryanofsky ryanofsky left a comment

Choose a reason for hiding this comment

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

Code review ACK fac107b. Seems good to add scopes and stop hardcoding m_node.mempool everywhere even if we still want to use shared mempools for now, to be able to make tests more lightweight later. Other changes look good too.

Copy link
Member

@glozow glozow left a comment

Choose a reason for hiding this comment

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

Seems fine to me. I had a few questions and wonder if other cleanups are possible too...

src/test/miner_tests.cpp Show resolved Hide resolved
src/test/miner_tests.cpp Show resolved Hide resolved
src/test/miner_tests.cpp Show resolved Hide resolved
src/test/miner_tests.cpp Outdated Show resolved Hide resolved
src/test/miner_tests.cpp Show resolved Hide resolved
src/test/miner_tests.cpp Show resolved Hide resolved
MacroFake added 4 commits October 5, 2022 13:34
No need for a shared mempool. Also remove unused chainparams parameter.
No need for a shared mempool. Also remove unused chainparams parameter.
No need for a shared mempool. Also remove unused chainparams parameter.

Can be reviewed with --ignore-all-space
@maflcko
Copy link
Member Author

maflcko commented Oct 5, 2022

Rebased, Squashed, and replied to comments

Copy link
Member

@glozow glozow left a comment

Choose a reason for hiding this comment

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

utACK faa1552

@fanquake fanquake merged commit 9eaa5db into bitcoin:master Oct 10, 2022
@maflcko maflcko deleted the 2205-test-miner-😊 branch October 10, 2022 12:19
sidhujag pushed a commit to syscoin/syscoin that referenced this pull request Oct 10, 2022
faa1552 test: Use dedicated mempool in TestBasicMining (MacroFake)
fafab38 test: Use dedicated mempool in TestPackageSelection (MacroFake)
fa4055d test: Use dedicated mempool in TestPrioritisedMining (MacroFake)
fa29218 test: Pass mempool reference to AssemblerForTest (MacroFake)

Pull request description:

  This cleans up the miner tests:

  * Removes duplicate/redundant and thus confusing chainparams object.
  * Uses a fresh mempool for each subtest instead of using the "global" one from the testing setup. This makes it easier to follow the tests in smaller scopes. Also it makes sure the mempool is truly cleared by reconstructing it. Finally, this removes calls to `clear`, see bitcoin#19909

ACKs for top commit:
  glozow:
    utACK faa1552

Tree-SHA512: ced1260f6ab70fba74b0fac7ff4fc7adfddcd2f3bee785249d2a4a9055ac253eff9090edbda7a17e72a71a81b56ff708d5ff64e1f57ebc7b7747d6c88fec51e3
@bitcoin bitcoin locked and limited conversation to collaborators Oct 10, 2023
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.

None yet

7 participants