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

Annotate test_mempool_performance.py #16693

Merged
Merged
Show file tree
Hide file tree
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
1 change: 0 additions & 1 deletion mypy-exclusions.txt
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@ tests.core.full_node.test_performance
tests.core.full_node.test_transactions
tests.core.make_block_generator
tests.core.mempool.test_mempool
tests.core.mempool.test_mempool_performance
tests.core.server.test_dos
tests.core.server.test_rate_limits
tests.core.ssl.test_ssl
Expand Down
22 changes: 15 additions & 7 deletions tests/core/mempool/test_mempool_performance.py
Original file line number Diff line number Diff line change
@@ -1,31 +1,39 @@
from __future__ import annotations

from typing import List

import pytest

from chia.protocols import full_node_protocol
from chia.simulator.setup_nodes import SimulatorsAndWallets
from chia.simulator.time_out_assert import time_out_assert
from chia.types.full_block import FullBlock
from chia.types.peer_info import PeerInfo
from chia.util.ints import uint32, uint64, uint128
from chia.wallet.util.tx_config import DEFAULT_TX_CONFIG
from chia.wallet.wallet_node import WalletNode
from tests.connection_utils import connect_and_get_peer
from tests.util.misc import BenchmarkRunner


async def wallet_height_at_least(wallet_node, h):
async def wallet_height_at_least(wallet_node: WalletNode, h: uint32) -> bool:
height = await wallet_node.wallet_state_manager.blockchain.get_finished_sync_up_to()
return height == h


async def wallet_balance_at_least(wallet_node: WalletNode, balance):
async def wallet_balance_at_least(wallet_node: WalletNode, balance: uint128) -> bool:
b = await wallet_node.wallet_state_manager.get_confirmed_balance_for_wallet(1)
return b >= balance


@pytest.mark.limit_consensus_modes(reason="benchmark")
@pytest.mark.asyncio
async def test_mempool_update_performance(
wallet_nodes_mempool_perf, default_400_blocks, self_hostname, benchmark_runner: BenchmarkRunner
):
wallet_nodes_mempool_perf: SimulatorsAndWallets,
default_400_blocks: List[FullBlock],
self_hostname: str,
benchmark_runner: BenchmarkRunner,
) -> None:
blocks = default_400_blocks
full_nodes, wallets, bt = wallet_nodes_mempool_perf
wallet_node = wallets[0][0]
Expand All @@ -42,13 +50,13 @@ async def test_mempool_update_performance(

await wallet_server.start_client(PeerInfo(self_hostname, server_1.get_port()), None)
await time_out_assert(60, wallet_height_at_least, True, wallet_node, 399)
send_amount = 40000000000000
fee_amount = 2213
send_amount = uint64(40000000000000)
fee_amount = uint64(2213)
await time_out_assert(60, wallet_balance_at_least, True, wallet_node, send_amount + fee_amount)

[big_transaction] = await wallet.generate_signed_transaction(send_amount, ph, DEFAULT_TX_CONFIG, fee_amount)

assert big_transaction.spend_bundle
assert big_transaction.spend_bundle is not None
await full_node_api_1.respond_transaction(
full_node_protocol.RespondTransaction(big_transaction.spend_bundle), peer, test=True
)
Expand Down
Loading