Skip to content

Conversation

@theStack
Copy link
Contributor

@theStack theStack commented Mar 27, 2023

The subtests in the functional test mempool_package_limits.py all follow the same pattern:

  1. first, check that the mempool is currently empty
  2. create and submit certain single txs to the mempool, prepare list of hex transactions
  3. check that testmempoolaccept on the package hex fails with a "package-mempool-limits" error on each tx result
  4. after mining a block, check that submitting the package succeeds

Note that steps 1,3,4 are identical for each of the subtests and only step 2 varies, so this might be a nice opportunity to deduplicate code by using a newly introduced decorator which executes the necessary before and after the essential part of the subtest. This also makes it easier to add new subtests without having to copy-paste those parts once again.

In addition, the first commit switches the fee unit from BTC to Satoshis, which allows to get rid of some imports (COIN and Decimal) and a comment for the test_desc_size_limits subtest is fixed (s/25KvB/21KvB/).

@DrahtBot
Copy link
Contributor

DrahtBot commented Mar 27, 2023

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

Reviews

See the guideline for information on the review process.

Type Reviewers
ACK glozow, ismaelsadeeq

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

@DrahtBot DrahtBot added the Tests label Mar 27, 2023
@glozow glozow self-assigned this Mar 28, 2023
This avoids having to convert from BTC to Sats and needs less imports.
Also specify the tx's target size in vsize rather than in weight, which
allows us to specify the fee-rate by a simple multiplication, rather
than having another magic number for it.
@theStack theStack force-pushed the 202303-test-package_limit_use_decorator branch from 0ed2f03 to e669833 Compare March 28, 2023 20:09
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 e669833

@fanquake fanquake requested a review from josibake March 30, 2023 08:54
@ismaelsadeeq
Copy link
Member

ACK e669833

# "package-mempool-limits" for each tx
# 4) after mining a block, clearing the pre-submitted transactions from mempool,
# check that submitting the created package succeeds
def check_package_limits(func):
Copy link
Member

Choose a reason for hiding this comment

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

Nice 💯
Just a couple of nit minor suggestions to improve the readability of the code:

Add a blank line after the first assertion assert_equal(0, node.getmempoolinfo()["size"])
Add a blank line after the line where package_hex is assigned to func(self, *args, **kwargs)

Separating the operations as written in the decorator comment, also goes well with PEP9 guidelines.

@glozow glozow added Refactoring and removed Tests labels Mar 30, 2023
@glozow glozow merged commit 328087d into bitcoin:master Mar 30, 2023
@theStack theStack deleted the 202303-test-package_limit_use_decorator branch March 30, 2023 17:51
sidhujag pushed a commit to syscoin/syscoin that referenced this pull request Apr 1, 2023
@bitcoin bitcoin locked and limited conversation to collaborators Mar 29, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants