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

CHIA-767 Simplify invariant_check_mempool #18176

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 4 additions & 13 deletions chia/_tests/util/misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -493,19 +493,10 @@ def create_logger(file: TextIO = sys.stdout) -> logging.Logger:


def invariant_check_mempool(mempool: Mempool) -> None:
with mempool._db_conn:
cursor = mempool._db_conn.execute("SELECT SUM(cost) FROM tx")
val = cursor.fetchone()[0]
if val is None:
val = 0
assert mempool._total_cost == val

with mempool._db_conn:
cursor = mempool._db_conn.execute("SELECT SUM(fee) FROM tx")
val = cursor.fetchone()[0]
if val is None:
val = 0
assert mempool._total_fee == val
with mempool._db_conn as conn:
cursor = conn.execute("SELECT COALESCE(SUM(cost), 0), COALESCE(SUM(fee), 0) FROM tx")
val = cursor.fetchone()
assert (mempool._total_cost, mempool._total_fee) == val


async def wallet_height_at_least(wallet_node: WalletNode, h: uint32) -> bool:
Expand Down
Loading