From b1bdbc40ab1bab6a9a15689cfaea7329a97a488f Mon Sep 17 00:00:00 2001 From: Kyle Altendorf Date: Wed, 1 Nov 2023 14:04:27 -0400 Subject: [PATCH] use anyio for tests (#16738) Co-authored-by: Amine Khaldi --- pytest.ini | 1 - setup.py | 1 - tests/blockchain/test_blockchain.py | 214 +++++++++--------- .../test_blockchain_transactions.py | 30 +-- tests/clvm/test_singletons.py | 2 +- tests/clvm/test_spend_sim.py | 6 +- tests/cmds/test_farm_cmd.py | 2 +- tests/conftest.py | 112 ++++----- tests/core/cmds/test_wallet.py | 14 +- tests/core/daemon/test_daemon.py | 68 +++--- tests/core/daemon/test_daemon_register.py | 6 +- tests/core/daemon/test_keychain_proxy.py | 11 +- tests/core/data_layer/conftest.py | 7 +- tests/core/data_layer/test_data_cli.py | 4 +- tests/core/data_layer/test_data_layer.py | 7 +- tests/core/data_layer/test_data_rpc.py | 53 +++-- tests/core/data_layer/test_data_store.py | 104 ++++----- .../core/data_layer/test_data_store_schema.py | 36 +-- tests/core/farmer/test_farmer_api.py | 4 +- tests/core/full_node/conftest.py | 17 -- .../full_node/full_sync/test_full_sync.py | 24 +- .../core/full_node/stores/test_block_store.py | 22 +- .../core/full_node/stores/test_coin_store.py | 16 +- .../full_node/stores/test_full_node_store.py | 11 +- .../core/full_node/stores/test_hint_store.py | 16 +- tests/core/full_node/test_address_manager.py | 32 +-- tests/core/full_node/test_block_height_map.py | 38 ++-- tests/core/full_node/test_conditions.py | 20 +- tests/core/full_node/test_full_node.py | 69 +++--- tests/core/full_node/test_hint_management.py | 4 +- tests/core/full_node/test_node_load.py | 2 +- tests/core/full_node/test_performance.py | 2 +- tests/core/full_node/test_transactions.py | 6 +- .../full_node/test_tx_processing_queue.py | 10 +- tests/core/mempool/test_mempool.py | 140 ++++++------ .../mempool/test_mempool_fee_estimator.py | 4 +- .../core/mempool/test_mempool_fee_protocol.py | 2 +- tests/core/mempool/test_mempool_manager.py | 58 ++--- .../core/mempool/test_mempool_performance.py | 2 +- tests/core/server/test_dos.py | 12 +- tests/core/server/test_loop.py | 4 +- tests/core/server/test_node_discovery.py | 2 +- tests/core/server/test_rate_limits.py | 22 +- tests/core/server/test_server.py | 16 +- tests/core/services/test_services.py | 4 +- tests/core/ssl/test_ssl.py | 8 +- tests/core/test_cost_calculation.py | 14 +- tests/core/test_crawler.py | 6 +- tests/core/test_crawler_rpc.py | 2 +- tests/core/test_daemon_rpc.py | 2 +- tests/core/test_db_conversion.py | 2 +- tests/core/test_db_validation.py | 2 +- tests/core/test_farmer_harvester_rpc.py | 16 +- tests/core/test_filter.py | 2 +- tests/core/test_full_node_rpc.py | 12 +- tests/core/test_merkle_set.py | 26 +-- tests/core/test_seeder.py | 6 +- tests/core/util/test_config.py | 2 +- tests/core/util/test_files.py | 22 +- tests/core/util/test_keychain.py | 18 +- tests/core/util/test_keyring_wrapper.py | 1 + tests/db/test_db_wrapper.py | 30 +-- tests/farmer_harvester/test_farmer.py | 4 +- .../farmer_harvester/test_farmer_harvester.py | 12 +- .../test_filter_prefix_bits.py | 5 +- .../test_fee_estimation_integration.py | 4 +- .../fee_estimation/test_fee_estimation_rpc.py | 45 ++-- .../test_mempoolitem_height_added.py | 4 +- tests/plot_sync/test_plot_sync.py | 19 +- tests/plot_sync/test_receiver.py | 12 +- tests/plot_sync/test_sender.py | 2 +- tests/plot_sync/test_sync_simulated.py | 6 +- tests/plotting/test_plot_manager.py | 18 +- tests/pools/test_pool_rpc.py | 25 +- tests/pools/test_pool_wallet.py | 4 +- tests/pools/test_wallet_pool_store.py | 4 +- tests/simulation/test_simulation.py | 19 +- tests/simulation/test_simulator.py | 14 +- tests/simulation/test_start_simulator.py | 5 +- tests/timelord/test_new_peak.py | 4 +- tests/timelord/test_timelord.py | 2 +- tests/util/test_full_block_utils.py | 4 +- tests/util/test_limited_semaphore.py | 2 +- tests/util/test_misc.py | 4 +- tests/util/test_network.py | 4 +- tests/util/test_priority_mutex.py | 20 +- tests/wallet/cat_wallet/test_cat_lifecycle.py | 12 +- tests/wallet/cat_wallet/test_cat_wallet.py | 22 +- .../wallet/cat_wallet/test_offer_lifecycle.py | 2 +- tests/wallet/cat_wallet/test_trades.py | 14 +- .../clawback/test_clawback_decorator.py | 6 +- .../clawback/test_clawback_lifecycle.py | 2 +- .../wallet/clawback/test_clawback_metadata.py | 2 +- tests/wallet/conftest.py | 3 +- tests/wallet/dao_wallet/test_dao_clvm.py | 2 +- tests/wallet/dao_wallet/test_dao_wallets.py | 22 +- tests/wallet/db_wallet/test_db_graftroot.py | 2 +- tests/wallet/db_wallet/test_dl_offers.py | 6 +- tests/wallet/db_wallet/test_dl_wallet.py | 12 +- tests/wallet/did_wallet/test_did.py | 28 +-- tests/wallet/nft_wallet/test_nft_1_offers.py | 16 +- tests/wallet/nft_wallet/test_nft_bulk_mint.py | 14 +- tests/wallet/nft_wallet/test_nft_lifecycle.py | 6 +- tests/wallet/nft_wallet/test_nft_offers.py | 10 +- tests/wallet/nft_wallet/test_nft_wallet.py | 26 +-- tests/wallet/rpc/test_dl_wallet_rpc.py | 2 +- tests/wallet/rpc/test_wallet_rpc.py | 69 +++--- .../simple_sync/test_simple_sync_protocol.py | 18 +- tests/wallet/sync/test_wallet_sync.py | 32 +-- tests/wallet/test_coin_selection.py | 24 +- tests/wallet/test_nft_store.py | 8 +- tests/wallet/test_notifications.py | 4 +- tests/wallet/test_puzzle_store.py | 4 +- tests/wallet/test_sign_coin_spends.py | 4 +- tests/wallet/test_singleton_lifecycle.py | 2 +- tests/wallet/test_singleton_store.py | 10 +- tests/wallet/test_transaction_store.py | 52 ++--- tests/wallet/test_wallet.py | 44 ++-- tests/wallet/test_wallet_blockchain.py | 2 +- tests/wallet/test_wallet_coin_store.py | 60 ++--- tests/wallet/test_wallet_interested_store.py | 2 +- tests/wallet/test_wallet_key_val_store.py | 2 +- tests/wallet/test_wallet_node.py | 20 +- tests/wallet/test_wallet_retry.py | 2 +- tests/wallet/test_wallet_state_manager.py | 10 +- tests/wallet/test_wallet_test_framework.py | 4 +- tests/wallet/test_wallet_trade_store.py | 6 +- tests/wallet/test_wallet_user_store.py | 2 +- tests/wallet/vc_wallet/test_vc_lifecycle.py | 10 +- tests/wallet/vc_wallet/test_vc_wallet.py | 6 +- tests/weight_proof/test_weight_proof.py | 30 +-- 131 files changed, 1138 insertions(+), 1148 deletions(-) delete mode 100644 tests/core/full_node/conftest.py diff --git a/pytest.ini b/pytest.ini index 54ddd1fc9c5f..7cdec1988a5e 100644 --- a/pytest.ini +++ b/pytest.ini @@ -5,7 +5,6 @@ addopts = --verbose --tb=short -n auto -p no:monitor log_level = WARNING console_output_style = count log_format = %(asctime)s %(name)s: %(levelname)s %(message)s -asyncio_mode = strict markers = limit_consensus_modes data_layer: Mark as a data layer related test. diff --git a/setup.py b/setup.py index aa0359aa7ffb..9b38657b98f2 100644 --- a/setup.py +++ b/setup.py @@ -51,7 +51,6 @@ dev_dependencies = [ "py3createtorrent==1.1.0", "pylint==3.0.2", "pytest==7.4.3", - "pytest-asyncio==0.21.1", "pytest-cov==4.1.0", "pytest-mock==3.12.0", "pytest-xdist==3.3.1", diff --git a/tests/blockchain/test_blockchain.py b/tests/blockchain/test_blockchain.py index cf66a345bbd5..4008a913d270 100644 --- a/tests/blockchain/test_blockchain.py +++ b/tests/blockchain/test_blockchain.py @@ -77,7 +77,7 @@ async def make_empty_blockchain(constants: ConsensusConstants): class TestGenesisBlock: - @pytest.mark.asyncio + @pytest.mark.anyio async def test_block_tools_proofs_400(self, default_400_blocks, blockchain_constants): vdf, proof = get_vdf_info_and_proof( blockchain_constants, @@ -88,7 +88,7 @@ class TestGenesisBlock: if validate_vdf(proof, blockchain_constants, ClassgroupElement.get_default_element(), vdf) is False: raise Exception("invalid proof") - @pytest.mark.asyncio + @pytest.mark.anyio async def test_block_tools_proofs_1000(self, default_1000_blocks, blockchain_constants): vdf, proof = get_vdf_info_and_proof( blockchain_constants, @@ -99,7 +99,7 @@ class TestGenesisBlock: if validate_vdf(proof, blockchain_constants, ClassgroupElement.get_default_element(), vdf) is False: raise Exception("invalid proof") - @pytest.mark.asyncio + @pytest.mark.anyio async def test_block_tools_proofs(self, blockchain_constants): vdf, proof = get_vdf_info_and_proof( blockchain_constants, @@ -110,29 +110,29 @@ class TestGenesisBlock: if validate_vdf(proof, blockchain_constants, ClassgroupElement.get_default_element(), vdf) is False: raise Exception("invalid proof") - @pytest.mark.asyncio + @pytest.mark.anyio async def test_non_overflow_genesis(self, empty_blockchain, bt): assert empty_blockchain.get_peak() is None genesis = bt.get_consecutive_blocks(1, force_overflow=False)[0] await _validate_and_add_block(empty_blockchain, genesis) assert empty_blockchain.get_peak().height == 0 - @pytest.mark.asyncio + @pytest.mark.anyio async def test_overflow_genesis(self, empty_blockchain, bt): genesis = bt.get_consecutive_blocks(1, force_overflow=True)[0] await _validate_and_add_block(empty_blockchain, genesis) - @pytest.mark.asyncio + @pytest.mark.anyio async def test_genesis_empty_slots(self, empty_blockchain, bt): genesis = bt.get_consecutive_blocks(1, force_overflow=False, skip_slots=30)[0] await _validate_and_add_block(empty_blockchain, genesis) - @pytest.mark.asyncio + @pytest.mark.anyio async def test_overflow_genesis_empty_slots(self, empty_blockchain, bt): genesis = bt.get_consecutive_blocks(1, force_overflow=True, skip_slots=3)[0] await _validate_and_add_block(empty_blockchain, genesis) - @pytest.mark.asyncio + @pytest.mark.anyio async def test_genesis_validate_1(self, empty_blockchain, bt): genesis = bt.get_consecutive_blocks(1, force_overflow=False)[0] bad_prev = bytes([1] * 32) @@ -142,7 +142,7 @@ class TestGenesisBlock: class TestBlockHeaderValidation: @pytest.mark.limit_consensus_modes(reason="save time") - @pytest.mark.asyncio + @pytest.mark.anyio async def test_long_chain(self, empty_blockchain, default_1000_blocks): blocks = default_1000_blocks for block in blocks: @@ -267,7 +267,7 @@ class TestBlockHeaderValidation: ) assert empty_blockchain.get_peak().height == len(blocks) - 1 - @pytest.mark.asyncio + @pytest.mark.anyio async def test_unfinished_blocks(self, empty_blockchain, softfork_height, bt): blockchain = empty_blockchain blocks = bt.get_consecutive_blocks(3) @@ -317,12 +317,12 @@ class TestBlockHeaderValidation: validate_res = await blockchain.validate_unfinished_block(unf, npc_result, False) assert validate_res.error is None - @pytest.mark.asyncio + @pytest.mark.anyio async def test_empty_genesis(self, empty_blockchain, bt): for block in bt.get_consecutive_blocks(2, skip_slots=3): await _validate_and_add_block(empty_blockchain, block) - @pytest.mark.asyncio + @pytest.mark.anyio async def test_empty_slots_non_genesis(self, empty_blockchain, bt): blockchain = empty_blockchain blocks = bt.get_consecutive_blocks(10) @@ -334,7 +334,7 @@ class TestBlockHeaderValidation: await _validate_and_add_block(empty_blockchain, block) assert blockchain.get_peak().height == 19 - @pytest.mark.asyncio + @pytest.mark.anyio async def test_one_sb_per_slot(self, empty_blockchain, bt): blockchain = empty_blockchain num_blocks = 20 @@ -344,7 +344,7 @@ class TestBlockHeaderValidation: await _validate_and_add_block(empty_blockchain, blocks[-1]) assert blockchain.get_peak().height == num_blocks - 1 - @pytest.mark.asyncio + @pytest.mark.anyio async def test_all_overflow(self, empty_blockchain, bt): blockchain = empty_blockchain num_rounds = 5 @@ -357,7 +357,7 @@ class TestBlockHeaderValidation: await _validate_and_add_block(empty_blockchain, block) assert blockchain.get_peak().height == num_blocks - 1 - @pytest.mark.asyncio + @pytest.mark.anyio async def test_unf_block_overflow(self, empty_blockchain, softfork_height, bt): blockchain = empty_blockchain @@ -401,7 +401,7 @@ class TestBlockHeaderValidation: await _validate_and_add_block(blockchain, blocks[-1]) - @pytest.mark.asyncio + @pytest.mark.anyio async def test_one_sb_per_two_slots(self, empty_blockchain, bt): blockchain = empty_blockchain num_blocks = 20 @@ -411,7 +411,7 @@ class TestBlockHeaderValidation: await _validate_and_add_block(blockchain, blocks[-1]) assert blockchain.get_peak().height == num_blocks - 1 - @pytest.mark.asyncio + @pytest.mark.anyio async def test_one_sb_per_five_slots(self, empty_blockchain, bt): blockchain = empty_blockchain num_blocks = 10 @@ -421,14 +421,14 @@ class TestBlockHeaderValidation: await _validate_and_add_block(blockchain, blocks[-1]) assert blockchain.get_peak().height == num_blocks - 1 - @pytest.mark.asyncio + @pytest.mark.anyio async def test_basic_chain_overflow(self, empty_blockchain, bt): blocks = bt.get_consecutive_blocks(5, force_overflow=True) for block in blocks: await _validate_and_add_block(empty_blockchain, block) assert empty_blockchain.get_peak().height == len(blocks) - 1 - @pytest.mark.asyncio + @pytest.mark.anyio async def test_one_sb_per_two_slots_force_overflow(self, empty_blockchain, bt): blockchain = empty_blockchain num_blocks = 10 @@ -438,7 +438,7 @@ class TestBlockHeaderValidation: await _validate_and_add_block(blockchain, blocks[-1]) assert blockchain.get_peak().height == num_blocks - 1 - @pytest.mark.asyncio + @pytest.mark.anyio async def test_invalid_prev(self, empty_blockchain, bt): # 1 blocks = bt.get_consecutive_blocks(2, force_overflow=False) @@ -447,7 +447,7 @@ class TestBlockHeaderValidation: await _validate_and_add_block(empty_blockchain, block_1_bad, expected_error=Err.INVALID_PREV_BLOCK_HASH) - @pytest.mark.asyncio + @pytest.mark.anyio async def test_invalid_pospace(self, empty_blockchain, bt): # 2 blocks = bt.get_consecutive_blocks(2, force_overflow=False) @@ -456,7 +456,7 @@ class TestBlockHeaderValidation: await _validate_and_add_block(empty_blockchain, block_1_bad, expected_error=Err.INVALID_POSPACE) - @pytest.mark.asyncio + @pytest.mark.anyio async def test_invalid_sub_slot_challenge_hash_genesis(self, empty_blockchain, bt): # 2a blocks = bt.get_consecutive_blocks(1, force_overflow=False, skip_slots=1) @@ -482,7 +482,7 @@ class TestBlockHeaderValidation: assert error.code == Err.INVALID_PREV_CHALLENGE_SLOT_HASH await _validate_and_add_block(empty_blockchain, block_0_bad, expected_result=AddBlockResult.INVALID_BLOCK) - @pytest.mark.asyncio + @pytest.mark.anyio async def test_invalid_sub_slot_challenge_hash_non_genesis(self, empty_blockchain, bt): # 2b blocks = bt.get_consecutive_blocks(1, force_overflow=False, skip_slots=0) @@ -509,7 +509,7 @@ class TestBlockHeaderValidation: assert error.code == Err.INVALID_PREV_CHALLENGE_SLOT_HASH await _validate_and_add_block(empty_blockchain, block_1_bad, expected_result=AddBlockResult.INVALID_BLOCK) - @pytest.mark.asyncio + @pytest.mark.anyio async def test_invalid_sub_slot_challenge_hash_empty_ss(self, empty_blockchain, bt): # 2c blocks = bt.get_consecutive_blocks(1, force_overflow=False, skip_slots=0) @@ -536,7 +536,7 @@ class TestBlockHeaderValidation: assert error.code == Err.INVALID_PREV_CHALLENGE_SLOT_HASH await _validate_and_add_block(empty_blockchain, block_1_bad, expected_result=AddBlockResult.INVALID_BLOCK) - @pytest.mark.asyncio + @pytest.mark.anyio async def test_genesis_no_icc(self, empty_blockchain, bt): # 2d blocks = bt.get_consecutive_blocks(1, force_overflow=False, skip_slots=1) @@ -640,12 +640,12 @@ class TestBlockHeaderValidation: await db_wrapper.close() bc1.shut_down() - @pytest.mark.asyncio + @pytest.mark.anyio async def test_invalid_icc_sub_slot_vdf(self, db_version, blockchain_constants): with TempKeyring() as keychain: await self.do_test_invalid_icc_sub_slot_vdf(keychain, db_version, blockchain_constants) - @pytest.mark.asyncio + @pytest.mark.anyio async def test_invalid_icc_into_cc(self, empty_blockchain, bt): blockchain = empty_blockchain blocks = bt.get_consecutive_blocks(1) @@ -736,7 +736,7 @@ class TestBlockHeaderValidation: # Finally, add the block properly await _validate_and_add_block(blockchain, block) - @pytest.mark.asyncio + @pytest.mark.anyio async def test_empty_slot_no_ses(self, empty_blockchain, bt): # 2l blockchain = empty_blockchain @@ -765,7 +765,7 @@ class TestBlockHeaderValidation: assert error.code == Err.INVALID_SUB_EPOCH_SUMMARY_HASH await _validate_and_add_block(blockchain, block_bad, expected_result=AddBlockResult.INVALID_BLOCK) - @pytest.mark.asyncio + @pytest.mark.anyio async def test_empty_sub_slots_epoch(self, empty_blockchain, default_400_blocks, bt): # 2m # Tests adding an empty sub slot after the sub-epoch / epoch. @@ -784,7 +784,7 @@ class TestBlockHeaderValidation: empty_blockchain, blocks_2[-1], expected_result=AddBlockResult.ADDED_AS_ORPHAN, skip_prevalidation=True ) - @pytest.mark.asyncio + @pytest.mark.anyio async def test_wrong_cc_hash_rc(self, empty_blockchain, bt): # 2o blockchain = empty_blockchain @@ -803,7 +803,7 @@ class TestBlockHeaderValidation: await _validate_and_add_block(blockchain, block_1_bad, expected_error=Err.INVALID_CHALLENGE_SLOT_HASH_RC) - @pytest.mark.asyncio + @pytest.mark.anyio async def test_invalid_cc_sub_slot_vdf(self, empty_blockchain, bt): # 2q blocks: List[FullBlock] = [] @@ -901,7 +901,7 @@ class TestBlockHeaderValidation: await _validate_and_add_block(empty_blockchain, block) - @pytest.mark.asyncio + @pytest.mark.anyio async def test_invalid_rc_sub_slot_vdf(self, empty_blockchain, bt): # 2p blocks: List[FullBlock] = [] @@ -974,7 +974,7 @@ class TestBlockHeaderValidation: await _validate_and_add_block(empty_blockchain, block) - @pytest.mark.asyncio + @pytest.mark.anyio async def test_genesis_bad_deficit(self, empty_blockchain, bt): # 2r block = bt.get_consecutive_blocks(1, skip_slots=2)[0] @@ -990,7 +990,7 @@ class TestBlockHeaderValidation: block_bad = recursive_replace(block, "finished_sub_slots", block.finished_sub_slots[:-1] + [new_finished_ss]) await _validate_and_add_block(empty_blockchain, block_bad, expected_error=Err.INVALID_DEFICIT) - @pytest.mark.asyncio + @pytest.mark.anyio async def test_reset_deficit(self, empty_blockchain, bt): # 2s, 2t blockchain = empty_blockchain @@ -1024,7 +1024,7 @@ class TestBlockHeaderValidation: await _validate_and_add_block(empty_blockchain, blocks[-1]) - @pytest.mark.asyncio + @pytest.mark.anyio async def test_genesis_has_ses(self, empty_blockchain, bt): # 3a block = bt.get_consecutive_blocks(1, skip_slots=1)[0] @@ -1052,7 +1052,7 @@ class TestBlockHeaderValidation: empty_blockchain, block_bad, expected_error=Err.INVALID_SUB_EPOCH_SUMMARY_HASH ) - @pytest.mark.asyncio + @pytest.mark.anyio async def test_no_ses_if_no_se(self, empty_blockchain, bt): # 3b blocks = bt.get_consecutive_blocks(1) @@ -1095,12 +1095,12 @@ class TestBlockHeaderValidation: return None await _validate_and_add_block(empty_blockchain, blocks[-1]) - @pytest.mark.asyncio + @pytest.mark.anyio async def test_too_many_blocks(self, empty_blockchain): # 4: TODO pass - @pytest.mark.asyncio + @pytest.mark.anyio async def test_bad_pos(self, empty_blockchain, bt): # 5 blocks = bt.get_consecutive_blocks(2) @@ -1138,7 +1138,7 @@ class TestBlockHeaderValidation: # TODO: test not passing the plot filter - @pytest.mark.asyncio + @pytest.mark.anyio async def test_bad_signage_point_index(self, empty_blockchain, bt): # 6 blocks = bt.get_consecutive_blocks(2) @@ -1155,7 +1155,7 @@ class TestBlockHeaderValidation: ) await _validate_and_add_block(empty_blockchain, block_bad, expected_error=Err.INVALID_SP_INDEX) - @pytest.mark.asyncio + @pytest.mark.anyio async def test_sp_0_no_sp(self, empty_blockchain, bt): # 7 blocks = [] @@ -1175,12 +1175,12 @@ class TestBlockHeaderValidation: ) await _validate_and_add_block(empty_blockchain, blocks[-1]) - @pytest.mark.asyncio + @pytest.mark.anyio async def test_epoch_overflows(self, empty_blockchain): # 9. TODO. This is hard to test because it requires modifying the block tools to make these special blocks pass - @pytest.mark.asyncio + @pytest.mark.anyio async def test_bad_total_iters(self, empty_blockchain, bt): # 10 blocks = bt.get_consecutive_blocks(2) @@ -1191,7 +1191,7 @@ class TestBlockHeaderValidation: ) await _validate_and_add_block(empty_blockchain, block_bad, expected_error=Err.INVALID_TOTAL_ITERS) - @pytest.mark.asyncio + @pytest.mark.anyio async def test_bad_rc_sp_vdf(self, empty_blockchain, bt): # 11 blocks = bt.get_consecutive_blocks(1) @@ -1225,7 +1225,7 @@ class TestBlockHeaderValidation: return None await _validate_and_add_block(empty_blockchain, blocks[-1]) - @pytest.mark.asyncio + @pytest.mark.anyio async def test_bad_rc_sp_sig(self, empty_blockchain, bt): # 12 blocks = bt.get_consecutive_blocks(2) @@ -1233,7 +1233,7 @@ class TestBlockHeaderValidation: block_bad = recursive_replace(blocks[-1], "reward_chain_block.reward_chain_sp_signature", G2Element.generator()) await _validate_and_add_block(empty_blockchain, block_bad, expected_error=Err.INVALID_RC_SIGNATURE) - @pytest.mark.asyncio + @pytest.mark.anyio async def test_bad_cc_sp_vdf(self, empty_blockchain, bt): # 13. Note: does not validate fully due to proof of space being validated first @@ -1268,7 +1268,7 @@ class TestBlockHeaderValidation: return None await _validate_and_add_block(empty_blockchain, blocks[-1]) - @pytest.mark.asyncio + @pytest.mark.anyio async def test_bad_cc_sp_sig(self, empty_blockchain, bt): # 14 blocks = bt.get_consecutive_blocks(2) @@ -1278,12 +1278,12 @@ class TestBlockHeaderValidation: ) await _validate_and_add_block(empty_blockchain, block_bad, expected_error=Err.INVALID_CC_SIGNATURE) - @pytest.mark.asyncio + @pytest.mark.anyio async def test_is_transaction_block(self, empty_blockchain): # 15: TODO pass - @pytest.mark.asyncio + @pytest.mark.anyio async def test_bad_foliage_sb_sig(self, empty_blockchain, bt): # 16 blocks = bt.get_consecutive_blocks(2) @@ -1291,7 +1291,7 @@ class TestBlockHeaderValidation: block_bad = recursive_replace(blocks[-1], "foliage.foliage_block_data_signature", G2Element.generator()) await _validate_and_add_block(empty_blockchain, block_bad, expected_error=Err.INVALID_PLOT_SIGNATURE) - @pytest.mark.asyncio + @pytest.mark.anyio async def test_bad_foliage_transaction_block_sig(self, empty_blockchain, bt): # 17 blocks = bt.get_consecutive_blocks(1) @@ -1307,7 +1307,7 @@ class TestBlockHeaderValidation: return None await _validate_and_add_block(empty_blockchain, blocks[-1]) - @pytest.mark.asyncio + @pytest.mark.anyio async def test_unfinished_reward_chain_sb_hash(self, empty_blockchain, bt): # 18 blocks = bt.get_consecutive_blocks(2) @@ -1320,7 +1320,7 @@ class TestBlockHeaderValidation: block_bad = recursive_replace(block_bad, "foliage.foliage_block_data_signature", new_fsb_sig) await _validate_and_add_block(empty_blockchain, block_bad, expected_error=Err.INVALID_URSB_HASH) - @pytest.mark.asyncio + @pytest.mark.anyio async def test_pool_target_height(self, empty_blockchain, bt): # 19 blocks = bt.get_consecutive_blocks(3) @@ -1332,7 +1332,7 @@ class TestBlockHeaderValidation: block_bad = recursive_replace(block_bad, "foliage.foliage_block_data_signature", new_fsb_sig) await _validate_and_add_block(empty_blockchain, block_bad, expected_error=Err.OLD_POOL_TARGET) - @pytest.mark.asyncio + @pytest.mark.anyio async def test_pool_target_pre_farm(self, empty_blockchain, bt): # 20a blocks = bt.get_consecutive_blocks(1) @@ -1344,7 +1344,7 @@ class TestBlockHeaderValidation: block_bad = recursive_replace(block_bad, "foliage.foliage_block_data_signature", new_fsb_sig) await _validate_and_add_block(empty_blockchain, block_bad, expected_error=Err.INVALID_PREFARM) - @pytest.mark.asyncio + @pytest.mark.anyio async def test_pool_target_signature(self, empty_blockchain, bt): # 20b blocks_initial = bt.get_consecutive_blocks(2) @@ -1368,7 +1368,7 @@ class TestBlockHeaderValidation: return None attempts += 1 - @pytest.mark.asyncio + @pytest.mark.anyio async def test_pool_target_contract(self, empty_blockchain, bt, seeded_random: random.Random): # 20c invalid pool target with contract blocks_initial = bt.get_consecutive_blocks(2) @@ -1392,7 +1392,7 @@ class TestBlockHeaderValidation: return None attempts += 1 - @pytest.mark.asyncio + @pytest.mark.anyio async def test_foliage_data_presence(self, empty_blockchain, bt): # 22 blocks = bt.get_consecutive_blocks(1) @@ -1419,7 +1419,7 @@ class TestBlockHeaderValidation: ], ) - @pytest.mark.asyncio + @pytest.mark.anyio async def test_foliage_transaction_block_hash(self, empty_blockchain, bt): # 23 blocks = bt.get_consecutive_blocks(1) @@ -1441,7 +1441,7 @@ class TestBlockHeaderValidation: return None await _validate_and_add_block(empty_blockchain, blocks[-1]) - @pytest.mark.asyncio + @pytest.mark.anyio async def test_genesis_bad_prev_block(self, empty_blockchain, bt): # 24a blocks = bt.get_consecutive_blocks(1) @@ -1456,7 +1456,7 @@ class TestBlockHeaderValidation: block_bad = recursive_replace(block_bad, "foliage.foliage_transaction_block_signature", new_fbh_sig) await _validate_and_add_block(empty_blockchain, block_bad, expected_error=Err.INVALID_PREV_BLOCK_HASH) - @pytest.mark.asyncio + @pytest.mark.anyio async def test_bad_prev_block_non_genesis(self, empty_blockchain, bt): # 24b blocks = bt.get_consecutive_blocks(1) @@ -1477,7 +1477,7 @@ class TestBlockHeaderValidation: return None await _validate_and_add_block(empty_blockchain, blocks[-1]) - @pytest.mark.asyncio + @pytest.mark.anyio async def test_bad_filter_hash(self, empty_blockchain, bt): # 25 blocks = bt.get_consecutive_blocks(1) @@ -1500,7 +1500,7 @@ class TestBlockHeaderValidation: return None await _validate_and_add_block(empty_blockchain, blocks[-1]) - @pytest.mark.asyncio + @pytest.mark.anyio async def test_bad_timestamp(self, bt): # 26 # the test constants set MAX_FUTURE_TIME to 10 days, restore it to @@ -1571,7 +1571,7 @@ class TestBlockHeaderValidation: return None await _validate_and_add_block(b, blocks[-1]) - @pytest.mark.asyncio + @pytest.mark.anyio async def test_height(self, empty_blockchain, bt): # 27 blocks = bt.get_consecutive_blocks(2) @@ -1579,14 +1579,14 @@ class TestBlockHeaderValidation: block_bad: FullBlock = recursive_replace(blocks[-1], "reward_chain_block.height", 2) await _validate_and_add_block(empty_blockchain, block_bad, expected_error=Err.INVALID_HEIGHT) - @pytest.mark.asyncio + @pytest.mark.anyio async def test_height_genesis(self, empty_blockchain, bt): # 27 blocks = bt.get_consecutive_blocks(1) block_bad: FullBlock = recursive_replace(blocks[-1], "reward_chain_block.height", 1) await _validate_and_add_block(empty_blockchain, block_bad, expected_error=Err.INVALID_PREV_BLOCK_HASH) - @pytest.mark.asyncio + @pytest.mark.anyio async def test_weight(self, empty_blockchain, bt): # 28 blocks = bt.get_consecutive_blocks(2) @@ -1594,14 +1594,14 @@ class TestBlockHeaderValidation: block_bad: FullBlock = recursive_replace(blocks[-1], "reward_chain_block.weight", 22131) await _validate_and_add_block(empty_blockchain, block_bad, expected_error=Err.INVALID_WEIGHT) - @pytest.mark.asyncio + @pytest.mark.anyio async def test_weight_genesis(self, empty_blockchain, bt): # 28 blocks = bt.get_consecutive_blocks(1) block_bad: FullBlock = recursive_replace(blocks[-1], "reward_chain_block.weight", 0) await _validate_and_add_block(empty_blockchain, block_bad, expected_error=Err.INVALID_WEIGHT) - @pytest.mark.asyncio + @pytest.mark.anyio async def test_bad_cc_ip_vdf(self, empty_blockchain, bt): # 29 blocks = bt.get_consecutive_blocks(1) @@ -1629,7 +1629,7 @@ class TestBlockHeaderValidation: ) await _validate_and_add_block(empty_blockchain, block_bad, expected_error=Err.INVALID_CC_IP_VDF) - @pytest.mark.asyncio + @pytest.mark.anyio async def test_bad_rc_ip_vdf(self, empty_blockchain, bt): # 30 blocks = bt.get_consecutive_blocks(1) @@ -1657,7 +1657,7 @@ class TestBlockHeaderValidation: ) await _validate_and_add_block(empty_blockchain, block_bad, expected_error=Err.INVALID_RC_IP_VDF) - @pytest.mark.asyncio + @pytest.mark.anyio async def test_bad_icc_ip_vdf(self, empty_blockchain, bt): # 31 blocks = bt.get_consecutive_blocks(1) @@ -1689,7 +1689,7 @@ class TestBlockHeaderValidation: await _validate_and_add_block(empty_blockchain, block_bad, expected_error=Err.INVALID_ICC_VDF) - @pytest.mark.asyncio + @pytest.mark.anyio async def test_reward_block_hash(self, empty_blockchain, bt): # 32 blocks = bt.get_consecutive_blocks(2) @@ -1697,7 +1697,7 @@ class TestBlockHeaderValidation: block_bad: FullBlock = recursive_replace(blocks[-1], "foliage.reward_block_hash", std_hash(b"")) await _validate_and_add_block(empty_blockchain, block_bad, expected_error=Err.INVALID_REWARD_BLOCK_HASH) - @pytest.mark.asyncio + @pytest.mark.anyio async def test_reward_block_hash_2(self, empty_blockchain, bt): # 33 blocks = bt.get_consecutive_blocks(1) @@ -1728,7 +1728,7 @@ rbr = AddBlockResult class TestPreValidation: - @pytest.mark.asyncio + @pytest.mark.anyio async def test_pre_validation_fails_bad_blocks(self, empty_blockchain, bt): blocks = bt.get_consecutive_blocks(2) await _validate_and_add_block(empty_blockchain, blocks[0]) @@ -1742,7 +1742,7 @@ class TestPreValidation: assert res[0].error is None assert res[1].error is not None - @pytest.mark.asyncio + @pytest.mark.anyio async def test_pre_validation(self, empty_blockchain, default_1000_blocks, bt): blocks = default_1000_blocks[:100] start = time.time() @@ -1786,7 +1786,7 @@ class TestBodyValidation: # CREATE_PUZZLE_ANNOUNCEMENT, # ASSERT_PUZZLE_ANNOUNCEMENT, - @pytest.mark.asyncio + @pytest.mark.anyio @pytest.mark.parametrize( "opcode", [ @@ -1858,7 +1858,7 @@ class TestBodyValidation: assert err is None assert state_change.fork_height == 2 - @pytest.mark.asyncio + @pytest.mark.anyio @pytest.mark.parametrize( "opcode,lock_value,expected", [ @@ -1973,7 +1973,7 @@ class TestBodyValidation: c = await b.coin_store.get_coin_record(coin.name()) assert c is not None and c.spent - @pytest.mark.asyncio + @pytest.mark.anyio @pytest.mark.parametrize( "opcode", [ @@ -2065,7 +2065,7 @@ class TestBodyValidation: res, error, state_change = await b.add_block(blocks[-1], repl_preval_results) assert (res, error, state_change.fork_height if state_change else None) == expected - @pytest.mark.asyncio + @pytest.mark.anyio @pytest.mark.parametrize("with_garbage", [True, False]) @pytest.mark.parametrize( "opcode,lock_value,expected", @@ -2186,7 +2186,7 @@ class TestBodyValidation: c = await b.coin_store.get_coin_record(coin2.name()) assert c is not None and not c.spent - @pytest.mark.asyncio + @pytest.mark.anyio async def test_not_tx_block_but_has_data(self, empty_blockchain, bt): # 1 blocks = bt.get_consecutive_blocks(1) @@ -2215,7 +2215,7 @@ class TestBodyValidation: empty_blockchain, block, expected_error=Err.NOT_BLOCK_BUT_HAS_DATA, skip_prevalidation=True ) - @pytest.mark.asyncio + @pytest.mark.anyio async def test_tx_block_missing_data(self, empty_blockchain, bt): # 2 b = empty_blockchain @@ -2240,7 +2240,7 @@ class TestBodyValidation: b, block, [Err.IS_TRANSACTION_BLOCK_BUT_NO_DATA, Err.INVALID_FOLIAGE_BLOCK_PRESENCE] ) - @pytest.mark.asyncio + @pytest.mark.anyio async def test_invalid_transactions_info_hash(self, empty_blockchain, bt): # 3 b = empty_blockchain @@ -2261,7 +2261,7 @@ class TestBodyValidation: await _validate_and_add_block(b, block, expected_error=Err.INVALID_TRANSACTIONS_INFO_HASH) - @pytest.mark.asyncio + @pytest.mark.anyio async def test_invalid_transactions_block_hash(self, empty_blockchain, bt): # 4 b = empty_blockchain @@ -2275,7 +2275,7 @@ class TestBodyValidation: await _validate_and_add_block(b, block, expected_error=Err.INVALID_FOLIAGE_BLOCK_HASH) - @pytest.mark.asyncio + @pytest.mark.anyio async def test_invalid_reward_claims(self, empty_blockchain, bt): # 5 b = empty_blockchain @@ -2343,7 +2343,7 @@ class TestBodyValidation: await _validate_and_add_block(b, block_2, expected_error=Err.INVALID_REWARD_COINS, skip_prevalidation=True) - @pytest.mark.asyncio + @pytest.mark.anyio async def test_invalid_transactions_generator_hash(self, empty_blockchain, bt): # 7 b = empty_blockchain @@ -2400,7 +2400,7 @@ class TestBodyValidation: block_2 = recursive_replace(block_2, "foliage.foliage_transaction_block_signature", new_fsb_sig) await _validate_and_add_block(b, block_2, expected_error=Err.INVALID_TRANSACTIONS_GENERATOR_HASH) - @pytest.mark.asyncio + @pytest.mark.anyio async def test_invalid_transactions_ref_list(self, empty_blockchain, bt, consensus_mode: ConsensusMode): # No generator should have [1]s for the root b = empty_blockchain @@ -2513,7 +2513,7 @@ class TestBodyValidation: skip_prevalidation=True, ) - @pytest.mark.asyncio + @pytest.mark.anyio async def test_cost_exceeds_max(self, empty_blockchain, softfork_height, bt): # 7 b = empty_blockchain @@ -2559,12 +2559,12 @@ class TestBodyValidation: assert results is not None assert Err(results[0].error) == Err.BLOCK_COST_EXCEEDS_MAX - @pytest.mark.asyncio + @pytest.mark.anyio async def test_clvm_must_not_fail(self, empty_blockchain, bt): # 8 pass - @pytest.mark.asyncio + @pytest.mark.anyio async def test_invalid_cost_in_block(self, empty_blockchain, softfork_height, bt): # 9 b = empty_blockchain @@ -2668,7 +2668,7 @@ class TestBodyValidation: # when the CLVM program exceeds cost during execution, it will fail with # a general runtime error. The previous test tests this. - @pytest.mark.asyncio + @pytest.mark.anyio async def test_max_coin_amount(self, db_version, bt): # 10 # TODO: fix, this is not reaching validation. Because we can't create a block with such amounts due to uint64 @@ -2720,7 +2720,7 @@ class TestBodyValidation: # await db_wrapper.close() # b.shut_down() - @pytest.mark.asyncio + @pytest.mark.anyio async def test_invalid_merkle_roots(self, empty_blockchain, bt): # 11 blocks = bt.get_consecutive_blocks( @@ -2768,7 +2768,7 @@ class TestBodyValidation: await _validate_and_add_block(empty_blockchain, block_2, expected_error=Err.BAD_REMOVAL_ROOT) - @pytest.mark.asyncio + @pytest.mark.anyio async def test_invalid_filter(self, empty_blockchain, bt): # 12 b = empty_blockchain @@ -2802,7 +2802,7 @@ class TestBodyValidation: await _validate_and_add_block(b, block_2, expected_error=Err.INVALID_TRANSACTIONS_FILTER_HASH) - @pytest.mark.asyncio + @pytest.mark.anyio async def test_duplicate_outputs(self, empty_blockchain, bt): # 13 b = empty_blockchain @@ -2832,7 +2832,7 @@ class TestBodyValidation: ) await _validate_and_add_block(b, blocks[-1], expected_error=Err.DUPLICATE_OUTPUT) - @pytest.mark.asyncio + @pytest.mark.anyio async def test_duplicate_removals(self, empty_blockchain, bt): # 14 b = empty_blockchain @@ -2861,7 +2861,7 @@ class TestBodyValidation: ) await _validate_and_add_block(b, blocks[-1], expected_error=Err.DOUBLE_SPEND) - @pytest.mark.asyncio + @pytest.mark.anyio async def test_double_spent_in_coin_store(self, empty_blockchain, bt): # 15 b = empty_blockchain @@ -2895,7 +2895,7 @@ class TestBodyValidation: await _validate_and_add_block(b, blocks[-1], expected_error=Err.DOUBLE_SPEND) - @pytest.mark.asyncio + @pytest.mark.anyio async def test_double_spent_in_reorg(self, empty_blockchain, bt): # 15 b = empty_blockchain @@ -2987,7 +2987,7 @@ class TestBodyValidation: farmer_coin = await b.coin_store.get_coin_record(farmer_coin.name()) assert first_coin is not None and farmer_coin.spent - @pytest.mark.asyncio + @pytest.mark.anyio async def test_minting_coin(self, empty_blockchain, bt): # 16 Minting coin check b = empty_blockchain @@ -3020,12 +3020,12 @@ class TestBodyValidation: await _validate_and_add_block(b, blocks[-1], expected_error=Err.MINTING_COIN) # 17 is tested in mempool tests - @pytest.mark.asyncio + @pytest.mark.anyio async def test_max_coin_amount_fee(self): # 18 TODO: we can't create a block with such amounts due to uint64 pass - @pytest.mark.asyncio + @pytest.mark.anyio async def test_invalid_fees_in_block(self, empty_blockchain, bt): # 19 b = empty_blockchain @@ -3066,7 +3066,7 @@ class TestBodyValidation: await _validate_and_add_block(b, block_2, expected_error=Err.INVALID_BLOCK_FEE_AMOUNT) - @pytest.mark.asyncio + @pytest.mark.anyio async def test_invalid_agg_sig(self, empty_blockchain, bt): # 22 b = empty_blockchain @@ -3112,7 +3112,7 @@ class TestBodyValidation: class TestReorgs: - @pytest.mark.asyncio + @pytest.mark.anyio async def test_basic_reorg(self, empty_blockchain, bt): b = empty_blockchain blocks = bt.get_consecutive_blocks(15) @@ -3131,7 +3131,7 @@ class TestReorgs: await _validate_and_add_block(b, reorg_block) assert b.get_peak().height == 16 - @pytest.mark.asyncio + @pytest.mark.anyio async def test_long_reorg(self, empty_blockchain, default_1500_blocks, test_long_reorg_blocks, bt): # Reorg longer than a difficulty adjustment # Also tests higher weight chain but lower height @@ -3175,14 +3175,14 @@ class TestReorgs: assert b.get_peak().weight > chain_1_weight assert b.get_peak().height < chain_1_height - @pytest.mark.asyncio + @pytest.mark.anyio async def test_long_compact_blockchain(self, empty_blockchain, default_2000_blocks_compact): b = empty_blockchain for block in default_2000_blocks_compact: await _validate_and_add_block(b, block, skip_prevalidation=True) assert b.get_peak().height == len(default_2000_blocks_compact) - 1 - @pytest.mark.asyncio + @pytest.mark.anyio async def test_reorg_from_genesis(self, empty_blockchain, bt): b = empty_blockchain @@ -3213,7 +3213,7 @@ class TestReorgs: assert b.get_peak().height == 17 - @pytest.mark.asyncio + @pytest.mark.anyio async def test_reorg_transaction(self, empty_blockchain, bt): b = empty_blockchain wallet_a = WalletTool(b.constants) @@ -3258,7 +3258,7 @@ class TestReorgs: for block in blocks_fork: await _validate_and_add_block_no_error(b, block) - @pytest.mark.asyncio + @pytest.mark.anyio async def test_get_header_blocks_in_range_tx_filter(self, empty_blockchain, bt): b = empty_blockchain blocks = bt.get_consecutive_blocks( @@ -3291,7 +3291,7 @@ class TestReorgs: ) assert blocks_with_filter[header_hash].header_hash == blocks_without_filter[header_hash].header_hash - @pytest.mark.asyncio + @pytest.mark.anyio async def test_get_blocks_at(self, empty_blockchain, default_1000_blocks): b = empty_blockchain heights = [] @@ -3305,7 +3305,7 @@ class TestReorgs: assert blocks[-1].height == 199 -@pytest.mark.asyncio +@pytest.mark.anyio async def test_reorg_new_ref(empty_blockchain, bt): b = empty_blockchain wallet_a = WalletTool(b.constants) @@ -3384,7 +3384,7 @@ async def test_reorg_new_ref(empty_blockchain, bt): # this test doesn't reorg, but _reconsider_peak() is passed a stale # "fork_height" to make it look like it's in a reorg, but all the same blocks # are just added back. -@pytest.mark.asyncio +@pytest.mark.anyio async def test_reorg_stale_fork_height(empty_blockchain, bt): b = empty_blockchain wallet_a = WalletTool(b.constants) @@ -3431,7 +3431,7 @@ async def test_reorg_stale_fork_height(empty_blockchain, bt): assert b.get_peak().height == 13 -@pytest.mark.asyncio +@pytest.mark.anyio async def test_chain_failed_rollback(empty_blockchain, bt): b = empty_blockchain wallet_a = WalletTool(b.constants) @@ -3487,7 +3487,7 @@ async def test_chain_failed_rollback(empty_blockchain, bt): assert b.get_peak().height == 19 -@pytest.mark.asyncio +@pytest.mark.anyio async def test_reorg_flip_flop(empty_blockchain, bt): b = empty_blockchain wallet_a = WalletTool(b.constants) diff --git a/tests/blockchain/test_blockchain_transactions.py b/tests/blockchain/test_blockchain_transactions.py index 6ddc4d3b79f3..ab261aa20780 100644 --- a/tests/blockchain/test_blockchain_transactions.py +++ b/tests/blockchain/test_blockchain_transactions.py @@ -30,7 +30,7 @@ log = logging.getLogger(__name__) class TestBlockchainTransactions: - @pytest.mark.asyncio + @pytest.mark.anyio async def test_basic_blockchain_tx( self, two_nodes: Tuple[FullNodeAPI, FullNodeAPI, ChiaServer, ChiaServer, BlockTools] ) -> None: @@ -94,7 +94,7 @@ class TestBlockchainTransactions: assert not unspent.spent assert not unspent.coinbase - @pytest.mark.asyncio + @pytest.mark.anyio async def test_validate_blockchain_with_double_spend( self, two_nodes: Tuple[FullNodeAPI, FullNodeAPI, ChiaServer, ChiaServer, BlockTools] ) -> None: @@ -134,7 +134,7 @@ class TestBlockchainTransactions: next_block = new_blocks[-1] await _validate_and_add_block(full_node_1.blockchain, next_block, expected_error=Err.DOUBLE_SPEND) - @pytest.mark.asyncio + @pytest.mark.anyio async def test_validate_blockchain_duplicate_output( self, two_nodes: Tuple[FullNodeAPI, FullNodeAPI, ChiaServer, ChiaServer, BlockTools] ) -> None: @@ -174,7 +174,7 @@ class TestBlockchainTransactions: next_block = new_blocks[-1] await _validate_and_add_block(full_node_1.blockchain, next_block, expected_error=Err.DUPLICATE_OUTPUT) - @pytest.mark.asyncio + @pytest.mark.anyio async def test_validate_blockchain_with_reorg_double_spend( self, two_nodes: Tuple[FullNodeAPI, FullNodeAPI, ChiaServer, ChiaServer, BlockTools] ) -> None: @@ -283,7 +283,7 @@ class TestBlockchainTransactions: for block in new_blocks_reorg: await full_node_api_1.full_node.add_block(block) - @pytest.mark.asyncio + @pytest.mark.anyio async def test_validate_blockchain_spend_reorg_coin( self, two_nodes: Tuple[FullNodeAPI, FullNodeAPI, ChiaServer, ChiaServer, BlockTools], softfork_height: uint32 ) -> None: @@ -371,7 +371,7 @@ class TestBlockchainTransactions: await full_node_api_1.full_node.add_block(new_blocks[-1]) - @pytest.mark.asyncio + @pytest.mark.anyio async def test_validate_blockchain_spend_reorg_cb_coin( self, two_nodes: Tuple[FullNodeAPI, FullNodeAPI, ChiaServer, ChiaServer, BlockTools] ) -> None: @@ -416,7 +416,7 @@ class TestBlockchainTransactions: await full_node_api_1.full_node.add_block(new_blocks[-1]) - @pytest.mark.asyncio + @pytest.mark.anyio async def test_validate_blockchain_spend_reorg_since_genesis( self, two_nodes: Tuple[FullNodeAPI, FullNodeAPI, ChiaServer, ChiaServer, BlockTools] ) -> None: @@ -467,7 +467,7 @@ class TestBlockchainTransactions: await full_node_api_1.full_node.add_block(new_blocks[-1]) - @pytest.mark.asyncio + @pytest.mark.anyio async def test_assert_my_coin_id( self, two_nodes: Tuple[FullNodeAPI, FullNodeAPI, ChiaServer, ChiaServer, BlockTools] ) -> None: @@ -539,7 +539,7 @@ class TestBlockchainTransactions: ) await _validate_and_add_block(full_node_1.blockchain, new_blocks[-1]) - @pytest.mark.asyncio + @pytest.mark.anyio async def test_assert_coin_announcement_consumed( self, two_nodes: Tuple[FullNodeAPI, FullNodeAPI, ChiaServer, ChiaServer, BlockTools] ) -> None: @@ -623,7 +623,7 @@ class TestBlockchainTransactions: # Try to validate newly created block await _validate_and_add_block(full_node_1.blockchain, new_blocks[-1]) - @pytest.mark.asyncio + @pytest.mark.anyio async def test_assert_puzzle_announcement_consumed( self, two_nodes: Tuple[FullNodeAPI, FullNodeAPI, ChiaServer, ChiaServer, BlockTools] ) -> None: @@ -707,7 +707,7 @@ class TestBlockchainTransactions: # Try to validate newly created block await _validate_and_add_block(full_node_1.blockchain, new_blocks[-1]) - @pytest.mark.asyncio + @pytest.mark.anyio async def test_assert_height_absolute( self, two_nodes: Tuple[FullNodeAPI, FullNodeAPI, ChiaServer, ChiaServer, BlockTools] ) -> None: @@ -773,7 +773,7 @@ class TestBlockchainTransactions: ) await _validate_and_add_block(full_node_1.blockchain, new_blocks[-1]) - @pytest.mark.asyncio + @pytest.mark.anyio async def test_assert_height_relative( self, two_nodes: Tuple[FullNodeAPI, FullNodeAPI, ChiaServer, ChiaServer, BlockTools] ) -> None: @@ -841,7 +841,7 @@ class TestBlockchainTransactions: ) await _validate_and_add_block(full_node_1.blockchain, new_blocks[-1]) - @pytest.mark.asyncio + @pytest.mark.anyio async def test_assert_seconds_relative( self, two_nodes: Tuple[FullNodeAPI, FullNodeAPI, ChiaServer, ChiaServer, BlockTools] ) -> None: @@ -913,7 +913,7 @@ class TestBlockchainTransactions: ) await _validate_and_add_block(full_node_1.blockchain, valid_new_blocks[-1]) - @pytest.mark.asyncio + @pytest.mark.anyio async def test_assert_seconds_absolute( self, two_nodes: Tuple[FullNodeAPI, FullNodeAPI, ChiaServer, ChiaServer, BlockTools] ) -> None: @@ -987,7 +987,7 @@ class TestBlockchainTransactions: ) await _validate_and_add_block(full_node_1.blockchain, valid_new_blocks[-1]) - @pytest.mark.asyncio + @pytest.mark.anyio async def test_assert_fee_condition( self, two_nodes: Tuple[FullNodeAPI, FullNodeAPI, ChiaServer, ChiaServer, BlockTools] ) -> None: diff --git a/tests/clvm/test_singletons.py b/tests/clvm/test_singletons.py index 950e3a477bfe..4e2af71def57 100644 --- a/tests/clvm/test_singletons.py +++ b/tests/clvm/test_singletons.py @@ -80,7 +80,7 @@ async def make_and_spend_bundle( raise AssertionError(fail_msg) -@pytest.mark.asyncio +@pytest.mark.anyio @pytest.mark.parametrize("version", [0, 1]) async def test_singleton_top_layer(version, cost_logger): async with sim_and_client() as (sim, sim_client): diff --git a/tests/clvm/test_spend_sim.py b/tests/clvm/test_spend_sim.py index 2510c1b04637..6ca7d27aeb6c 100644 --- a/tests/clvm/test_spend_sim.py +++ b/tests/clvm/test_spend_sim.py @@ -10,7 +10,7 @@ from chia.types.coin_spend import CoinSpend from chia.types.spend_bundle import SpendBundle -@pytest.mark.asyncio +@pytest.mark.anyio async def test_farming(): async with sim_and_client(pass_prefarm=False) as (sim, _): for i in range(0, 5): @@ -21,7 +21,7 @@ async def test_farming(): assert sim.block_records[0].reward_claims_incorporated[0].amount == 18375000000000000000 -@pytest.mark.asyncio +@pytest.mark.anyio async def test_rewind(): async with sim_and_client() as (sim, _): for i in range(0, 5): @@ -35,7 +35,7 @@ async def test_rewind(): assert sim.blocks[-1].height == 5 -@pytest.mark.asyncio +@pytest.mark.anyio async def test_all_endpoints(): async with sim_and_client() as (sim, sim_client): for i in range(0, 5): diff --git a/tests/cmds/test_farm_cmd.py b/tests/cmds/test_farm_cmd.py index 147235e0113a..f85db224e169 100644 --- a/tests/cmds/test_farm_cmd.py +++ b/tests/cmds/test_farm_cmd.py @@ -20,7 +20,7 @@ from chia.wallet.wallet_node import WalletNode from chia.wallet.wallet_node_api import WalletNodeAPI -@pytest.mark.asyncio +@pytest.mark.anyio async def test_farm_summary_command( capsys: CaptureFixture[str], farmer_one_harvester_simulator_wallet: Tuple[ diff --git a/tests/conftest.py b/tests/conftest.py index ce35f3c4236b..bc74e925acb3 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -1,6 +1,7 @@ # flake8: noqa E402 # See imports after multiprocessing.set_start_method from __future__ import annotations +import asyncio import dataclasses import datetime import functools @@ -15,7 +16,6 @@ from typing import Any, AsyncIterator, Callable, Dict, Iterator, List, Tuple, Un import aiohttp import pytest -import pytest_asyncio # TODO: update after resolution in https://github.com/pytest-dev/pytest/issues/7469 from _pytest.fixtures import SubRequest @@ -77,6 +77,16 @@ from chia.simulator.setup_nodes import setup_farmer_multi_harvester from chia.util.keyring_wrapper import KeyringWrapper +@pytest.fixture(scope="session") +def anyio_backend(): + return "asyncio" + + +@pytest.fixture(name="event_loop") +async def event_loop_fixture() -> asyncio.events.AbstractEventLoop: + return asyncio.get_running_loop() + + @pytest.fixture(name="seeded_random") def seeded_random_fixture() -> random.Random: seeded_random = random.Random() @@ -173,15 +183,15 @@ def blockchain_constants(consensus_mode) -> ConsensusConstants: @pytest.fixture(scope="session", name="bt") -def block_tools_fixture(get_keychain, blockchain_constants) -> BlockTools: +async def block_tools_fixture(get_keychain, blockchain_constants, anyio_backend) -> BlockTools: # Note that this causes a lot of CPU and disk traffic - disk, DB, ports, process creation ... - _shared_block_tools = create_block_tools(constants=blockchain_constants, keychain=get_keychain) + _shared_block_tools = await create_block_tools_async(constants=blockchain_constants, keychain=get_keychain) return _shared_block_tools # if you have a system that has an unusual hostname for localhost and you want # to run the tests, change the `self_hostname` fixture -@pytest_asyncio.fixture(scope="session") +@pytest.fixture(scope="session") def self_hostname(): return "127.0.0.1" @@ -195,7 +205,7 @@ def self_hostname(): # the fixtures below. Just be aware of the filesystem modification during bt fixture creation -@pytest_asyncio.fixture(scope="function") +@pytest.fixture(scope="function") async def empty_blockchain(latest_db_version, blockchain_constants): """ Provides a list of 10 valid blocks, as well as a blockchain with 9 blocks added to it. @@ -454,7 +464,7 @@ def pytest_collection_modifyitems(session, config: pytest.Config, items: List[py raise Exception("\n".join(all_error_lines)) -@pytest_asyncio.fixture(scope="function") +@pytest.fixture(scope="function") async def node_with_params(request, blockchain_constants: ConsensusConstants): params = {} if request: @@ -463,31 +473,31 @@ async def node_with_params(request, blockchain_constants: ConsensusConstants): yield sims[0] -@pytest_asyncio.fixture(scope="function") +@pytest.fixture(scope="function") async def two_nodes(db_version: int, self_hostname, blockchain_constants: ConsensusConstants): async with setup_two_nodes(blockchain_constants, db_version=db_version, self_hostname=self_hostname) as _: yield _ -@pytest_asyncio.fixture(scope="function") +@pytest.fixture(scope="function") async def setup_two_nodes_fixture(db_version: int, blockchain_constants: ConsensusConstants): async with setup_simulators_and_wallets(2, 0, blockchain_constants, db_version=db_version) as _: yield _ -@pytest_asyncio.fixture(scope="function") +@pytest.fixture(scope="function") async def three_nodes(db_version: int, self_hostname, blockchain_constants): async with setup_n_nodes(blockchain_constants, 3, db_version=db_version, self_hostname=self_hostname) as _: yield _ -@pytest_asyncio.fixture(scope="function") +@pytest.fixture(scope="function") async def five_nodes(db_version: int, self_hostname, blockchain_constants): async with setup_n_nodes(blockchain_constants, 5, db_version=db_version, self_hostname=self_hostname) as _: yield _ -@pytest_asyncio.fixture(scope="function") +@pytest.fixture(scope="function") async def wallet_nodes(blockchain_constants, consensus_mode): constants = blockchain_constants async with setup_simulators_and_wallets( @@ -504,31 +514,31 @@ async def wallet_nodes(blockchain_constants, consensus_mode): yield full_node_1, full_node_2, server_1, server_2, wallet_a, wallet_receiver, bt -@pytest_asyncio.fixture(scope="function") +@pytest.fixture(scope="function") async def setup_four_nodes(db_version, blockchain_constants: ConsensusConstants): async with setup_simulators_and_wallets(4, 0, blockchain_constants, db_version=db_version) as _: yield _ -@pytest_asyncio.fixture(scope="function") +@pytest.fixture(scope="function") async def two_nodes_sim_and_wallets_services(blockchain_constants, consensus_mode): async with setup_simulators_and_wallets_service(2, 0, blockchain_constants) as _: yield _ -@pytest_asyncio.fixture(scope="function") +@pytest.fixture(scope="function") async def one_wallet_and_one_simulator_services(blockchain_constants: ConsensusConstants): async with setup_simulators_and_wallets_service(1, 1, blockchain_constants) as _: yield _ -@pytest_asyncio.fixture(scope="function") +@pytest.fixture(scope="function") async def wallet_node_100_pk(blockchain_constants: ConsensusConstants): async with setup_simulators_and_wallets(1, 1, blockchain_constants, initial_num_public_keys=100) as _: yield _ -@pytest_asyncio.fixture(scope="function") +@pytest.fixture(scope="function") async def simulator_and_wallet( blockchain_constants: ConsensusConstants, ) -> AsyncIterator[Tuple[List[FullNodeSimulator], List[Tuple[WalletNode, ChiaServer]], BlockTools]]: @@ -536,7 +546,7 @@ async def simulator_and_wallet( yield _ -@pytest_asyncio.fixture(scope="function") +@pytest.fixture(scope="function") async def two_wallet_nodes(request, blockchain_constants: ConsensusConstants): params = {} if request and request.param_index > 0: @@ -545,7 +555,7 @@ async def two_wallet_nodes(request, blockchain_constants: ConsensusConstants): yield _ -@pytest_asyncio.fixture(scope="function") +@pytest.fixture(scope="function") async def two_wallet_nodes_services( blockchain_constants: ConsensusConstants, ) -> AsyncIterator[ @@ -555,7 +565,7 @@ async def two_wallet_nodes_services( yield _ -@pytest_asyncio.fixture(scope="function") +@pytest.fixture(scope="function") async def two_wallet_nodes_custom_spam_filtering( spam_filter_after_n_txs, xch_spam_amount, blockchain_constants: ConsensusConstants ): @@ -563,19 +573,19 @@ async def two_wallet_nodes_custom_spam_filtering( yield _ -@pytest_asyncio.fixture(scope="function") +@pytest.fixture(scope="function") async def three_sim_two_wallets(blockchain_constants: ConsensusConstants): async with setup_simulators_and_wallets(3, 2, blockchain_constants) as _: yield _ -@pytest_asyncio.fixture(scope="function") +@pytest.fixture(scope="function") async def setup_two_nodes_and_wallet(blockchain_constants: ConsensusConstants): async with setup_simulators_and_wallets(2, 1, blockchain_constants, db_version=2) as _: yield _ -@pytest_asyncio.fixture(scope="function") +@pytest.fixture(scope="function") async def setup_two_nodes_and_wallet_fast_retry(blockchain_constants: ConsensusConstants): async with setup_simulators_and_wallets( 1, 1, blockchain_constants, config_overrides={"wallet.tx_resend_timeout_secs": 1}, db_version=2 @@ -583,33 +593,33 @@ async def setup_two_nodes_and_wallet_fast_retry(blockchain_constants: ConsensusC yield _ -@pytest_asyncio.fixture(scope="function") +@pytest.fixture(scope="function") async def three_wallet_nodes(blockchain_constants: ConsensusConstants): async with setup_simulators_and_wallets(1, 3, blockchain_constants) as _: yield _ -@pytest_asyncio.fixture(scope="function") +@pytest.fixture(scope="function") async def wallet_two_node_simulator(blockchain_constants: ConsensusConstants): async with setup_simulators_and_wallets(2, 1, blockchain_constants) as _: yield _ -@pytest_asyncio.fixture(scope="function") +@pytest.fixture(scope="function") async def wallet_nodes_mempool_perf(bt): key_seed = bt.farmer_master_sk_entropy async with setup_simulators_and_wallets(2, 1, bt.constants, key_seed=key_seed) as _: yield _ -@pytest_asyncio.fixture(scope="function") +@pytest.fixture(scope="function") async def two_nodes_two_wallets_with_same_keys(bt) -> AsyncIterator[SimulatorsAndWallets]: key_seed = bt.farmer_master_sk_entropy async with setup_simulators_and_wallets(2, 2, bt.constants, key_seed=key_seed) as _: yield _ -@pytest_asyncio.fixture +@pytest.fixture async def wallet_nodes_perf(blockchain_constants: ConsensusConstants): async with setup_simulators_and_wallets( 1, 1, blockchain_constants, config_overrides={"MEMPOOL_BLOCK_BUFFER": 1, "MAX_BLOCK_COST_CLVM": 11000000000} @@ -625,13 +635,13 @@ async def wallet_nodes_perf(blockchain_constants: ConsensusConstants): yield full_node_1, server_1, wallet_a, wallet_receiver, bt -@pytest_asyncio.fixture(scope="function") +@pytest.fixture(scope="function") async def three_nodes_two_wallets(blockchain_constants: ConsensusConstants): async with setup_simulators_and_wallets(3, 2, blockchain_constants) as _: yield _ -@pytest_asyncio.fixture(scope="function") +@pytest.fixture(scope="function") async def one_node( blockchain_constants: ConsensusConstants, ) -> AsyncIterator[Tuple[List[Service], List[FullNodeSimulator], BlockTools]]: @@ -639,7 +649,7 @@ async def one_node( yield _ -@pytest_asyncio.fixture(scope="function") +@pytest.fixture(scope="function") async def one_node_one_block( blockchain_constants: ConsensusConstants, ) -> AsyncIterator[Tuple[Union[FullNodeAPI, FullNodeSimulator], ChiaServer, BlockTools]]: @@ -667,7 +677,7 @@ async def one_node_one_block( yield full_node_1, server_1, bt -@pytest_asyncio.fixture(scope="function") +@pytest.fixture(scope="function") async def two_nodes_one_block(blockchain_constants: ConsensusConstants): async with setup_simulators_and_wallets(2, 0, blockchain_constants) as (nodes, _, bt): full_node_1 = nodes[0] @@ -695,7 +705,7 @@ async def two_nodes_one_block(blockchain_constants: ConsensusConstants): yield full_node_1, full_node_2, server_1, server_2, bt -@pytest_asyncio.fixture(scope="function") +@pytest.fixture(scope="function") async def farmer_one_harvester_simulator_wallet( tmp_path: Path, blockchain_constants: ConsensusConstants, @@ -720,13 +730,13 @@ async def farmer_one_harvester_simulator_wallet( FarmerOneHarvester = Tuple[List[Service[Harvester, HarvesterAPI]], Service[Farmer, FarmerAPI], BlockTools] -@pytest_asyncio.fixture(scope="function") +@pytest.fixture(scope="function") async def farmer_one_harvester(tmp_path: Path, get_b_tools: BlockTools) -> AsyncIterator[FarmerOneHarvester]: async with setup_farmer_multi_harvester(get_b_tools, 1, tmp_path, get_b_tools.constants, start_services=True) as _: yield _ -@pytest_asyncio.fixture(scope="function") +@pytest.fixture(scope="function") async def farmer_one_harvester_not_started( tmp_path: Path, get_b_tools: BlockTools ) -> AsyncIterator[Tuple[List[Service], Service]]: @@ -734,7 +744,7 @@ async def farmer_one_harvester_not_started( yield _ -@pytest_asyncio.fixture(scope="function") +@pytest.fixture(scope="function") async def farmer_two_harvester_not_started( tmp_path: Path, get_b_tools: BlockTools ) -> AsyncIterator[Tuple[List[Service], Service]]: @@ -742,7 +752,7 @@ async def farmer_two_harvester_not_started( yield _ -@pytest_asyncio.fixture(scope="function") +@pytest.fixture(scope="function") async def farmer_three_harvester_not_started( tmp_path: Path, get_b_tools: BlockTools ) -> AsyncIterator[Tuple[List[Service], Service]]: @@ -750,7 +760,7 @@ async def farmer_three_harvester_not_started( yield _ -@pytest_asyncio.fixture(scope="function") +@pytest.fixture(scope="function") async def get_daemon(bt): async with setup_daemon(btools=bt) as _: yield _ @@ -763,18 +773,18 @@ def empty_keyring(): KeyringWrapper.cleanup_shared_instance() -@pytest_asyncio.fixture(scope="function") +@pytest.fixture(scope="function") async def get_temp_keyring(): with TempKeyring() as keychain: yield keychain -@pytest_asyncio.fixture(scope="function") +@pytest.fixture(scope="function") async def get_b_tools_1(get_temp_keyring): return await create_block_tools_async(constants=test_constants_modified, keychain=get_temp_keyring) -@pytest_asyncio.fixture(scope="function") +@pytest.fixture(scope="function") async def get_b_tools(get_temp_keyring): local_b_tools = await create_block_tools_async(constants=test_constants_modified, keychain=get_temp_keyring) new_config = local_b_tools._config @@ -782,7 +792,7 @@ async def get_b_tools(get_temp_keyring): return local_b_tools -@pytest_asyncio.fixture(scope="function") +@pytest.fixture(scope="function") async def daemon_connection_and_temp_keychain( get_b_tools: BlockTools, ) -> AsyncIterator[Tuple[aiohttp.ClientWebSocketResponse, Keychain]]: @@ -799,7 +809,7 @@ async def daemon_connection_and_temp_keychain( yield ws, keychain -@pytest_asyncio.fixture(scope="function") +@pytest.fixture(scope="function") async def wallets_prefarm_services(two_wallet_nodes_services, self_hostname, trusted, request): """ Sets up the node with 10 blocks, and returns a payer and payee wallet. @@ -862,12 +872,12 @@ async def wallets_prefarm_services(two_wallet_nodes_services, self_hostname, tru ) -@pytest_asyncio.fixture(scope="function") +@pytest.fixture(scope="function") async def wallets_prefarm(wallets_prefarm_services): return wallets_prefarm_services[0], wallets_prefarm_services[1], wallets_prefarm_services[4] -@pytest_asyncio.fixture(scope="function") +@pytest.fixture(scope="function") async def three_wallets_prefarm(three_wallet_nodes, self_hostname, trusted): """ Sets up the node with 10 blocks, and returns a payer and payee wallet. @@ -919,25 +929,25 @@ async def three_wallets_prefarm(three_wallet_nodes, self_hostname, trusted): ) -@pytest_asyncio.fixture(scope="function") +@pytest.fixture(scope="function") async def introducer_service(bt): async with setup_introducer(bt, 0) as _: yield _ -@pytest_asyncio.fixture(scope="function") +@pytest.fixture(scope="function") async def timelord(bt): async with setup_timelord(uint16(0), False, bt.constants, bt.config, bt.root_path) as service: yield service._api, service._node.server -@pytest_asyncio.fixture(scope="function") +@pytest.fixture(scope="function") async def timelord_service(bt: BlockTools) -> AsyncIterator[Service[Timelord, TimelordAPI]]: async with setup_timelord(uint16(0), False, bt.constants, bt.config, bt.root_path) as _: yield _ -@pytest_asyncio.fixture(scope="function") +@pytest.fixture(scope="function") async def crawler_service( root_path_populated_with_config: Path, database_uri: str ) -> AsyncIterator[Service[Crawler, CrawlerAPI]]: @@ -945,7 +955,7 @@ async def crawler_service( yield service -@pytest_asyncio.fixture(scope="function") +@pytest.fixture(scope="function") async def seeder_service(root_path_populated_with_config: Path, database_uri: str) -> AsyncIterator[DNSServer]: async with setup_seeder(root_path_populated_with_config, database_uri) as seeder: yield seeder @@ -1013,7 +1023,7 @@ def cost_logger_fixture() -> Iterator[CostLogger]: print(cost_logger.log_cost_statistics()) -@pytest_asyncio.fixture(scope="function") +@pytest.fixture(scope="function") async def simulation(bt, get_b_tools): async with setup_full_system(test_constants_modified, bt, get_b_tools, db_version=2) as full_system: yield full_system, get_b_tools @@ -1024,7 +1034,7 @@ HarvesterFarmerEnvironment = Tuple[ ] -@pytest_asyncio.fixture(scope="function") +@pytest.fixture(scope="function") async def harvester_farmer_environment( farmer_one_harvester: Tuple[List[Service[Harvester, HarvesterAPI]], Service[Farmer, FarmerAPI], BlockTools], self_hostname: str, diff --git a/tests/core/cmds/test_wallet.py b/tests/core/cmds/test_wallet.py index e60b774ab3d8..3cdf0fbf8cc3 100644 --- a/tests/core/cmds/test_wallet.py +++ b/tests/core/cmds/test_wallet.py @@ -23,7 +23,7 @@ async def cat_name_resolver(asset_id: bytes32) -> Optional[Tuple[Optional[uint32 return TEST_ASSET_ID_NAME_MAPPING.get(asset_id) -@pytest.mark.asyncio +@pytest.mark.anyio async def test_print_offer_summary_xch(capsys: Any) -> None: summary_dict = {"xch": 1_000_000_000_000} @@ -34,7 +34,7 @@ async def test_print_offer_summary_xch(capsys: Any) -> None: assert "XCH (Wallet ID: 1): 1.0 (1000000000000 mojos)" in captured.out -@pytest.mark.asyncio +@pytest.mark.anyio async def test_print_offer_summary_cat(capsys: Any) -> None: summary_dict = { TEST_DUCKSAUCE_ASSET_ID: 1_000, @@ -47,7 +47,7 @@ async def test_print_offer_summary_cat(capsys: Any) -> None: assert "DuckSauce (Wallet ID: 2): 1.0 (1000 mojos)" in captured.out -@pytest.mark.asyncio +@pytest.mark.anyio async def test_print_offer_summary_multiple_cats(capsys: Any) -> None: summary_dict = { TEST_DUCKSAUCE_ASSET_ID: 1_000, @@ -62,7 +62,7 @@ async def test_print_offer_summary_multiple_cats(capsys: Any) -> None: assert "CrunchBerries (Wallet ID: 3): 2.0 (2000 mojos)" in captured.out -@pytest.mark.asyncio +@pytest.mark.anyio async def test_print_offer_summary_xch_and_cats(capsys: Any) -> None: summary_dict = { "xch": 2_500_000_000_000, @@ -81,7 +81,7 @@ async def test_print_offer_summary_xch_and_cats(capsys: Any) -> None: assert "UnicornTears (Wallet ID: 4): 3.333 (3333 mojos)" in captured.out -@pytest.mark.asyncio +@pytest.mark.anyio async def test_print_offer_summary_xch_and_cats_with_zero_values(capsys: Any) -> None: summary_dict = { "xch": 0, @@ -100,7 +100,7 @@ async def test_print_offer_summary_xch_and_cats_with_zero_values(capsys: Any) -> assert "UnicornTears (Wallet ID: 4): 0.0 (0 mojos)" in captured.out -@pytest.mark.asyncio +@pytest.mark.anyio async def test_print_offer_summary_cat_with_fee_and_change(capsys: Any) -> None: summary_dict = { TEST_DUCKSAUCE_ASSET_ID: 1_000, @@ -115,7 +115,7 @@ async def test_print_offer_summary_cat_with_fee_and_change(capsys: Any) -> None: assert "Unknown: 3456 mojos [Typically represents change returned from the included fee]" in captured.out -@pytest.mark.asyncio +@pytest.mark.anyio async def test_print_offer_summary_xch_with_one_mojo(capsys: Any) -> None: summary_dict = {"xch": 1} diff --git a/tests/core/daemon/test_daemon.py b/tests/core/daemon/test_daemon.py index c43506de22a8..3d583626f491 100644 --- a/tests/core/daemon/test_daemon.py +++ b/tests/core/daemon/test_daemon.py @@ -409,7 +409,7 @@ async def daemon_client_with_config_and_keys(get_keychain_for_function, get_daem return client -@pytest.mark.asyncio +@pytest.mark.anyio async def test_daemon_passthru(get_daemon, bt): ws_server = get_daemon config = bt.config @@ -530,14 +530,14 @@ def test_is_service_running_with_services_and_connections( assert daemon.is_service_running(service) == expected_result -@pytest.mark.asyncio +@pytest.mark.anyio async def test_running_services_no_services(mock_lonely_daemon): daemon = mock_lonely_daemon response = await daemon.running_services() assert_running_services_response(response, {"success": True, "running_services": []}) -@pytest.mark.asyncio +@pytest.mark.anyio async def test_running_services_with_services(mock_daemon_with_services): daemon = mock_daemon_with_services response = await daemon.running_services() @@ -546,7 +546,7 @@ async def test_running_services_with_services(mock_daemon_with_services): ) -@pytest.mark.asyncio +@pytest.mark.anyio async def test_running_services_with_services_and_connections(mock_daemon_with_services_and_connections): daemon = mock_daemon_with_services_and_connections response = await daemon.running_services() @@ -555,7 +555,7 @@ async def test_running_services_with_services_and_connections(mock_daemon_with_s ) -@pytest.mark.asyncio +@pytest.mark.anyio async def test_get_routes(mock_lonely_daemon): daemon = mock_lonely_daemon response = await daemon.get_routes({}) @@ -654,7 +654,7 @@ async def test_get_routes(mock_lonely_daemon): pubkeys_only=True, ), ) -@pytest.mark.asyncio +@pytest.mark.anyio async def test_get_wallet_addresses( mock_daemon_with_config_and_keys, monkeypatch, @@ -718,7 +718,7 @@ async def test_get_wallet_addresses( }, ), ) -@pytest.mark.asyncio +@pytest.mark.anyio async def test_get_keys_for_plotting( mock_daemon_with_config_and_keys, monkeypatch, @@ -735,7 +735,7 @@ async def test_get_keys_for_plotting( response={}, ), ) -@pytest.mark.asyncio +@pytest.mark.anyio async def test_get_keys_for_plotting_error( mock_daemon_with_config_and_keys, monkeypatch, @@ -746,9 +746,9 @@ async def test_get_keys_for_plotting_error( await daemon.get_keys_for_plotting(case.request) -@pytest.mark.asyncio +@pytest.mark.anyio async def test_get_keys_for_plotting_client(daemon_client_with_config_and_keys): - client = await daemon_client_with_config_and_keys + client = daemon_client_with_config_and_keys response = await client.get_keys_for_plotting() assert response["data"]["success"] is True assert len(response["data"]["keys"]) == 2 @@ -762,7 +762,7 @@ async def test_get_keys_for_plotting_client(daemon_client_with_config_and_keys): await client.close() -@pytest.mark.asyncio +@pytest.mark.anyio @pytest.mark.parametrize( "service_request, expected_result, expected_exception", [ @@ -784,7 +784,7 @@ async def test_is_running_no_services(mock_lonely_daemon, service_request, expec assert response == expected_result -@pytest.mark.asyncio +@pytest.mark.anyio @pytest.mark.parametrize( "service_request, expected_result, expected_exception", [ @@ -823,7 +823,7 @@ async def test_is_running_with_services( assert response == expected_result -@pytest.mark.asyncio +@pytest.mark.anyio @pytest.mark.parametrize( "service_request, expected_result, expected_exception", [ @@ -867,7 +867,7 @@ async def test_is_running_with_services_and_connections( assert response == expected_result -@pytest.mark.asyncio +@pytest.mark.anyio async def test_validate_keyring_passphrase_rpc(daemon_connection_and_temp_keychain): ws, keychain = daemon_connection_and_temp_keychain @@ -915,7 +915,7 @@ async def test_validate_keyring_passphrase_rpc(daemon_connection_and_temp_keycha assert_response(await ws.receive(), empty_passphrase_response_data) -@pytest.mark.asyncio +@pytest.mark.anyio async def test_add_private_key(daemon_connection_and_temp_keychain): ws, keychain = daemon_connection_and_temp_keychain @@ -971,7 +971,7 @@ async def test_add_private_key(daemon_connection_and_temp_keychain): assert_response(await ws.receive(), invalid_mnemonic_response_data) -@pytest.mark.asyncio +@pytest.mark.anyio async def test_add_private_key_label(daemon_connection_and_temp_keychain): ws, keychain = daemon_connection_and_temp_keychain @@ -1008,7 +1008,7 @@ async def test_add_private_key_label(daemon_connection_and_temp_keychain): ) -@pytest.mark.asyncio +@pytest.mark.anyio async def test_get_key(daemon_connection_and_temp_keychain): ws, keychain = daemon_connection_and_temp_keychain @@ -1042,7 +1042,7 @@ async def test_get_key(daemon_connection_and_temp_keychain): assert_response(await ws.receive(), fingerprint_not_found_response_data(123456)) -@pytest.mark.asyncio +@pytest.mark.anyio async def test_get_keys(daemon_connection_and_temp_keychain): ws, keychain = daemon_connection_and_temp_keychain @@ -1073,7 +1073,7 @@ async def test_get_keys(daemon_connection_and_temp_keychain): assert_response(await ws.receive(), get_keys_response_data(keys_added)) -@pytest.mark.asyncio +@pytest.mark.anyio async def test_get_public_key(daemon_connection_and_temp_keychain): ws, keychain = daemon_connection_and_temp_keychain @@ -1095,7 +1095,7 @@ async def test_get_public_key(daemon_connection_and_temp_keychain): assert key in allowed_keys, f"Unexpected key '{key}' found in response." -@pytest.mark.asyncio +@pytest.mark.anyio async def test_get_public_keys(daemon_connection_and_temp_keychain): ws, keychain = daemon_connection_and_temp_keychain @@ -1124,7 +1124,7 @@ async def test_get_public_keys(daemon_connection_and_temp_keychain): assert key in allowed_keys, f"Unexpected key '{key}' found in response." -@pytest.mark.asyncio +@pytest.mark.anyio async def test_key_renaming(daemon_connection_and_temp_keychain): ws, keychain = daemon_connection_and_temp_keychain keychain.add_private_key(test_key_data.mnemonic_str()) @@ -1148,7 +1148,7 @@ async def test_key_renaming(daemon_connection_and_temp_keychain): ) -@pytest.mark.asyncio +@pytest.mark.anyio async def test_key_label_deletion(daemon_connection_and_temp_keychain): ws, keychain = daemon_connection_and_temp_keychain @@ -1221,7 +1221,7 @@ async def test_key_label_deletion(daemon_connection_and_temp_keychain): ), ], ) -@pytest.mark.asyncio +@pytest.mark.anyio async def test_key_label_methods( daemon_connection_and_temp_keychain, method: str, parameter: Dict[str, Any], response_data_dict: Dict[str, Any] ) -> None: @@ -1231,7 +1231,7 @@ async def test_key_label_methods( assert_response(await ws.receive(), response_data_dict) -@pytest.mark.asyncio +@pytest.mark.anyio async def test_bad_json(daemon_connection_and_temp_keychain: Tuple[aiohttp.ClientWebSocketResponse, Keychain]) -> None: ws, _ = daemon_connection_and_temp_keychain @@ -1329,7 +1329,7 @@ async def test_bad_json(daemon_connection_and_temp_keychain: Tuple[aiohttp.Clien }, ), ) -@pytest.mark.asyncio +@pytest.mark.anyio async def test_misc_daemon_ws( daemon_connection_and_temp_keychain: Tuple[aiohttp.ClientWebSocketResponse, Keychain], case: RouteCase, @@ -1343,7 +1343,7 @@ async def test_misc_daemon_ws( assert_response(response, case.response) -@pytest.mark.asyncio +@pytest.mark.anyio async def test_unexpected_json( daemon_connection_and_temp_keychain: Tuple[aiohttp.ClientWebSocketResponse, Keychain] ) -> None: @@ -1363,7 +1363,7 @@ async def test_unexpected_json( "command_to_test", [("start_service"), ("stop_service"), ("start_plotting"), ("stop_plotting"), ("is_running"), ("register_service")], ) -@pytest.mark.asyncio +@pytest.mark.anyio async def test_commands_with_no_data( daemon_connection_and_temp_keychain: Tuple[aiohttp.ClientWebSocketResponse, Keychain], command_to_test: str ) -> None: @@ -1407,7 +1407,7 @@ async def test_commands_with_no_data( response={"success": True, "error": None}, ), ) -@pytest.mark.asyncio +@pytest.mark.anyio async def test_set_keyring_passphrase_ws( daemon_connection_and_temp_keychain: Tuple[aiohttp.ClientWebSocketResponse, Keychain], case: RouteCase, @@ -1510,7 +1510,7 @@ async def test_set_keyring_passphrase_ws( response={"success": True, "error": None}, ), ) -@pytest.mark.asyncio +@pytest.mark.anyio async def test_passphrase_apis( daemon_connection_and_temp_keychain: Tuple[aiohttp.ClientWebSocketResponse, Keychain], case: RouteCase, @@ -1547,7 +1547,7 @@ async def test_passphrase_apis( response={"success": False, "error": "validation exception"}, ), ) -@pytest.mark.asyncio +@pytest.mark.anyio async def test_keyring_file_deleted( daemon_connection_and_temp_keychain: Tuple[aiohttp.ClientWebSocketResponse, Keychain], case: RouteCase, @@ -1605,7 +1605,7 @@ async def test_keyring_file_deleted( }, ), ) -@pytest.mark.asyncio +@pytest.mark.anyio async def test_plotter_errors( daemon_connection_and_temp_keychain: Tuple[aiohttp.ClientWebSocketResponse, Keychain], case: RouteCase ) -> None: @@ -1718,7 +1718,7 @@ async def test_plotter_errors( }, ), ) -@pytest.mark.asyncio +@pytest.mark.anyio async def test_plotter_options( daemon_connection_and_temp_keychain: Tuple[aiohttp.ClientWebSocketResponse, Keychain], get_b_tools: BlockTools, @@ -1784,7 +1784,7 @@ def check_plot_queue_log( return plot_info["log_new"].startswith(expected_log_entry) -@pytest.mark.asyncio +@pytest.mark.anyio async def test_plotter_roundtrip( daemon_connection_and_temp_keychain: Tuple[aiohttp.ClientWebSocketResponse, Keychain], get_b_tools: BlockTools ) -> None: @@ -1856,7 +1856,7 @@ async def test_plotter_roundtrip( assert_plot_queue_response(response, "state_changed", "state_changed", plot_id, "FINISHED") -@pytest.mark.asyncio +@pytest.mark.anyio async def test_plotter_stop_plotting( daemon_connection_and_temp_keychain: Tuple[aiohttp.ClientWebSocketResponse, Keychain], get_b_tools: BlockTools ) -> None: diff --git a/tests/core/daemon/test_daemon_register.py b/tests/core/daemon/test_daemon_register.py index 416c03d350cb..ff1f3a141a71 100644 --- a/tests/core/daemon/test_daemon_register.py +++ b/tests/core/daemon/test_daemon_register.py @@ -8,7 +8,7 @@ from chia.simulator.block_tools import BlockTools from chia.util.ws_message import create_payload -@pytest.mark.asyncio +@pytest.mark.anyio async def test_multiple_register_same(get_daemon: WebSocketServer, bt: BlockTools) -> None: ws_server = get_daemon config = bt.config @@ -35,7 +35,7 @@ async def test_multiple_register_same(get_daemon: WebSocketServer, bt: BlockTool assert len(connections) == 1 -@pytest.mark.asyncio +@pytest.mark.anyio async def test_multiple_register_different(get_daemon: WebSocketServer, bt: BlockTools) -> None: ws_server = get_daemon config = bt.config @@ -71,7 +71,7 @@ async def test_multiple_register_different(get_daemon: WebSocketServer, bt: Bloc assert connections == set() -@pytest.mark.asyncio +@pytest.mark.anyio async def test_remove_connection(get_daemon: WebSocketServer, bt: BlockTools) -> None: ws_server = get_daemon config = bt.config diff --git a/tests/core/daemon/test_keychain_proxy.py b/tests/core/daemon/test_keychain_proxy.py index 3fa534d5255f..1f3391197f9c 100644 --- a/tests/core/daemon/test_keychain_proxy.py +++ b/tests/core/daemon/test_keychain_proxy.py @@ -5,7 +5,6 @@ from dataclasses import replace from typing import AsyncGenerator import pytest -import pytest_asyncio from chia.daemon.keychain_proxy import KeychainProxy, connect_to_keychain_and_validate from chia.simulator.block_tools import BlockTools @@ -17,7 +16,7 @@ TEST_KEY_2 = KeyData.generate(label="👨‍✈️🥦") TEST_KEY_3 = KeyData.generate(label="☕️🍬") -@pytest_asyncio.fixture(scope="function") +@pytest.fixture(scope="function") async def keychain_proxy(get_b_tools: BlockTools) -> AsyncGenerator[KeychainProxy, None]: async with setup_daemon(btools=get_b_tools) as daemon: log = logging.getLogger("keychain_proxy_fixture") @@ -27,14 +26,14 @@ async def keychain_proxy(get_b_tools: BlockTools) -> AsyncGenerator[KeychainProx await keychain_proxy.close() -@pytest_asyncio.fixture(scope="function") +@pytest.fixture(scope="function") async def keychain_proxy_with_keys(keychain_proxy: KeychainProxy) -> KeychainProxy: await keychain_proxy.add_private_key(TEST_KEY_1.mnemonic_str(), TEST_KEY_1.label) await keychain_proxy.add_private_key(TEST_KEY_2.mnemonic_str(), TEST_KEY_2.label) return keychain_proxy -@pytest.mark.asyncio +@pytest.mark.anyio async def test_add_private_key(keychain_proxy: KeychainProxy) -> None: keychain = keychain_proxy await keychain.add_private_key(TEST_KEY_3.mnemonic_str(), TEST_KEY_3.label) @@ -43,7 +42,7 @@ async def test_add_private_key(keychain_proxy: KeychainProxy) -> None: @pytest.mark.parametrize("include_secrets", [True, False]) -@pytest.mark.asyncio +@pytest.mark.anyio async def test_get_key(keychain_proxy_with_keys: KeychainProxy, include_secrets: bool) -> None: keychain = keychain_proxy_with_keys key = await keychain.get_key(TEST_KEY_1.fingerprint, include_secrets=include_secrets) @@ -52,7 +51,7 @@ async def test_get_key(keychain_proxy_with_keys: KeychainProxy, include_secrets: @pytest.mark.parametrize("include_secrets", [True, False]) -@pytest.mark.asyncio +@pytest.mark.anyio async def test_get_keys(keychain_proxy_with_keys: KeychainProxy, include_secrets: bool) -> None: keychain = keychain_proxy_with_keys keys = await keychain.get_keys(include_secrets=include_secrets) diff --git a/tests/core/data_layer/conftest.py b/tests/core/data_layer/conftest.py index 8858bfa1f7b8..ee15ccc59b6e 100644 --- a/tests/core/data_layer/conftest.py +++ b/tests/core/data_layer/conftest.py @@ -7,7 +7,6 @@ import time from typing import Any, AsyncIterable, Awaitable, Callable, Dict, Iterator import pytest -import pytest_asyncio # https://github.com/pytest-dev/pytest/issues/7469 from _pytest.fixtures import SubRequest @@ -60,14 +59,14 @@ def tree_id_fixture() -> bytes32: return bytes32(pad + base) -@pytest_asyncio.fixture(name="raw_data_store", scope="function") +@pytest.fixture(name="raw_data_store", scope="function") async def raw_data_store_fixture(database_uri: str) -> AsyncIterable[DataStore]: store = await DataStore.create(database=database_uri, uri=True) yield store await store.close() -@pytest_asyncio.fixture(name="data_store", scope="function") +@pytest.fixture(name="data_store", scope="function") async def data_store_fixture(raw_data_store: DataStore, tree_id: bytes32) -> AsyncIterable[DataStore]: await raw_data_store.create_tree(tree_id=tree_id, status=Status.COMMITTED) @@ -81,7 +80,7 @@ def node_type_fixture(request: SubRequest) -> NodeType: return request.param # type: ignore[no-any-return] -@pytest_asyncio.fixture(name="valid_node_values") +@pytest.fixture(name="valid_node_values") async def valid_node_values_fixture( data_store: DataStore, tree_id: bytes32, diff --git a/tests/core/data_layer/test_data_cli.py b/tests/core/data_layer/test_data_cli.py index 5c953e8ad444..51e13683d8da 100644 --- a/tests/core/data_layer/test_data_cli.py +++ b/tests/core/data_layer/test_data_cli.py @@ -10,7 +10,7 @@ from tests.core.data_layer.util import ChiaRoot pytestmark = pytest.mark.data_layer -@pytest.mark.asyncio +@pytest.mark.anyio async def test_help(chia_root: ChiaRoot) -> None: """Just a trivial test to make sure the subprocessing is at least working and the data executable does run. @@ -20,7 +20,7 @@ async def test_help(chia_root: ChiaRoot) -> None: @pytest.mark.skip -@pytest.mark.asyncio +@pytest.mark.anyio def test_round_trip(chia_root: ChiaRoot, chia_daemon: None, chia_data: None) -> None: """Create a table, insert a row, get the row by its hash.""" diff --git a/tests/core/data_layer/test_data_layer.py b/tests/core/data_layer/test_data_layer.py index 0bb07618a86f..e12fcb9dda78 100644 --- a/tests/core/data_layer/test_data_layer.py +++ b/tests/core/data_layer/test_data_layer.py @@ -7,7 +7,6 @@ from typing import Any, AsyncIterator, Awaitable, Callable, Dict, List, Optional import aiohttp import pytest -import pytest_asyncio from aiohttp import web from chia.data_layer.data_layer import DataLayer @@ -31,7 +30,7 @@ class SufficientWalletRpcClient: @pytest.mark.parametrize(argnames="enable", argvalues=[True, False], ids=["log", "do not log"]) -@pytest.mark.asyncio +@pytest.mark.anyio async def test_sql_logs(enable: bool, config: Dict[str, Any], tmp_chia_root: Path) -> None: config["data_layer"]["log_sqlite_cmds"] = enable @@ -99,7 +98,7 @@ class RecordingWebServer: await self.web_server.await_closed() -@pytest_asyncio.fixture(name="recording_web_server") +@pytest.fixture(name="recording_web_server") async def recording_web_server_fixture(self_hostname: str) -> AsyncIterator[RecordingWebServer]: server = await RecordingWebServer.create( hostname=self_hostname, @@ -111,7 +110,7 @@ async def recording_web_server_fixture(self_hostname: str) -> AsyncIterator[Reco await server.await_closed() -@pytest.mark.asyncio +@pytest.mark.anyio async def test_plugin_requests_use_custom_headers( recording_web_server: RecordingWebServer, config: Dict[str, Any], diff --git a/tests/core/data_layer/test_data_rpc.py b/tests/core/data_layer/test_data_rpc.py index 38d9260f1f50..3f490abc7a6d 100644 --- a/tests/core/data_layer/test_data_rpc.py +++ b/tests/core/data_layer/test_data_rpc.py @@ -15,7 +15,6 @@ from typing import Any, AsyncIterator, Dict, List, Optional, Tuple, cast import anyio import pytest -import pytest_asyncio from chia.cmds.data_funcs import clear_pending_roots, wallet_log_in_cmd from chia.consensus.block_rewards import calculate_base_farmer_reward, calculate_pool_reward @@ -109,7 +108,7 @@ async def init_data_layer( yield data_layer_service._api.data_layer -@pytest_asyncio.fixture(name="bare_data_layer_api") +@pytest.fixture(name="bare_data_layer_api") async def bare_data_layer_api_fixture(tmp_path: Path, bt: BlockTools) -> AsyncIterator[DataLayerRpcApi]: # we won't use this port, this fixture is for _just_ a data layer rpc port = uint16(1) @@ -215,7 +214,7 @@ def create_mnemonic(seed: bytes = b"ab") -> str: return bytes_to_mnemonic(mnemonic_bytes=bytes(random_.randrange(256) for _ in range(32))) -@pytest.mark.asyncio +@pytest.mark.anyio async def test_create_insert_get( self_hostname: str, one_wallet_and_one_simulator_services: SimulatorsAndWalletsServices, tmp_path: Path ) -> None: @@ -265,7 +264,7 @@ async def test_create_insert_get( await data_rpc_api.batch_update({"id": store_id.hex(), "changelist": changelist}) -@pytest.mark.asyncio +@pytest.mark.anyio async def test_upsert( self_hostname: str, one_wallet_and_one_simulator_services: SimulatorsAndWalletsServices, tmp_path: Path ) -> None: @@ -295,7 +294,7 @@ async def test_upsert( assert hexstr_to_bytes(res["value"]) == value -@pytest.mark.asyncio +@pytest.mark.anyio async def test_create_double_insert( self_hostname: str, one_wallet_and_one_simulator_services: SimulatorsAndWalletsServices, tmp_path: Path ) -> None: @@ -332,7 +331,7 @@ async def test_create_double_insert( await data_rpc_api.get_value({"id": store_id.hex(), "key": key1.hex()}) -@pytest.mark.asyncio +@pytest.mark.anyio async def test_keys_values_ancestors( self_hostname: str, one_wallet_and_one_simulator_services: SimulatorsAndWalletsServices, tmp_path: Path ) -> None: @@ -403,7 +402,7 @@ async def test_keys_values_ancestors( assert len(pairs_after["keys_values"]) == len(keys_after["keys"]) == 7 -@pytest.mark.asyncio +@pytest.mark.anyio async def test_get_roots( self_hostname: str, one_wallet_and_one_simulator_services: SimulatorsAndWalletsServices, tmp_path: Path ) -> None: @@ -456,7 +455,7 @@ async def test_get_roots( assert roots["root_hashes"][1]["timestamp"] > 0 -@pytest.mark.asyncio +@pytest.mark.anyio async def test_get_root_history( self_hostname: str, one_wallet_and_one_simulator_services: SimulatorsAndWalletsServices, tmp_path: Path ) -> None: @@ -510,7 +509,7 @@ async def test_get_root_history( assert history2["root_history"][2]["timestamp"] > history2["root_history"][1]["timestamp"] -@pytest.mark.asyncio +@pytest.mark.anyio async def test_get_kv_diff( self_hostname: str, one_wallet_and_one_simulator_services: SimulatorsAndWalletsServices, tmp_path: Path ) -> None: @@ -577,7 +576,7 @@ async def test_get_kv_diff( assert diff1 in diff_res["diff"] -@pytest.mark.asyncio +@pytest.mark.anyio async def test_batch_update_matches_single_operations( self_hostname: str, one_wallet_and_one_simulator_services: SimulatorsAndWalletsServices, tmp_path: Path ) -> None: @@ -649,7 +648,7 @@ async def test_batch_update_matches_single_operations( assert batch_hash == expected_res_hash -@pytest.mark.asyncio +@pytest.mark.anyio async def test_get_owned_stores( self_hostname: str, one_wallet_and_one_simulator_services: SimulatorsAndWalletsServices, tmp_path: Path ) -> None: @@ -689,7 +688,7 @@ async def test_get_owned_stores( assert store_ids == sorted(expected_store_ids) -@pytest.mark.asyncio +@pytest.mark.anyio async def test_subscriptions( self_hostname: str, one_wallet_and_one_simulator_services: SimulatorsAndWalletsServices, tmp_path: Path ) -> None: @@ -736,7 +735,7 @@ class OfferSetup: full_node_api: FullNodeSimulator -@pytest_asyncio.fixture(name="offer_setup") +@pytest.fixture(name="offer_setup") async def offer_setup_fixture( self_hostname: str, two_wallet_nodes_services: SimulatorsAndWalletsServices, @@ -1482,7 +1481,7 @@ make_one_take_one_unpopulated_reference = MakeAndTakeReference( pytest.param(make_one_take_one_unpopulated_reference, id="one for one unpopulated"), ], ) -@pytest.mark.asyncio +@pytest.mark.anyio async def test_make_and_take_offer(offer_setup: OfferSetup, reference: MakeAndTakeReference) -> None: offer_setup = await populate_offer_setup(offer_setup=offer_setup, count=reference.entries_to_insert) @@ -1569,7 +1568,7 @@ async def test_make_and_take_offer(offer_setup: OfferSetup, reference: MakeAndTa ], ) @pytest.mark.parametrize(argnames="maker_or_taker", argvalues=["maker", "taker"]) -@pytest.mark.asyncio +@pytest.mark.anyio async def test_make_and_then_take_offer_invalid_inclusion_key( reference: MakeAndTakeReference, maker_or_taker: str, @@ -1594,7 +1593,7 @@ async def test_make_and_then_take_offer_invalid_inclusion_key( ) -@pytest.mark.asyncio +@pytest.mark.anyio async def test_verify_offer_rpc_valid(bare_data_layer_api: DataLayerRpcApi) -> None: reference = make_one_take_one_reference @@ -1612,7 +1611,7 @@ async def test_verify_offer_rpc_valid(bare_data_layer_api: DataLayerRpcApi) -> N } -@pytest.mark.asyncio +@pytest.mark.anyio async def test_verify_offer_rpc_invalid(bare_data_layer_api: DataLayerRpcApi) -> None: reference = make_one_take_one_reference broken_taker_offer = copy.deepcopy(reference.make_offer_response) @@ -1632,7 +1631,7 @@ async def test_verify_offer_rpc_invalid(bare_data_layer_api: DataLayerRpcApi) -> } -@pytest.mark.asyncio +@pytest.mark.anyio async def test_make_offer_failure_rolls_back_db(offer_setup: OfferSetup) -> None: # TODO: only needs the maker and db? wallet? reference = make_one_take_one_reference @@ -1674,7 +1673,7 @@ async def test_make_offer_failure_rolls_back_db(offer_setup: OfferSetup) -> None pytest.param(make_one_take_one_unpopulated_reference, id="one for one unpopulated"), ], ) -@pytest.mark.asyncio +@pytest.mark.anyio async def test_make_and_cancel_offer(offer_setup: OfferSetup, reference: MakeAndTakeReference) -> None: offer_setup = await populate_offer_setup(offer_setup=offer_setup, count=reference.entries_to_insert) @@ -1750,7 +1749,7 @@ async def test_make_and_cancel_offer(offer_setup: OfferSetup, reference: MakeAnd pytest.param(False, id="insecure"), ], ) -@pytest.mark.asyncio +@pytest.mark.anyio async def test_make_and_cancel_offer_then_update( offer_setup: OfferSetup, reference: MakeAndTakeReference, secure: bool ) -> None: @@ -1839,7 +1838,7 @@ async def test_make_and_cancel_offer_then_update( pytest.param(make_one_take_one_unpopulated_reference, id="one for one unpopulated"), ], ) -@pytest.mark.asyncio +@pytest.mark.anyio async def test_make_and_cancel_offer_not_secure_clears_pending_roots( offer_setup: OfferSetup, reference: MakeAndTakeReference, @@ -1881,7 +1880,7 @@ async def test_make_and_cancel_offer_not_secure_clears_pending_roots( @pytest.mark.limit_consensus_modes(reason="does not depend on consensus rules") -@pytest.mark.asyncio +@pytest.mark.anyio async def test_get_sync_status( self_hostname: str, one_wallet_and_one_simulator_services: SimulatorsAndWalletsServices, tmp_path: Path ) -> None: @@ -1938,7 +1937,7 @@ async def test_get_sync_status( @pytest.mark.limit_consensus_modes(reason="does not depend on consensus rules") @pytest.mark.parametrize(argnames="layer", argvalues=list(InterfaceLayer)) -@pytest.mark.asyncio +@pytest.mark.anyio async def test_clear_pending_roots( self_hostname: str, one_wallet_and_one_simulator_services: SimulatorsAndWalletsServices, @@ -2035,7 +2034,7 @@ async def test_clear_pending_roots( @pytest.mark.limit_consensus_modes(reason="does not depend on consensus rules") -@pytest.mark.asyncio +@pytest.mark.anyio async def test_issue_15955_deadlock( self_hostname: str, one_wallet_and_one_simulator_services: SimulatorsAndWalletsServices, tmp_path: Path ) -> None: @@ -2091,7 +2090,7 @@ async def test_issue_15955_deadlock( @pytest.mark.parametrize(argnames="maximum_full_file_count", argvalues=[1, 5, 100]) -@pytest.mark.asyncio +@pytest.mark.anyio async def test_maximum_full_file_count( self_hostname: str, one_wallet_and_one_simulator_services: SimulatorsAndWalletsServices, @@ -2144,7 +2143,7 @@ async def test_maximum_full_file_count( @pytest.mark.parametrize("retain", [True, False]) @pytest.mark.limit_consensus_modes(reason="does not depend on consensus rules") -@pytest.mark.asyncio +@pytest.mark.anyio async def test_unsubscribe_removes_files( self_hostname: str, one_wallet_and_one_simulator_services: SimulatorsAndWalletsServices, @@ -2194,7 +2193,7 @@ async def test_unsubscribe_removes_files( @pytest.mark.parametrize(argnames="layer", argvalues=list(InterfaceLayer)) @pytest.mark.limit_consensus_modes(reason="does not depend on consensus rules") -@pytest.mark.asyncio +@pytest.mark.anyio async def test_wallet_log_in_changes_active_fingerprint( self_hostname: str, one_wallet_and_one_simulator_services: SimulatorsAndWalletsServices, diff --git a/tests/core/data_layer/test_data_store.py b/tests/core/data_layer/test_data_store.py index 369993993193..44b6d0d809fc 100644 --- a/tests/core/data_layer/test_data_store.py +++ b/tests/core/data_layer/test_data_store.py @@ -62,7 +62,7 @@ table_columns: Dict[str, List[str]] = { # and with good error messages. -@pytest.mark.asyncio +@pytest.mark.anyio async def test_valid_node_values_fixture_are_valid(data_store: DataStore, valid_node_values: Dict[str, Any]) -> None: async with data_store.db_wrapper.writer() as writer: await writer.execute( @@ -75,7 +75,7 @@ async def test_valid_node_values_fixture_are_valid(data_store: DataStore, valid_ @pytest.mark.parametrize(argnames=["table_name", "expected_columns"], argvalues=table_columns.items()) -@pytest.mark.asyncio +@pytest.mark.anyio async def test_create_creates_tables_and_columns( database_uri: str, table_name: str, expected_columns: List[str] ) -> None: @@ -102,7 +102,7 @@ async def test_create_creates_tables_and_columns( await db_wrapper.close() -@pytest.mark.asyncio +@pytest.mark.anyio async def test_create_tree_accepts_bytes32(raw_data_store: DataStore) -> None: tree_id = bytes32(b"\0" * 32) @@ -110,7 +110,7 @@ async def test_create_tree_accepts_bytes32(raw_data_store: DataStore) -> None: @pytest.mark.parametrize(argnames=["length"], argvalues=[[length] for length in [*range(0, 32), *range(33, 48)]]) -@pytest.mark.asyncio +@pytest.mark.anyio async def test_create_tree_fails_for_not_bytes32(raw_data_store: DataStore, length: int) -> None: bad_tree_id = b"\0" * length @@ -120,7 +120,7 @@ async def test_create_tree_fails_for_not_bytes32(raw_data_store: DataStore, leng await raw_data_store.create_tree(tree_id=bad_tree_id) # type: ignore[arg-type] -@pytest.mark.asyncio +@pytest.mark.anyio async def test_get_trees(raw_data_store: DataStore) -> None: expected_tree_ids = set() @@ -134,13 +134,13 @@ async def test_get_trees(raw_data_store: DataStore) -> None: assert tree_ids == expected_tree_ids -@pytest.mark.asyncio +@pytest.mark.anyio async def test_table_is_empty(data_store: DataStore, tree_id: bytes32) -> None: is_empty = await data_store.table_is_empty(tree_id=tree_id) assert is_empty -@pytest.mark.asyncio +@pytest.mark.anyio async def test_table_is_not_empty(data_store: DataStore, tree_id: bytes32) -> None: key = b"\x01\x02" value = b"abc" @@ -158,7 +158,7 @@ async def test_table_is_not_empty(data_store: DataStore, tree_id: bytes32) -> No assert not is_empty -# @pytest.mark.asyncio +# @pytest.mark.anyio # async def test_create_root_provides_bytes32(raw_data_store: DataStore, tree_id: bytes32) -> None: # await raw_data_store.create_tree(tree_id=tree_id) # # TODO: catchup with the node_hash= @@ -167,7 +167,7 @@ async def test_table_is_not_empty(data_store: DataStore, tree_id: bytes32) -> No # assert isinstance(root_hash, bytes32) -@pytest.mark.asyncio +@pytest.mark.anyio async def test_insert_over_empty(data_store: DataStore, tree_id: bytes32) -> None: key = b"\x01\x02" value = b"abc" @@ -176,7 +176,7 @@ async def test_insert_over_empty(data_store: DataStore, tree_id: bytes32) -> Non assert insert_result.node_hash == leaf_hash(key=key, value=value) -@pytest.mark.asyncio +@pytest.mark.anyio async def test_insert_increments_generation(data_store: DataStore, tree_id: bytes32) -> None: keys = [b"a", b"b", b"c", b"d"] # efghijklmnopqrstuvwxyz") value = b"\x01\x02\x03" @@ -202,7 +202,7 @@ async def test_insert_increments_generation(data_store: DataStore, tree_id: byte assert generations == expected -@pytest.mark.asyncio +@pytest.mark.anyio async def test_get_tree_generation_returns_none_when_none_available( raw_data_store: DataStore, tree_id: bytes32, @@ -211,7 +211,7 @@ async def test_get_tree_generation_returns_none_when_none_available( await raw_data_store.get_tree_generation(tree_id=tree_id) -@pytest.mark.asyncio +@pytest.mark.anyio async def test_insert_internal_node_does_nothing_if_matching(data_store: DataStore, tree_id: bytes32) -> None: await add_01234567_example(data_store=data_store, tree_id=tree_id) @@ -232,7 +232,7 @@ async def test_insert_internal_node_does_nothing_if_matching(data_store: DataSto assert after == before -@pytest.mark.asyncio +@pytest.mark.anyio async def test_insert_terminal_node_does_nothing_if_matching(data_store: DataStore, tree_id: bytes32) -> None: await add_01234567_example(data_store=data_store, tree_id=tree_id) @@ -251,7 +251,7 @@ async def test_insert_terminal_node_does_nothing_if_matching(data_store: DataSto assert after == before -@pytest.mark.asyncio +@pytest.mark.anyio async def test_build_a_tree( data_store: DataStore, tree_id: bytes32, @@ -266,7 +266,7 @@ async def test_build_a_tree( assert actual == example.expected -@pytest.mark.asyncio +@pytest.mark.anyio async def test_get_node_by_key(data_store: DataStore, tree_id: bytes32) -> None: example = await add_0123_example(data_store=data_store, tree_id=tree_id) @@ -278,7 +278,7 @@ async def test_get_node_by_key(data_store: DataStore, tree_id: bytes32) -> None: assert actual.hash == key_node_hash -@pytest.mark.asyncio +@pytest.mark.anyio async def test_get_ancestors(data_store: DataStore, tree_id: bytes32) -> None: example = await add_0123_example(data_store=data_store, tree_id=tree_id) @@ -297,7 +297,7 @@ async def test_get_ancestors(data_store: DataStore, tree_id: bytes32) -> None: assert ancestors == ancestors_2 -@pytest.mark.asyncio +@pytest.mark.anyio async def test_get_ancestors_optimized(data_store: DataStore, tree_id: bytes32) -> None: ancestors: List[Tuple[int, bytes32, List[InternalNode]]] = [] random = Random() @@ -371,7 +371,7 @@ async def test_get_ancestors_optimized(data_store: DataStore, tree_id: bytes32) assert current_ancestors == expected_ancestors -@pytest.mark.asyncio +@pytest.mark.anyio @pytest.mark.parametrize( "use_optimized", [True, False], @@ -457,7 +457,7 @@ async def test_batch_update(data_store: DataStore, tree_id: bytes32, use_optimiz @pytest.mark.parametrize(argnames="side", argvalues=list(Side)) -@pytest.mark.asyncio +@pytest.mark.anyio async def test_insert_batch_reference_and_side( data_store: DataStore, tree_id: bytes32, @@ -496,7 +496,7 @@ async def test_insert_batch_reference_and_side( raise Exception("invalid side for test") -@pytest.mark.asyncio +@pytest.mark.anyio async def test_ancestor_table_unique_inserts(data_store: DataStore, tree_id: bytes32) -> None: await add_0123_example(data_store=data_store, tree_id=tree_id) hash_1 = bytes32.from_hexstr("0763561814685fbf92f6ca71fbb1cb11821951450d996375c239979bd63e9535") @@ -508,7 +508,7 @@ async def test_ancestor_table_unique_inserts(data_store: DataStore, tree_id: byt await data_store._insert_ancestor_table(hash_1, hash_2, tree_id, 2) -@pytest.mark.asyncio +@pytest.mark.anyio async def test_get_pairs( data_store: DataStore, tree_id: bytes32, @@ -521,7 +521,7 @@ async def test_get_pairs( assert [node.hash for node in pairs] == example.terminal_nodes -@pytest.mark.asyncio +@pytest.mark.anyio async def test_get_pairs_when_empty(data_store: DataStore, tree_id: bytes32) -> None: pairs = await data_store.get_keys_values(tree_id=tree_id) @@ -533,7 +533,7 @@ async def test_get_pairs_when_empty(data_store: DataStore, tree_id: bytes32) -> argvalues=[[b"\x06", b"\x06"], [b"\x06", b"\x07"]], ids=["same values", "different values"], ) -@pytest.mark.asyncio() +@pytest.mark.anyio() async def test_inserting_duplicate_key_fails( data_store: DataStore, tree_id: bytes32, @@ -573,7 +573,7 @@ async def test_inserting_duplicate_key_fails( ) -@pytest.mark.asyncio() +@pytest.mark.anyio() async def test_inserting_invalid_length_hash_raises_original_exception( data_store: DataStore, ) -> None: @@ -589,7 +589,7 @@ async def test_inserting_invalid_length_hash_raises_original_exception( ) -@pytest.mark.asyncio() +@pytest.mark.anyio() async def test_inserting_invalid_length_ancestor_hash_raises_original_exception( data_store: DataStore, tree_id: bytes32, @@ -604,7 +604,7 @@ async def test_inserting_invalid_length_ancestor_hash_raises_original_exception( ) -@pytest.mark.asyncio() +@pytest.mark.anyio() async def test_autoinsert_balances_from_scratch(data_store: DataStore, tree_id: bytes32) -> None: random = Random() random.seed(100, version=2) @@ -623,7 +623,7 @@ async def test_autoinsert_balances_from_scratch(data_store: DataStore, tree_id: assert 11 <= statistics.mean(heights.values()) <= 12 -@pytest.mark.asyncio() +@pytest.mark.anyio() async def test_autoinsert_balances_gaps(data_store: DataStore, tree_id: bytes32) -> None: random = Random() random.seed(101, version=2) @@ -660,7 +660,7 @@ async def test_autoinsert_balances_gaps(data_store: DataStore, tree_id: bytes32) "use_hint", [True, False], ) -@pytest.mark.asyncio() +@pytest.mark.anyio() async def test_delete_from_left_both_terminal(data_store: DataStore, tree_id: bytes32, use_hint: bool) -> None: await add_01234567_example(data_store=data_store, tree_id=tree_id) @@ -702,7 +702,7 @@ async def test_delete_from_left_both_terminal(data_store: DataStore, tree_id: by "use_hint", [True, False], ) -@pytest.mark.asyncio() +@pytest.mark.anyio() async def test_delete_from_left_other_not_terminal(data_store: DataStore, tree_id: bytes32, use_hint: bool) -> None: await add_01234567_example(data_store=data_store, tree_id=tree_id) @@ -744,7 +744,7 @@ async def test_delete_from_left_other_not_terminal(data_store: DataStore, tree_i "use_hint", [True, False], ) -@pytest.mark.asyncio() +@pytest.mark.anyio() async def test_delete_from_right_both_terminal(data_store: DataStore, tree_id: bytes32, use_hint: bool) -> None: await add_01234567_example(data_store=data_store, tree_id=tree_id) @@ -786,7 +786,7 @@ async def test_delete_from_right_both_terminal(data_store: DataStore, tree_id: b "use_hint", [True, False], ) -@pytest.mark.asyncio() +@pytest.mark.anyio() async def test_delete_from_right_other_not_terminal(data_store: DataStore, tree_id: bytes32, use_hint: bool) -> None: await add_01234567_example(data_store=data_store, tree_id=tree_id) @@ -824,7 +824,7 @@ async def test_delete_from_right_other_not_terminal(data_store: DataStore, tree_ assert result == expected -@pytest.mark.asyncio +@pytest.mark.anyio async def test_proof_of_inclusion_by_hash(data_store: DataStore, tree_id: bytes32) -> None: """A proof of inclusion contains the expected sibling side, sibling hash, combined hash, key, value, and root hash values. @@ -860,7 +860,7 @@ async def test_proof_of_inclusion_by_hash(data_store: DataStore, tree_id: bytes3 assert proof == ProofOfInclusion(node_hash=node.hash, layers=expected_layers) -@pytest.mark.asyncio +@pytest.mark.anyio async def test_proof_of_inclusion_by_hash_no_ancestors(data_store: DataStore, tree_id: bytes32) -> None: """Check proper proof of inclusion creation when the node being proved is the root.""" await data_store.autoinsert(key=b"\x04", value=b"\x03", tree_id=tree_id, status=Status.COMMITTED) @@ -873,7 +873,7 @@ async def test_proof_of_inclusion_by_hash_no_ancestors(data_store: DataStore, tr assert proof == ProofOfInclusion(node_hash=node.hash, layers=[]) -@pytest.mark.asyncio +@pytest.mark.anyio async def test_proof_of_inclusion_by_hash_program(data_store: DataStore, tree_id: bytes32) -> None: """The proof of inclusion program has the expected Python equivalence.""" @@ -892,7 +892,7 @@ async def test_proof_of_inclusion_by_hash_program(data_store: DataStore, tree_id ] -@pytest.mark.asyncio +@pytest.mark.anyio async def test_proof_of_inclusion_by_hash_equals_by_key(data_store: DataStore, tree_id: bytes32) -> None: """The proof of inclusion is equal between hash and key requests.""" @@ -905,7 +905,7 @@ async def test_proof_of_inclusion_by_hash_equals_by_key(data_store: DataStore, t assert proof_by_hash == proof_by_key -@pytest.mark.asyncio +@pytest.mark.anyio async def test_proof_of_inclusion_by_hash_bytes(data_store: DataStore, tree_id: bytes32) -> None: """The proof of inclusion provided by the data store is able to be converted to a program and subsequently to bytes. @@ -926,7 +926,7 @@ async def test_proof_of_inclusion_by_hash_bytes(data_store: DataStore, tree_id: assert bytes(proof.as_program()) == expected -# @pytest.mark.asyncio +# @pytest.mark.anyio # async def test_create_first_pair(data_store: DataStore, tree_id: bytes) -> None: # key = SExp.to([1, 2]) # value = SExp.to(b'abc') @@ -950,7 +950,7 @@ valid_program_hex = Program.to((b"abc", 2)).as_bin().hex() invalid_program_hex = b"\xab\xcd".hex() -@pytest.mark.asyncio +@pytest.mark.anyio async def test_check_roots_are_incrementing_missing_zero(raw_data_store: DataStore) -> None: tree_id = hexstr_to_bytes("c954ab71ffaf5b0f129b04b35fdc7c84541f4375167e730e2646bfcfdb7cf2cd") @@ -976,7 +976,7 @@ async def test_check_roots_are_incrementing_missing_zero(raw_data_store: DataSto await raw_data_store._check_roots_are_incrementing() -@pytest.mark.asyncio +@pytest.mark.anyio async def test_check_roots_are_incrementing_gap(raw_data_store: DataStore) -> None: tree_id = hexstr_to_bytes("c954ab71ffaf5b0f129b04b35fdc7c84541f4375167e730e2646bfcfdb7cf2cd") @@ -1002,7 +1002,7 @@ async def test_check_roots_are_incrementing_gap(raw_data_store: DataStore) -> No await raw_data_store._check_roots_are_incrementing() -@pytest.mark.asyncio +@pytest.mark.anyio async def test_check_hashes_internal(raw_data_store: DataStore) -> None: async with raw_data_store.db_wrapper.writer() as writer: await writer.execute( @@ -1022,7 +1022,7 @@ async def test_check_hashes_internal(raw_data_store: DataStore) -> None: await raw_data_store._check_hashes() -@pytest.mark.asyncio +@pytest.mark.anyio async def test_check_hashes_terminal(raw_data_store: DataStore) -> None: async with raw_data_store.db_wrapper.writer() as writer: await writer.execute( @@ -1042,7 +1042,7 @@ async def test_check_hashes_terminal(raw_data_store: DataStore) -> None: await raw_data_store._check_hashes() -@pytest.mark.asyncio +@pytest.mark.anyio async def test_root_state(data_store: DataStore, tree_id: bytes32) -> None: key = b"\x01\x02" value = b"abc" @@ -1053,7 +1053,7 @@ async def test_root_state(data_store: DataStore, tree_id: bytes32) -> None: assert is_empty -@pytest.mark.asyncio +@pytest.mark.anyio async def test_change_root_state(data_store: DataStore, tree_id: bytes32) -> None: key = b"\x01\x02" value = b"abc" @@ -1073,7 +1073,7 @@ async def test_change_root_state(data_store: DataStore, tree_id: bytes32) -> Non assert root.node_hash is not None -@pytest.mark.asyncio +@pytest.mark.anyio async def test_kv_diff(data_store: DataStore, tree_id: bytes32) -> None: random = Random() random.seed(100, version=2) @@ -1118,7 +1118,7 @@ async def test_kv_diff(data_store: DataStore, tree_id: bytes32) -> None: assert diffs == expected_diff -@pytest.mark.asyncio +@pytest.mark.anyio async def test_kv_diff_2(data_store: DataStore, tree_id: bytes32) -> None: insert_result = await data_store.insert( key=b"000", @@ -1137,7 +1137,7 @@ async def test_kv_diff_2(data_store: DataStore, tree_id: bytes32) -> None: assert diff_3 == set() -@pytest.mark.asyncio +@pytest.mark.anyio async def test_rollback_to_generation(data_store: DataStore, tree_id: bytes32) -> None: await add_0123_example(data_store, tree_id) expected_hashes = [] @@ -1150,7 +1150,7 @@ async def test_rollback_to_generation(data_store: DataStore, tree_id: bytes32) - assert root.node_hash == expected_hash -@pytest.mark.asyncio +@pytest.mark.anyio async def test_subscribe_unsubscribe(data_store: DataStore, tree_id: bytes32) -> None: await data_store.subscribe(Subscription(tree_id, [ServerInfo("http://127:0:0:1/8000", 1, 1)])) subscriptions = await data_store.get_subscriptions() @@ -1197,7 +1197,7 @@ async def test_subscribe_unsubscribe(data_store: DataStore, tree_id: bytes32) -> ] -@pytest.mark.asyncio +@pytest.mark.anyio async def test_server_selection(data_store: DataStore, tree_id: bytes32) -> None: start_timestamp = 1000 await data_store.subscribe( @@ -1262,7 +1262,7 @@ async def test_server_selection(data_store: DataStore, tree_id: bytes32) -> None "test_delta", [True, False], ) -@pytest.mark.asyncio +@pytest.mark.anyio async def test_data_server_files(data_store: DataStore, tree_id: bytes32, test_delta: bool, tmp_path: Path) -> None: roots: List[Root] = [] num_batches = 10 @@ -1313,7 +1313,7 @@ async def test_data_server_files(data_store: DataStore, tree_id: bytes32, test_d generation += 1 -@pytest.mark.asyncio +@pytest.mark.anyio async def test_pending_roots(data_store: DataStore, tree_id: bytes32) -> None: key = b"\x01\x02" value = b"abc" @@ -1345,7 +1345,7 @@ async def test_pending_roots(data_store: DataStore, tree_id: bytes32) -> None: assert pending_root is None -@pytest.mark.asyncio +@pytest.mark.anyio async def test_clear_pending_roots_returns_root(data_store: DataStore, tree_id: bytes32) -> None: key = b"\x01\x02" value = b"abc" @@ -1398,7 +1398,7 @@ class BatchInsertBenchmarkCase: limit=36, ), ) -@pytest.mark.asyncio +@pytest.mark.anyio async def test_benchmark_batch_insert_speed( data_store: DataStore, tree_id: bytes32, diff --git a/tests/core/data_layer/test_data_store_schema.py b/tests/core/data_layer/test_data_store_schema.py index fc63d8a2e6f3..8ad2561675a7 100644 --- a/tests/core/data_layer/test_data_store_schema.py +++ b/tests/core/data_layer/test_data_store_schema.py @@ -13,7 +13,7 @@ from tests.core.data_layer.util import add_01234567_example, create_valid_node_v pytestmark = pytest.mark.data_layer -@pytest.mark.asyncio +@pytest.mark.anyio async def test_node_update_fails(data_store: DataStore, tree_id: bytes32) -> None: await add_01234567_example(data_store=data_store, tree_id=tree_id) node = await data_store.get_node_by_key(key=b"\x04", tree_id=tree_id) @@ -30,7 +30,7 @@ async def test_node_update_fails(data_store: DataStore, tree_id: bytes32) -> Non @pytest.mark.parametrize(argnames="length", argvalues=sorted(set(range(50)) - {32})) -@pytest.mark.asyncio +@pytest.mark.anyio async def test_node_hash_must_be_32( data_store: DataStore, tree_id: bytes32, @@ -50,7 +50,7 @@ async def test_node_hash_must_be_32( ) -@pytest.mark.asyncio +@pytest.mark.anyio async def test_node_hash_must_not_be_null( data_store: DataStore, tree_id: bytes32, @@ -69,7 +69,7 @@ async def test_node_hash_must_not_be_null( ) -@pytest.mark.asyncio +@pytest.mark.anyio async def test_node_type_must_be_valid( data_store: DataStore, node_type: NodeType, @@ -90,7 +90,7 @@ async def test_node_type_must_be_valid( @pytest.mark.parametrize(argnames="side", argvalues=Side) -@pytest.mark.asyncio +@pytest.mark.anyio async def test_node_internal_child_not_null(data_store: DataStore, tree_id: bytes32, side: Side) -> None: await add_01234567_example(data_store=data_store, tree_id=tree_id) node_a = await data_store.get_node_by_key(key=b"\x02", tree_id=tree_id) @@ -116,7 +116,7 @@ async def test_node_internal_child_not_null(data_store: DataStore, tree_id: byte @pytest.mark.parametrize(argnames="bad_child_hash", argvalues=[b"\x01" * 32, b"\0" * 31, b""]) @pytest.mark.parametrize(argnames="side", argvalues=Side) -@pytest.mark.asyncio +@pytest.mark.anyio async def test_node_internal_must_be_valid_reference( data_store: DataStore, tree_id: bytes32, @@ -148,7 +148,7 @@ async def test_node_internal_must_be_valid_reference( @pytest.mark.parametrize(argnames="key_or_value", argvalues=["key", "value"]) -@pytest.mark.asyncio +@pytest.mark.anyio async def test_node_terminal_key_value_not_null(data_store: DataStore, tree_id: bytes32, key_or_value: str) -> None: await add_01234567_example(data_store=data_store, tree_id=tree_id) @@ -167,7 +167,7 @@ async def test_node_terminal_key_value_not_null(data_store: DataStore, tree_id: @pytest.mark.parametrize(argnames="length", argvalues=sorted(set(range(50)) - {32})) -@pytest.mark.asyncio +@pytest.mark.anyio async def test_root_tree_id_must_be_32(data_store: DataStore, tree_id: bytes32, length: int) -> None: example = await add_01234567_example(data_store=data_store, tree_id=tree_id) bad_tree_id = bytes([0] * length) @@ -184,7 +184,7 @@ async def test_root_tree_id_must_be_32(data_store: DataStore, tree_id: bytes32, ) -@pytest.mark.asyncio +@pytest.mark.anyio async def test_root_tree_id_must_not_be_null(data_store: DataStore, tree_id: bytes32) -> None: example = await add_01234567_example(data_store=data_store, tree_id=tree_id) values = {"tree_id": None, "generation": 0, "node_hash": example.terminal_nodes[0], "status": Status.PENDING} @@ -201,7 +201,7 @@ async def test_root_tree_id_must_not_be_null(data_store: DataStore, tree_id: byt @pytest.mark.parametrize(argnames="generation", argvalues=[-200, -2, -1]) -@pytest.mark.asyncio +@pytest.mark.anyio async def test_root_generation_must_not_be_less_than_zero( data_store: DataStore, tree_id: bytes32, generation: int ) -> None: @@ -224,7 +224,7 @@ async def test_root_generation_must_not_be_less_than_zero( ) -@pytest.mark.asyncio +@pytest.mark.anyio async def test_root_generation_must_not_be_null(data_store: DataStore, tree_id: bytes32) -> None: example = await add_01234567_example(data_store=data_store, tree_id=tree_id) values = { @@ -245,7 +245,7 @@ async def test_root_generation_must_not_be_null(data_store: DataStore, tree_id: ) -@pytest.mark.asyncio +@pytest.mark.anyio async def test_root_node_hash_must_reference(data_store: DataStore) -> None: values = {"tree_id": bytes32([0] * 32), "generation": 0, "node_hash": bytes32([0] * 32), "status": Status.PENDING} @@ -261,7 +261,7 @@ async def test_root_node_hash_must_reference(data_store: DataStore) -> None: @pytest.mark.parametrize(argnames="bad_status", argvalues=sorted(set(range(-20, 20)) - {*Status})) -@pytest.mark.asyncio +@pytest.mark.anyio async def test_root_status_must_be_valid(data_store: DataStore, tree_id: bytes32, bad_status: int) -> None: example = await add_01234567_example(data_store=data_store, tree_id=tree_id) values = { @@ -282,7 +282,7 @@ async def test_root_status_must_be_valid(data_store: DataStore, tree_id: bytes32 ) -@pytest.mark.asyncio +@pytest.mark.anyio async def test_root_status_must_not_be_null(data_store: DataStore, tree_id: bytes32) -> None: example = await add_01234567_example(data_store=data_store, tree_id=tree_id) values = {"tree_id": bytes32([0] * 32), "generation": 0, "node_hash": example.terminal_nodes[0], "status": None} @@ -298,7 +298,7 @@ async def test_root_status_must_not_be_null(data_store: DataStore, tree_id: byte ) -@pytest.mark.asyncio +@pytest.mark.anyio async def test_root_tree_id_generation_must_be_unique(data_store: DataStore, tree_id: bytes32) -> None: example = await add_01234567_example(data_store=data_store, tree_id=tree_id) values = {"tree_id": tree_id, "generation": 0, "node_hash": example.terminal_nodes[0], "status": Status.COMMITTED} @@ -315,7 +315,7 @@ async def test_root_tree_id_generation_must_be_unique(data_store: DataStore, tre @pytest.mark.parametrize(argnames="length", argvalues=sorted(set(range(50)) - {32})) -@pytest.mark.asyncio +@pytest.mark.anyio async def test_ancestors_ancestor_must_be_32( data_store: DataStore, tree_id: bytes32, @@ -334,7 +334,7 @@ async def test_ancestors_ancestor_must_be_32( @pytest.mark.parametrize(argnames="length", argvalues=sorted(set(range(50)) - {32})) -@pytest.mark.asyncio +@pytest.mark.anyio async def test_ancestors_tree_id_must_be_32( data_store: DataStore, tree_id: bytes32, @@ -353,7 +353,7 @@ async def test_ancestors_tree_id_must_be_32( @pytest.mark.parametrize(argnames="length", argvalues=sorted(set(range(50)) - {32})) -@pytest.mark.asyncio +@pytest.mark.anyio async def test_subscriptions_tree_id_must_be_32( data_store: DataStore, tree_id: bytes32, diff --git a/tests/core/farmer/test_farmer_api.py b/tests/core/farmer/test_farmer_api.py index 73829442001b..a979cbe7657a 100644 --- a/tests/core/farmer/test_farmer_api.py +++ b/tests/core/farmer/test_farmer_api.py @@ -26,7 +26,7 @@ async def begin_task(coro: Coroutine[Any, Any, T]) -> Task[T]: return task -@pytest.mark.asyncio +@pytest.mark.anyio async def test_farmer_ignores_concurrent_duplicate_signage_points( farmer_one_harvester: FarmerOneHarvester, self_hostname: str ) -> None: @@ -54,7 +54,7 @@ async def test_farmer_ignores_concurrent_duplicate_signage_points( assert ProtocolMessageTypes(response).name == "new_signage_point_harvester" -@pytest.mark.asyncio +@pytest.mark.anyio async def test_farmer_responds_with_signed_values(farmer_one_harvester: FarmerOneHarvester, self_hostname: str) -> None: _, farmer_service, _ = farmer_one_harvester farmer_api: FarmerAPI = farmer_service._api diff --git a/tests/core/full_node/conftest.py b/tests/core/full_node/conftest.py deleted file mode 100644 index 1561624145c8..000000000000 --- a/tests/core/full_node/conftest.py +++ /dev/null @@ -1,17 +0,0 @@ -from __future__ import annotations - -import asyncio -from typing import Iterator - -import pytest - - -# This is an optimization to reduce runtime by reducing setup and teardown on the -# wallet nodes fixture below. -# https://github.com/pytest-dev/pytest-asyncio/blob/v0.18.1/pytest_asyncio/plugin.py#L479-L484 -@pytest.fixture(scope="module") -def event_loop(request: pytest.FixtureRequest) -> Iterator[asyncio.AbstractEventLoop]: - """Create an instance of the default event loop for each test case.""" - loop = asyncio.get_event_loop_policy().new_event_loop() - yield loop - loop.close() diff --git a/tests/core/full_node/full_sync/test_full_sync.py b/tests/core/full_node/full_sync/test_full_sync.py index b62eb4a1b9ca..a6617fea3f25 100644 --- a/tests/core/full_node/full_sync/test_full_sync.py +++ b/tests/core/full_node/full_sync/test_full_sync.py @@ -27,7 +27,7 @@ log = logging.getLogger(__name__) class TestFullSync: - @pytest.mark.asyncio + @pytest.mark.anyio async def test_long_sync_from_zero(self, five_nodes, default_400_blocks, bt, self_hostname): # Must be larger than "sync_block_behind_threshold" in the config num_blocks = len(default_400_blocks) @@ -113,7 +113,7 @@ class TestFullSync: await time_out_assert(timeout_seconds, node_height_exactly, True, full_node_5, 409) await time_out_assert(timeout_seconds, node_height_exactly, True, full_node_1, 409) - @pytest.mark.asyncio + @pytest.mark.anyio async def test_sync_from_fork_point_and_weight_proof( self, three_nodes, default_1000_blocks, default_400_blocks, self_hostname ): @@ -186,7 +186,7 @@ class TestFullSync: await time_out_assert(180, node_height_exactly, True, full_node_1, 999) await time_out_assert(180, node_height_exactly, True, full_node_2, 999) - @pytest.mark.asyncio + @pytest.mark.anyio async def test_batch_sync(self, two_nodes, self_hostname): # Must be below "sync_block_behind_threshold" in the config num_blocks = 20 @@ -209,7 +209,7 @@ class TestFullSync: ) await time_out_assert(60, node_height_exactly, True, full_node_2, num_blocks - 1) - @pytest.mark.asyncio + @pytest.mark.anyio async def test_backtrack_sync_1(self, two_nodes, self_hostname): full_node_1, full_node_2, server_1, server_2, bt = two_nodes blocks = bt.get_consecutive_blocks(1, skip_slots=1) @@ -226,7 +226,7 @@ class TestFullSync: ) await time_out_assert(60, node_height_exactly, True, full_node_2, 2) - @pytest.mark.asyncio + @pytest.mark.anyio async def test_backtrack_sync_2(self, two_nodes, self_hostname): full_node_1, full_node_2, server_1, server_2, bt = two_nodes blocks = bt.get_consecutive_blocks(1, skip_slots=3) @@ -242,7 +242,7 @@ class TestFullSync: ) await time_out_assert(60, node_height_exactly, True, full_node_2, 8) - @pytest.mark.asyncio + @pytest.mark.anyio async def test_close_height_but_big_reorg(self, three_nodes, bt, self_hostname): blocks_a = bt.get_consecutive_blocks(50) blocks_b = bt.get_consecutive_blocks(51, seed=b"B") @@ -280,7 +280,7 @@ class TestFullSync: await time_out_assert(80, node_height_exactly, True, full_node_2, 89) await time_out_assert(80, node_height_exactly, True, full_node_3, 89) - @pytest.mark.asyncio + @pytest.mark.anyio async def test_sync_bad_peak_while_synced( self, three_nodes, default_1000_blocks, default_1500_blocks, self_hostname ): @@ -326,7 +326,7 @@ class TestFullSync: assert node_height_exactly(full_node_2, 999) - @pytest.mark.asyncio + @pytest.mark.anyio async def test_block_ses_mismatch(self, two_nodes, default_1000_blocks, self_hostname, monkeypatch): full_node_1, full_node_2, server_1, server_2, _ = two_nodes blocks = default_1000_blocks @@ -372,7 +372,7 @@ class TestFullSync: # assert we failed somewhere between sub epoch 0 to sub epoch 1 assert node_height_between(full_node_2, summary_heights[0], summary_heights[1]) - @pytest.mark.asyncio + @pytest.mark.anyio @pytest.mark.skip("skipping until we re-enable the capability in chia.protocols.shared_protocol") async def test_sync_none_wp_response_backward_comp(self, three_nodes, default_1000_blocks, self_hostname): num_blocks_initial = len(default_1000_blocks) - 50 @@ -418,7 +418,7 @@ class TestFullSync: @pytest.mark.limit_consensus_modes(reason="save time") @pytest.mark.skip("This feature depends on (now removed) CHIP-13") - @pytest.mark.asyncio + @pytest.mark.anyio async def test_bad_peak_in_cache( self, two_nodes, default_400_blocks, blockchain_constants, self_hostname, consensus_mode ): @@ -445,7 +445,7 @@ class TestFullSync: @pytest.mark.limit_consensus_modes(reason="save time") @pytest.mark.skip("This feature depends on (now removed) CHIP-13") - @pytest.mark.asyncio + @pytest.mark.anyio async def test_skip_bad_peak_validation( self, two_nodes, default_400_blocks, blockchain_constants, self_hostname, consensus_mode ): @@ -470,7 +470,7 @@ class TestFullSync: with pytest.raises(ValueError, match="Weight proof failed bad peak cache validation"): await full_node_1.full_node.request_validate_wp(peak.header_hash, peak.height, peak.weight) - @pytest.mark.asyncio + @pytest.mark.anyio async def test_bad_peak_cache_invalidation( self, two_nodes, default_1000_blocks, blockchain_constants, consensus_mode ): diff --git a/tests/core/full_node/stores/test_block_store.py b/tests/core/full_node/stores/test_block_store.py index f3108ef1c062..64c825f5272a 100644 --- a/tests/core/full_node/stores/test_block_store.py +++ b/tests/core/full_node/stores/test_block_store.py @@ -41,7 +41,7 @@ def use_cache(request: SubRequest) -> bool: @pytest.mark.limit_consensus_modes(reason="save time") -@pytest.mark.asyncio +@pytest.mark.anyio async def test_block_store(tmp_dir: Path, db_version: int, bt: BlockTools, use_cache: bool) -> None: assert sqlite3.threadsafety >= 1 @@ -129,7 +129,7 @@ async def test_block_store(tmp_dir: Path, db_version: int, bt: BlockTools, use_c @pytest.mark.limit_consensus_modes(reason="save time") -@pytest.mark.asyncio +@pytest.mark.anyio async def test_deadlock(tmp_dir: Path, db_version: int, bt: BlockTools, use_cache: bool) -> None: """ This test was added because the store was deadlocking in certain situations, when fetching and @@ -162,7 +162,7 @@ async def test_deadlock(tmp_dir: Path, db_version: int, bt: BlockTools, use_cach @pytest.mark.limit_consensus_modes(reason="save time") -@pytest.mark.asyncio +@pytest.mark.anyio async def test_rollback(bt: BlockTools, tmp_dir: Path, use_cache: bool) -> None: blocks = bt.get_consecutive_blocks(10) @@ -208,7 +208,7 @@ async def test_rollback(bt: BlockTools, tmp_dir: Path, use_cache: bool) -> None: @pytest.mark.limit_consensus_modes(reason="save time") -@pytest.mark.asyncio +@pytest.mark.anyio async def test_count_compactified_blocks(bt: BlockTools, tmp_dir: Path, db_version: int, use_cache: bool) -> None: blocks = bt.get_consecutive_blocks(10) @@ -228,7 +228,7 @@ async def test_count_compactified_blocks(bt: BlockTools, tmp_dir: Path, db_versi @pytest.mark.limit_consensus_modes(reason="save time") -@pytest.mark.asyncio +@pytest.mark.anyio async def test_count_uncompactified_blocks(bt: BlockTools, tmp_dir: Path, db_version: int, use_cache: bool) -> None: blocks = bt.get_consecutive_blocks(10) @@ -248,7 +248,7 @@ async def test_count_uncompactified_blocks(bt: BlockTools, tmp_dir: Path, db_ver @pytest.mark.limit_consensus_modes(reason="save time") -@pytest.mark.asyncio +@pytest.mark.anyio async def test_replace_proof(bt: BlockTools, tmp_dir: Path, db_version: int, use_cache: bool) -> None: blocks = bt.get_consecutive_blocks(10) @@ -295,7 +295,7 @@ async def test_replace_proof(bt: BlockTools, tmp_dir: Path, db_version: int, use @pytest.mark.limit_consensus_modes(reason="save time") -@pytest.mark.asyncio +@pytest.mark.anyio async def test_get_generator(bt: BlockTools, db_version: int, use_cache: bool) -> None: blocks = bt.get_consecutive_blocks(10) @@ -335,7 +335,7 @@ async def test_get_generator(bt: BlockTools, db_version: int, use_cache: bool) - @pytest.mark.limit_consensus_modes(reason="save time") -@pytest.mark.asyncio +@pytest.mark.anyio async def test_get_blocks_by_hash(tmp_dir: Path, bt: BlockTools, db_version: int, use_cache: bool) -> None: assert sqlite3.threadsafety >= 1 blocks = bt.get_consecutive_blocks(10) @@ -374,7 +374,7 @@ async def test_get_blocks_by_hash(tmp_dir: Path, bt: BlockTools, db_version: int @pytest.mark.limit_consensus_modes(reason="save time") -@pytest.mark.asyncio +@pytest.mark.anyio async def test_get_block_bytes_in_range(tmp_dir: Path, bt: BlockTools, db_version: int, use_cache: bool) -> None: assert sqlite3.threadsafety >= 1 blocks = bt.get_consecutive_blocks(10) @@ -402,14 +402,14 @@ async def test_get_block_bytes_in_range(tmp_dir: Path, bt: BlockTools, db_versio await store_2.get_block_bytes_in_range(0, 10) -@pytest.mark.asyncio +@pytest.mark.anyio async def test_unsupported_version(tmp_dir: Path, use_cache: bool) -> None: with pytest.raises(RuntimeError, match="BlockStore does not support database schema v1"): async with DBConnection(1) as db_wrapper: await BlockStore.create(db_wrapper, use_cache=use_cache) -@pytest.mark.asyncio +@pytest.mark.anyio async def test_get_peak(tmp_dir: Path, db_version: int, use_cache: bool) -> None: async with DBConnection(db_version) as db_wrapper: store = await BlockStore.create(db_wrapper, use_cache=use_cache) diff --git a/tests/core/full_node/stores/test_coin_store.py b/tests/core/full_node/stores/test_coin_store.py index 3080cc576b66..93bf57360050 100644 --- a/tests/core/full_node/stores/test_coin_store.py +++ b/tests/core/full_node/stores/test_coin_store.py @@ -51,7 +51,7 @@ def get_future_reward_coins(block: FullBlock) -> Tuple[Coin, Coin]: @pytest.mark.limit_consensus_modes(reason="save time") -@pytest.mark.asyncio +@pytest.mark.anyio async def test_basic_coin_store(db_version: int, softfork_height: uint32, bt: BlockTools) -> None: wallet_a = WALLET_A reward_ph = wallet_a.get_new_puzzlehash() @@ -162,7 +162,7 @@ async def test_basic_coin_store(db_version: int, softfork_height: uint32, bt: Bl @pytest.mark.limit_consensus_modes(reason="save time") -@pytest.mark.asyncio +@pytest.mark.anyio async def test_set_spent(db_version: int, bt: BlockTools) -> None: blocks = bt.get_consecutive_blocks(9, []) @@ -207,7 +207,7 @@ async def test_set_spent(db_version: int, bt: BlockTools) -> None: @pytest.mark.limit_consensus_modes(reason="save time") -@pytest.mark.asyncio +@pytest.mark.anyio async def test_num_unspent(bt: BlockTools, db_version: int) -> None: blocks = bt.get_consecutive_blocks(37, []) @@ -241,7 +241,7 @@ async def test_num_unspent(bt: BlockTools, db_version: int) -> None: @pytest.mark.limit_consensus_modes(reason="save time") -@pytest.mark.asyncio +@pytest.mark.anyio async def test_rollback(db_version: int, bt: BlockTools) -> None: blocks = bt.get_consecutive_blocks(20) @@ -327,7 +327,7 @@ async def test_rollback(db_version: int, bt: BlockTools) -> None: assert record is None -@pytest.mark.asyncio +@pytest.mark.anyio async def test_basic_reorg(tmp_dir: Path, db_version: int, bt: BlockTools) -> None: async with DBConnection(db_version) as db_wrapper: initial_block_count = 30 @@ -380,7 +380,7 @@ async def test_basic_reorg(tmp_dir: Path, db_version: int, bt: BlockTools) -> No @pytest.mark.limit_consensus_modes(reason="save time") -@pytest.mark.asyncio +@pytest.mark.anyio async def test_get_puzzle_hash(tmp_dir: Path, db_version: int, bt: BlockTools) -> None: async with DBConnection(db_version) as db_wrapper: num_blocks = 20 @@ -410,7 +410,7 @@ async def test_get_puzzle_hash(tmp_dir: Path, db_version: int, bt: BlockTools) - b.shut_down() -@pytest.mark.asyncio +@pytest.mark.anyio async def test_get_coin_states(db_version: int) -> None: async with DBConnection(db_version) as db_wrapper: crs = [ @@ -493,7 +493,7 @@ async def test_get_coin_states(db_version: int) -> None: assert len(await coin_store.get_coin_states_by_ids(True, coins, uint32(0), max_items=10000)) == 600 -@pytest.mark.asyncio +@pytest.mark.anyio async def test_unsupported_version() -> None: with pytest.raises(RuntimeError, match="CoinStore does not support database schema v1"): async with DBConnection(1) as db_wrapper: diff --git a/tests/core/full_node/stores/test_full_node_store.py b/tests/core/full_node/stores/test_full_node_store.py index a5647018568e..ad6c1c48b4d6 100644 --- a/tests/core/full_node/stores/test_full_node_store.py +++ b/tests/core/full_node/stores/test_full_node_store.py @@ -6,7 +6,6 @@ import random from typing import AsyncIterator, List, Optional import pytest -import pytest_asyncio from chia.consensus.blockchain import AddBlockResult, Blockchain from chia.consensus.constants import ConsensusConstants @@ -32,7 +31,7 @@ from tests.util.blockchain import create_blockchain log = logging.getLogger(__name__) -@pytest_asyncio.fixture(scope="function") +@pytest.fixture(scope="function") async def custom_block_tools(blockchain_constants: ConsensusConstants) -> AsyncIterator[BlockTools]: with TempKeyring() as keychain: patched_constants = dataclasses.replace( @@ -43,7 +42,7 @@ async def custom_block_tools(blockchain_constants: ConsensusConstants) -> AsyncI yield await create_block_tools_async(constants=patched_constants, keychain=keychain) -@pytest_asyncio.fixture(scope="function") +@pytest.fixture(scope="function") async def empty_blockchain(db_version: int, blockchain_constants: ConsensusConstants) -> AsyncIterator[Blockchain]: patched_constants = dataclasses.replace( blockchain_constants, @@ -56,7 +55,7 @@ async def empty_blockchain(db_version: int, blockchain_constants: ConsensusConst bc1.shut_down() -@pytest_asyncio.fixture(scope="function") +@pytest.fixture(scope="function") async def empty_blockchain_with_original_constants( db_version: int, blockchain_constants: ConsensusConstants ) -> AsyncIterator[Blockchain]: @@ -67,7 +66,7 @@ async def empty_blockchain_with_original_constants( @pytest.mark.limit_consensus_modes(reason="save time") -@pytest.mark.asyncio +@pytest.mark.anyio @pytest.mark.parametrize("normalized_to_identity", [False, True]) async def test_basic_store( empty_blockchain: Blockchain, @@ -927,7 +926,7 @@ async def test_basic_store( @pytest.mark.limit_consensus_modes(reason="save time") -@pytest.mark.asyncio +@pytest.mark.anyio async def test_long_chain_slots( empty_blockchain_with_original_constants: Blockchain, default_1000_blocks: List[FullBlock], diff --git a/tests/core/full_node/stores/test_hint_store.py b/tests/core/full_node/stores/test_hint_store.py index 1da5951f8af9..effb2b393341 100644 --- a/tests/core/full_node/stores/test_hint_store.py +++ b/tests/core/full_node/stores/test_hint_store.py @@ -22,7 +22,7 @@ from tests.util.db_connection import DBConnection log = logging.getLogger(__name__) -@pytest.mark.asyncio +@pytest.mark.anyio async def test_basic_store(db_version: int) -> None: async with DBConnection(db_version) as db_wrapper: hint_store = await HintStore.create(db_wrapper) @@ -48,7 +48,7 @@ async def test_basic_store(db_version: int) -> None: assert coins_for_non_hint == [] -@pytest.mark.asyncio +@pytest.mark.anyio async def test_duplicate_coins(db_version: int) -> None: async with DBConnection(db_version) as db_wrapper: hint_store = await HintStore.create(db_wrapper) @@ -66,7 +66,7 @@ async def test_duplicate_coins(db_version: int) -> None: assert coin_id_0 in coins_for_hint_1 -@pytest.mark.asyncio +@pytest.mark.anyio async def test_duplicate_hints(db_version: int) -> None: async with DBConnection(db_version) as db_wrapper: hint_store = await HintStore.create(db_wrapper) @@ -86,7 +86,7 @@ async def test_duplicate_hints(db_version: int) -> None: assert coins_for_hint_1 == [] -@pytest.mark.asyncio +@pytest.mark.anyio async def test_duplicates(db_version: int) -> None: async with DBConnection(db_version) as db_wrapper: hint_store = await HintStore.create(db_wrapper) @@ -108,7 +108,7 @@ async def test_duplicates(db_version: int) -> None: assert rows[0][0] == 1 -@pytest.mark.asyncio +@pytest.mark.anyio async def test_hints_in_blockchain( wallet_nodes: Tuple[ FullNodeSimulator, FullNodeSimulator, ChiaServer, ChiaServer, WalletTool, WalletTool, BlockTools @@ -153,7 +153,7 @@ async def test_hints_in_blockchain( assert get_hint[0] == Coin(coin_spent.name(), puzzle_hash, uint64(1)).name() -@pytest.mark.asyncio +@pytest.mark.anyio async def test_counts(db_version: int) -> None: async with DBConnection(db_version) as db_wrapper: hint_store = await HintStore.create(db_wrapper) @@ -172,7 +172,7 @@ async def test_counts(db_version: int) -> None: assert count == 2 -@pytest.mark.asyncio +@pytest.mark.anyio async def test_limits(db_version: int) -> None: async with DBConnection(db_version) as db_wrapper: hint_store = await HintStore.create(db_wrapper) @@ -192,7 +192,7 @@ async def test_limits(db_version: int) -> None: assert len(await hint_store.get_coin_ids(hint, max_items=10000)) == 200 -@pytest.mark.asyncio +@pytest.mark.anyio async def test_unsupported_version() -> None: with pytest.raises(RuntimeError, match="HintStore does not support database schema v1"): async with DBConnection(1) as db_wrapper: diff --git a/tests/core/full_node/test_address_manager.py b/tests/core/full_node/test_address_manager.py index 97134e51b9c4..d0d58e9abc29 100644 --- a/tests/core/full_node/test_address_manager.py +++ b/tests/core/full_node/test_address_manager.py @@ -41,7 +41,7 @@ class AddressManagerTest(AddressManager): class TestPeerManager: - @pytest.mark.asyncio + @pytest.mark.anyio async def test_addr_manager(self): addrman = AddressManagerTest() # Test: Does Addrman respond correctly when empty. @@ -76,7 +76,7 @@ class TestPeerManager: assert await addrman2.add_peer_info(peers) assert await addrman2.size() >= 1 - @pytest.mark.asyncio + @pytest.mark.anyio async def test_addr_manager_ports(self): addrman = AddressManagerTest() assert await addrman.size() == 0 @@ -102,7 +102,7 @@ class TestPeerManager: # This is a fleaky test, since it uses randomness. # TODO: Make sure it always succeeds. - @pytest.mark.asyncio + @pytest.mark.anyio async def test_addrman_select(self): addrman = AddressManagerTest() source = PeerInfo("252.2.2.2", 8444) @@ -158,7 +158,7 @@ class TestPeerManager: break assert len(ports) == 3 - @pytest.mark.asyncio + @pytest.mark.anyio async def test_addrman_collisions_new(self): addrman = AddressManagerTest() assert await addrman.size() == 0 @@ -178,7 +178,7 @@ class TestPeerManager: assert await addrman.add_peer_info([peer2], source) assert await addrman.size() == 8 - @pytest.mark.asyncio + @pytest.mark.anyio async def test_addrman_collisions_tried(self): addrman = AddressManagerTest() assert await addrman.size() == 0 @@ -200,7 +200,7 @@ class TestPeerManager: assert await addrman.add_peer_info([peer2], source) assert await addrman.size() == 77 - @pytest.mark.asyncio + @pytest.mark.anyio async def test_addrman_find(self): addrman = AddressManagerTest() assert await addrman.size() == 0 @@ -231,7 +231,7 @@ class TestPeerManager: assert info3[0] is not None and info3[1] is not None assert info3[0].peer_info == peer3 - @pytest.mark.asyncio + @pytest.mark.anyio async def test_addrman_create(self): addrman = AddressManagerTest() assert await addrman.size() == 0 @@ -243,7 +243,7 @@ class TestPeerManager: info, _ = addrman.find_(peer1) assert info.peer_info == peer1 - @pytest.mark.asyncio + @pytest.mark.anyio async def test_addrman_delete(self): addrman = AddressManagerTest() assert await addrman.size() == 0 @@ -259,7 +259,7 @@ class TestPeerManager: info2, _ = addrman.find_(peer1) assert info2 is None - @pytest.mark.asyncio + @pytest.mark.anyio async def test_addrman_get_peers(self): addrman = AddressManagerTest() assert await addrman.size() == 0 @@ -305,7 +305,7 @@ class TestPeerManager: percent = math.ceil(percent * 23 / 100) assert len(peers4) == percent - @pytest.mark.asyncio + @pytest.mark.anyio async def test_addrman_tried_bucket(self): peer1 = PeerInfo("250.1.1.1", 8444) t_peer1 = TimestampedPeerInfo("250.1.1.1", 8444, 0) @@ -352,7 +352,7 @@ class TestPeerManager: buckets.append(bucket) assert len(buckets) > 8 - @pytest.mark.asyncio + @pytest.mark.anyio async def test_addrman_new_bucket(self): t_peer1 = TimestampedPeerInfo("250.1.2.1", 8444, 0) source1 = PeerInfo("250.1.2.1", 8444) @@ -407,7 +407,7 @@ class TestPeerManager: assert len(buckets) > 64 - @pytest.mark.asyncio + @pytest.mark.anyio async def test_addrman_select_collision_no_collision(self): addrman = AddressManagerTest() collision = await addrman.select_tried_collision() @@ -433,7 +433,7 @@ class TestPeerManager: collision = await addrman.select_tried_collision() assert collision is None - @pytest.mark.asyncio + @pytest.mark.anyio async def test_addrman_no_evict(self): addrman = AddressManagerTest() @@ -483,7 +483,7 @@ class TestPeerManager: collision = await addrman.select_tried_collision() assert collision is None - @pytest.mark.asyncio + @pytest.mark.anyio async def test_addrman_eviction_works(self): addrman = AddressManagerTest() assert await addrman.size() == 0 @@ -526,7 +526,7 @@ class TestPeerManager: await addrman.resolve_tried_collisions() assert await addrman.select_tried_collision() is None - @pytest.mark.asyncio + @pytest.mark.anyio # use tmp_path pytest fixture to create a temporary directory async def test_serialization(self, tmp_path: Path): addrman = AddressManagerTest() @@ -572,7 +572,7 @@ class TestPeerManager: assert recovered == 3 peers_dat_filename.unlink() - @pytest.mark.asyncio + @pytest.mark.anyio async def test_cleanup(self): addrman = AddressManagerTest() peer1 = TimestampedPeerInfo("250.250.2.1", 8444, 100000) diff --git a/tests/core/full_node/test_block_height_map.py b/tests/core/full_node/test_block_height_map.py index d9d933df6a93..27510065041e 100644 --- a/tests/core/full_node/test_block_height_map.py +++ b/tests/core/full_node/test_block_height_map.py @@ -89,7 +89,7 @@ async def setup_chain( class TestBlockHeightMap: - @pytest.mark.asyncio + @pytest.mark.anyio async def test_height_to_hash(self, tmp_dir: Path, db_version: int) -> None: async with DBConnection(db_version) as db_wrapper: await setup_db(db_wrapper) @@ -104,7 +104,7 @@ class TestBlockHeightMap: for height in reversed(range(10)): assert height_map.get_hash(uint32(height)) == gen_block_hash(height) - @pytest.mark.asyncio + @pytest.mark.anyio async def test_height_to_hash_long_chain(self, tmp_dir: Path, db_version: int) -> None: async with DBConnection(db_version) as db_wrapper: await setup_db(db_wrapper) @@ -119,7 +119,7 @@ class TestBlockHeightMap: assert height_map.get_hash(uint32(height)) == gen_block_hash(height) @pytest.mark.parametrize("ses_every", [20, 1]) - @pytest.mark.asyncio + @pytest.mark.anyio async def test_save_restore(self, ses_every: int, tmp_dir: Path, db_version: int) -> None: async with DBConnection(db_version) as db_wrapper: await setup_db(db_wrapper) @@ -160,7 +160,7 @@ class TestBlockHeightMap: with pytest.raises(KeyError) as _: height_map.get_ses(uint32(height)) - @pytest.mark.asyncio + @pytest.mark.anyio async def test_restore_entire_chain(self, tmp_dir: Path, db_version: int) -> None: # this is a test where the height-to-hash and height-to-ses caches are # entirely unrelated to the database. Make sure they can both be fully @@ -193,7 +193,7 @@ class TestBlockHeightMap: with pytest.raises(KeyError) as _: height_map.get_ses(uint32(height)) - @pytest.mark.asyncio + @pytest.mark.anyio async def test_restore_ses_only(self, tmp_dir: Path, db_version: int) -> None: # this is a test where the height-to-hash is complete and correct but # sub epoch summaries are missing. We need to be able to restore them in @@ -225,7 +225,7 @@ class TestBlockHeightMap: with pytest.raises(KeyError) as _: height_map.get_ses(uint32(height)) - @pytest.mark.asyncio + @pytest.mark.anyio async def test_restore_extend(self, tmp_dir: Path, db_version: int) -> None: # test the case where the cache has fewer blocks than the DB, and that # we correctly load all the missing blocks from the DB to update the @@ -265,7 +265,7 @@ class TestBlockHeightMap: with pytest.raises(KeyError) as _: height_map.get_ses(uint32(height)) - @pytest.mark.asyncio + @pytest.mark.anyio async def test_height_to_hash_with_orphans(self, tmp_dir: Path, db_version: int) -> None: async with DBConnection(db_version) as db_wrapper: await setup_db(db_wrapper) @@ -280,7 +280,7 @@ class TestBlockHeightMap: for height in range(10): assert height_map.get_hash(uint32(height)) == gen_block_hash(height) - @pytest.mark.asyncio + @pytest.mark.anyio async def test_height_to_hash_update(self, tmp_dir: Path, db_version: int) -> None: async with DBConnection(db_version) as db_wrapper: await setup_db(db_wrapper) @@ -301,7 +301,7 @@ class TestBlockHeightMap: assert height_map.get_hash(uint32(10)) == gen_block_hash(100) - @pytest.mark.asyncio + @pytest.mark.anyio async def test_update_ses(self, tmp_dir: Path, db_version: int) -> None: async with DBConnection(db_version) as db_wrapper: await setup_db(db_wrapper) @@ -320,7 +320,7 @@ class TestBlockHeightMap: assert height_map.get_ses(uint32(10)) == gen_ses(10) assert height_map.get_hash(uint32(10)) == gen_block_hash(10) - @pytest.mark.asyncio + @pytest.mark.anyio async def test_height_to_ses(self, tmp_dir: Path, db_version: int) -> None: async with DBConnection(db_version) as db_wrapper: await setup_db(db_wrapper) @@ -345,7 +345,7 @@ class TestBlockHeightMap: with pytest.raises(KeyError) as _: height_map.get_ses(uint32(9)) - @pytest.mark.asyncio + @pytest.mark.anyio async def test_rollback(self, tmp_dir: Path, db_version: int) -> None: async with DBConnection(db_version) as db_wrapper: await setup_db(db_wrapper) @@ -381,7 +381,7 @@ class TestBlockHeightMap: with pytest.raises(KeyError) as _: height_map.get_ses(uint32(8)) - @pytest.mark.asyncio + @pytest.mark.anyio async def test_rollback2(self, tmp_dir: Path, db_version: int) -> None: async with DBConnection(db_version) as db_wrapper: await setup_db(db_wrapper) @@ -412,7 +412,7 @@ class TestBlockHeightMap: with pytest.raises(KeyError) as _: height_map.get_ses(uint32(8)) - @pytest.mark.asyncio + @pytest.mark.anyio async def test_cache_file_nothing_to_write(self, tmp_dir: Path, db_version: int) -> None: # This is a test where the height-to-hash data is entirely used from # the cache file and there is nothing to write in that file as a result. @@ -439,7 +439,7 @@ class TestBlockHeightMap: for idx in range(0, len(heights), 32): assert new_heights[idx : idx + 32] == heights[idx : idx + 32] - @pytest.mark.asyncio + @pytest.mark.anyio async def test_cache_file_replace_everything(self, tmp_dir: Path, db_version: int) -> None: # This is a test where the height-to-hash is entirely unrelated to the # database. Make sure it can be fully replaced @@ -461,7 +461,7 @@ class TestBlockHeightMap: for i in range(0, len(heights), 32): assert new_heights[i : i + 32] != heights[i : i + 32] - @pytest.mark.asyncio + @pytest.mark.anyio async def test_cache_file_extend(self, tmp_dir: Path, db_version: int) -> None: # Test the case where the cache has fewer blocks than the DB, and that # we correctly load all the missing blocks from the DB to update the @@ -488,7 +488,7 @@ class TestBlockHeightMap: for idx in range(0, len(heights), 32): assert new_heights[idx : idx + 32] == heights[idx : idx + 32] - @pytest.mark.asyncio + @pytest.mark.anyio async def test_cache_file_truncate(self, tmp_dir: Path, db_version: int) -> None: # Test the case where the cache has more blocks than the DB, the cache # file will be truncated @@ -515,14 +515,14 @@ class TestBlockHeightMap: assert new_heights[idx * 32 : idx * 32 + 32] == gen_block_hash(idx) -@pytest.mark.asyncio +@pytest.mark.anyio async def test_unsupported_version(tmp_dir: Path) -> None: with pytest.raises(RuntimeError, match="BlockHeightMap does not support database schema v1"): async with DBConnection(1) as db_wrapper: await BlockHeightMap.create(tmp_dir, db_wrapper) -@pytest.mark.asyncio +@pytest.mark.anyio async def test_empty_chain(tmp_dir: Path, db_version: int) -> None: async with DBConnection(db_version) as db_wrapper: await setup_db(db_wrapper) @@ -536,7 +536,7 @@ async def test_empty_chain(tmp_dir: Path, db_version: int) -> None: height_map.get_hash(uint32(0)) -@pytest.mark.asyncio +@pytest.mark.anyio async def test_peak_only_chain(tmp_dir: Path, db_version: int) -> None: async with DBConnection(db_version) as db_wrapper: await setup_db(db_wrapper) diff --git a/tests/core/full_node/test_conditions.py b/tests/core/full_node/test_conditions.py index 251a80fa177b..6fd8a6b4e876 100644 --- a/tests/core/full_node/test_conditions.py +++ b/tests/core/full_node/test_conditions.py @@ -122,7 +122,7 @@ co = ConditionOpcode class TestConditions: - @pytest.mark.asyncio + @pytest.mark.anyio @pytest.mark.parametrize( "opcode, expected_cost", [ @@ -160,7 +160,7 @@ class TestConditions: assert new_block.transactions_info is not None assert new_block.transactions_info.cost - block_base_cost == expected_cost - @pytest.mark.asyncio + @pytest.mark.anyio @pytest.mark.parametrize( "condition, expected_cost", [ @@ -187,7 +187,7 @@ class TestConditions: assert new_block.transactions_info is not None assert new_block.transactions_info.cost - block_base_cost == expected_cost - @pytest.mark.asyncio + @pytest.mark.anyio @pytest.mark.parametrize( "opcode,value,expected", [ @@ -275,7 +275,7 @@ class TestConditions: conditions = Program.to(assemble(f"(({opcode[0]} {value}))")) await check_conditions(bt, conditions, expected_err=expected) - @pytest.mark.asyncio + @pytest.mark.anyio async def test_invalid_my_id(self, bt): blocks = await initial_blocks(bt) coin = list(blocks[-2].get_included_reward_coins())[0] @@ -284,14 +284,14 @@ class TestConditions: conditions = Program.to(assemble(f"(({ConditionOpcode.ASSERT_MY_COIN_ID[0]} 0x{wrong_name.hex()}))")) await check_conditions(bt, conditions, expected_err=Err.ASSERT_MY_COIN_ID_FAILED) - @pytest.mark.asyncio + @pytest.mark.anyio async def test_valid_my_id(self, bt): blocks = await initial_blocks(bt) coin = list(blocks[-2].get_included_reward_coins())[0] conditions = Program.to(assemble(f"(({ConditionOpcode.ASSERT_MY_COIN_ID[0]} 0x{coin.name().hex()}))")) await check_conditions(bt, conditions) - @pytest.mark.asyncio + @pytest.mark.anyio async def test_invalid_coin_announcement(self, bt): blocks = await initial_blocks(bt) coin = list(blocks[-2].get_included_reward_coins())[0] @@ -304,7 +304,7 @@ class TestConditions: ) await check_conditions(bt, conditions, expected_err=Err.ASSERT_ANNOUNCE_CONSUMED_FAILED) - @pytest.mark.asyncio + @pytest.mark.anyio async def test_valid_coin_announcement(self, bt): blocks = await initial_blocks(bt) coin = list(blocks[-2].get_included_reward_coins())[0] @@ -317,7 +317,7 @@ class TestConditions: ) await check_conditions(bt, conditions) - @pytest.mark.asyncio + @pytest.mark.anyio async def test_invalid_puzzle_announcement(self, bt): announce = Announcement(EASY_PUZZLE_HASH, b"test_bad") conditions = Program.to( @@ -328,7 +328,7 @@ class TestConditions: ) await check_conditions(bt, conditions, expected_err=Err.ASSERT_ANNOUNCE_CONSUMED_FAILED) - @pytest.mark.asyncio + @pytest.mark.anyio async def test_valid_puzzle_announcement(self, bt): announce = Announcement(EASY_PUZZLE_HASH, b"test") conditions = Program.to( @@ -339,7 +339,7 @@ class TestConditions: ) await check_conditions(bt, conditions) - @pytest.mark.asyncio + @pytest.mark.anyio @pytest.mark.parametrize( "prefix, condition, num, expect_err", [ diff --git a/tests/core/full_node/test_full_node.py b/tests/core/full_node/test_full_node.py index 3ac05b0bf2cb..63aaeb96bc13 100644 --- a/tests/core/full_node/test_full_node.py +++ b/tests/core/full_node/test_full_node.py @@ -1,11 +1,12 @@ from __future__ import annotations import asyncio +import contextlib import dataclasses import logging import random import time -from typing import Dict, List, Optional, Tuple +from typing import Coroutine, Dict, List, Optional, Tuple import pytest from blspy import AugSchemeMPL, G2Element, PrivateKey @@ -107,7 +108,7 @@ async def get_block_path(full_node: FullNodeAPI): return blocks_list -@pytest.mark.asyncio +@pytest.mark.anyio async def test_sync_no_farmer( setup_two_nodes_and_wallet, default_1000_blocks: List[FullBlock], @@ -147,7 +148,7 @@ async def test_sync_no_farmer( class TestFullNodeBlockCompression: - @pytest.mark.asyncio + @pytest.mark.anyio @pytest.mark.parametrize("tx_size", [3000000000000]) async def test_block_compression( self, setup_two_nodes_and_wallet, empty_blockchain, tx_size, self_hostname, consensus_mode @@ -473,13 +474,13 @@ class TestFullNodeBlockCompression: class TestFullNodeProtocol: - @pytest.mark.asyncio + @pytest.mark.anyio async def test_spendbundle_serialization(self): sb: SpendBundle = make_spend_bundle(1) protocol_message = RespondTransaction(sb) assert bytes(sb) == bytes(protocol_message) - @pytest.mark.asyncio + @pytest.mark.anyio async def test_inbound_connection_limit(self, setup_four_nodes, self_hostname): nodes, _, _ = setup_four_nodes server_1 = nodes[0].full_node.server @@ -491,7 +492,7 @@ class TestFullNodeProtocol: await server_i.start_client(PeerInfo(self_hostname, server_1.get_port())) assert len(server_1.get_connections(NodeType.FULL_NODE)) == 2 - @pytest.mark.asyncio + @pytest.mark.anyio async def test_request_peers(self, wallet_nodes, self_hostname): full_node_1, full_node_2, server_1, server_2, wallet_a, wallet_receiver, _ = wallet_nodes full_node_2.full_node.full_node_peers.address_manager.make_private_subnets_valid() @@ -512,7 +513,7 @@ class TestFullNodeProtocol: await time_out_assert_custom_interval(10, 1, have_msgs, True) full_node_1.full_node.full_node_peers.address_manager = AddressManager() - @pytest.mark.asyncio + @pytest.mark.anyio async def test_basic_chain(self, wallet_nodes, self_hostname): full_node_1, full_node_2, server_1, server_2, wallet_a, wallet_receiver, bt = wallet_nodes @@ -535,7 +536,7 @@ class TestFullNodeProtocol: assert full_node_1.full_node.blockchain.get_peak().height == 29 - @pytest.mark.asyncio + @pytest.mark.anyio async def test_respond_end_of_sub_slot(self, wallet_nodes, self_hostname): full_node_1, full_node_2, server_1, server_2, wallet_a, wallet_receiver, bt = wallet_nodes @@ -593,7 +594,7 @@ class TestFullNodeProtocol: ), ) - @pytest.mark.asyncio + @pytest.mark.anyio async def test_respond_end_of_sub_slot_no_reorg(self, wallet_nodes, self_hostname): full_node_1, full_node_2, server_1, server_2, wallet_a, wallet_receiver, bt = wallet_nodes @@ -630,7 +631,7 @@ class TestFullNodeProtocol: assert full_node_1.full_node.full_node_store.finished_sub_slots == original_ss - @pytest.mark.asyncio + @pytest.mark.anyio async def test_respond_end_of_sub_slot_race(self, wallet_nodes, self_hostname): full_node_1, full_node_2, server_1, server_2, wallet_a, wallet_receiver, bt = wallet_nodes @@ -660,7 +661,7 @@ class TestFullNodeProtocol: for slot in blocks[-1].finished_sub_slots: await full_node_1.respond_end_of_sub_slot(fnp.RespondEndOfSubSlot(slot), peer) - @pytest.mark.asyncio + @pytest.mark.anyio async def test_respond_unfinished(self, wallet_nodes, self_hostname): full_node_1, full_node_2, server_1, server_2, wallet_a, wallet_receiver, bt = wallet_nodes @@ -808,7 +809,7 @@ class TestFullNodeProtocol: await full_node_1.full_node.add_block(block_no_transactions) assert full_node_1.full_node.blockchain.contains_block(block.header_hash) - @pytest.mark.asyncio + @pytest.mark.anyio async def test_new_peak(self, wallet_nodes, self_hostname): full_node_1, full_node_2, server_1, server_2, wallet_a, wallet_receiver, bt = wallet_nodes @@ -842,6 +843,10 @@ class TestFullNodeProtocol: await time_out_assert(10, time_out_messages(incoming_queue, "request_block", 0)) task_2.cancel() + async def suppress_value_error(coro: Coroutine) -> None: + with contextlib.suppress(ValueError): + await coro + # Ignores low weight new_peak = fnp.NewPeak( blocks_reorg[-2].header_hash, @@ -850,7 +855,7 @@ class TestFullNodeProtocol: uint32(0), blocks_reorg[-2].reward_chain_block.get_unfinished().get_hash(), ) - asyncio.create_task(full_node_1.new_peak(new_peak, dummy_peer)) + asyncio.create_task(suppress_value_error(full_node_1.new_peak(new_peak, dummy_peer))) await time_out_assert(10, time_out_messages(incoming_queue, "request_block", 0)) # Does not ignore equal weight @@ -861,10 +866,10 @@ class TestFullNodeProtocol: uint32(0), blocks_reorg[-1].reward_chain_block.get_unfinished().get_hash(), ) - asyncio.create_task(full_node_1.new_peak(new_peak, dummy_peer)) + asyncio.create_task(suppress_value_error(full_node_1.new_peak(new_peak, dummy_peer))) await time_out_assert(10, time_out_messages(incoming_queue, "request_block", 1)) - @pytest.mark.asyncio + @pytest.mark.anyio async def test_new_transaction_and_mempool(self, wallet_nodes, self_hostname, seeded_random: random.Random): full_node_1, full_node_2, server_1, server_2, wallet_a, wallet_receiver, bt = wallet_nodes wallet_ph = wallet_a.get_new_puzzlehash() @@ -1046,7 +1051,7 @@ class TestFullNodeProtocol: assert err is None assert status == MempoolInclusionStatus.SUCCESS - @pytest.mark.asyncio + @pytest.mark.anyio async def test_request_respond_transaction(self, wallet_nodes, self_hostname, seeded_random: random.Random): full_node_1, full_node_2, server_1, server_2, wallet_a, wallet_receiver, bt = wallet_nodes wallet_ph = wallet_a.get_new_puzzlehash() @@ -1094,7 +1099,7 @@ class TestFullNodeProtocol: assert msg is not None assert msg.data == bytes(fnp.RespondTransaction(spend_bundle)) - @pytest.mark.asyncio + @pytest.mark.anyio async def test_respond_transaction_fail(self, wallet_nodes, self_hostname, seeded_random: random.Random): full_node_1, full_node_2, server_1, server_2, wallet_a, wallet_receiver, bt = wallet_nodes blocks = await full_node_1.get_all_full_blocks() @@ -1141,7 +1146,7 @@ class TestFullNodeProtocol: await asyncio.sleep(1) assert incoming_queue.qsize() == 0 - @pytest.mark.asyncio + @pytest.mark.anyio async def test_request_block(self, wallet_nodes): full_node_1, full_node_2, server_1, server_2, wallet_a, wallet_receiver, bt = wallet_nodes blocks = await full_node_1.get_all_full_blocks() @@ -1183,7 +1188,7 @@ class TestFullNodeProtocol: res = await full_node_1.request_block(fnp.RequestBlock(blocks[-1].height - 1, True)) assert res.type != ProtocolMessageTypes.reject_block.value - @pytest.mark.asyncio + @pytest.mark.anyio async def test_request_blocks(self, wallet_nodes): full_node_1, full_node_2, server_1, server_2, wallet_a, wallet_receiver, bt = wallet_nodes blocks = await full_node_1.get_all_full_blocks() @@ -1244,7 +1249,7 @@ class TestFullNodeProtocol: assert fetched_blocks[-1].transactions_generator is not None assert std_hash(fetched_blocks[-1]) == std_hash(blocks_t[-1]) - @pytest.mark.asyncio + @pytest.mark.anyio async def test_new_unfinished_block(self, wallet_nodes, self_hostname): full_node_1, full_node_2, server_1, server_2, wallet_a, wallet_receiver, bt = wallet_nodes blocks = await full_node_1.get_all_full_blocks() @@ -1275,7 +1280,7 @@ class TestFullNodeProtocol: res = await full_node_1.new_unfinished_block(fnp.NewUnfinishedBlock(unf.partial_hash)) assert res is None - @pytest.mark.asyncio + @pytest.mark.anyio @pytest.mark.parametrize( "committment,expected", [ @@ -1427,7 +1432,7 @@ class TestFullNodeProtocol: with pytest.raises(ConsensusError, match=f"{str(expected).split('.')[1]}"): await full_node_1.full_node.add_unfinished_block(unf, peer) - @pytest.mark.asyncio + @pytest.mark.anyio async def test_double_blocks_same_pospace(self, wallet_nodes, self_hostname): full_node_1, full_node_2, server_1, server_2, wallet_a, wallet_receiver, bt = wallet_nodes @@ -1477,7 +1482,7 @@ class TestFullNodeProtocol: await time_out_assert(10, time_out_messages(incoming_queue, "request_block", 1)) rb_task.cancel() - @pytest.mark.asyncio + @pytest.mark.anyio async def test_request_unfinished_block(self, wallet_nodes, self_hostname): full_node_1, full_node_2, server_1, server_2, wallet_a, wallet_receiver, bt = wallet_nodes blocks = await full_node_1.get_all_full_blocks() @@ -1507,7 +1512,7 @@ class TestFullNodeProtocol: res = await full_node_1.request_unfinished_block(fnp.RequestUnfinishedBlock(unf.partial_hash)) assert res is not None - @pytest.mark.asyncio + @pytest.mark.anyio async def test_new_signage_point_or_end_of_sub_slot(self, wallet_nodes, self_hostname): full_node_1, full_node_2, server_1, server_2, wallet_a, wallet_receiver, bt = wallet_nodes blocks = await full_node_1.get_all_full_blocks() @@ -1562,7 +1567,7 @@ class TestFullNodeProtocol: await time_out_assert(20, caught_up_slots) - @pytest.mark.asyncio + @pytest.mark.anyio async def test_new_signage_point_caching(self, wallet_nodes, empty_blockchain, self_hostname): full_node_1, full_node_2, server_1, server_2, wallet_a, wallet_receiver, bt = wallet_nodes blocks = await full_node_1.get_all_full_blocks() @@ -1621,7 +1626,7 @@ class TestFullNodeProtocol: sp = full_node_1.full_node.full_node_store.get_signage_point(sp.cc_vdf.output.get_hash()) assert sp is not None - @pytest.mark.asyncio + @pytest.mark.anyio async def test_slot_catch_up_genesis(self, setup_two_nodes_fixture, self_hostname): nodes, _, bt = setup_two_nodes_fixture server_1 = nodes[0].full_node.server @@ -1652,7 +1657,7 @@ class TestFullNodeProtocol: await time_out_assert(20, caught_up_slots) - @pytest.mark.asyncio + @pytest.mark.anyio async def test_compact_protocol(self, setup_two_nodes_fixture): nodes, _, bt = setup_two_nodes_fixture full_node_1 = nodes[0] @@ -1770,7 +1775,7 @@ class TestFullNodeProtocol: await full_node_2.full_node.add_block(block) assert full_node_2.full_node.blockchain.get_peak().height == height - @pytest.mark.asyncio + @pytest.mark.anyio async def test_compact_protocol_invalid_messages(self, setup_two_nodes_fixture, self_hostname): nodes, _, bt = setup_two_nodes_fixture full_node_1 = nodes[0] @@ -1997,7 +2002,7 @@ class TestFullNodeProtocol: assert not block.challenge_chain_sp_proof.normalized_to_identity assert not block.challenge_chain_ip_proof.normalized_to_identity - @pytest.mark.asyncio + @pytest.mark.anyio async def test_respond_compact_proof_message_limit(self, setup_two_nodes_fixture): nodes, _, bt = setup_two_nodes_fixture full_node_1 = nodes[0] @@ -2067,7 +2072,7 @@ class TestFullNodeProtocol: [[(uint16(max(Capability) + 1), "1")], True], ], ) - @pytest.mark.asyncio + @pytest.mark.anyio async def test_invalid_capability_can_connect( self, two_nodes: Tuple[FullNodeAPI, FullNodeAPI, ChiaServer, ChiaServer, BlockTools], @@ -2091,7 +2096,7 @@ class TestFullNodeProtocol: assert connected == expect_success, custom_capabilities -@pytest.mark.asyncio +@pytest.mark.anyio async def test_node_start_with_existing_blocks(db_version: int) -> None: with TempKeyring(populate=True) as keychain: block_tools = await create_block_tools_async(keychain=keychain) @@ -2121,7 +2126,7 @@ async def test_node_start_with_existing_blocks(db_version: int) -> None: assert block_record.height == expected_height, f"wrong height on cycle {cycle + 1}" -@pytest.mark.asyncio +@pytest.mark.anyio async def test_wallet_sync_task_failure( one_node: SimulatorsAndWalletsServices, caplog: pytest.LogCaptureFixture ) -> None: diff --git a/tests/core/full_node/test_hint_management.py b/tests/core/full_node/test_hint_management.py index 5bef93992821..3c9fb56a9e5d 100644 --- a/tests/core/full_node/test_hint_management.py +++ b/tests/core/full_node/test_hint_management.py @@ -100,7 +100,7 @@ def no_sub(c: bytes32) -> bool: return False -@pytest.mark.asyncio +@pytest.mark.anyio async def test_hints_to_add(bt: BlockTools, empty_blockchain: Blockchain) -> None: blocks = bt.get_consecutive_blocks(2) await _validate_and_add_block(empty_blockchain, blocks[0]) @@ -122,7 +122,7 @@ async def test_hints_to_add(bt: BlockTools, empty_blockchain: Blockchain) -> Non assert set(hints_to_add) == {(first_coin_id, b"1" * 32), (second_coin_id, b"1" * 3), (third_coin_id, b"1" * 32)} -@pytest.mark.asyncio +@pytest.mark.anyio async def test_lookup_coin_ids(bt: BlockTools, empty_blockchain: Blockchain) -> None: blocks = bt.get_consecutive_blocks(2) await _validate_and_add_block(empty_blockchain, blocks[0]) diff --git a/tests/core/full_node/test_node_load.py b/tests/core/full_node/test_node_load.py index 309cf3741f4a..d448dba14007 100644 --- a/tests/core/full_node/test_node_load.py +++ b/tests/core/full_node/test_node_load.py @@ -9,7 +9,7 @@ from tests.util.misc import BenchmarkRunner class TestNodeLoad: - @pytest.mark.asyncio + @pytest.mark.anyio async def test_blocks_load(self, two_nodes, self_hostname, benchmark_runner: BenchmarkRunner): num_blocks = 50 full_node_1, full_node_2, server_1, server_2, bt = two_nodes diff --git a/tests/core/full_node/test_performance.py b/tests/core/full_node/test_performance.py index 89813e0aa95a..49a74b0d0c91 100644 --- a/tests/core/full_node/test_performance.py +++ b/tests/core/full_node/test_performance.py @@ -37,7 +37,7 @@ async def get_block_path(full_node: FullNodeAPI): class TestPerformance: - @pytest.mark.asyncio + @pytest.mark.anyio async def test_full_block_performance( self, request: pytest.FixtureRequest, wallet_nodes_perf, self_hostname, benchmark_runner: BenchmarkRunner ): diff --git a/tests/core/full_node/test_transactions.py b/tests/core/full_node/test_transactions.py index 6bda32bd6533..8d13ea0305db 100644 --- a/tests/core/full_node/test_transactions.py +++ b/tests/core/full_node/test_transactions.py @@ -18,7 +18,7 @@ from chia.wallet.util.tx_config import DEFAULT_TX_CONFIG class TestTransactions: - @pytest.mark.asyncio + @pytest.mark.anyio async def test_wallet_coinbase(self, simulator_and_wallet, self_hostname): num_blocks = 5 full_nodes, wallets, _ = simulator_and_wallet @@ -40,7 +40,7 @@ class TestTransactions: print(await wallet.get_confirmed_balance(), funds) await time_out_assert(20, wallet.get_confirmed_balance, funds) - @pytest.mark.asyncio + @pytest.mark.anyio async def test_tx_propagation(self, three_nodes_two_wallets, self_hostname, seeded_random: random.Random): num_blocks = 5 full_nodes, wallets, _ = three_nodes_two_wallets @@ -124,7 +124,7 @@ class TestTransactions: ) await time_out_assert(20, wallet_1.wallet_state_manager.main_wallet.get_confirmed_balance, 10) - @pytest.mark.asyncio + @pytest.mark.anyio async def test_mempool_tx_sync(self, three_nodes_two_wallets, self_hostname, seeded_random: random.Random): num_blocks = 5 full_nodes, wallets, _ = three_nodes_two_wallets diff --git a/tests/core/full_node/test_tx_processing_queue.py b/tests/core/full_node/test_tx_processing_queue.py index b0f117b50cc0..265ac3a05299 100644 --- a/tests/core/full_node/test_tx_processing_queue.py +++ b/tests/core/full_node/test_tx_processing_queue.py @@ -25,7 +25,7 @@ def get_transaction_queue_entry(peer_id: Optional[bytes32], tx_index: int) -> Tr return cast(TransactionQueueEntry, FakeTransactionQueueEntry(index=tx_index, peer_id=peer_id)) -@pytest.mark.asyncio +@pytest.mark.anyio async def test_local_txs(seeded_random: random.Random) -> None: transaction_queue = TransactionQueue(1000, log) # test 1 tx @@ -50,7 +50,7 @@ async def test_local_txs(seeded_random: random.Random) -> None: assert list_txs[i] == resulting_txs[i] -@pytest.mark.asyncio +@pytest.mark.anyio async def test_one_peer_and_await(seeded_random: random.Random) -> None: transaction_queue = TransactionQueue(1000, log) num_txs = 100 @@ -84,7 +84,7 @@ async def test_one_peer_and_await(seeded_random: random.Random) -> None: await asyncio.wait_for(task, 1) # we should never time out here -@pytest.mark.asyncio +@pytest.mark.anyio async def test_lots_of_peers(seeded_random: random.Random) -> None: transaction_queue = TransactionQueue(1000, log) num_peers = 1000 @@ -106,7 +106,7 @@ async def test_lots_of_peers(seeded_random: random.Random) -> None: assert list_txs[i] == resulting_txs[i * 1000] -@pytest.mark.asyncio +@pytest.mark.anyio async def test_full_queue(seeded_random: random.Random) -> None: transaction_queue = TransactionQueue(1000, log) num_peers = 100 @@ -128,7 +128,7 @@ async def test_full_queue(seeded_random: random.Random) -> None: resulting_txs.append(await transaction_queue.pop()) -@pytest.mark.asyncio +@pytest.mark.anyio async def test_queue_cleanup_and_fairness(seeded_random: random.Random) -> None: transaction_queue = TransactionQueue(1000, log) peer_a = bytes32.random(seeded_random) diff --git a/tests/core/mempool/test_mempool.py b/tests/core/mempool/test_mempool.py index 0f3a3a3757d3..45d750a97a58 100644 --- a/tests/core/mempool/test_mempool.py +++ b/tests/core/mempool/test_mempool.py @@ -296,7 +296,7 @@ class TestPendingTxCache: class TestMempool: - @pytest.mark.asyncio + @pytest.mark.anyio async def test_basic_mempool(self, one_node_one_block, wallet_a): full_node_1, server_1, bt = one_node_one_block @@ -367,7 +367,7 @@ mis = MempoolInclusionStatus class TestMempoolManager: - @pytest.mark.asyncio + @pytest.mark.anyio async def test_basic_mempool_manager(self, two_nodes_one_block, wallet_a, self_hostname): full_node_1, full_node_2, server_1, server_2, bt = two_nodes_one_block @@ -387,7 +387,7 @@ class TestMempoolManager: spend_bundle.name(), ) - @pytest.mark.asyncio + @pytest.mark.anyio @pytest.mark.parametrize( "opcode,lock_value,expected", [ @@ -457,7 +457,7 @@ class TestMempoolManager: # this test makes sure that one spend successfully asserts the announce from # another spend, even though the assert condition is duplicated 100 times - @pytest.mark.asyncio + @pytest.mark.anyio async def test_coin_announcement_duplicate_consumed(self, one_node_one_block, wallet_a): def test_fun(coin_1: Coin, coin_2: Coin) -> SpendBundle: announce = Announcement(coin_2.name(), b"test") @@ -481,7 +481,7 @@ class TestMempoolManager: # this test makes sure that one spend successfully asserts the announce from # another spend, even though the create announcement is duplicated 100 times - @pytest.mark.asyncio + @pytest.mark.anyio async def test_coin_duplicate_announcement_consumed(self, one_node_one_block, wallet_a): def test_fun(coin_1: Coin, coin_2: Coin) -> SpendBundle: announce = Announcement(coin_2.name(), b"test") @@ -503,7 +503,7 @@ class TestMempoolManager: assert mempool_bundle == bundle assert status == MempoolInclusionStatus.SUCCESS - @pytest.mark.asyncio + @pytest.mark.anyio async def test_double_spend(self, two_nodes_one_block, wallet_a, self_hostname): reward_ph = wallet_a.get_new_puzzlehash() full_node_1, full_node_2, server_1, server_2, bt = two_nodes_one_block @@ -564,7 +564,7 @@ class TestMempoolManager: def assert_sb_not_in_pool(self, node, sb): assert node.full_node.mempool_manager.get_spendbundle(sb.name()) is None - @pytest.mark.asyncio + @pytest.mark.anyio async def test_double_spend_with_higher_fee(self, two_nodes_one_block, wallet_a, self_hostname): reward_ph = wallet_a.get_new_puzzlehash() @@ -639,7 +639,7 @@ class TestMempoolManager: self.assert_sb_not_in_pool(full_node_1, sb12) self.assert_sb_not_in_pool(full_node_1, sb3) - @pytest.mark.asyncio + @pytest.mark.anyio async def test_invalid_signature(self, one_node_one_block, wallet_a): reward_ph = wallet_a.get_new_puzzlehash() @@ -714,7 +714,7 @@ class TestMempoolManager: status, err = await respond_transaction(full_node_1, tx1, dummy_peer, test=True) return blocks, spend_bundle1, dummy_peer, status, err - @pytest.mark.asyncio + @pytest.mark.anyio async def condition_tester2(self, node_server_bt, wallet_a, test_fun: Callable[[Coin, Coin], SpendBundle]): reward_ph = wallet_a.get_new_puzzlehash() full_node_1, server_1, bt = node_server_bt @@ -751,7 +751,7 @@ class TestMempoolManager: return blocks, bundle, status, err - @pytest.mark.asyncio + @pytest.mark.anyio async def test_invalid_block_index(self, one_node_one_block, wallet_a): full_node_1, server_1, bt = one_node_one_block blocks = await full_node_1.get_all_full_blocks() @@ -768,7 +768,7 @@ class TestMempoolManager: assert err == Err.ASSERT_HEIGHT_ABSOLUTE_FAILED assert status == MempoolInclusionStatus.PENDING - @pytest.mark.asyncio + @pytest.mark.anyio async def test_block_index_missing_arg(self, one_node_one_block, wallet_a): full_node_1, server_1, bt = one_node_one_block cvp = ConditionWithArgs(ConditionOpcode.ASSERT_HEIGHT_ABSOLUTE, []) @@ -780,7 +780,7 @@ class TestMempoolManager: assert err == Err.INVALID_CONDITION assert status == MempoolInclusionStatus.FAILED - @pytest.mark.asyncio + @pytest.mark.anyio async def test_correct_block_index(self, one_node_one_block, wallet_a): full_node_1, server_1, bt = one_node_one_block cvp = ConditionWithArgs(ConditionOpcode.ASSERT_HEIGHT_ABSOLUTE, [int_to_bytes(1)]) @@ -791,7 +791,7 @@ class TestMempoolManager: assert sb1 == spend_bundle1 assert status == MempoolInclusionStatus.SUCCESS - @pytest.mark.asyncio + @pytest.mark.anyio async def test_block_index_garbage(self, one_node_one_block, wallet_a): full_node_1, server_1, bt = one_node_one_block # garbage at the end of the argument list is ignored in consensus mode, @@ -804,7 +804,7 @@ class TestMempoolManager: assert sb1 is None assert status == MempoolInclusionStatus.FAILED - @pytest.mark.asyncio + @pytest.mark.anyio async def test_negative_block_index(self, one_node_one_block, wallet_a): full_node_1, server_1, bt = one_node_one_block cvp = ConditionWithArgs(ConditionOpcode.ASSERT_HEIGHT_ABSOLUTE, [int_to_bytes(-1)]) @@ -815,7 +815,7 @@ class TestMempoolManager: assert sb1 == spend_bundle1 assert status == MempoolInclusionStatus.SUCCESS - @pytest.mark.asyncio + @pytest.mark.anyio async def test_invalid_block_age(self, one_node_one_block, wallet_a): full_node_1, server_1, bt = one_node_one_block cvp = ConditionWithArgs(ConditionOpcode.ASSERT_HEIGHT_RELATIVE, [int_to_bytes(5)]) @@ -827,7 +827,7 @@ class TestMempoolManager: # the transaction may become valid later assert status == MempoolInclusionStatus.PENDING - @pytest.mark.asyncio + @pytest.mark.anyio async def test_block_age_missing_arg(self, one_node_one_block, wallet_a): full_node_1, server_1, bt = one_node_one_block cvp = ConditionWithArgs(ConditionOpcode.ASSERT_HEIGHT_RELATIVE, []) @@ -839,7 +839,7 @@ class TestMempoolManager: # the transaction may become valid later assert status == MempoolInclusionStatus.FAILED - @pytest.mark.asyncio + @pytest.mark.anyio async def test_correct_block_age(self, one_node_one_block, wallet_a): full_node_1, server_1, bt = one_node_one_block cvp = ConditionWithArgs(ConditionOpcode.ASSERT_HEIGHT_RELATIVE, [int_to_bytes(1)]) @@ -853,7 +853,7 @@ class TestMempoolManager: assert sb1 == spend_bundle1 assert status == MempoolInclusionStatus.SUCCESS - @pytest.mark.asyncio + @pytest.mark.anyio async def test_block_age_garbage(self, one_node_one_block, wallet_a): full_node_1, server_1, bt = one_node_one_block # garbage at the end of the argument list is ignored in consensus mode, @@ -869,7 +869,7 @@ class TestMempoolManager: assert sb1 is None assert status == MempoolInclusionStatus.FAILED - @pytest.mark.asyncio + @pytest.mark.anyio async def test_negative_block_age(self, one_node_one_block, wallet_a): full_node_1, server_1, bt = one_node_one_block cvp = ConditionWithArgs(ConditionOpcode.ASSERT_HEIGHT_RELATIVE, [int_to_bytes(-1)]) @@ -883,7 +883,7 @@ class TestMempoolManager: assert sb1 == spend_bundle1 assert status == MempoolInclusionStatus.SUCCESS - @pytest.mark.asyncio + @pytest.mark.anyio async def test_correct_my_id(self, one_node_one_block, wallet_a): full_node_1, server_1, bt = one_node_one_block @@ -901,7 +901,7 @@ class TestMempoolManager: assert sb1 == spend_bundle1 assert status == MempoolInclusionStatus.SUCCESS - @pytest.mark.asyncio + @pytest.mark.anyio async def test_my_id_garbage(self, one_node_one_block, wallet_a): full_node_1, server_1, bt = one_node_one_block @@ -921,7 +921,7 @@ class TestMempoolManager: assert sb1 is None assert status == MempoolInclusionStatus.FAILED - @pytest.mark.asyncio + @pytest.mark.anyio async def test_invalid_my_id(self, one_node_one_block, wallet_a): full_node_1, server_1, bt = one_node_one_block @@ -940,7 +940,7 @@ class TestMempoolManager: assert sb1 is None assert status == MempoolInclusionStatus.FAILED - @pytest.mark.asyncio + @pytest.mark.anyio async def test_my_id_missing_arg(self, one_node_one_block, wallet_a): full_node_1, server_1, bt = one_node_one_block cvp = ConditionWithArgs(ConditionOpcode.ASSERT_MY_COIN_ID, []) @@ -952,7 +952,7 @@ class TestMempoolManager: assert sb1 is None assert status == MempoolInclusionStatus.FAILED - @pytest.mark.asyncio + @pytest.mark.anyio async def test_assert_time_exceeds(self, one_node_one_block, wallet_a): full_node_1, server_1, bt = one_node_one_block # 5 seconds should be before the next block @@ -966,7 +966,7 @@ class TestMempoolManager: assert sb1 == spend_bundle1 assert status == MempoolInclusionStatus.SUCCESS - @pytest.mark.asyncio + @pytest.mark.anyio async def test_assert_time_fail(self, one_node_one_block, wallet_a): full_node_1, server_1, bt = one_node_one_block time_now = full_node_1.full_node.blockchain.get_peak().timestamp + 1000 @@ -979,7 +979,7 @@ class TestMempoolManager: assert sb1 is None assert status == MempoolInclusionStatus.FAILED - @pytest.mark.asyncio + @pytest.mark.anyio async def test_assert_height_pending(self, one_node_one_block, wallet_a): full_node_1, server_1, bt = one_node_one_block print(full_node_1.full_node.blockchain.get_peak()) @@ -993,7 +993,7 @@ class TestMempoolManager: assert sb1 is None assert status == MempoolInclusionStatus.PENDING - @pytest.mark.asyncio + @pytest.mark.anyio async def test_assert_time_negative(self, one_node_one_block, wallet_a): full_node_1, server_1, bt = one_node_one_block time_now = -1 @@ -1006,7 +1006,7 @@ class TestMempoolManager: assert sb1 == spend_bundle1 assert status == MempoolInclusionStatus.SUCCESS - @pytest.mark.asyncio + @pytest.mark.anyio async def test_assert_time_missing_arg(self, one_node_one_block, wallet_a): full_node_1, server_1, bt = one_node_one_block @@ -1018,7 +1018,7 @@ class TestMempoolManager: assert sb1 is None assert status == MempoolInclusionStatus.FAILED - @pytest.mark.asyncio + @pytest.mark.anyio async def test_assert_time_garbage(self, one_node_one_block, wallet_a): full_node_1, server_1, bt = one_node_one_block time_now = full_node_1.full_node.blockchain.get_peak().timestamp + 5 @@ -1033,7 +1033,7 @@ class TestMempoolManager: assert sb1 is None assert status == MempoolInclusionStatus.FAILED - @pytest.mark.asyncio + @pytest.mark.anyio async def test_assert_time_relative_exceeds(self, one_node_one_block, wallet_a): full_node_1, server_1, bt = one_node_one_block time_relative = 3 @@ -1059,7 +1059,7 @@ class TestMempoolManager: assert sb1 == spend_bundle1 assert status == MempoolInclusionStatus.SUCCESS - @pytest.mark.asyncio + @pytest.mark.anyio async def test_assert_time_relative_garbage(self, one_node_one_block, wallet_a): full_node_1, server_1, bt = one_node_one_block time_relative = 0 @@ -1075,7 +1075,7 @@ class TestMempoolManager: assert sb1 is None assert status == MempoolInclusionStatus.FAILED - @pytest.mark.asyncio + @pytest.mark.anyio async def test_assert_time_relative_missing_arg(self, one_node_one_block, wallet_a): full_node_1, server_1, bt = one_node_one_block @@ -1088,7 +1088,7 @@ class TestMempoolManager: assert sb1 is None assert status == MempoolInclusionStatus.FAILED - @pytest.mark.asyncio + @pytest.mark.anyio async def test_assert_time_relative_negative(self, one_node_one_block, wallet_a): full_node_1, server_1, bt = one_node_one_block time_relative = -3 @@ -1103,7 +1103,7 @@ class TestMempoolManager: assert status == MempoolInclusionStatus.SUCCESS # ensure one spend can assert a coin announcement from another spend - @pytest.mark.asyncio + @pytest.mark.anyio async def test_correct_coin_announcement_consumed(self, one_node_one_block, wallet_a): def test_fun(coin_1: Coin, coin_2: Coin) -> SpendBundle: announce = Announcement(coin_2.name(), b"test") @@ -1127,7 +1127,7 @@ class TestMempoolManager: # ensure one spend can assert a coin announcement from another spend, even # though the conditions have garbage at the end - @pytest.mark.asyncio + @pytest.mark.anyio @pytest.mark.parametrize( "assert_garbage,announce_garbage,expected,expected_included", [ @@ -1169,7 +1169,7 @@ class TestMempoolManager: mempool_bundle = full_node_1.full_node.mempool_manager.get_spendbundle(bundle.name()) assert mempool_bundle == bundle - @pytest.mark.asyncio + @pytest.mark.anyio async def test_coin_announcement_missing_arg(self, one_node_one_block, wallet_a): full_node_1, server_1, bt = one_node_one_block @@ -1190,7 +1190,7 @@ class TestMempoolManager: assert full_node_1.full_node.mempool_manager.get_spendbundle(bundle.name()) is None assert status == MempoolInclusionStatus.FAILED - @pytest.mark.asyncio + @pytest.mark.anyio async def test_coin_announcement_missing_arg2(self, one_node_one_block, wallet_a): full_node_1, server_1, bt = one_node_one_block @@ -1212,7 +1212,7 @@ class TestMempoolManager: assert full_node_1.full_node.mempool_manager.get_spendbundle(bundle.name()) is None assert status == MempoolInclusionStatus.FAILED - @pytest.mark.asyncio + @pytest.mark.anyio async def test_coin_announcement_too_big(self, one_node_one_block, wallet_a): full_node_1, server_1, bt = one_node_one_block @@ -1247,7 +1247,7 @@ class TestMempoolManager: # ensure an assert coin announcement is rejected if it doesn't match the # create announcement - @pytest.mark.asyncio + @pytest.mark.anyio async def test_invalid_coin_announcement_rejected(self, one_node_one_block, wallet_a): full_node_1, server_1, bt = one_node_one_block @@ -1276,7 +1276,7 @@ class TestMempoolManager: assert mempool_bundle is None assert status == MempoolInclusionStatus.FAILED - @pytest.mark.asyncio + @pytest.mark.anyio async def test_invalid_coin_announcement_rejected_two(self, one_node_one_block, wallet_a): full_node_1, server_1, bt = one_node_one_block @@ -1302,7 +1302,7 @@ class TestMempoolManager: assert mempool_bundle is None assert status == MempoolInclusionStatus.FAILED - @pytest.mark.asyncio + @pytest.mark.anyio async def test_correct_puzzle_announcement(self, one_node_one_block, wallet_a): full_node_1, server_1, bt = one_node_one_block @@ -1328,7 +1328,7 @@ class TestMempoolManager: assert mempool_bundle == bundle assert status == MempoolInclusionStatus.SUCCESS - @pytest.mark.asyncio + @pytest.mark.anyio @pytest.mark.parametrize( "assert_garbage,announce_garbage,expected,expected_included", [ @@ -1371,7 +1371,7 @@ class TestMempoolManager: mempool_bundle = full_node_1.full_node.mempool_manager.get_spendbundle(bundle.name()) assert mempool_bundle == bundle - @pytest.mark.asyncio + @pytest.mark.anyio async def test_puzzle_announcement_missing_arg(self, one_node_one_block, wallet_a): full_node_1, server_1, bt = one_node_one_block @@ -1397,7 +1397,7 @@ class TestMempoolManager: assert mempool_bundle is None assert status == MempoolInclusionStatus.FAILED - @pytest.mark.asyncio + @pytest.mark.anyio async def test_puzzle_announcement_missing_arg2(self, one_node_one_block, wallet_a): full_node_1, server_1, bt = one_node_one_block @@ -1425,7 +1425,7 @@ class TestMempoolManager: assert mempool_bundle is None assert status == MempoolInclusionStatus.FAILED - @pytest.mark.asyncio + @pytest.mark.anyio async def test_invalid_puzzle_announcement_rejected(self, one_node_one_block, wallet_a): full_node_1, server_1, bt = one_node_one_block @@ -1454,7 +1454,7 @@ class TestMempoolManager: assert mempool_bundle is None assert status == MempoolInclusionStatus.FAILED - @pytest.mark.asyncio + @pytest.mark.anyio async def test_invalid_puzzle_announcement_rejected_two(self, one_node_one_block, wallet_a): full_node_1, server_1, bt = one_node_one_block @@ -1483,7 +1483,7 @@ class TestMempoolManager: assert mempool_bundle is None assert status == MempoolInclusionStatus.FAILED - @pytest.mark.asyncio + @pytest.mark.anyio async def test_assert_fee_condition(self, one_node_one_block, wallet_a): full_node_1, server_1, bt = one_node_one_block cvp = ConditionWithArgs(ConditionOpcode.RESERVE_FEE, [int_to_bytes(10)]) @@ -1497,7 +1497,7 @@ class TestMempoolManager: assert mempool_bundle is not None assert status == MempoolInclusionStatus.SUCCESS - @pytest.mark.asyncio + @pytest.mark.anyio async def test_assert_fee_condition_garbage(self, one_node_one_block, wallet_a): full_node_1, server_1, bt = one_node_one_block # garbage at the end of the arguments is ignored in consensus mode, but @@ -1513,7 +1513,7 @@ class TestMempoolManager: assert mempool_bundle is None assert status == MempoolInclusionStatus.FAILED - @pytest.mark.asyncio + @pytest.mark.anyio async def test_assert_fee_condition_missing_arg(self, one_node_one_block, wallet_a): full_node_1, server_1, bt = one_node_one_block cvp = ConditionWithArgs(ConditionOpcode.RESERVE_FEE, []) @@ -1527,7 +1527,7 @@ class TestMempoolManager: assert mempool_bundle is None assert status == MempoolInclusionStatus.FAILED - @pytest.mark.asyncio + @pytest.mark.anyio async def test_assert_fee_condition_negative_fee(self, one_node_one_block, wallet_a): full_node_1, server_1, bt = one_node_one_block cvp = ConditionWithArgs(ConditionOpcode.RESERVE_FEE, [int_to_bytes(-1)]) @@ -1545,7 +1545,7 @@ class TestMempoolManager: full_node_1.full_node.blockchain, blocks[-1], expected_error=Err.RESERVE_FEE_CONDITION_FAILED ) - @pytest.mark.asyncio + @pytest.mark.anyio async def test_assert_fee_condition_fee_too_large(self, one_node_one_block, wallet_a): full_node_1, server_1, bt = one_node_one_block cvp = ConditionWithArgs(ConditionOpcode.RESERVE_FEE, [int_to_bytes(2**64)]) @@ -1563,7 +1563,7 @@ class TestMempoolManager: full_node_1.full_node.blockchain, blocks[-1], expected_error=Err.RESERVE_FEE_CONDITION_FAILED ) - @pytest.mark.asyncio + @pytest.mark.anyio async def test_assert_fee_condition_wrong_fee(self, one_node_one_block, wallet_a): full_node_1, server_1, bt = one_node_one_block @@ -1576,7 +1576,7 @@ class TestMempoolManager: assert mempool_bundle is None assert status == MempoolInclusionStatus.FAILED - @pytest.mark.asyncio + @pytest.mark.anyio async def test_stealing_fee(self, two_nodes_one_block, wallet_a): reward_ph = wallet_a.get_new_puzzlehash() full_node_1, full_node_2, server_1, server_2, bt = two_nodes_one_block @@ -1632,7 +1632,7 @@ class TestMempoolManager: assert mempool_bundle is None assert status == MempoolInclusionStatus.FAILED - @pytest.mark.asyncio + @pytest.mark.anyio async def test_double_spend_same_bundle(self, two_nodes_one_block, wallet_a): reward_ph = wallet_a.get_new_puzzlehash() full_node_1, full_node_2, server_1, server_2, bt = two_nodes_one_block @@ -1677,7 +1677,7 @@ class TestMempoolManager: assert sb is None assert status == MempoolInclusionStatus.FAILED - @pytest.mark.asyncio + @pytest.mark.anyio async def test_agg_sig_condition(self, one_node_one_block, wallet_a): reward_ph = wallet_a.get_new_puzzlehash() full_node_1, server_1, bt = one_node_one_block @@ -1722,7 +1722,7 @@ class TestMempoolManager: # sb = full_node_1.full_node.mempool_manager.get_spendbundle(spend_bundle.name()) # assert sb is spend_bundle - @pytest.mark.asyncio + @pytest.mark.anyio async def test_correct_my_parent(self, one_node_one_block, wallet_a): full_node_1, server_1, bt = one_node_one_block @@ -1741,7 +1741,7 @@ class TestMempoolManager: assert sb1 == spend_bundle1 assert status == MempoolInclusionStatus.SUCCESS - @pytest.mark.asyncio + @pytest.mark.anyio async def test_my_parent_garbage(self, one_node_one_block, wallet_a): full_node_1, server_1, bt = one_node_one_block @@ -1762,7 +1762,7 @@ class TestMempoolManager: assert sb1 is None assert status == MempoolInclusionStatus.FAILED - @pytest.mark.asyncio + @pytest.mark.anyio async def test_my_parent_missing_arg(self, one_node_one_block, wallet_a): full_node_1, server_1, bt = one_node_one_block cvp = ConditionWithArgs(ConditionOpcode.ASSERT_MY_PARENT_ID, []) @@ -1775,7 +1775,7 @@ class TestMempoolManager: assert sb1 is None assert status == MempoolInclusionStatus.FAILED - @pytest.mark.asyncio + @pytest.mark.anyio async def test_invalid_my_parent(self, one_node_one_block, wallet_a): full_node_1, server_1, bt = one_node_one_block @@ -1795,7 +1795,7 @@ class TestMempoolManager: assert sb1 is None assert status == MempoolInclusionStatus.FAILED - @pytest.mark.asyncio + @pytest.mark.anyio async def test_correct_my_puzhash(self, one_node_one_block, wallet_a): full_node_1, server_1, bt = one_node_one_block @@ -1814,7 +1814,7 @@ class TestMempoolManager: assert sb1 == spend_bundle1 assert status == MempoolInclusionStatus.SUCCESS - @pytest.mark.asyncio + @pytest.mark.anyio async def test_my_puzhash_garbage(self, one_node_one_block, wallet_a): full_node_1, server_1, bt = one_node_one_block @@ -1834,7 +1834,7 @@ class TestMempoolManager: assert sb1 is None assert status == MempoolInclusionStatus.FAILED - @pytest.mark.asyncio + @pytest.mark.anyio async def test_my_puzhash_missing_arg(self, one_node_one_block, wallet_a): full_node_1, server_1, bt = one_node_one_block cvp = ConditionWithArgs(ConditionOpcode.ASSERT_MY_PUZZLEHASH, []) @@ -1847,7 +1847,7 @@ class TestMempoolManager: assert sb1 is None assert status == MempoolInclusionStatus.FAILED - @pytest.mark.asyncio + @pytest.mark.anyio async def test_invalid_my_puzhash(self, one_node_one_block, wallet_a): full_node_1, server_1, bt = one_node_one_block @@ -1866,7 +1866,7 @@ class TestMempoolManager: assert sb1 is None assert status == MempoolInclusionStatus.FAILED - @pytest.mark.asyncio + @pytest.mark.anyio async def test_correct_my_amount(self, one_node_one_block, wallet_a): full_node_1, server_1, bt = one_node_one_block @@ -1885,7 +1885,7 @@ class TestMempoolManager: assert sb1 == spend_bundle1 assert status == MempoolInclusionStatus.SUCCESS - @pytest.mark.asyncio + @pytest.mark.anyio async def test_my_amount_garbage(self, one_node_one_block, wallet_a): full_node_1, server_1, bt = one_node_one_block @@ -1906,7 +1906,7 @@ class TestMempoolManager: assert sb1 is None assert status == MempoolInclusionStatus.FAILED - @pytest.mark.asyncio + @pytest.mark.anyio async def test_my_amount_missing_arg(self, one_node_one_block, wallet_a): full_node_1, server_1, bt = one_node_one_block cvp = ConditionWithArgs(ConditionOpcode.ASSERT_MY_AMOUNT, []) @@ -1919,7 +1919,7 @@ class TestMempoolManager: assert sb1 is None assert status == MempoolInclusionStatus.FAILED - @pytest.mark.asyncio + @pytest.mark.anyio async def test_invalid_my_amount(self, one_node_one_block, wallet_a): full_node_1, server_1, bt = one_node_one_block cvp = ConditionWithArgs(ConditionOpcode.ASSERT_MY_AMOUNT, [int_to_bytes(1000)]) @@ -1932,7 +1932,7 @@ class TestMempoolManager: assert sb1 is None assert status == MempoolInclusionStatus.FAILED - @pytest.mark.asyncio + @pytest.mark.anyio async def test_negative_my_amount(self, one_node_one_block, wallet_a): full_node_1, server_1, bt = one_node_one_block cvp = ConditionWithArgs(ConditionOpcode.ASSERT_MY_AMOUNT, [int_to_bytes(-1)]) @@ -1945,7 +1945,7 @@ class TestMempoolManager: assert sb1 is None assert status == MempoolInclusionStatus.FAILED - @pytest.mark.asyncio + @pytest.mark.anyio async def test_my_amount_too_large(self, one_node_one_block, wallet_a): full_node_1, server_1, bt = one_node_one_block cvp = ConditionWithArgs(ConditionOpcode.ASSERT_MY_AMOUNT, [int_to_bytes(2**64)]) @@ -2636,7 +2636,7 @@ class TestMaliciousGenerators: spend = npc_result.conds.spends[0] assert len(spend.create_coin) == 6094 - @pytest.mark.asyncio + @pytest.mark.anyio async def test_invalid_coin_spend_coin(self, one_node_one_block, wallet_a): full_node_1, server_1, bt = one_node_one_block reward_ph = wallet_a.get_new_puzzlehash() diff --git a/tests/core/mempool/test_mempool_fee_estimator.py b/tests/core/mempool/test_mempool_fee_estimator.py index 23ed6d96bad6..6dc2e7ce9946 100644 --- a/tests/core/mempool/test_mempool_fee_estimator.py +++ b/tests/core/mempool/test_mempool_fee_estimator.py @@ -16,7 +16,7 @@ from tests.core.consensus.test_pot_iterations import test_constants from tests.util.db_connection import DBConnection -@pytest.mark.asyncio +@pytest.mark.anyio async def test_basics() -> None: fee_store = FeeStore() fee_tracker = FeeTracker(fee_store) @@ -59,7 +59,7 @@ async def test_basics() -> None: assert long.median != -1 -@pytest.mark.asyncio +@pytest.mark.anyio async def test_fee_increase() -> None: async with DBConnection(db_version=2) as db_wrapper: coin_store = await CoinStore.create(db_wrapper) diff --git a/tests/core/mempool/test_mempool_fee_protocol.py b/tests/core/mempool/test_mempool_fee_protocol.py index 17182fdf8343..38799da5ba7f 100644 --- a/tests/core/mempool/test_mempool_fee_protocol.py +++ b/tests/core/mempool/test_mempool_fee_protocol.py @@ -18,7 +18,7 @@ from chia.wallet.wallet import Wallet from tests.core.node_height import node_height_at_least -@pytest.mark.asyncio +@pytest.mark.anyio async def test_protocol_messages( simulator_and_wallet: Tuple[ List[Union[FullNodeAPI, FullNodeSimulator]], List[Tuple[Wallet, ChiaServer]], BlockTools diff --git a/tests/core/mempool/test_mempool_manager.py b/tests/core/mempool/test_mempool_manager.py index f11b107f905f..4f7a772deaef 100644 --- a/tests/core/mempool/test_mempool_manager.py +++ b/tests/core/mempool/test_mempool_manager.py @@ -388,7 +388,7 @@ def mempool_item_from_spendbundle(spend_bundle: SpendBundle) -> MempoolItem: ) -@pytest.mark.asyncio +@pytest.mark.anyio async def test_empty_spend_bundle() -> None: mempool_manager = await instantiate_mempool_manager(zero_calls_get_coin_record) sb = SpendBundle([], G2Element()) @@ -396,7 +396,7 @@ async def test_empty_spend_bundle() -> None: await mempool_manager.pre_validate_spendbundle(sb, None, sb.name()) -@pytest.mark.asyncio +@pytest.mark.anyio async def test_negative_addition_amount() -> None: mempool_manager = await instantiate_mempool_manager(zero_calls_get_coin_record) conditions = [[ConditionOpcode.CREATE_COIN, IDENTITY_PUZZLE_HASH, -1]] @@ -405,7 +405,7 @@ async def test_negative_addition_amount() -> None: await mempool_manager.pre_validate_spendbundle(sb, None, sb.name()) -@pytest.mark.asyncio +@pytest.mark.anyio async def test_valid_addition_amount() -> None: mempool_manager = await instantiate_mempool_manager(zero_calls_get_coin_record) max_amount = mempool_manager.constants.MAX_COIN_AMOUNT @@ -416,7 +416,7 @@ async def test_valid_addition_amount() -> None: assert npc_result.error is None -@pytest.mark.asyncio +@pytest.mark.anyio async def test_too_big_addition_amount() -> None: mempool_manager = await instantiate_mempool_manager(zero_calls_get_coin_record) max_amount = mempool_manager.constants.MAX_COIN_AMOUNT @@ -426,7 +426,7 @@ async def test_too_big_addition_amount() -> None: await mempool_manager.pre_validate_spendbundle(sb, None, sb.name()) -@pytest.mark.asyncio +@pytest.mark.anyio async def test_duplicate_output() -> None: mempool_manager = await instantiate_mempool_manager(zero_calls_get_coin_record) conditions = [ @@ -438,7 +438,7 @@ async def test_duplicate_output() -> None: await mempool_manager.pre_validate_spendbundle(sb, None, sb.name()) -@pytest.mark.asyncio +@pytest.mark.anyio async def test_block_cost_exceeds_max() -> None: mempool_manager = await instantiate_mempool_manager(zero_calls_get_coin_record) conditions = [] @@ -449,7 +449,7 @@ async def test_block_cost_exceeds_max() -> None: await mempool_manager.pre_validate_spendbundle(sb, None, sb.name()) -@pytest.mark.asyncio +@pytest.mark.anyio async def test_double_spend_prevalidation() -> None: mempool_manager = await instantiate_mempool_manager(zero_calls_get_coin_record) conditions = [[ConditionOpcode.CREATE_COIN, IDENTITY_PUZZLE_HASH, 1]] @@ -459,7 +459,7 @@ async def test_double_spend_prevalidation() -> None: await mempool_manager.pre_validate_spendbundle(sb_twice, None, sb_twice.name()) -@pytest.mark.asyncio +@pytest.mark.anyio async def test_minting_coin() -> None: mempool_manager = await instantiate_mempool_manager(zero_calls_get_coin_record) conditions = [[ConditionOpcode.CREATE_COIN, IDENTITY_PUZZLE_HASH, TEST_COIN_AMOUNT]] @@ -472,7 +472,7 @@ async def test_minting_coin() -> None: await mempool_manager.pre_validate_spendbundle(sb, None, sb.name()) -@pytest.mark.asyncio +@pytest.mark.anyio async def test_reserve_fee_condition() -> None: mempool_manager = await instantiate_mempool_manager(zero_calls_get_coin_record) conditions = [[ConditionOpcode.RESERVE_FEE, TEST_COIN_AMOUNT]] @@ -485,7 +485,7 @@ async def test_reserve_fee_condition() -> None: await mempool_manager.pre_validate_spendbundle(sb, None, sb.name()) -@pytest.mark.asyncio +@pytest.mark.anyio async def test_unknown_unspent() -> None: async def get_coin_record(_: bytes32) -> Optional[CoinRecord]: return None @@ -496,7 +496,7 @@ async def test_unknown_unspent() -> None: assert result == (None, MempoolInclusionStatus.FAILED, Err.UNKNOWN_UNSPENT) -@pytest.mark.asyncio +@pytest.mark.anyio async def test_same_sb_twice_with_eligible_coin() -> None: mempool_manager = await instantiate_mempool_manager(get_coin_record_for_test_coins) sb1_conditions = [ @@ -520,7 +520,7 @@ async def test_same_sb_twice_with_eligible_coin() -> None: assert mempool_manager.get_spendbundle(sb_name) == sb -@pytest.mark.asyncio +@pytest.mark.anyio async def test_sb_twice_with_eligible_coin_and_different_spends_order() -> None: mempool_manager = await instantiate_mempool_manager(get_coin_record_for_test_coins) sb1_conditions = [ @@ -558,7 +558,7 @@ co = ConditionOpcode mis = MempoolInclusionStatus -@pytest.mark.asyncio +@pytest.mark.anyio @pytest.mark.parametrize( "opcode,lock_value,expected_status,expected_error", [ @@ -828,7 +828,7 @@ def test_can_replace(existing_items: List[MempoolItem], new_item: MempoolItem, e assert can_replace(existing_items, removals, new_item) == expected -@pytest.mark.asyncio +@pytest.mark.anyio async def test_get_items_not_in_filter() -> None: mempool_manager = await instantiate_mempool_manager(get_coin_record_for_test_coins) conditions = [[ConditionOpcode.CREATE_COIN, IDENTITY_PUZZLE_HASH, 1]] @@ -873,7 +873,7 @@ async def test_get_items_not_in_filter() -> None: assert result == [sb1] -@pytest.mark.asyncio +@pytest.mark.anyio async def test_total_mempool_fees() -> None: coin_records: Dict[bytes32, CoinRecord] = {} @@ -906,7 +906,7 @@ async def test_total_mempool_fees() -> None: @pytest.mark.parametrize("reverse_tx_order", [True, False]) -@pytest.mark.asyncio +@pytest.mark.anyio async def test_create_bundle_from_mempool(reverse_tx_order: bool) -> None: async def make_coin_spends(coins: List[Coin], *, high_fees: bool = True) -> List[CoinSpend]: spends_list = [] @@ -941,7 +941,7 @@ async def test_create_bundle_from_mempool(reverse_tx_order: bool) -> None: assert len([s for s in low_rate_spends if s in result[0].coin_spends]) == 0 -@pytest.mark.asyncio +@pytest.mark.anyio async def test_create_bundle_from_mempool_on_max_cost() -> None: # This test exercises the path where an item's inclusion would exceed the # maximum cumulative cost, so it gets skipped as a result @@ -991,7 +991,7 @@ async def test_create_bundle_from_mempool_on_max_cost() -> None: (co.ASSERT_BEFORE_SECONDS_RELATIVE, 120, False, 9900 + 120), ], ) -@pytest.mark.asyncio +@pytest.mark.anyio async def test_assert_before_expiration( opcode: ConditionOpcode, arg: int, expect_eviction: bool, expect_limit: Optional[int] ) -> None: @@ -1070,7 +1070,7 @@ def assert_sb_not_in_pool(mempool_manager: MempoolManager, sb: SpendBundle) -> N assert mempool_manager.get_spendbundle(sb.name()) is None -@pytest.mark.asyncio +@pytest.mark.anyio async def test_insufficient_fee_increase() -> None: mempool_manager, coins = await setup_mempool_with_coins(coin_amounts=list(range(1000000000, 1000000010))) sb1_1 = await make_and_send_spendbundle(mempool_manager, coins[0]) @@ -1082,7 +1082,7 @@ async def test_insufficient_fee_increase() -> None: assert_sb_not_in_pool(mempool_manager, sb1_2) -@pytest.mark.asyncio +@pytest.mark.anyio async def test_sufficient_fee_increase() -> None: mempool_manager, coins = await setup_mempool_with_coins(coin_amounts=list(range(1000000000, 1000000010))) sb1_1 = await make_and_send_spendbundle(mempool_manager, coins[0]) @@ -1092,7 +1092,7 @@ async def test_sufficient_fee_increase() -> None: assert_sb_in_pool(mempool_manager, sb1_2) -@pytest.mark.asyncio +@pytest.mark.anyio async def test_superset() -> None: # Aggregated spendbundle sb12 replaces sb1 since it spends a superset # of coins spent in sb1 @@ -1105,7 +1105,7 @@ async def test_superset() -> None: assert_sb_not_in_pool(mempool_manager, sb1) -@pytest.mark.asyncio +@pytest.mark.anyio async def test_superset_violation() -> None: mempool_manager, coins = await setup_mempool_with_coins(coin_amounts=list(range(1000000000, 1000000010))) sb1 = make_test_spendbundle(coins[0]) @@ -1124,7 +1124,7 @@ async def test_superset_violation() -> None: assert_sb_not_in_pool(mempool_manager, sb23) -@pytest.mark.asyncio +@pytest.mark.anyio async def test_total_fpc_decrease() -> None: mempool_manager, coins = await setup_mempool_with_coins(coin_amounts=list(range(1000000000, 1000000010))) sb1 = make_test_spendbundle(coins[0]) @@ -1143,7 +1143,7 @@ async def test_total_fpc_decrease() -> None: assert_sb_not_in_pool(mempool_manager, sb1234) -@pytest.mark.asyncio +@pytest.mark.anyio async def test_sufficient_total_fpc_increase() -> None: mempool_manager, coins = await setup_mempool_with_coins(coin_amounts=list(range(1000000000, 1000000010))) sb1 = make_test_spendbundle(coins[0]) @@ -1163,7 +1163,7 @@ async def test_sufficient_total_fpc_increase() -> None: assert_sb_not_in_pool(mempool_manager, sb3) -@pytest.mark.asyncio +@pytest.mark.anyio async def test_replace_with_extra_eligible_coin() -> None: mempool_manager, coins = await setup_mempool_with_coins(coin_amounts=list(range(1000000000, 1000000010))) sb1234 = SpendBundle.aggregate([make_test_spendbundle(coins[i]) for i in range(4)]) @@ -1177,7 +1177,7 @@ async def test_replace_with_extra_eligible_coin() -> None: assert_sb_in_pool(mempool_manager, sb1234_2) -@pytest.mark.asyncio +@pytest.mark.anyio async def test_replacing_one_with_an_eligible_coin() -> None: mempool_manager, coins = await setup_mempool_with_coins(coin_amounts=list(range(1000000000, 1000000010))) sb123 = SpendBundle.aggregate([make_test_spendbundle(coins[i]) for i in range(3)]) @@ -1339,7 +1339,7 @@ def test_dedup_info_eligible_3rd_time_another_2nd_time_and_one_non_eligible() -> assert eligible_coin_spends == expected_eligible_spends -@pytest.mark.asyncio +@pytest.mark.anyio @pytest.mark.parametrize("new_height_step", [1, 2, -1]) async def test_coin_spending_different_ways_then_finding_it_spent_in_new_peak(new_height_step: int) -> None: # This test makes sure all mempool items that spend a coin (in different ways) @@ -1376,7 +1376,7 @@ async def test_coin_spending_different_ways_then_finding_it_spent_in_new_peak(ne assert len(list(mempool_manager.mempool.items_by_feerate())) == 0 -@pytest.mark.asyncio +@pytest.mark.anyio async def test_bundle_coin_spends() -> None: # This tests the construction of bundle_coin_spends map for mempool items # We're creating sb123e with 4 coins, one of them being eligible @@ -1400,7 +1400,7 @@ async def test_bundle_coin_spends() -> None: ) -@pytest.mark.asyncio +@pytest.mark.anyio async def test_identical_spend_aggregation_e2e(simulator_and_wallet: SimulatorsAndWallets, self_hostname: str) -> None: def get_sb_names_by_coin_id( full_node_api: FullNodeSimulator, diff --git a/tests/core/mempool/test_mempool_performance.py b/tests/core/mempool/test_mempool_performance.py index 06375e71129e..0b3f549d677b 100644 --- a/tests/core/mempool/test_mempool_performance.py +++ b/tests/core/mempool/test_mempool_performance.py @@ -27,7 +27,7 @@ async def wallet_balance_at_least(wallet_node: WalletNode, balance: uint128) -> @pytest.mark.limit_consensus_modes(reason="benchmark") -@pytest.mark.asyncio +@pytest.mark.anyio async def test_mempool_update_performance( wallet_nodes_mempool_perf: SimulatorsAndWallets, default_400_blocks: List[FullBlock], diff --git a/tests/core/server/test_dos.py b/tests/core/server/test_dos.py index aeb1048cbea2..fc79fe83d92d 100644 --- a/tests/core/server/test_dos.py +++ b/tests/core/server/test_dos.py @@ -38,7 +38,7 @@ class FakeRateLimiter: class TestDos: - @pytest.mark.asyncio + @pytest.mark.anyio async def test_large_message_disconnect_and_ban(self, setup_two_nodes_fixture, self_hostname): nodes, _, _ = setup_two_nodes_fixture server_1 = nodes[0].full_node.server @@ -84,7 +84,7 @@ class TestDos: pass await session.close() - @pytest.mark.asyncio + @pytest.mark.anyio async def test_bad_handshake_and_ban(self, setup_two_nodes_fixture, self_hostname): nodes, _, _ = setup_two_nodes_fixture server_1 = nodes[0].full_node.server @@ -126,7 +126,7 @@ class TestDos: await session.close() - @pytest.mark.asyncio + @pytest.mark.anyio async def test_invalid_protocol_handshake(self, setup_two_nodes_fixture, self_hostname): nodes, _, _ = setup_two_nodes_fixture server_1 = nodes[0].full_node.server @@ -157,7 +157,7 @@ class TestDos: await session.close() await asyncio.sleep(1) # give some time for cleanup to work - @pytest.mark.asyncio + @pytest.mark.anyio async def test_spam_tx(self, setup_two_nodes_fixture, self_hostname): nodes, _, _ = setup_two_nodes_fixture full_node_1, full_node_2 = nodes @@ -212,7 +212,7 @@ class TestDos: await time_out_assert(15, is_banned) - @pytest.mark.asyncio + @pytest.mark.anyio async def test_spam_message_non_tx(self, setup_two_nodes_fixture, self_hostname): nodes, _, _ = setup_two_nodes_fixture full_node_1, full_node_2 = nodes @@ -261,7 +261,7 @@ class TestDos: await time_out_assert(15, is_banned) - @pytest.mark.asyncio + @pytest.mark.anyio async def test_spam_message_too_large(self, setup_two_nodes_fixture, self_hostname): nodes, _, _ = setup_two_nodes_fixture full_node_1, full_node_2 = nodes diff --git a/tests/core/server/test_loop.py b/tests/core/server/test_loop.py index bf1d58659fce..be0dabc6ee8a 100644 --- a/tests/core/server/test_loop.py +++ b/tests/core/server/test_loop.py @@ -149,7 +149,7 @@ class ServeInThread: chia_policy.global_max_concurrent_connections = self.original_connection_limit -@pytest.mark.asyncio +@pytest.mark.anyio async def test_loop(tmp_path: pathlib.Path) -> None: logger = create_logger() @@ -260,7 +260,7 @@ async def test_loop(tmp_path: pathlib.Path) -> None: argvalues=[1, 3], ids=lambda cycles: f"{cycles} cycle{'s' if cycles != 1 else ''}", ) -@pytest.mark.asyncio +@pytest.mark.anyio async def test_limits_connections(repetition: int, cycles: int, tmp_path: pathlib.Path) -> None: ip = "127.0.0.1" connection_limit = 10 diff --git a/tests/core/server/test_node_discovery.py b/tests/core/server/test_node_discovery.py index f8afa40cb01e..133456528a7e 100644 --- a/tests/core/server/test_node_discovery.py +++ b/tests/core/server/test_node_discovery.py @@ -13,7 +13,7 @@ from chia.simulator.block_tools import BlockTools from chia.util.default_root import SIMULATOR_ROOT_PATH -@pytest.mark.asyncio +@pytest.mark.anyio async def test_enable_private_networks( two_nodes: Tuple[FullNodeAPI, FullNodeAPI, ChiaServer, ChiaServer, BlockTools], ) -> None: diff --git a/tests/core/server/test_rate_limits.py b/tests/core/server/test_rate_limits.py index 364a7c386ed9..d88829317172 100644 --- a/tests/core/server/test_rate_limits.py +++ b/tests/core/server/test_rate_limits.py @@ -23,13 +23,13 @@ test_different_versions_results: List[int] = [] class TestRateLimits: - @pytest.mark.asyncio + @pytest.mark.anyio async def test_get_rate_limits_to_use(self): assert get_rate_limits_to_use(rl_v2, rl_v2) != get_rate_limits_to_use(rl_v2, rl_v1) assert get_rate_limits_to_use(rl_v1, rl_v1) == get_rate_limits_to_use(rl_v2, rl_v1) assert get_rate_limits_to_use(rl_v1, rl_v1) == get_rate_limits_to_use(rl_v1, rl_v2) - @pytest.mark.asyncio + @pytest.mark.anyio async def test_too_many_messages(self): # Too many messages r = RateLimiter(incoming=True) @@ -57,7 +57,7 @@ class TestRateLimits: saw_disconnect = True assert saw_disconnect - @pytest.mark.asyncio + @pytest.mark.anyio async def test_large_message(self): # Large tx small_tx_message = make_msg(ProtocolMessageTypes.respond_transaction, bytes([1] * 500 * 1024)) @@ -74,7 +74,7 @@ class TestRateLimits: assert r.process_msg_and_check(small_vdf_message, rl_v2, rl_v2) assert not r.process_msg_and_check(large_vdf_message, rl_v2, rl_v2) - @pytest.mark.asyncio + @pytest.mark.anyio async def test_too_much_data(self): # Too much data r = RateLimiter(incoming=True) @@ -101,7 +101,7 @@ class TestRateLimits: saw_disconnect = True assert saw_disconnect - @pytest.mark.asyncio + @pytest.mark.anyio async def test_non_tx_aggregate_limits(self): # Frequency limits r = RateLimiter(incoming=True) @@ -137,7 +137,7 @@ class TestRateLimits: saw_disconnect = True assert saw_disconnect - @pytest.mark.asyncio + @pytest.mark.anyio async def test_periodic_reset(self): r = RateLimiter(True, 5) tx_message = make_msg(ProtocolMessageTypes.respond_transaction, bytes([1] * 500 * 1024)) @@ -169,7 +169,7 @@ class TestRateLimits: await asyncio.sleep(6) assert r.process_msg_and_check(new_tx_message, rl_v2, rl_v2) - @pytest.mark.asyncio + @pytest.mark.anyio async def test_percentage_limits(self): r = RateLimiter(True, 60, 40) new_peak_message = make_msg(ProtocolMessageTypes.new_peak, bytes([1] * 40)) @@ -228,7 +228,7 @@ class TestRateLimits: saw_disconnect = True assert saw_disconnect - @pytest.mark.asyncio + @pytest.mark.anyio async def test_too_many_outgoing_messages(self): # Too many messages r = RateLimiter(incoming=False) @@ -251,7 +251,7 @@ class TestRateLimits: new_signatures_message = make_msg(ProtocolMessageTypes.respond_signatures, bytes([1])) assert r.process_msg_and_check(new_signatures_message, rl_v2, rl_v2) - @pytest.mark.asyncio + @pytest.mark.anyio async def test_too_many_incoming_messages(self): # Too many messages r = RateLimiter(incoming=True) @@ -298,7 +298,7 @@ class TestRateLimits: ], indirect=True, ) - @pytest.mark.asyncio + @pytest.mark.anyio async def test_different_versions(self, node_with_params, node_with_params_b, self_hostname): node_a = node_with_params node_b = node_with_params_b @@ -332,7 +332,7 @@ class TestRateLimits: if len(test_different_versions_results) >= 4: assert len(set(test_different_versions_results)) >= 2 - @pytest.mark.asyncio + @pytest.mark.anyio async def test_compose(self): rl_1 = rl_numbers[1] rl_2 = rl_numbers[2] diff --git a/tests/core/server/test_server.py b/tests/core/server/test_server.py index 2ec642a5acb0..18d3c328a5af 100644 --- a/tests/core/server/test_server.py +++ b/tests/core/server/test_server.py @@ -40,7 +40,7 @@ class TestAPI: raise ApiError(Err.NO_TRANSACTIONS_WHILE_SYNCING, f"Some error message: {request.transaction_id}", b"ab") -@pytest.mark.asyncio +@pytest.mark.anyio async def test_duplicate_client_connection( two_nodes: Tuple[FullNodeAPI, FullNodeAPI, ChiaServer, ChiaServer, BlockTools], self_hostname: str ) -> None: @@ -49,7 +49,7 @@ async def test_duplicate_client_connection( assert not await server_2.start_client(PeerInfo(self_hostname, server_1.get_port()), None) -@pytest.mark.asyncio +@pytest.mark.anyio @pytest.mark.parametrize("method", [repr, str]) async def test_connection_string_conversion( two_nodes_one_block: Tuple[FullNodeAPI, FullNodeAPI, ChiaServer, ChiaServer, BlockTools], @@ -65,7 +65,7 @@ async def test_connection_string_conversion( assert len(converted) < 1000 -@pytest.mark.asyncio +@pytest.mark.anyio async def test_connection_versions( self_hostname: str, one_wallet_and_one_simulator_services: SimulatorsAndWalletsServices ) -> None: @@ -83,7 +83,7 @@ async def test_connection_versions( assert connection.get_version() == chia_full_version_str() -@pytest.mark.asyncio +@pytest.mark.anyio async def test_api_not_ready( self_hostname: str, one_wallet_and_one_simulator_services: SimulatorsAndWalletsServices, @@ -110,7 +110,7 @@ async def test_api_not_ready( @pytest.mark.parametrize("version", ["0.0.34", "0.0.35", "0.0.36"]) -@pytest.mark.asyncio +@pytest.mark.anyio async def test_error_response( one_wallet_and_one_simulator_services: SimulatorsAndWalletsServices, self_hostname: str, @@ -147,7 +147,7 @@ async def test_error_response( @pytest.mark.parametrize( "error", [Error(int16(Err.UNKNOWN.value), "1", bytes([1, 2, 3])), Error(int16(Err.UNKNOWN.value), "2", None)] ) -@pytest.mark.asyncio +@pytest.mark.anyio async def test_error_receive( one_wallet_and_one_simulator_services: SimulatorsAndWalletsServices, self_hostname: str, @@ -174,7 +174,7 @@ async def test_error_receive( await time_out_assert(10, error_log_found, True, wallet_connection) -@pytest.mark.asyncio +@pytest.mark.anyio async def test_call_api_of_specific( two_nodes: Tuple[FullNodeAPI, FullNodeAPI, ChiaServer, ChiaServer, BlockTools], self_hostname: str ) -> None: @@ -189,7 +189,7 @@ async def test_call_api_of_specific( assert isinstance(message, RejectBlock) -@pytest.mark.asyncio +@pytest.mark.anyio async def test_call_api_of_specific_for_missing_peer( two_nodes: Tuple[FullNodeAPI, FullNodeAPI, ChiaServer, ChiaServer, BlockTools] ) -> None: diff --git a/tests/core/services/test_services.py b/tests/core/services/test_services.py index 070032b77449..7b03310701f8 100644 --- a/tests/core/services/test_services.py +++ b/tests/core/services/test_services.py @@ -53,7 +53,7 @@ async def wait_for_daemon_connection(root_path: Path, config: Dict[str, Any], ti @pytest.mark.parametrize(argnames="signal_number", argvalues=sendable_termination_signals) -@pytest.mark.asyncio +@pytest.mark.anyio async def test_daemon_terminates(signal_number: signal.Signals, chia_root: ChiaRoot) -> None: port = find_available_listen_port() with lock_and_load_config(root_path=chia_root.path, filename="config.yaml") as config: @@ -91,7 +91,7 @@ async def test_daemon_terminates(signal_number: signal.Signals, chia_root: ChiaR # [, "chia.data_layer.data_layer_server", "data_layer"], ], ) -@pytest.mark.asyncio +@pytest.mark.anyio async def test_services_terminate( signal_number: signal.Signals, chia_root: ChiaRoot, diff --git a/tests/core/ssl/test_ssl.py b/tests/core/ssl/test_ssl.py index b30ea3536602..ef1976847e3f 100644 --- a/tests/core/ssl/test_ssl.py +++ b/tests/core/ssl/test_ssl.py @@ -38,7 +38,7 @@ async def establish_connection(server: ChiaServer, self_hostname: str, ssl_conte class TestSSL: - @pytest.mark.asyncio + @pytest.mark.anyio async def test_public_connections(self, simulator_and_wallet, self_hostname): full_nodes, wallets, _ = simulator_and_wallet full_node_api = full_nodes[0] @@ -48,7 +48,7 @@ class TestSSL: success = await server_2.start_client(PeerInfo(self_hostname, server_1.get_port()), None) assert success is True - @pytest.mark.asyncio + @pytest.mark.anyio async def test_farmer(self, farmer_one_harvester, self_hostname): _, farmer_service, bt = farmer_one_harvester farmer_api = farmer_service._api @@ -79,7 +79,7 @@ class TestSSL: with pytest.raises(aiohttp.ServerDisconnectedError): await establish_connection(farmer_server, self_hostname, ssl_context) - @pytest.mark.asyncio + @pytest.mark.anyio async def test_full_node(self, simulator_and_wallet, self_hostname): full_nodes, wallets, bt = simulator_and_wallet full_node_api = full_nodes[0] @@ -98,7 +98,7 @@ class TestSSL: ssl_context = ssl_context_for_client(chia_ca_crt_path, chia_ca_key_path, pub_crt, pub_key) await establish_connection(full_node_server, self_hostname, ssl_context) - @pytest.mark.asyncio + @pytest.mark.anyio async def test_introducer(self, introducer_service, self_hostname): introducer_server = introducer_service._node.server chia_ca_crt_path, chia_ca_key_path = chia_ssl_ca_paths(introducer_service.root_path, introducer_service.config) diff --git a/tests/core/test_cost_calculation.py b/tests/core/test_cost_calculation.py index 163427b613e9..28a1af0aae60 100644 --- a/tests/core/test_cost_calculation.py +++ b/tests/core/test_cost_calculation.py @@ -53,7 +53,7 @@ def large_block_generator(size): return blob -@pytest.mark.asyncio +@pytest.mark.anyio async def test_basics(softfork_height, bt): wallet_tool = bt.get_pool_wallet_tool() ph = wallet_tool.get_new_puzzlehash() @@ -111,7 +111,7 @@ async def test_basics(softfork_height, bt): ) -@pytest.mark.asyncio +@pytest.mark.anyio async def test_mempool_mode(softfork_height, bt): wallet_tool = bt.get_pool_wallet_tool() ph = wallet_tool.get_new_puzzlehash() @@ -173,7 +173,7 @@ async def test_mempool_mode(softfork_height, bt): assert spend_info.puzzle.to_program() == puzzle -@pytest.mark.asyncio +@pytest.mark.anyio async def test_clvm_mempool_mode(softfork_height): block = Program.from_bytes(bytes(SMALL_BLOCK_GENERATOR.program)) disassembly = binutils.disassemble(block) @@ -201,7 +201,7 @@ async def test_clvm_mempool_mode(softfork_height): assert npc_result.error is None -@pytest.mark.asyncio +@pytest.mark.anyio async def test_tx_generator_speed(softfork_height, benchmark_runner: BenchmarkRunner): LARGE_BLOCK_COIN_CONSUMED_COUNT = 687 generator_bytes = large_block_generator(LARGE_BLOCK_COIN_CONSUMED_COUNT) @@ -222,7 +222,7 @@ async def test_tx_generator_speed(softfork_height, benchmark_runner: BenchmarkRu assert len(npc_result.conds.spends) == LARGE_BLOCK_COIN_CONSUMED_COUNT -@pytest.mark.asyncio +@pytest.mark.anyio async def test_clvm_max_cost(softfork_height): block = Program.from_bytes(bytes(SMALL_BLOCK_GENERATOR.program)) disassembly = binutils.disassemble(block) @@ -254,7 +254,7 @@ async def test_clvm_max_cost(softfork_height): assert npc_result.cost > 10000000 -@pytest.mark.asyncio +@pytest.mark.anyio async def test_standard_tx(benchmark_runner: BenchmarkRunner): # this isn't a real public key, but we don't care public_key = bytes.fromhex( @@ -278,7 +278,7 @@ async def test_standard_tx(benchmark_runner: BenchmarkRunner): total_cost += cost -@pytest.mark.asyncio +@pytest.mark.anyio async def test_get_puzzle_and_solution_for_coin_performance(benchmark_runner: BenchmarkRunner): from clvm.casts import int_from_bytes diff --git a/tests/core/test_crawler.py b/tests/core/test_crawler.py index aebacb8a1d9c..786a7133a434 100644 --- a/tests/core/test_crawler.py +++ b/tests/core/test_crawler.py @@ -22,7 +22,7 @@ from chia.types.peer_info import PeerInfo from chia.util.ints import uint32, uint64, uint128 -@pytest.mark.asyncio +@pytest.mark.anyio async def test_unknown_messages( self_hostname: str, one_node: SimulatorsAndWalletsServices, @@ -46,7 +46,7 @@ async def test_unknown_messages( await time_out_assert(10, receiving_failed) -@pytest.mark.asyncio +@pytest.mark.anyio async def test_valid_message( self_hostname: str, one_node: SimulatorsAndWalletsServices, @@ -72,7 +72,7 @@ async def test_valid_message( await time_out_assert(10, peer_added) -@pytest.mark.asyncio +@pytest.mark.anyio async def test_crawler_to_db( crawler_service: Service[Crawler, CrawlerAPI], one_node: SimulatorsAndWalletsServices ) -> None: diff --git a/tests/core/test_crawler_rpc.py b/tests/core/test_crawler_rpc.py index 35af061fa5d1..ae074ed32a73 100644 --- a/tests/core/test_crawler_rpc.py +++ b/tests/core/test_crawler_rpc.py @@ -6,7 +6,7 @@ from chia.rpc.crawler_rpc_api import CrawlerRpcApi from chia.seeder.crawler import Crawler -@pytest.mark.asyncio +@pytest.mark.anyio async def test_get_ips_after_timestamp(bt): crawler = Crawler(bt.config.get("seeder", {}), bt.root_path, constants=bt.constants) crawler_rpc_api = CrawlerRpcApi(crawler) diff --git a/tests/core/test_daemon_rpc.py b/tests/core/test_daemon_rpc.py index 937acd342e68..70fec9825154 100644 --- a/tests/core/test_daemon_rpc.py +++ b/tests/core/test_daemon_rpc.py @@ -6,7 +6,7 @@ from chia import __version__ from chia.daemon.client import connect_to_daemon -@pytest.mark.asyncio +@pytest.mark.anyio async def test_get_version_rpc(get_daemon, bt): ws_server = get_daemon config = bt.config diff --git a/tests/core/test_db_conversion.py b/tests/core/test_db_conversion.py index 69c960a5358a..e928980fa215 100644 --- a/tests/core/test_db_conversion.py +++ b/tests/core/test_db_conversion.py @@ -26,7 +26,7 @@ def rand_bytes(num) -> bytes: return bytes(ret) -@pytest.mark.asyncio +@pytest.mark.anyio @pytest.mark.parametrize("with_hints", [True, False]) @pytest.mark.skip("we no longer support DB v1") async def test_blocks(default_1000_blocks, with_hints: bool): diff --git a/tests/core/test_db_validation.py b/tests/core/test_db_validation.py index af097c4fae03..ad931cb15981 100644 --- a/tests/core/test_db_validation.py +++ b/tests/core/test_db_validation.py @@ -149,7 +149,7 @@ async def make_db(db_file: Path, blocks: List[FullBlock]) -> None: await db_wrapper.close() -@pytest.mark.asyncio +@pytest.mark.anyio async def test_db_validate_default_1000_blocks(default_1000_blocks: List[FullBlock]) -> None: with TempFile() as db_file: await make_db(db_file, default_1000_blocks) diff --git a/tests/core/test_farmer_harvester_rpc.py b/tests/core/test_farmer_harvester_rpc.py index ca516a504d67..48b8a8d5e130 100644 --- a/tests/core/test_farmer_harvester_rpc.py +++ b/tests/core/test_farmer_harvester_rpc.py @@ -61,7 +61,7 @@ async def wait_for_synced_receiver(farmer: Farmer, harvester_id: bytes32) -> Non await time_out_assert(30, wait) -@pytest.mark.asyncio +@pytest.mark.anyio async def test_get_routes(harvester_farmer_environment: HarvesterFarmerEnvironment) -> None: farmer_service, farmer_rpc_client, harvester_service, harvester_rpc_client, _ = harvester_farmer_environment assert farmer_service.rpc_server is not None @@ -71,7 +71,7 @@ async def test_get_routes(harvester_farmer_environment: HarvesterFarmerEnvironme @pytest.mark.parametrize("endpoint", ["get_harvesters", "get_harvesters_summary"]) -@pytest.mark.asyncio +@pytest.mark.anyio async def test_farmer_get_harvesters_and_summary( harvester_farmer_environment: HarvesterFarmerEnvironment, endpoint: str ) -> None: @@ -119,7 +119,7 @@ async def test_farmer_get_harvesters_and_summary( await time_out_assert_custom_interval(30, 1, test_get_harvesters) -@pytest.mark.asyncio +@pytest.mark.anyio async def test_farmer_signage_point_endpoints(harvester_farmer_environment: HarvesterFarmerEnvironment) -> None: farmer_service, farmer_rpc_client, _, _, _ = harvester_farmer_environment farmer_api = farmer_service._api @@ -139,7 +139,7 @@ async def test_farmer_signage_point_endpoints(harvester_farmer_environment: Harv assert (await farmer_rpc_client.get_signage_point(std_hash(b"2"))) is not None -@pytest.mark.asyncio +@pytest.mark.anyio async def test_farmer_reward_target_endpoints(harvester_farmer_environment: HarvesterFarmerEnvironment) -> None: farmer_service, farmer_rpc_client, _, _, bt = harvester_farmer_environment farmer_api = farmer_service._api @@ -193,7 +193,7 @@ async def test_farmer_reward_target_endpoints(harvester_farmer_environment: Harv await farmer_rpc_client.set_reward_targets(None, replaced_char) -@pytest.mark.asyncio +@pytest.mark.anyio async def test_farmer_get_pool_state( harvester_farmer_environment: HarvesterFarmerEnvironment, self_hostname: str ) -> None: @@ -250,7 +250,7 @@ async def test_farmer_get_pool_state( assert pool_dict[key][0] == list(since_24h) -@pytest.mark.asyncio +@pytest.mark.anyio async def test_farmer_get_pool_state_plot_count( harvester_farmer_environment: HarvesterFarmerEnvironment, self_hostname: str ) -> None: @@ -355,7 +355,7 @@ def test_plot_matches_filter(filter_item: FilterItem, match: bool) -> None: (FarmerRpcClient.get_harvester_plots_duplicates, ["duplicates_0"], None, False, 3), ], ) -@pytest.mark.asyncio +@pytest.mark.anyio @pytest.mark.skipif(sys.platform == "win32", reason="avoiding crashes on windows until we fix this (crashing workers)") async def test_farmer_get_harvester_plots_endpoints( harvester_farmer_environment: HarvesterFarmerEnvironment, @@ -466,7 +466,7 @@ async def test_farmer_get_harvester_plots_endpoints( } -@pytest.mark.asyncio +@pytest.mark.anyio @pytest.mark.skip("This test causes hangs occasionally. TODO: fix this.") async def test_harvester_add_plot_directory(harvester_farmer_environment: HarvesterFarmerEnvironment) -> None: _, _, harvester_service, harvester_rpc_client, _ = harvester_farmer_environment diff --git a/tests/core/test_filter.py b/tests/core/test_filter.py index 922c32344872..6eef6705af3c 100644 --- a/tests/core/test_filter.py +++ b/tests/core/test_filter.py @@ -6,7 +6,7 @@ import pytest from chiabip158 import PyBIP158 -@pytest.mark.asyncio +@pytest.mark.anyio async def test_basic_filter_test(simulator_and_wallet): full_nodes, wallets, bt = simulator_and_wallet wallet_node, server_2 = wallets[0] diff --git a/tests/core/test_full_node_rpc.py b/tests/core/test_full_node_rpc.py index 59dd0d327e4e..477d29e2b57d 100644 --- a/tests/core/test_full_node_rpc.py +++ b/tests/core/test_full_node_rpc.py @@ -36,7 +36,7 @@ from tests.connection_utils import connect_and_get_peer from tests.util.rpc import validate_get_routes -@pytest.mark.asyncio +@pytest.mark.anyio async def test1(two_nodes_sim_and_wallets_services, self_hostname, consensus_mode): num_blocks = 5 nodes, _, bt = two_nodes_sim_and_wallets_services @@ -426,7 +426,7 @@ async def test1(two_nodes_sim_and_wallets_services, self_hostname, consensus_mod await client.await_closed() -@pytest.mark.asyncio +@pytest.mark.anyio async def test_signage_points(two_nodes_sim_and_wallets_services, empty_blockchain): nodes, _, bt = two_nodes_sim_and_wallets_services full_node_service_1, full_node_service_2 = nodes @@ -557,7 +557,7 @@ async def test_signage_points(two_nodes_sim_and_wallets_services, empty_blockcha await client.await_closed() -@pytest.mark.asyncio +@pytest.mark.anyio async def test_get_blockchain_state(one_wallet_and_one_simulator_services, self_hostname): num_blocks = 5 nodes, _, bt = one_wallet_and_one_simulator_services @@ -638,7 +638,7 @@ async def test_get_blockchain_state(one_wallet_and_one_simulator_services, self_ await client.await_closed() -@pytest.mark.asyncio +@pytest.mark.anyio async def test_coin_name_not_in_request(one_node, self_hostname): [full_node_service], _, _ = one_node @@ -657,7 +657,7 @@ async def test_coin_name_not_in_request(one_node, self_hostname): await client.await_closed() -@pytest.mark.asyncio +@pytest.mark.anyio async def test_coin_name_not_found_in_mempool(one_node, self_hostname): [full_node_service], _, _ = one_node @@ -679,7 +679,7 @@ async def test_coin_name_not_found_in_mempool(one_node, self_hostname): await client.await_closed() -@pytest.mark.asyncio +@pytest.mark.anyio async def test_coin_name_found_in_mempool(one_node, self_hostname): [full_node_service], _, bt = one_node full_node_api = full_node_service._api diff --git a/tests/core/test_merkle_set.py b/tests/core/test_merkle_set.py index da693c34e103..db5cfa41f5fc 100644 --- a/tests/core/test_merkle_set.py +++ b/tests/core/test_merkle_set.py @@ -13,7 +13,7 @@ from chia.types.blockchain_format.sized_bytes import bytes32 from chia.util.merkle_set import MerkleSet, confirm_included_already_hashed -@pytest.mark.asyncio +@pytest.mark.anyio async def test_basics(bt): num_blocks = 20 blocks = bt.get_consecutive_blocks(num_blocks) @@ -49,7 +49,7 @@ def hashdown(buf: bytes) -> bytes32: return bytes32(sha256(bytes([0] * 30) + buf).digest()) -@pytest.mark.asyncio +@pytest.mark.anyio async def test_merkle_set_invalid_hash_size(): merkle_set = MerkleSet() @@ -75,7 +75,7 @@ async def test_merkle_set_invalid_hash_size(): compute_merkle_set_root([b""]) -@pytest.mark.asyncio +@pytest.mark.anyio async def test_merkle_set_1(): a = bytes32([0x80] + [0] * 31) merkle_set = MerkleSet() @@ -84,7 +84,7 @@ async def test_merkle_set_1(): assert merkle_set.get_root() == sha256(b"\1" + a).digest() -@pytest.mark.asyncio +@pytest.mark.anyio async def test_merkle_set_duplicate(): a = bytes32([0x80] + [0] * 31) merkle_set = MerkleSet() @@ -94,14 +94,14 @@ async def test_merkle_set_duplicate(): assert merkle_set.get_root() == sha256(b"\1" + a).digest() -@pytest.mark.asyncio +@pytest.mark.anyio async def test_merkle_set_0(): merkle_set = MerkleSet() assert merkle_set.get_root() == bytes32(compute_merkle_set_root([])) assert merkle_set.get_root() == bytes32([0] * 32) -@pytest.mark.asyncio +@pytest.mark.anyio async def test_merkle_set_2(): a = bytes32([0x80] + [0] * 31) b = bytes32([0x70] + [0] * 31) @@ -112,7 +112,7 @@ async def test_merkle_set_2(): assert merkle_set.get_root() == hashdown(b"\1\1" + b + a) -@pytest.mark.asyncio +@pytest.mark.anyio async def test_merkle_set_2_reverse(): a = bytes32([0x80] + [0] * 31) b = bytes32([0x70] + [0] * 31) @@ -123,7 +123,7 @@ async def test_merkle_set_2_reverse(): assert merkle_set.get_root() == hashdown(b"\1\1" + b + a) -@pytest.mark.asyncio +@pytest.mark.anyio async def test_merkle_set_3(): a = bytes32([0x80] + [0] * 31) b = bytes32([0x70] + [0] * 31) @@ -144,7 +144,7 @@ async def test_merkle_set_3(): # b c -@pytest.mark.asyncio +@pytest.mark.anyio async def test_merkle_set_4(): a = bytes32([0x80] + [0] * 31) b = bytes32([0x70] + [0] * 31) @@ -166,7 +166,7 @@ async def test_merkle_set_4(): # b c a d -@pytest.mark.asyncio +@pytest.mark.anyio async def test_merkle_set_5(): BLANK = bytes32([0] * 32) @@ -215,7 +215,7 @@ async def test_merkle_set_5(): # e c -@pytest.mark.asyncio +@pytest.mark.anyio async def test_merkle_left_edge(): BLANK = bytes32([0] * 32) a = bytes32([0x80] + [0] * 31) @@ -256,7 +256,7 @@ async def test_merkle_left_edge(): # c d -@pytest.mark.asyncio +@pytest.mark.anyio async def test_merkle_right_edge(): BLANK = bytes32([0] * 32) a = bytes32([0x40] + [0] * 31) @@ -304,7 +304,7 @@ def rand_hash(rng: random.Random) -> bytes32: return bytes32(ret) -@pytest.mark.asyncio +@pytest.mark.anyio @pytest.mark.skip("This test is expensive and has already convinced us there are no discrepancies") async def test_merkle_set_random_regression(): rng = random.Random() diff --git a/tests/core/test_seeder.py b/tests/core/test_seeder.py index 33ef7b5112bf..201e927da57e 100644 --- a/tests/core/test_seeder.py +++ b/tests/core/test_seeder.py @@ -146,7 +146,7 @@ def assert_standard_results( @pytest.mark.skip(reason="Flaky test with fixes in progress") -@pytest.mark.asyncio +@pytest.mark.anyio @pytest.mark.parametrize("use_tcp, target_address, request_type", all_test_combinations) async def test_error_conditions( seeder_service: DNSServer, use_tcp: bool, target_address: str, request_type: dns.rdatatype.RdataType @@ -237,7 +237,7 @@ async def test_error_conditions( @pytest.mark.skip(reason="Flaky test with fixes in progress") -@pytest.mark.asyncio +@pytest.mark.anyio @pytest.mark.parametrize("use_tcp, target_address, request_type", all_test_combinations) async def test_dns_queries( seeder_service: DNSServer, use_tcp: bool, target_address: str, request_type: dns.rdatatype.RdataType @@ -274,7 +274,7 @@ async def test_dns_queries( @pytest.mark.skip(reason="Flaky test with fixes in progress") -@pytest.mark.asyncio +@pytest.mark.anyio @pytest.mark.parametrize("use_tcp, target_address, request_type", all_test_combinations) async def test_db_processing( seeder_service: DNSServer, diff --git a/tests/core/util/test_config.py b/tests/core/util/test_config.py index 47d15b016a4d..316965e8f7f1 100644 --- a/tests/core/util/test_config.py +++ b/tests/core/util/test_config.py @@ -281,7 +281,7 @@ class TestConfig: except TimeoutError: pytest.skip("Timed out waiting for reader/writer processes to complete") - @pytest.mark.asyncio + @pytest.mark.anyio async def test_non_atomic_writes(self, root_path_populated_with_config, default_config_dict): """ Test whether one continuous writer (writing constantly, but not atomically) will interfere with many diff --git a/tests/core/util/test_files.py b/tests/core/util/test_files.py index 95333e979f18..73d846ccd8df 100644 --- a/tests/core/util/test_files.py +++ b/tests/core/util/test_files.py @@ -173,7 +173,7 @@ class TestMoveFile: class TestMoveFileAsync: - @pytest.mark.asyncio + @pytest.mark.anyio # use tmp_path pytest fixture to create a temporary directory async def test_move_file_async(self, tmp_path: Path): """ @@ -188,7 +188,7 @@ class TestMoveFileAsync: assert dst_path.exists() is True assert dst_path.read_text() == "source" - @pytest.mark.asyncio + @pytest.mark.anyio # use tmp_path pytest fixture to create a temporary directory async def test_move_file_async_failure_no_reattempts(self, tmp_path: Path, monkeypatch): """ @@ -213,7 +213,7 @@ class TestMoveFileAsync: assert src_path.exists() is True assert dst_path.exists() is False - @pytest.mark.asyncio + @pytest.mark.anyio # use tmp_path pytest fixture to create a temporary directory async def test_move_file_async_success_on_reattempt(self, tmp_path: Path, monkeypatch): """ @@ -249,7 +249,7 @@ class TestMoveFileAsync: assert dst_path.exists() is True assert dst_path.read_text() == "source" - @pytest.mark.asyncio + @pytest.mark.anyio # use tmp_path pytest fixture to create a temporary directory async def test_move_file_async_failure_on_reattempt(self, tmp_path: Path, monkeypatch): """ @@ -282,7 +282,7 @@ class TestMoveFileAsync: class TestWriteFile: - @pytest.mark.asyncio + @pytest.mark.anyio # use tmp_path pytest fixture to create a temporary directory async def test_write_file(self, tmp_path: Path): """ @@ -293,7 +293,7 @@ class TestWriteFile: await write_file_async(dest_path, "test") assert dest_path.read_text() == "test" - @pytest.mark.asyncio + @pytest.mark.anyio # use tmp_path pytest fixture to create a temporary directory async def test_write_file_overwrite(self, tmp_path: Path): """ @@ -305,7 +305,7 @@ class TestWriteFile: await write_file_async(dest_path, "test2") assert dest_path.read_text() == "test2" - @pytest.mark.asyncio + @pytest.mark.anyio # use tmp_path pytest fixture to create a temporary directory async def test_write_file_create_intermediate_dirs(self, tmp_path: Path): """ @@ -316,7 +316,7 @@ class TestWriteFile: await write_file_async(dest_path, "test") assert dest_path.read_text() == "test" - @pytest.mark.asyncio + @pytest.mark.anyio # use tmp_path pytest fixture to create a temporary directory async def test_write_file_existing_intermediate_dirs(self, tmp_path: Path): """ @@ -329,7 +329,7 @@ class TestWriteFile: await write_file_async(dest_path, "test") assert dest_path.read_text() == "test" - @pytest.mark.asyncio + @pytest.mark.anyio # use tmp_path pytest fixture to create a temporary directory async def test_write_file_default_permissions(self, tmp_path: Path): """ @@ -348,7 +348,7 @@ class TestWriteFile: # Expect: file has default permissions of 0o600 assert oct(dest_path.stat().st_mode)[-3:] == oct(0o600)[-3:] - @pytest.mark.asyncio + @pytest.mark.anyio # use tmp_path pytest fixture to create a temporary directory async def test_write_file_custom_permissions(self, tmp_path: Path): """ @@ -364,7 +364,7 @@ class TestWriteFile: # Expect: file has custom permissions of 0o642 assert oct(dest_path.stat().st_mode)[-3:] == oct(0o642)[-3:] - @pytest.mark.asyncio + @pytest.mark.anyio # use tmp_path pytest fixture to create a temporary directory async def test_write_file_os_replace_raising_permissionerror(self, tmp_path: Path, monkeypatch): """ diff --git a/tests/core/util/test_keychain.py b/tests/core/util/test_keychain.py index 9598a4f0f5a0..638ce632dc88 100644 --- a/tests/core/util/test_keychain.py +++ b/tests/core/util/test_keychain.py @@ -293,7 +293,8 @@ def test_key_data_post_init( @pytest.mark.parametrize("include_secrets", [True, False]) -def test_get_key(include_secrets: bool, get_temp_keyring: Keychain): +@pytest.mark.anyio +async def test_get_key(include_secrets: bool, get_temp_keyring: Keychain): keychain: Keychain = get_temp_keyring expected_keys = [] # Add 10 keys and validate the result `get_key` for each of them after each addition @@ -320,7 +321,8 @@ def test_get_key(include_secrets: bool, get_temp_keyring: Keychain): @pytest.mark.parametrize("include_secrets", [True, False]) -def test_get_keys(include_secrets: bool, get_temp_keyring: Keychain): +@pytest.mark.anyio +async def test_get_keys(include_secrets: bool, get_temp_keyring: Keychain): keychain: Keychain = get_temp_keyring # Should be empty on start assert keychain.get_keys(include_secrets) == [] @@ -343,7 +345,8 @@ def test_get_keys(include_secrets: bool, get_temp_keyring: Keychain): assert keychain.get_keys(include_secrets) == [] -def test_set_label(get_temp_keyring: Keychain) -> None: +@pytest.mark.anyio +async def test_set_label(get_temp_keyring: Keychain) -> None: keychain: Keychain = get_temp_keyring # Generate a key and add it without label key_data_0 = KeyData.generate(label=None) @@ -385,7 +388,8 @@ def test_set_label(get_temp_keyring: Keychain) -> None: ("a" * 70, "label exceeds max length: 70/65"), ], ) -def test_set_label_invalid_labels(label: str, message: str, get_temp_keyring: Keychain) -> None: +@pytest.mark.anyio +async def test_set_label_invalid_labels(label: str, message: str, get_temp_keyring: Keychain) -> None: keychain: Keychain = get_temp_keyring key_data = KeyData.generate() keychain.add_private_key(key_data.mnemonic_str()) @@ -394,7 +398,8 @@ def test_set_label_invalid_labels(label: str, message: str, get_temp_keyring: Ke assert e.value.label == label -def test_delete_label(get_temp_keyring: Keychain) -> None: +@pytest.mark.anyio +async def test_delete_label(get_temp_keyring: Keychain) -> None: keychain: Keychain = get_temp_keyring # Generate two keys and add them to the keychain key_data_0 = KeyData.generate(label="key_0") @@ -433,7 +438,8 @@ def test_delete_label(get_temp_keyring: Keychain) -> None: @pytest.mark.parametrize("delete_all", [True, False]) -def test_delete_drops_labels(get_temp_keyring: Keychain, delete_all: bool) -> None: +@pytest.mark.anyio +async def test_delete_drops_labels(get_temp_keyring: Keychain, delete_all: bool) -> None: keychain: Keychain = get_temp_keyring # Generate some keys and add them to the keychain labels = [f"key_{i}" for i in range(5)] diff --git a/tests/core/util/test_keyring_wrapper.py b/tests/core/util/test_keyring_wrapper.py index 375acc8b797f..c34d8566aa6c 100644 --- a/tests/core/util/test_keyring_wrapper.py +++ b/tests/core/util/test_keyring_wrapper.py @@ -12,6 +12,7 @@ from chia.util.keyring_wrapper import DEFAULT_PASSPHRASE_IF_NO_MASTER_PASSPHRASE log = logging.getLogger(__name__) +# TODO: might need to use the anyio_backend fixture per https://anyio.readthedocs.io/en/stable/testing.html @pytest.fixture(autouse=True, scope="function") def setup_keyring_wrapper(): yield diff --git a/tests/db/test_db_wrapper.py b/tests/db/test_db_wrapper.py index 21674a8e3c8c..7b9a6526875b 100644 --- a/tests/db/test_db_wrapper.py +++ b/tests/db/test_db_wrapper.py @@ -100,7 +100,7 @@ def get_reader_method_fixture(request: SubRequest) -> Callable[[], ConnectionCon return request.param # type: ignore[no-any-return] -@pytest.mark.asyncio +@pytest.mark.anyio @pytest.mark.parametrize( argnames="acquire_outside", argvalues=[pytest.param(False, id="not acquired outside"), pytest.param(True, id="acquired outside")], @@ -132,7 +132,7 @@ async def test_concurrent_writers(acquire_outside: bool, get_reader_method: GetR assert value == concurrent_task_count -@pytest.mark.asyncio +@pytest.mark.anyio async def test_writers_nests() -> None: async with DBConnection(2) as db_wrapper: await setup_table(db_wrapper) @@ -151,7 +151,7 @@ async def test_writers_nests() -> None: assert value == 1 -@pytest.mark.asyncio +@pytest.mark.anyio async def test_writer_journal_mode_wal() -> None: async with PathDBConnection(2) as db_wrapper: async with db_wrapper.writer() as connection: @@ -160,7 +160,7 @@ async def test_writer_journal_mode_wal() -> None: assert result == ("wal",) -@pytest.mark.asyncio +@pytest.mark.anyio async def test_reader_journal_mode_wal() -> None: async with PathDBConnection(2) as db_wrapper: async with db_wrapper.reader_no_transaction() as connection: @@ -169,7 +169,7 @@ async def test_reader_journal_mode_wal() -> None: assert result == ("wal",) -@pytest.mark.asyncio +@pytest.mark.anyio async def test_partial_failure() -> None: values = [] async with DBConnection(2) as db_wrapper: @@ -196,7 +196,7 @@ async def test_partial_failure() -> None: assert values == [42, 1337, 1, 42] -@pytest.mark.asyncio +@pytest.mark.anyio async def test_readers_nests(get_reader_method: GetReaderMethod) -> None: async with DBConnection(2) as db_wrapper: await setup_table(db_wrapper) @@ -212,7 +212,7 @@ async def test_readers_nests(get_reader_method: GetReaderMethod) -> None: assert value == 0 -@pytest.mark.asyncio +@pytest.mark.anyio async def test_readers_nests_writer(get_reader_method: GetReaderMethod) -> None: async with DBConnection(2) as db_wrapper: await setup_table(db_wrapper) @@ -235,7 +235,7 @@ async def test_readers_nests_writer(get_reader_method: GetReaderMethod) -> None: pytest.param(False, id="no transaction"), ], ) -@pytest.mark.asyncio +@pytest.mark.anyio async def test_only_transactioned_reader_ignores_writer(transactioned: bool) -> None: writer_committed = asyncio.Event() reader_read = asyncio.Event() @@ -273,7 +273,7 @@ async def test_only_transactioned_reader_ignores_writer(transactioned: bool) -> assert await query_value(connection=reader) == 1 -@pytest.mark.asyncio +@pytest.mark.anyio async def test_reader_nests_and_ends_transaction() -> None: async with DBConnection(2) as db_wrapper: async with db_wrapper.reader() as reader: @@ -288,7 +288,7 @@ async def test_reader_nests_and_ends_transaction() -> None: assert not reader.in_transaction -@pytest.mark.asyncio +@pytest.mark.anyio async def test_writer_in_reader_works() -> None: async with PathDBConnection(2) as db_wrapper: await setup_table(db_wrapper) @@ -303,7 +303,7 @@ async def test_writer_in_reader_works() -> None: assert await query_value(connection=reader) == 0 -@pytest.mark.asyncio +@pytest.mark.anyio async def test_reader_transaction_is_deferred() -> None: async with DBConnection(2) as db_wrapper: await setup_table(db_wrapper) @@ -319,7 +319,7 @@ async def test_reader_transaction_is_deferred() -> None: assert await query_value(connection=reader) == 1 -@pytest.mark.asyncio +@pytest.mark.anyio @pytest.mark.parametrize( argnames="acquire_outside", argvalues=[pytest.param(False, id="not acquired outside"), pytest.param(True, id="acquired outside")], @@ -348,7 +348,7 @@ async def test_concurrent_readers(acquire_outside: bool, get_reader_method: GetR assert values == [1] * concurrent_task_count -@pytest.mark.asyncio +@pytest.mark.anyio @pytest.mark.parametrize( argnames="acquire_outside", argvalues=[pytest.param(False, id="not acquired outside"), pytest.param(True, id="acquired outside")], @@ -402,7 +402,7 @@ async def test_mixed_readers_writers(acquire_outside: bool, get_reader_method: G [DBWrapper2.reader_no_transaction, False], ], ) -@pytest.mark.asyncio +@pytest.mark.anyio async def test_in_transaction_as_expected( manager_method: Callable[[DBWrapper2], ConnectionContextManager], expected: bool, @@ -414,7 +414,7 @@ async def test_in_transaction_as_expected( assert connection.in_transaction == expected -@pytest.mark.asyncio +@pytest.mark.anyio async def test_cancelled_reader_does_not_cancel_writer() -> None: async with DBConnection(2) as db_wrapper: await setup_table(db_wrapper) diff --git a/tests/farmer_harvester/test_farmer.py b/tests/farmer_harvester/test_farmer.py index 60a85c523bd8..fd23453c664d 100644 --- a/tests/farmer_harvester/test_farmer.py +++ b/tests/farmer_harvester/test_farmer.py @@ -548,7 +548,7 @@ def test_increment_pool_stats(case: IncrementPoolStatsCase) -> None: ), ], ) -@pytest.mark.asyncio +@pytest.mark.anyio async def test_farmer_new_proof_of_space_for_pool_stats( harvester_farmer_environment: HarvesterFarmerEnvironment, case: NewProofOfSpaceCase, @@ -850,7 +850,7 @@ class PoolStateCase: ), ), ) -@pytest.mark.asyncio +@pytest.mark.anyio async def test_farmer_pool_response( mocker: MockerFixture, farmer_one_harvester: Tuple[List[Service[Harvester, HarvesterAPI]], Service[Farmer, FarmerAPI], BlockTools], diff --git a/tests/farmer_harvester/test_farmer_harvester.py b/tests/farmer_harvester/test_farmer_harvester.py index 356a844fe9f5..02a9ada40b91 100644 --- a/tests/farmer_harvester/test_farmer_harvester.py +++ b/tests/farmer_harvester/test_farmer_harvester.py @@ -44,7 +44,7 @@ async def update_harvester_config(harvester_rpc_port: Optional[int], root_path: return await harvester_client.update_harvester_config(config) -@pytest.mark.asyncio +@pytest.mark.anyio async def test_start_with_empty_keychain( farmer_one_harvester_not_started: Tuple[ List[Service[Harvester, HarvesterAPI]], Service[Farmer, FarmerAPI], BlockTools @@ -71,7 +71,7 @@ async def test_start_with_empty_keychain( assert not farmer.started -@pytest.mark.asyncio +@pytest.mark.anyio async def test_harvester_handshake( farmer_one_harvester_not_started: Tuple[ List[Service[Harvester, HarvesterAPI]], Service[Farmer, FarmerAPI], BlockTools @@ -137,7 +137,7 @@ async def test_harvester_handshake( await time_out_assert(5, handshake_done, True) -@pytest.mark.asyncio +@pytest.mark.anyio async def test_farmer_respond_signatures( caplog: pytest.LogCaptureFixture, harvester_farmer_environment: HarvesterFarmerEnvironment ) -> None: @@ -170,7 +170,7 @@ async def test_farmer_respond_signatures( assert expected_error in caplog.text -@pytest.mark.asyncio +@pytest.mark.anyio async def test_harvester_config( farmer_one_harvester: Tuple[List[Service[Harvester, HarvesterAPI]], Service[Farmer, FarmerAPI], BlockTools] ) -> None: @@ -214,7 +214,7 @@ async def test_harvester_config( check_config_match(new_config, harvester_config) -@pytest.mark.asyncio +@pytest.mark.anyio async def test_missing_signage_point( farmer_one_harvester: Tuple[List[Service[Harvester, HarvesterAPI]], Service[Farmer, FarmerAPI], BlockTools] ) -> None: @@ -286,7 +286,7 @@ async def test_missing_signage_point( assert number_of_missing_sps == uint32(1) -@pytest.mark.asyncio +@pytest.mark.anyio async def test_harvester_has_no_server( farmer_one_harvester: Tuple[List[Service[Farmer, FarmerAPI]], Service[Harvester, HarvesterAPI], BlockTools], ) -> None: diff --git a/tests/farmer_harvester/test_filter_prefix_bits.py b/tests/farmer_harvester/test_filter_prefix_bits.py index 039195acb777..b15e798181a2 100644 --- a/tests/farmer_harvester/test_filter_prefix_bits.py +++ b/tests/farmer_harvester/test_filter_prefix_bits.py @@ -5,7 +5,6 @@ from pathlib import Path from typing import Any, AsyncIterator, Dict, List, Optional, Tuple import pytest -import pytest_asyncio from chia.farmer.farmer_api import FarmerAPI from chia.harvester.harvester import Harvester @@ -51,7 +50,7 @@ def test_filter_prefix_bits_on_blocks( assert passed == should_pass -@pytest_asyncio.fixture(scope="function") +@pytest.fixture(scope="function") async def farmer_harvester_with_filter_size_9( get_temp_keyring: Keychain, tmp_path: Path, self_hostname: str ) -> AsyncIterator[Tuple[Service[Harvester, HarvesterAPI], FarmerAPI]]: @@ -88,7 +87,7 @@ async def farmer_harvester_with_filter_size_9( @pytest.mark.parametrize(argnames=["peak_height", "eligible_plots"], argvalues=[(5495999, 0), (5496000, 1)]) -@pytest.mark.asyncio +@pytest.mark.anyio async def test_filter_prefix_bits_with_farmer_harvester( farmer_harvester_with_filter_size_9: Tuple[Service[Harvester, HarvesterAPI], FarmerAPI], peak_height: uint32, diff --git a/tests/fee_estimation/test_fee_estimation_integration.py b/tests/fee_estimation/test_fee_estimation_integration.py index e8b397c45ae3..c5f843970870 100644 --- a/tests/fee_estimation/test_fee_estimation_integration.py +++ b/tests/fee_estimation/test_fee_estimation_integration.py @@ -215,7 +215,7 @@ def test_current_block_height_new_block_then_new_height() -> None: assert mempool.fee_estimator.current_block_height == height + 1 # type: ignore[attr-defined] -@pytest.mark.asyncio +@pytest.mark.anyio async def test_mm_new_peak_changes_fee_estimator_block_height() -> None: mempool_manager = await instantiate_mempool_manager(zero_calls_get_coin_record) block2 = create_test_block_record(height=uint32(2)) @@ -223,7 +223,7 @@ async def test_mm_new_peak_changes_fee_estimator_block_height() -> None: assert mempool_manager.mempool.fee_estimator.block_height == uint32(2) # type: ignore[attr-defined] -@pytest.mark.asyncio +@pytest.mark.anyio async def test_mm_calls_new_block_height() -> None: mempool_manager = await instantiate_mempool_manager(zero_calls_get_coin_record) new_block_height_called = False diff --git a/tests/fee_estimation/test_fee_estimation_rpc.py b/tests/fee_estimation/test_fee_estimation_rpc.py index 8f2feae45258..5760bc44a9f8 100644 --- a/tests/fee_estimation/test_fee_estimation_rpc.py +++ b/tests/fee_estimation/test_fee_estimation_rpc.py @@ -4,7 +4,6 @@ import re from typing import Any, List, Tuple import pytest -import pytest_asyncio from chia.full_node.full_node import FullNode from chia.rpc.full_node_rpc_api import FullNodeRpcApi @@ -22,7 +21,7 @@ from chia.wallet.wallet_node import WalletNode from chia.wallet.wallet_node_api import WalletNodeAPI -@pytest_asyncio.fixture(scope="function") +@pytest.fixture(scope="function") async def setup_node_and_rpc( two_wallet_nodes_services: Tuple[ List[Service[FullNode, FullNodeSimulator]], List[Service[WalletNode, WalletNodeAPI]], BlockTools @@ -50,7 +49,7 @@ async def setup_node_and_rpc( return client, full_node_rpc_api -@pytest_asyncio.fixture(scope="function") +@pytest.fixture(scope="function") async def one_node_no_blocks( one_node: Tuple[List[Service[FullNode, FullNodeSimulator]], List[Service[WalletNode, WalletNodeAPI]], BlockTools] ) -> Tuple[FullNodeRpcClient, FullNodeRpcApi]: @@ -70,7 +69,7 @@ async def one_node_no_blocks( return client, full_node_rpc_api -@pytest.mark.asyncio +@pytest.mark.anyio async def test_get_blockchain_state(setup_node_and_rpc: Tuple[FullNodeRpcClient, FullNodeRpcApi]) -> None: # Confirm full node setup correctly client, _ = setup_node_and_rpc @@ -78,7 +77,7 @@ async def test_get_blockchain_state(setup_node_and_rpc: Tuple[FullNodeRpcClient, assert response["genesis_challenge_initialized"] is True -@pytest.mark.asyncio +@pytest.mark.anyio async def test_empty_request(setup_node_and_rpc: Tuple[FullNodeRpcClient, FullNodeRpcApi]) -> None: client, full_node_rpc_api = setup_node_and_rpc @@ -86,7 +85,7 @@ async def test_empty_request(setup_node_and_rpc: Tuple[FullNodeRpcClient, FullNo await full_node_rpc_api.get_fee_estimate({}) -@pytest.mark.asyncio +@pytest.mark.anyio async def test_empty_peak(one_node_no_blocks: Tuple[FullNodeRpcClient, FullNodeRpcApi]) -> None: client, full_node_rpc_api = one_node_no_blocks response = await full_node_rpc_api.get_fee_estimate({"target_times": [], "cost": 1}) @@ -109,56 +108,56 @@ async def test_empty_peak(one_node_no_blocks: Tuple[FullNodeRpcClient, FullNodeR } -@pytest.mark.asyncio +@pytest.mark.anyio async def test_no_target_times(setup_node_and_rpc: Tuple[FullNodeRpcClient, FullNodeRpcApi]) -> None: client, full_node_rpc_api = setup_node_and_rpc with pytest.raises(ValueError): await full_node_rpc_api.get_fee_estimate({"cost": 1}) -@pytest.mark.asyncio +@pytest.mark.anyio async def test_negative_time(setup_node_and_rpc: Tuple[FullNodeRpcClient, FullNodeRpcApi]) -> None: client, full_node_rpc_api = setup_node_and_rpc with pytest.raises(ValueError): await full_node_rpc_api.get_fee_estimate({"cost": 1, "target_times": [-1]}) -@pytest.mark.asyncio +@pytest.mark.anyio async def test_negative_cost(setup_node_and_rpc: Tuple[FullNodeRpcClient, FullNodeRpcApi]) -> None: client, full_node_rpc_api = setup_node_and_rpc with pytest.raises(ValueError): await full_node_rpc_api.get_fee_estimate({"cost": -1, "target_times": [1]}) -@pytest.mark.asyncio +@pytest.mark.anyio async def test_no_cost_or_tx(setup_node_and_rpc: Tuple[FullNodeRpcClient, FullNodeRpcApi]) -> None: client, full_node_rpc_api = setup_node_and_rpc with pytest.raises(ValueError): await full_node_rpc_api.get_fee_estimate({"target_times": []}) -@pytest.mark.asyncio +@pytest.mark.anyio async def test_both_cost_and_tx(setup_node_and_rpc: Tuple[FullNodeRpcClient, FullNodeRpcApi]) -> None: client, full_node_rpc_api = setup_node_and_rpc with pytest.raises(ValueError): await full_node_rpc_api.get_fee_estimate({"target_times": [], "cost": 1, "spend_bundle": "80"}) -@pytest.mark.asyncio +@pytest.mark.anyio async def test_target_times_invalid_type(setup_node_and_rpc: Tuple[FullNodeRpcClient, FullNodeRpcApi]) -> None: client, full_node_rpc_api = setup_node_and_rpc with pytest.raises(TypeError): await full_node_rpc_api.get_fee_estimate({"target_times": 1, "cost": 1}) -@pytest.mark.asyncio +@pytest.mark.anyio async def test_cost_invalid_type(setup_node_and_rpc: Tuple[FullNodeRpcClient, FullNodeRpcApi]) -> None: client, full_node_rpc_api = setup_node_and_rpc with pytest.raises(ValueError): await full_node_rpc_api.get_fee_estimate({"target_times": [], "cost": "a lot"}) -@pytest.mark.asyncio +@pytest.mark.anyio async def test_tx_invalid_type(setup_node_and_rpc: Tuple[FullNodeRpcClient, FullNodeRpcApi]) -> None: client, full_node_rpc_api = setup_node_and_rpc with pytest.raises(TypeError): @@ -168,7 +167,7 @@ async def test_tx_invalid_type(setup_node_and_rpc: Tuple[FullNodeRpcClient, Full ##################### -@pytest.mark.asyncio +@pytest.mark.anyio async def test_empty_target_times(setup_node_and_rpc: Tuple[FullNodeRpcClient, FullNodeRpcApi]) -> None: client, full_node_rpc_api = setup_node_and_rpc response = await full_node_rpc_api.get_fee_estimate({"target_times": [], "cost": 1}) @@ -176,7 +175,7 @@ async def test_empty_target_times(setup_node_and_rpc: Tuple[FullNodeRpcClient, F assert response["target_times"] == [] -@pytest.mark.asyncio +@pytest.mark.anyio async def test_cost(setup_node_and_rpc: Tuple[FullNodeRpcClient, FullNodeRpcApi]) -> None: client, full_node_rpc_api = setup_node_and_rpc response = await full_node_rpc_api.get_fee_estimate({"target_times": [1], "cost": 1}) @@ -184,7 +183,7 @@ async def test_cost(setup_node_and_rpc: Tuple[FullNodeRpcClient, FullNodeRpcApi] assert response["target_times"] == [1] -@pytest.mark.asyncio +@pytest.mark.anyio async def test_tx(setup_node_and_rpc: Tuple[FullNodeRpcClient, FullNodeRpcApi], bt: BlockTools) -> None: client, full_node_rpc_api = setup_node_and_rpc wallet_a: WalletTool = bt.get_pool_wallet_tool() @@ -201,7 +200,7 @@ async def test_tx(setup_node_and_rpc: Tuple[FullNodeRpcClient, FullNodeRpcApi], assert response["target_times"] == [1] -@pytest.mark.asyncio +@pytest.mark.anyio async def test_multiple(setup_node_and_rpc: Tuple[FullNodeRpcClient, FullNodeRpcApi]) -> None: client, full_node_rpc_api = setup_node_and_rpc response = await full_node_rpc_api.get_fee_estimate({"target_times": [1, 5, 10, 15, 60, 120, 180, 240], "cost": 1}) @@ -217,7 +216,7 @@ def get_test_spendbundle(bt: BlockTools) -> SpendBundle: return wallet_a.generate_signed_transaction(uint64(coin_to_spend.amount), recevier_puzzle_hash, coin_to_spend) -@pytest.mark.asyncio +@pytest.mark.anyio async def test_validate_fee_estimate_cost_err( setup_node_and_rpc: Tuple[FullNodeRpcClient, FullNodeRpcApi], bt: BlockTools ) -> None: @@ -242,7 +241,7 @@ async def test_validate_fee_estimate_cost_err( _ = await full_node_rpc_api.get_fee_estimate(request) -@pytest.mark.asyncio +@pytest.mark.anyio async def test_validate_fee_estimate_cost_ok( setup_node_and_rpc: Tuple[FullNodeRpcClient, FullNodeRpcApi], bt: BlockTools ) -> None: @@ -260,7 +259,7 @@ async def test_validate_fee_estimate_cost_ok( _ = await full_node_rpc_api.get_fee_estimate(request) -@pytest.mark.asyncio +@pytest.mark.anyio async def test_get_spendbundle_type_cost_missing( setup_node_and_rpc: Tuple[FullNodeRpcClient, FullNodeRpcApi], bt: BlockTools ) -> None: @@ -270,7 +269,7 @@ async def test_get_spendbundle_type_cost_missing( _ = await full_node_rpc_api.get_fee_estimate(request) -@pytest.mark.asyncio +@pytest.mark.anyio async def test_get_spendbundle_type_cost_spend_count_ok( setup_node_and_rpc: Tuple[FullNodeRpcClient, FullNodeRpcApi], bt: BlockTools ) -> None: @@ -282,7 +281,7 @@ async def test_get_spendbundle_type_cost_spend_count_ok( print(spend_count, ret) -@pytest.mark.asyncio +@pytest.mark.anyio async def test_get_spendbundle_type_cost_spend_count_bad( setup_node_and_rpc: Tuple[FullNodeRpcClient, FullNodeRpcApi], bt: BlockTools ) -> None: diff --git a/tests/fee_estimation/test_mempoolitem_height_added.py b/tests/fee_estimation/test_mempoolitem_height_added.py index 28cffc4e897c..9e9c5b859887 100644 --- a/tests/fee_estimation/test_mempoolitem_height_added.py +++ b/tests/fee_estimation/test_mempoolitem_height_added.py @@ -78,7 +78,7 @@ async def init_test( return estimator, spend_coins, fee_coins # new_reward_coins -@pytest.mark.asyncio +@pytest.mark.anyio async def test_mempool_inclusion_filter_basic() -> None: async with sim_and_client(defaults=NEW_DEFAULT_CONSTANTS, pass_prefarm=False) as (sim, cli): estimator, spend_coins, fee_coins = await init_test(sim, cli, the_puzzle_hash, 1) @@ -108,7 +108,7 @@ async def test_mempool_inclusion_filter_basic() -> None: assert mempool_item.name not in removal_ids -@pytest.mark.asyncio +@pytest.mark.anyio async def test_mempoolitem_height_added(db_version: int) -> None: async with sim_and_client(defaults=NEW_DEFAULT_CONSTANTS, pass_prefarm=False) as (sim, cli): estimator, spend_coins, fee_coins = await init_test(sim, cli, the_puzzle_hash, 1) diff --git a/tests/plot_sync/test_plot_sync.py b/tests/plot_sync/test_plot_sync.py index 9bb09ac8bf9a..2634c13d7e4b 100644 --- a/tests/plot_sync/test_plot_sync.py +++ b/tests/plot_sync/test_plot_sync.py @@ -8,7 +8,6 @@ from shutil import copy from typing import Any, Callable, List, Optional, Tuple import pytest -import pytest_asyncio from blspy import G1Element from chia.farmer.farmer import Farmer @@ -275,7 +274,7 @@ class Environment: ) -@pytest_asyncio.fixture(scope="function") +@pytest.fixture(scope="function") async def environment( tmp_path: Path, farmer_two_harvester_not_started: Tuple[ @@ -341,7 +340,7 @@ async def environment( ) -@pytest.mark.asyncio +@pytest.mark.anyio async def test_sync_valid(environment: Environment) -> None: env: Environment = environment env.add_directory(0, env.dir_1) @@ -370,7 +369,7 @@ async def test_sync_valid(environment: Environment) -> None: await env.run_sync_test() -@pytest.mark.asyncio +@pytest.mark.anyio async def test_sync_invalid(environment: Environment) -> None: env: Environment = environment assert len(env.farmer.plot_sync_receivers) == 2 @@ -412,7 +411,7 @@ async def test_sync_invalid(environment: Environment) -> None: await env.run_sync_test() -@pytest.mark.asyncio +@pytest.mark.anyio async def test_sync_keys_missing(environment: Environment) -> None: env: Environment = environment env.add_directory(0, env.dir_1) @@ -448,7 +447,7 @@ async def test_sync_keys_missing(environment: Environment) -> None: await env.run_sync_test() -@pytest.mark.asyncio +@pytest.mark.anyio async def test_sync_duplicates(environment: Environment) -> None: env: Environment = environment # dir_4 and then dir_duplicates contain the same plots. Load dir_4 first to make sure the plots seen as duplicates @@ -494,13 +493,13 @@ async def remove_and_validate_all_directories(env: Environment) -> None: await env.run_sync_test() -@pytest.mark.asyncio +@pytest.mark.anyio async def test_add_and_remove_all_directories(environment: Environment) -> None: await add_and_validate_all_directories(environment) await remove_and_validate_all_directories(environment) -@pytest.mark.asyncio +@pytest.mark.anyio async def test_harvester_restart(environment: Environment) -> None: env: Environment = environment # Load all directories for both harvesters @@ -526,7 +525,7 @@ async def test_harvester_restart(environment: Environment) -> None: await env.run_sync_test() -@pytest.mark.asyncio +@pytest.mark.anyio async def test_farmer_restart(environment: Environment) -> None: env: Environment = environment # Load all directories for both harvesters @@ -564,7 +563,7 @@ async def test_farmer_restart(environment: Environment) -> None: assert len(plot_manager.get_duplicates()) == len(receiver.duplicates()) == expected.duplicates_count -@pytest.mark.asyncio +@pytest.mark.anyio async def test_sync_start_and_disconnect_while_sync_is_active( farmer_one_harvester: Tuple[List[Service[Harvester, HarvesterAPI]], Service[Farmer, FarmerAPI], BlockTools] ) -> None: diff --git a/tests/plot_sync/test_receiver.py b/tests/plot_sync/test_receiver.py index c43f1252daee..2ee207650323 100644 --- a/tests/plot_sync/test_receiver.py +++ b/tests/plot_sync/test_receiver.py @@ -128,7 +128,7 @@ def post_function_validate(receiver: Receiver, data: Union[List[Plot], List[str] assert path in receiver._current_sync.delta.duplicates.additions -@pytest.mark.asyncio +@pytest.mark.anyio async def run_sync_step(receiver: Receiver, sync_step: SyncStepData) -> None: assert receiver.current_sync().state == sync_step.state last_sync_time_before = receiver._last_sync.time_done @@ -222,7 +222,7 @@ def test_default_values(seeded_random: random.Random) -> None: ) -@pytest.mark.asyncio +@pytest.mark.anyio async def test_reset(seeded_random: random.Random) -> None: receiver, sync_steps = plot_sync_setup(seeded_random=seeded_random) connection_before = receiver.connection() @@ -256,7 +256,7 @@ async def test_reset(seeded_random: random.Random) -> None: @pytest.mark.parametrize("counts_only", [True, False]) -@pytest.mark.asyncio +@pytest.mark.anyio async def test_to_dict(counts_only: bool, seeded_random: random.Random) -> None: receiver, sync_steps = plot_sync_setup(seeded_random=seeded_random) plot_sync_dict_1 = receiver.to_dict(counts_only) @@ -337,7 +337,7 @@ async def test_to_dict(counts_only: bool, seeded_random: random.Random) -> None: } -@pytest.mark.asyncio +@pytest.mark.anyio async def test_sync_flow(seeded_random: random.Random) -> None: receiver, sync_steps = plot_sync_setup(seeded_random=seeded_random) @@ -379,7 +379,7 @@ async def test_sync_flow(seeded_random: random.Random) -> None: assert receiver.current_sync().state == State.idle -@pytest.mark.asyncio +@pytest.mark.anyio async def test_invalid_ids(seeded_random: random.Random) -> None: receiver, sync_steps = plot_sync_setup(seeded_random=seeded_random) for state in State: @@ -430,7 +430,7 @@ async def test_invalid_ids(seeded_random: random.Random) -> None: pytest.param(State.removed, ErrorCodes.plot_not_available, id="not available"), ], ) -@pytest.mark.asyncio +@pytest.mark.anyio async def test_plot_errors(state_to_fail: State, expected_error_code: ErrorCodes, seeded_random: random.Random) -> None: receiver, sync_steps = plot_sync_setup(seeded_random=seeded_random) for state in State: diff --git a/tests/plot_sync/test_sender.py b/tests/plot_sync/test_sender.py index 8b837a454c79..1323e2208fa8 100644 --- a/tests/plot_sync/test_sender.py +++ b/tests/plot_sync/test_sender.py @@ -48,7 +48,7 @@ def test_set_connection_values(bt: BlockTools, seeded_random: random.Random) -> assert sender._connection == farmer_connection # type: ignore[comparison-overlap] -@pytest.mark.asyncio +@pytest.mark.anyio async def test_start_stop_send_task(bt: BlockTools) -> None: sender = Sender(bt.plot_manager, HarvestingMode.CPU) # Make sure starting/restarting works diff --git a/tests/plot_sync/test_sync_simulated.py b/tests/plot_sync/test_sync_simulated.py index 17a57cae778f..cb2e15455779 100644 --- a/tests/plot_sync/test_sync_simulated.py +++ b/tests/plot_sync/test_sync_simulated.py @@ -291,7 +291,7 @@ def create_example_plots(count: int, seeded_random: random.Random) -> List[PlotI ] -@pytest.mark.asyncio +@pytest.mark.anyio async def test_sync_simulated( farmer_three_harvester_not_started: Tuple[ List[Service[Harvester, HarvesterAPI]], Service[Farmer, FarmerAPI], BlockTools @@ -373,7 +373,7 @@ async def test_sync_simulated( ErrorSimulation.RespondTwice, ], ) -@pytest.mark.asyncio +@pytest.mark.anyio async def test_farmer_error_simulation( farmer_one_harvester_not_started: Tuple[ List[Service[Harvester, HarvesterAPI]], Service[Farmer, FarmerAPI], BlockTools @@ -401,7 +401,7 @@ async def test_farmer_error_simulation( @pytest.mark.parametrize("simulate_error", [ErrorSimulation.NonRecoverableError, ErrorSimulation.NotConnected]) -@pytest.mark.asyncio +@pytest.mark.anyio async def test_sync_reset_cases( farmer_one_harvester_not_started: Tuple[ List[Service[Harvester, HarvesterAPI]], Service[Farmer, FarmerAPI], BlockTools diff --git a/tests/plotting/test_plot_manager.py b/tests/plotting/test_plot_manager.py index bda22f1f74b1..a511ec406102 100644 --- a/tests/plotting/test_plot_manager.py +++ b/tests/plotting/test_plot_manager.py @@ -170,7 +170,7 @@ def trigger_remove_plot(_: Path, plot_path: str): @pytest.mark.limit_consensus_modes(reason="not dependent on consensus, does not support parallel execution") -@pytest.mark.asyncio +@pytest.mark.anyio async def test_plot_refreshing(environment): env: Environment = environment expected_result = PlotRefreshResult() @@ -365,7 +365,7 @@ async def test_plot_refreshing(environment): ) -@pytest.mark.asyncio +@pytest.mark.anyio async def test_initial_refresh_flag(environment: Environment) -> None: env: Environment = environment assert env.refresh_tester.plot_manager.initial_refresh() @@ -376,7 +376,7 @@ async def test_initial_refresh_flag(environment: Environment) -> None: assert env.refresh_tester.plot_manager.initial_refresh() -@pytest.mark.asyncio +@pytest.mark.anyio async def test_invalid_plots(environment): env: Environment = environment expected_result = PlotRefreshResult() @@ -429,7 +429,7 @@ async def test_invalid_plots(environment): assert retry_test_plot not in env.refresh_tester.plot_manager.failed_to_open_filenames -@pytest.mark.asyncio +@pytest.mark.anyio async def test_keys_missing(environment: Environment) -> None: env: Environment = environment not_in_keychain_plots: List[Path] = get_test_plots("not_in_keychain") @@ -465,7 +465,7 @@ async def test_keys_missing(environment: Environment) -> None: assert len(env.refresh_tester.plot_manager.no_key_filenames) == 0 -@pytest.mark.asyncio +@pytest.mark.anyio async def test_plot_info_caching(environment, bt): env: Environment = environment expected_result = PlotRefreshResult() @@ -527,7 +527,7 @@ async def test_plot_info_caching(environment, bt): plot_manager.stop_refreshing() -@pytest.mark.asyncio +@pytest.mark.anyio async def test_drop_too_large_cache_entries(environment, bt): env: Environment = environment expected_result = PlotRefreshResult(loaded=env.dir_1.plot_info_list(), processed=len(env.dir_1)) @@ -612,7 +612,7 @@ async def test_drop_too_large_cache_entries(environment, bt): assert_cache([plot_info for plot_info in plot_infos if plot_info.prover.get_filename() not in invalid_entries]) -@pytest.mark.asyncio +@pytest.mark.anyio async def test_cache_lifetime(environment: Environment) -> None: # Load a directory to produce a cache file env: Environment = environment @@ -654,7 +654,7 @@ async def test_cache_lifetime(environment: Environment) -> None: pytest.param(PlotRefreshEvents.done, id="done"), ], ) -@pytest.mark.asyncio +@pytest.mark.anyio async def test_callback_event_raises(environment, event_to_raise: PlotRefreshEvents): last_event_fired: Optional[PlotRefreshEvents] = None @@ -702,7 +702,7 @@ async def test_callback_event_raises(environment, event_to_raise: PlotRefreshEve await env.refresh_tester.run(expected_result) -@pytest.mark.asyncio +@pytest.mark.anyio async def test_recursive_plot_scan(environment: Environment) -> None: env: Environment = environment # Create a directory tree with some subdirectories containing plots, others not. diff --git a/tests/pools/test_pool_rpc.py b/tests/pools/test_pool_rpc.py index be92fd5ec105..ab6159c57f10 100644 --- a/tests/pools/test_pool_rpc.py +++ b/tests/pools/test_pool_rpc.py @@ -10,7 +10,6 @@ from shutil import rmtree from typing import Any, AsyncIterator, Dict, List, Tuple import pytest -import pytest_asyncio # TODO: update after resolution in https://github.com/pytest-dev/pytest/issues/7469 from _pytest.fixtures import SubRequest @@ -96,7 +95,7 @@ def fee(trusted: bool) -> uint64: OneWalletNodeAndRpc = Tuple[WalletRpcClient, Any, FullNodeSimulator, int, BlockTools] -@pytest_asyncio.fixture(scope="function") +@pytest.fixture(scope="function") async def one_wallet_node_and_rpc( trusted: bool, self_hostname: str, blockchain_constants: ConsensusConstants ) -> AsyncIterator[OneWalletNodeAndRpc]: @@ -134,7 +133,7 @@ async def one_wallet_node_and_rpc( Setup = Tuple[FullNodeSimulator, WalletNode, bytes32, int, WalletRpcClient] -@pytest_asyncio.fixture(scope="function") +@pytest.fixture(scope="function") async def setup( one_wallet_and_one_simulator_services: Tuple[ List[Service[FullNode, FullNodeSimulator]], List[Service[WalletNode, WalletNodeAPI]], BlockTools @@ -185,7 +184,7 @@ async def setup( class TestPoolWalletRpc: - @pytest.mark.asyncio + @pytest.mark.anyio async def test_create_new_pool_wallet_self_farm( self, one_wallet_node_and_rpc: OneWalletNodeAndRpc, @@ -237,7 +236,7 @@ class TestPoolWalletRpc: assert hexstr_to_bytes(pool_config["launcher_id"]) == launcher_id assert pool_config["pool_url"] == "" - @pytest.mark.asyncio + @pytest.mark.anyio async def test_create_new_pool_wallet_farm_to_pool( self, one_wallet_node_and_rpc: OneWalletNodeAndRpc, @@ -290,7 +289,7 @@ class TestPoolWalletRpc: assert hexstr_to_bytes(pool_config["launcher_id"]) == launcher_id assert pool_config["pool_url"] == "http://pool.example.com" - @pytest.mark.asyncio + @pytest.mark.anyio async def test_create_multiple_pool_wallets( self, one_wallet_node_and_rpc: OneWalletNodeAndRpc, @@ -403,7 +402,7 @@ class TestPoolWalletRpc: assert owner_sk is not None assert owner_sk[0] != auth_sk - @pytest.mark.asyncio + @pytest.mark.anyio async def test_absorb_self( self, one_wallet_node_and_rpc: OneWalletNodeAndRpc, fee: uint64, self_hostname: str ) -> None: @@ -481,7 +480,7 @@ class TestPoolWalletRpc: tx1 = await client.get_transactions(1) assert (250_000_000_000 + fee) in [tx.amount for tx in tx1] - @pytest.mark.asyncio + @pytest.mark.anyio async def test_absorb_self_multiple_coins( self, one_wallet_node_and_rpc: OneWalletNodeAndRpc, fee: uint64, self_hostname: str ) -> None: @@ -550,7 +549,7 @@ class TestPoolWalletRpc: assert pool_bal["confirmed_wallet_balance"] == pool_expected_confirmed_balance assert main_bal["confirmed_wallet_balance"] == main_expected_confirmed_balance # 10499999999999 - @pytest.mark.asyncio + @pytest.mark.anyio async def test_absorb_pooling( self, one_wallet_node_and_rpc: OneWalletNodeAndRpc, fee: uint64, self_hostname: str ) -> None: @@ -669,7 +668,7 @@ class TestPoolWalletRpc: bal2 = await client.get_wallet_balance(2) assert bal2["confirmed_wallet_balance"] == 0 - @pytest.mark.asyncio + @pytest.mark.anyio async def test_self_pooling_to_pooling(self, setup: Setup, fee: uint64, self_hostname: str) -> None: """ This tests self-pooling -> pooling @@ -757,7 +756,7 @@ class TestPoolWalletRpc: await time_out_assert(20, status_is_farming_to_pool, True, wallet_id_2) assert len(await wallet_node.wallet_state_manager.tx_store.get_unconfirmed_for_wallet(2)) == 0 - @pytest.mark.asyncio + @pytest.mark.anyio async def test_leave_pool(self, setup: Setup, fee: uint64, self_hostname: str) -> None: """This tests self-pooling -> pooling -> escaping -> self pooling""" full_node_api, wallet_node, our_ph, total_block_rewards, client = setup @@ -856,7 +855,7 @@ class TestPoolWalletRpc: await time_out_assert(timeout=MAX_WAIT_SECS, function=status_is_self_pooling) assert len(await wallet_node.wallet_state_manager.tx_store.get_unconfirmed_for_wallet(2)) == 0 - @pytest.mark.asyncio + @pytest.mark.anyio async def test_change_pools(self, setup: Setup, fee: uint64, self_hostname: str) -> None: """This tests Pool A -> escaping -> Pool B""" full_node_api, wallet_node, our_ph, total_block_rewards, client = setup @@ -923,7 +922,7 @@ class TestPoolWalletRpc: assert pw_info.current.relative_lock_height == 10 assert len(await wallet_node.wallet_state_manager.tx_store.get_unconfirmed_for_wallet(2)) == 0 - @pytest.mark.asyncio + @pytest.mark.anyio async def test_change_pools_reorg(self, setup: Setup, fee: uint64, self_hostname: str) -> None: """This tests Pool A -> escaping -> reorg -> escaping -> Pool B""" full_node_api, wallet_node, our_ph, total_block_rewards, client = setup diff --git a/tests/pools/test_pool_wallet.py b/tests/pools/test_pool_wallet.py index e2cf62397286..9d17b7e56517 100644 --- a/tests/pools/test_pool_wallet.py +++ b/tests/pools/test_pool_wallet.py @@ -50,7 +50,7 @@ class MockPoolWalletInfo: current: MockPoolState -@pytest.mark.asyncio +@pytest.mark.anyio async def test_update_pool_config_new_config(monkeypatch: Any) -> None: """ Test that PoolWallet can create a new pool config @@ -115,7 +115,7 @@ async def test_update_pool_config_new_config(monkeypatch: Any) -> None: assert updated_configs[0].owner_public_key == owner_pubkey -@pytest.mark.asyncio +@pytest.mark.anyio async def test_update_pool_config_existing_payout_instructions(monkeypatch: Any) -> None: """ Test that PoolWallet will retain existing payout_instructions when updating the pool config. diff --git a/tests/pools/test_wallet_pool_store.py b/tests/pools/test_wallet_pool_store.py index f4c624425e1d..1b948c75b320 100644 --- a/tests/pools/test_wallet_pool_store.py +++ b/tests/pools/test_wallet_pool_store.py @@ -59,7 +59,7 @@ class DummySpends: class TestWalletPoolStore: - @pytest.mark.asyncio + @pytest.mark.anyio async def test_store(self, seeded_random: random.Random): async with DBConnection(1) as db_wrapper: store = await WalletPoolStore.create(db_wrapper) @@ -141,7 +141,7 @@ class TestWalletPoolStore: assert await store.get_spends_for_wallet(1) == [] -@pytest.mark.asyncio +@pytest.mark.anyio async def test_delete_wallet(seeded_random: random.Random) -> None: dummy_spends = DummySpends(seeded_random=seeded_random) for i in range(5): diff --git a/tests/simulation/test_simulation.py b/tests/simulation/test_simulation.py index ab3c9febbcd1..fd1b09f28f69 100644 --- a/tests/simulation/test_simulation.py +++ b/tests/simulation/test_simulation.py @@ -7,7 +7,6 @@ from typing import AsyncIterator, List, Tuple import aiohttp import pkg_resources import pytest -import pytest_asyncio from chia.cmds.units import units from chia.consensus.block_record import BlockRecord @@ -53,7 +52,7 @@ test_constants_modified = dataclasses.replace( # fixture, to test all versions of the database schema. This doesn't work # because of a hack in shutting down the full node, which means you cannot run # more than one simulations per process. -@pytest_asyncio.fixture(scope="function") +@pytest.fixture(scope="function") async def extra_node(self_hostname) -> AsyncIterator[FullNodeAPI | FullNodeSimulator]: with TempKeyring() as keychain: b_tools = await create_block_tools_async(constants=test_constants_modified, keychain=keychain) @@ -69,7 +68,7 @@ async def extra_node(self_hostname) -> AsyncIterator[FullNodeAPI | FullNodeSimul class TestSimulation: @pytest.mark.limit_consensus_modes(reason="This test only supports one running at a time.") - @pytest.mark.asyncio + @pytest.mark.anyio async def test_full_system(self, simulation, extra_node, self_hostname): full_system: FullSystem bt: BlockTools @@ -186,7 +185,7 @@ class TestSimulation: assert blockchain_state_found, "Could not get blockchain state from daemon and node" - @pytest.mark.asyncio + @pytest.mark.anyio async def test_simulator_auto_farm_and_get_coins( self, two_wallet_nodes: Tuple[List[FullNodeSimulator], List[Tuple[WalletNode, ChiaServer]], BlockTools], @@ -250,7 +249,7 @@ class TestSimulation: assert len(reorg_non_spent_coins) == 12 and len(reorg_spent_and_non_spent_coins) == 12 assert tx.additions not in spent_and_non_spent_coins # just double check that those got reverted. - @pytest.mark.asyncio + @pytest.mark.anyio @pytest.mark.parametrize(argnames="count", argvalues=[0, 1, 2, 5, 10]) async def test_simulation_farm_blocks_to_puzzlehash( self, @@ -268,7 +267,7 @@ class TestSimulation: expected_height = None if count == 0 else count assert full_node_api.full_node.blockchain.get_peak_height() == expected_height - @pytest.mark.asyncio + @pytest.mark.anyio @pytest.mark.parametrize(argnames="count", argvalues=[0, 1, 2, 5, 10]) async def test_simulation_farm_blocks( self, @@ -322,7 +321,7 @@ class TestSimulation: assert isinstance(end_time, uint64) assert end_time - start_time >= new_time_per_block - @pytest.mark.asyncio + @pytest.mark.anyio @pytest.mark.parametrize( argnames=["amount", "coin_count"], argvalues=[ @@ -365,7 +364,7 @@ class TestSimulation: spendable_coins = await wallet.wallet_state_manager.get_spendable_coins_for_wallet(wallet.id()) assert len(spendable_coins) == coin_count - @pytest.mark.asyncio + @pytest.mark.anyio async def test_wait_transaction_records_entered_mempool( self, self_hostname: str, @@ -404,7 +403,7 @@ class TestSimulation: # assert tx.is_in_mempool() @pytest.mark.parametrize(argnames="records_or_bundles_or_coins", argvalues=["records", "bundles", "coins"]) - @pytest.mark.asyncio + @pytest.mark.anyio async def test_process_transactions( self, self_hostname: str, @@ -470,7 +469,7 @@ class TestSimulation: coin_record = await full_node_api.full_node.coin_store.get_coin_record(coin.name()) assert coin_record is not None - @pytest.mark.asyncio + @pytest.mark.anyio @pytest.mark.parametrize( argnames="amounts", argvalues=[ diff --git a/tests/simulation/test_simulator.py b/tests/simulation/test_simulator.py index 00a8a5d689a7..12134b50d200 100644 --- a/tests/simulation/test_simulator.py +++ b/tests/simulation/test_simulator.py @@ -47,7 +47,7 @@ def test_backoff_saturates_at_final() -> None: assert next(backoff) == 3 -@pytest.mark.asyncio +@pytest.mark.anyio @pytest.mark.parametrize(argnames="count", argvalues=[0, 1, 2, 5, 10]) @pytest.mark.parametrize(argnames="guarantee_transaction_blocks", argvalues=[False, True]) async def test_simulation_farm_blocks_to_puzzlehash( @@ -69,7 +69,7 @@ async def test_simulation_farm_blocks_to_puzzlehash( assert full_node_api.full_node.blockchain.get_peak_height() == expected_height -@pytest.mark.asyncio +@pytest.mark.anyio @pytest.mark.parametrize(argnames="count", argvalues=[0, 1, 2, 5, 10]) async def test_simulation_farm_blocks_to_wallet( count: int, @@ -95,7 +95,7 @@ async def test_simulation_farm_blocks_to_wallet( assert [unconfirmed_balance, confirmed_balance] == [rewards, rewards] -@pytest.mark.asyncio +@pytest.mark.anyio @pytest.mark.parametrize( argnames=["amount", "coin_count"], argvalues=[ @@ -137,7 +137,7 @@ async def test_simulation_farm_rewards_to_wallet( assert len(all_coin_records) == coin_count -@pytest.mark.asyncio +@pytest.mark.anyio async def test_wait_transaction_records_entered_mempool( simulator_and_wallet: Tuple[List[FullNodeSimulator], List[Tuple[WalletNode, ChiaServer]], BlockTools], ) -> None: @@ -172,7 +172,7 @@ async def test_wait_transaction_records_entered_mempool( assert full_node_api.full_node.mempool_manager.get_spendbundle(tx.spend_bundle.name()) is not None -@pytest.mark.asyncio +@pytest.mark.anyio async def test_process_transaction_records( simulator_and_wallet: Tuple[List[FullNodeSimulator], List[Tuple[WalletNode, ChiaServer]], BlockTools], ) -> None: @@ -206,7 +206,7 @@ async def test_process_transaction_records( assert full_node_api.full_node.coin_store.get_coin_record(coin.name()) is not None -@pytest.mark.asyncio +@pytest.mark.anyio @pytest.mark.parametrize( argnames="amounts", argvalues=[ @@ -233,7 +233,7 @@ async def test_create_coins_with_amounts( assert sorted(coin.amount for coin in coins) == sorted(amounts) -@pytest.mark.asyncio +@pytest.mark.anyio @pytest.mark.parametrize( argnames="amounts", argvalues=[ diff --git a/tests/simulation/test_start_simulator.py b/tests/simulation/test_start_simulator.py index f3b138568568..00cae28d88d2 100644 --- a/tests/simulation/test_start_simulator.py +++ b/tests/simulation/test_start_simulator.py @@ -5,7 +5,6 @@ from pathlib import Path from typing import Any, AsyncGenerator, Dict, Tuple import pytest -import pytest_asyncio from chia.simulator.full_node_simulator import FullNodeSimulator from chia.simulator.simulator_full_node_rpc_client import SimulatorFullNodeRpcClient @@ -26,14 +25,14 @@ class TestStartSimulator: These tests are designed to test the user facing functionality of the simulator. """ - @pytest_asyncio.fixture(scope="function") + @pytest.fixture(scope="function") async def get_chia_simulator( self, tmp_path: Path, empty_keyring: Keychain ) -> AsyncGenerator[Tuple[FullNodeSimulator, Path, Dict[str, Any], str, int, Keychain], None]: async for simulator_args in get_full_chia_simulator(chia_root=tmp_path, keychain=empty_keyring): yield simulator_args - @pytest.mark.asyncio + @pytest.mark.anyio async def test_start_simulator( self, get_chia_simulator: Tuple[FullNodeSimulator, Path, Dict[str, Any], str, int, Keychain] ) -> None: diff --git a/tests/timelord/test_new_peak.py b/tests/timelord/test_new_peak.py index 327c65fd33b7..c5ec44d3565e 100644 --- a/tests/timelord/test_new_peak.py +++ b/tests/timelord/test_new_peak.py @@ -22,7 +22,7 @@ from tests.util.blockchain import create_blockchain class TestNewPeak: - @pytest.mark.asyncio + @pytest.mark.anyio async def test_timelord_new_peak_basic( self, bt: BlockTools, timelord: Tuple[TimelordAPI, ChiaServer], default_1000_blocks: List[FullBlock] ) -> None: @@ -67,7 +67,7 @@ class TestNewPeak: return None - @pytest.mark.asyncio + @pytest.mark.anyio async def test_timelord_new_peak_heavier_unfinished( self, bt: BlockTools, timelord: Tuple[TimelordAPI, ChiaServer], default_1000_blocks: List[FullBlock] ) -> None: diff --git a/tests/timelord/test_timelord.py b/tests/timelord/test_timelord.py index f4868ce1a4a5..900c0310b278 100644 --- a/tests/timelord/test_timelord.py +++ b/tests/timelord/test_timelord.py @@ -7,7 +7,7 @@ from chia.timelord.timelord import Timelord from chia.timelord.timelord_api import TimelordAPI -@pytest.mark.asyncio +@pytest.mark.anyio async def test_timelord_has_no_server(timelord_service: Service[Timelord, TimelordAPI]) -> None: timelord_server = timelord_service._node.server assert timelord_server.webserver is None diff --git a/tests/util/test_full_block_utils.py b/tests/util/test_full_block_utils.py index 4e151bada449..b8956482d6b2 100644 --- a/tests/util/test_full_block_utils.py +++ b/tests/util/test_full_block_utils.py @@ -243,7 +243,7 @@ def get_full_blocks() -> Iterator[FullBlock]: ) -@pytest.mark.asyncio +@pytest.mark.anyio @pytest.mark.skip("This test is expensive and has already convinced us the parser works") async def test_parser(): # loop over every combination of Optionals being set and not set @@ -262,7 +262,7 @@ async def test_parser(): # assert gen == FullBlock.from_bytes(block_bytes).transactions_generator -@pytest.mark.asyncio +@pytest.mark.anyio @pytest.mark.skip("This test is expensive and has already convinced us the parser works") async def test_header_block(): for block in get_full_blocks(): diff --git a/tests/util/test_limited_semaphore.py b/tests/util/test_limited_semaphore.py index 02f53c3512a3..713ddf24b54c 100644 --- a/tests/util/test_limited_semaphore.py +++ b/tests/util/test_limited_semaphore.py @@ -8,7 +8,7 @@ import pytest from chia.util.limited_semaphore import LimitedSemaphore, LimitedSemaphoreFullError -@pytest.mark.asyncio +@pytest.mark.anyio async def test_stuff() -> None: active_limit = 2 waiting_limit = 4 diff --git a/tests/util/test_misc.py b/tests/util/test_misc.py index 3a1476508d4e..f413f58a0468 100644 --- a/tests/util/test_misc.py +++ b/tests/util/test_misc.py @@ -9,7 +9,7 @@ from chia.util.misc import format_bytes, format_minutes, to_batches, validate_di class TestMisc: - @pytest.mark.asyncio + @pytest.mark.anyio async def test_format_bytes(self): assert format_bytes(None) == "Invalid" assert format_bytes(dict()) == "Invalid" @@ -29,7 +29,7 @@ class TestMisc: assert format_bytes(1024**10) == "1048576.000 YiB" assert format_bytes(1024**20).endswith("YiB") - @pytest.mark.asyncio + @pytest.mark.anyio async def test_format_minutes(self): assert format_minutes(None) == "Invalid" assert format_minutes(dict()) == "Invalid" diff --git a/tests/util/test_network.py b/tests/util/test_network.py index 72a1fbf57dc7..671425806a97 100644 --- a/tests/util/test_network.py +++ b/tests/util/test_network.py @@ -11,7 +11,7 @@ from chia.util.network import IPAddress, resolve class TestNetwork: - @pytest.mark.asyncio + @pytest.mark.anyio async def test_resolve4(self): # Run these tests forcing IPv4 resolution prefer_ipv6 = False @@ -20,7 +20,7 @@ class TestNetwork: assert await resolve("localhost", prefer_ipv6=prefer_ipv6) == IPAddress.create("127.0.0.1") assert await resolve("example.net", prefer_ipv6=prefer_ipv6) == IPAddress.create("93.184.216.34") - @pytest.mark.asyncio + @pytest.mark.anyio @pytest.mark.skipif( condition=("GITHUB_ACTIONS" in os.environ) and (sys.platform in {"darwin", "win32"}), reason="macOS and Windows runners in GitHub Actions do not seem to support IPv6", diff --git a/tests/util/test_priority_mutex.py b/tests/util/test_priority_mutex.py index eecce633f7bd..f132a5590a55 100644 --- a/tests/util/test_priority_mutex.py +++ b/tests/util/test_priority_mutex.py @@ -37,7 +37,7 @@ class RequestNotCompleteError(Exception): class TestPriorityMutex: - @pytest.mark.asyncio + @pytest.mark.anyio async def test_priority_mutex(self) -> None: mutex = PriorityMutex.create(priority_type=MutexPriority) @@ -194,7 +194,7 @@ def test_comparisons_fail_for_incomplete_requests( method(case.self, case.other) -@pytest.mark.asyncio +@pytest.mark.anyio async def test_reacquisition_fails() -> None: mutex = PriorityMutex.create(priority_type=MutexPriority) request = Request(id="again!", priority=MutexPriority.low) @@ -251,7 +251,7 @@ async def test_reacquisition_fails() -> None: ), ], ) -@pytest.mark.asyncio +@pytest.mark.anyio async def test_order(case: OrderCase) -> None: mutex = PriorityMutex.create(priority_type=MutexPriority) @@ -275,7 +275,7 @@ def expected_acquisition_order(requests: List[Request]) -> List[Request]: ] -@pytest.mark.asyncio +@pytest.mark.anyio async def test_sequential_acquisitions() -> None: mutex = PriorityMutex.create(priority_type=MutexPriority) @@ -290,7 +290,7 @@ async def test_sequential_acquisitions() -> None: # just testing that we can get through a bunch of miscellaneous acquisitions -@pytest.mark.asyncio +@pytest.mark.anyio async def test_nested_acquisition_raises() -> None: mutex = PriorityMutex.create(priority_type=MutexPriority) @@ -306,7 +306,7 @@ async def to_be_cancelled(mutex: PriorityMutex[MutexPriority]) -> None: assert False -@pytest.mark.asyncio +@pytest.mark.anyio async def test_to_be_cancelled_fails_if_not_cancelled() -> None: mutex = PriorityMutex.create(priority_type=MutexPriority) @@ -314,7 +314,7 @@ async def test_to_be_cancelled_fails_if_not_cancelled() -> None: await to_be_cancelled(mutex=mutex) -@pytest.mark.asyncio +@pytest.mark.anyio async def test_cancellation_while_waiting() -> None: mutex = PriorityMutex.create(priority_type=MutexPriority) @@ -356,7 +356,7 @@ async def test_cancellation_while_waiting() -> None: # testing many repeatable randomization cases @pytest.mark.parametrize(argnames="seed", argvalues=range(100), ids=lambda seed: f"random seed {seed}") -@pytest.mark.asyncio +@pytest.mark.anyio async def test_retains_request_order_for_matching_priority(seed: int) -> None: mutex = PriorityMutex.create(priority_type=MutexPriority) @@ -449,7 +449,7 @@ async def create_acquire_tasks_in_controlled_order( return tasks -@pytest.mark.asyncio +@pytest.mark.anyio async def test_multiple_tasks_track_active_task_accurately() -> None: mutex = PriorityMutex.create(priority_type=MutexPriority) @@ -474,7 +474,7 @@ async def test_multiple_tasks_track_active_task_accurately() -> None: await other_task -@pytest.mark.asyncio +@pytest.mark.anyio async def test_no_task_fails_as_expected(monkeypatch: pytest.MonkeyPatch) -> None: """Note that this case is not expected to be possible in reality""" mutex = PriorityMutex.create(priority_type=MutexPriority) diff --git a/tests/wallet/cat_wallet/test_cat_lifecycle.py b/tests/wallet/cat_wallet/test_cat_lifecycle.py index 146c8084d7af..a00eab61b259 100644 --- a/tests/wallet/cat_wallet/test_cat_lifecycle.py +++ b/tests/wallet/cat_wallet/test_cat_lifecycle.py @@ -93,7 +93,7 @@ async def do_spend( class TestCATLifecycle: @pytest.mark.limit_consensus_modes(allowed=[ConsensusMode.PLAIN, ConsensusMode.HARD_FORK_2_0], reason="save time") - @pytest.mark.asyncio + @pytest.mark.anyio async def test_cat_mod(self, cost_logger, consensus_mode): async with sim_and_client() as (sim, sim_client): tail = Program.to([]) @@ -263,7 +263,7 @@ class TestCATLifecycle: ) @pytest.mark.limit_consensus_modes(allowed=[ConsensusMode.PLAIN, ConsensusMode.HARD_FORK_2_0], reason="save time") - @pytest.mark.asyncio + @pytest.mark.anyio async def test_complex_spend(self, cost_logger, consensus_mode): async with sim_and_client() as (sim, sim_client): tail = Program.to([]) @@ -358,7 +358,7 @@ class TestCATLifecycle: ) @pytest.mark.limit_consensus_modes(allowed=[ConsensusMode.PLAIN, ConsensusMode.HARD_FORK_2_0], reason="save time") - @pytest.mark.asyncio + @pytest.mark.anyio async def test_genesis_by_id(self, cost_logger, consensus_mode): async with sim_and_client() as (sim, sim_client): standard_acs = Program.to(1) @@ -400,7 +400,7 @@ class TestCATLifecycle: ) @pytest.mark.limit_consensus_modes(allowed=[ConsensusMode.PLAIN, ConsensusMode.HARD_FORK_2_0], reason="save time") - @pytest.mark.asyncio + @pytest.mark.anyio async def test_genesis_by_puzhash(self, cost_logger, consensus_mode): async with sim_and_client() as (sim, sim_client): standard_acs = Program.to(1) @@ -442,7 +442,7 @@ class TestCATLifecycle: ) @pytest.mark.limit_consensus_modes(allowed=[ConsensusMode.PLAIN, ConsensusMode.HARD_FORK_2_0], reason="save time") - @pytest.mark.asyncio + @pytest.mark.anyio async def test_everything_with_signature(self, cost_logger, consensus_mode): async with sim_and_client() as (sim, sim_client): sk = PrivateKey.from_bytes(secret_exponent_for_index(1).to_bytes(32, "big")) @@ -554,7 +554,7 @@ class TestCATLifecycle: ) @pytest.mark.limit_consensus_modes(allowed=[ConsensusMode.PLAIN, ConsensusMode.HARD_FORK_2_0], reason="save time") - @pytest.mark.asyncio + @pytest.mark.anyio async def test_delegated_tail(self, cost_logger, consensus_mode): async with sim_and_client() as (sim, sim_client): standard_acs = Program.to(1) diff --git a/tests/wallet/cat_wallet/test_cat_wallet.py b/tests/wallet/cat_wallet/test_cat_wallet.py index 7954d133865f..233def5b4ad2 100644 --- a/tests/wallet/cat_wallet/test_cat_wallet.py +++ b/tests/wallet/cat_wallet/test_cat_wallet.py @@ -44,7 +44,7 @@ class TestCATWallet: "trusted", [True, False], ) - @pytest.mark.asyncio + @pytest.mark.anyio async def test_cat_creation(self, self_hostname, two_wallet_nodes, trusted): num_blocks = 3 full_nodes, wallets, _ = two_wallet_nodes @@ -118,7 +118,7 @@ class TestCATWallet: ) await time_out_assert(20, cat_wallet.get_confirmed_balance, 0) - @pytest.mark.asyncio + @pytest.mark.anyio async def test_cat_creation_unique_lineage_store(self, self_hostname, two_wallet_nodes): num_blocks = 3 full_nodes, wallets, _ = two_wallet_nodes @@ -170,7 +170,7 @@ class TestCATWallet: "trusted", [True, False], ) - @pytest.mark.asyncio + @pytest.mark.anyio async def test_cat_spend(self, self_hostname, two_wallet_nodes, trusted): num_blocks = 3 full_nodes, wallets, _ = two_wallet_nodes @@ -284,7 +284,7 @@ class TestCATWallet: "trusted", [True, False], ) - @pytest.mark.asyncio + @pytest.mark.anyio async def test_cat_reuse_address(self, self_hostname, two_wallet_nodes, trusted): num_blocks = 3 full_nodes, wallets, _ = two_wallet_nodes @@ -392,7 +392,7 @@ class TestCATWallet: "trusted", [True, False], ) - @pytest.mark.asyncio + @pytest.mark.anyio async def test_get_wallet_for_asset_id(self, self_hostname, two_wallet_nodes, trusted): num_blocks = 3 full_nodes, wallets, _ = two_wallet_nodes @@ -449,7 +449,7 @@ class TestCATWallet: "trusted", [True, False], ) - @pytest.mark.asyncio + @pytest.mark.anyio async def test_cat_doesnt_see_eve(self, self_hostname, two_wallet_nodes, trusted): num_blocks = 3 full_nodes, wallets, _ = two_wallet_nodes @@ -546,7 +546,7 @@ class TestCATWallet: "trusted", [True, False], ) - @pytest.mark.asyncio + @pytest.mark.anyio async def test_cat_spend_multiple(self, self_hostname, three_wallet_nodes, trusted): num_blocks = 3 full_nodes, wallets, _ = three_wallet_nodes @@ -673,7 +673,7 @@ class TestCATWallet: @pytest.mark.limit_consensus_modes(allowed=[ConsensusMode.PLAIN, ConsensusMode.HARD_FORK_2_0], reason="save time") @pytest.mark.parametrize("trusted", [True, False]) - @pytest.mark.asyncio + @pytest.mark.anyio async def test_cat_max_amount_send(self, self_hostname, two_wallet_nodes, trusted): num_blocks = 3 full_nodes, wallets, _ = two_wallet_nodes @@ -786,7 +786,7 @@ class TestCATWallet: @pytest.mark.limit_consensus_modes(allowed=[ConsensusMode.PLAIN, ConsensusMode.HARD_FORK_2_0], reason="save time") @pytest.mark.parametrize("trusted", [True, False]) @pytest.mark.parametrize("autodiscovery", [True, False]) - @pytest.mark.asyncio + @pytest.mark.anyio async def test_cat_hint(self, self_hostname, two_wallet_nodes, trusted, autodiscovery): num_blocks = 3 full_nodes, wallets, _ = two_wallet_nodes @@ -904,7 +904,7 @@ class TestCATWallet: "trusted", [True, False], ) - @pytest.mark.asyncio + @pytest.mark.anyio async def test_cat_change_detection( self, self_hostname: str, one_wallet_and_one_simulator_services: SimulatorsAndWalletsServices, trusted: bool ) -> None: @@ -1062,7 +1062,7 @@ class TestCATWallet: assert not full_node_api.full_node.subscriptions.has_ph_subscription(puzzlehash_unhardened) -@pytest.mark.asyncio +@pytest.mark.anyio async def test_unacknowledged_cat_table() -> None: db_name = Path(tempfile.TemporaryDirectory().name).joinpath("test.sqlite") db_name.parent.mkdir(parents=True, exist_ok=True) diff --git a/tests/wallet/cat_wallet/test_offer_lifecycle.py b/tests/wallet/cat_wallet/test_offer_lifecycle.py index ad7423e6e6f3..3e926a4d22b7 100644 --- a/tests/wallet/cat_wallet/test_offer_lifecycle.py +++ b/tests/wallet/cat_wallet/test_offer_lifecycle.py @@ -167,7 +167,7 @@ def generate_secure_bundle( class TestOfferLifecycle: - @pytest.mark.asyncio() + @pytest.mark.anyio() async def test_complex_offer(self, cost_logger): async with sim_and_client() as (sim, sim_client): coins_needed: Dict[Optional[str], List[int]] = { diff --git a/tests/wallet/cat_wallet/test_trades.py b/tests/wallet/cat_wallet/test_trades.py index d323fc345c73..e504feca5bd3 100644 --- a/tests/wallet/cat_wallet/test_trades.py +++ b/tests/wallet/cat_wallet/test_trades.py @@ -65,7 +65,7 @@ async def claim_pending_approval_balance( # So to avoid the overhead of start up for identical tests, we only change the softfork param for the tests that use it. # To pin down the behavior that we intend to eventually deprecate, it only gets one test case. @pytest.mark.limit_consensus_modes(allowed=[ConsensusMode.PLAIN, ConsensusMode.HARD_FORK_2_0], reason="save time") -@pytest.mark.asyncio +@pytest.mark.anyio @pytest.mark.parametrize( "wallets_prefarm_services,trusted,reuse_puzhash,credential_restricted,active_softfork_height", [ @@ -739,7 +739,7 @@ async def test_cat_trades( [True, False], ) class TestCATTrades: - @pytest.mark.asyncio + @pytest.mark.anyio async def test_trade_cancellation(self, wallets_prefarm): ( [wallet_node_maker, maker_funds], @@ -864,7 +864,7 @@ class TestCATTrades: await time_out_assert(15, get_trade_and_status, TradeStatus.CANCELLED, trade_manager_maker, trade_make) - @pytest.mark.asyncio + @pytest.mark.anyio async def test_trade_cancellation_balance_check(self, wallets_prefarm): ( [wallet_node_maker, maker_funds], @@ -918,7 +918,7 @@ class TestCATTrades: await time_out_assert(15, get_trade_and_status, TradeStatus.CANCELLED, trade_manager_maker, trade_make) @pytest.mark.limit_consensus_modes(allowed=[ConsensusMode.PLAIN, ConsensusMode.HARD_FORK_2_0], reason="save time") - @pytest.mark.asyncio + @pytest.mark.anyio async def test_trade_conflict(self, three_wallets_prefarm): ( [wallet_node_maker, maker_funds], @@ -981,7 +981,7 @@ class TestCATTrades: await full_node.process_transaction_records(records=offer_tx_records) await time_out_assert(15, get_trade_and_status, TradeStatus.FAILED, trade_manager_trader, tr2) - @pytest.mark.asyncio + @pytest.mark.anyio async def test_trade_bad_spend(self, wallets_prefarm): ( [wallet_node_maker, maker_funds], @@ -1045,7 +1045,7 @@ class TestCATTrades: await full_node.process_transaction_records(records=offer_tx_records) await time_out_assert(30, get_trade_and_status, TradeStatus.FAILED, trade_manager_taker, tr1) - @pytest.mark.asyncio + @pytest.mark.anyio async def test_trade_high_fee(self, wallets_prefarm): ( [wallet_node_maker, maker_funds], @@ -1100,7 +1100,7 @@ class TestCATTrades: await full_node.process_transaction_records(records=txs1) await time_out_assert(15, get_trade_and_status, TradeStatus.CONFIRMED, trade_manager_taker, tr1) - @pytest.mark.asyncio + @pytest.mark.anyio async def test_aggregated_trade_state(self, wallets_prefarm): ( [wallet_node_maker, maker_funds], diff --git a/tests/wallet/clawback/test_clawback_decorator.py b/tests/wallet/clawback/test_clawback_decorator.py index d4f319461313..592c1d348f60 100644 --- a/tests/wallet/clawback/test_clawback_decorator.py +++ b/tests/wallet/clawback/test_clawback_decorator.py @@ -17,7 +17,7 @@ from chia.wallet.wallet_node import WalletNode "trusted", [True, False], ) -@pytest.mark.asyncio +@pytest.mark.anyio async def test_missing_decorator( simulator_and_wallet: Tuple[List[FullNodeSimulator], List[Tuple[WalletNode, ChiaServer]], BlockTools], trusted: bool, @@ -37,7 +37,7 @@ async def test_missing_decorator( "trusted", [True, False], ) -@pytest.mark.asyncio +@pytest.mark.anyio async def test_unknown_decorator( simulator_and_wallet: Tuple[List[FullNodeSimulator], List[Tuple[WalletNode, ChiaServer]], BlockTools], trusted: bool, @@ -57,7 +57,7 @@ async def test_unknown_decorator( "trusted", [True, False], ) -@pytest.mark.asyncio +@pytest.mark.anyio async def test_decorator( simulator_and_wallet: Tuple[List[FullNodeSimulator], List[Tuple[WalletNode, ChiaServer]], BlockTools], trusted: bool, diff --git a/tests/wallet/clawback/test_clawback_lifecycle.py b/tests/wallet/clawback/test_clawback_lifecycle.py index 341cbde03b32..a15dd1459742 100644 --- a/tests/wallet/clawback/test_clawback_lifecycle.py +++ b/tests/wallet/clawback/test_clawback_lifecycle.py @@ -84,7 +84,7 @@ class TestClawbackLifecycle: signatures.append(signature) return AugSchemeMPL.aggregate(signatures) - @pytest.mark.asyncio() + @pytest.mark.anyio async def test_clawback_spends(self, cost_logger: CostLogger) -> None: async with sim_and_client() as (sim, sim_client): key_lookup = KeyTool() diff --git a/tests/wallet/clawback/test_clawback_metadata.py b/tests/wallet/clawback/test_clawback_metadata.py index 75bad759315c..4bc178df1695 100644 --- a/tests/wallet/clawback/test_clawback_metadata.py +++ b/tests/wallet/clawback/test_clawback_metadata.py @@ -19,7 +19,7 @@ from chia.wallet.wallet_node import WalletNode "trusted", [True, False], ) -@pytest.mark.asyncio +@pytest.mark.anyio async def test_is_recipient( simulator_and_wallet: Tuple[List[FullNodeSimulator], List[Tuple[WalletNode, ChiaServer]], BlockTools], trusted: bool, diff --git a/tests/wallet/conftest.py b/tests/wallet/conftest.py index e68fcf4acb10..3e5e7b4bdf91 100644 --- a/tests/wallet/conftest.py +++ b/tests/wallet/conftest.py @@ -7,7 +7,6 @@ from dataclasses import asdict, dataclass, field, replace from typing import Any, AsyncIterator, Dict, List, Optional, Union import pytest -import pytest_asyncio from chia.consensus.constants import ConsensusConstants from chia.rpc.wallet_rpc_client import WalletRpcClient @@ -303,7 +302,7 @@ def tx_config(request: Any) -> TXConfig: # This fixture automatically creates 4 parametrized tests trusted/untrusted x reuse/new derivations # These parameterizations can be skipped by manually specifying "trusted" or "reuse puzhash" to the fixture -@pytest_asyncio.fixture(scope="function") +@pytest.fixture(scope="function") async def wallet_environments( trusted_full_node: bool, tx_config: TXConfig, diff --git a/tests/wallet/dao_wallet/test_dao_clvm.py b/tests/wallet/dao_wallet/test_dao_clvm.py index 705f3f4dfd12..1f667d0850bb 100644 --- a/tests/wallet/dao_wallet/test_dao_clvm.py +++ b/tests/wallet/dao_wallet/test_dao_clvm.py @@ -1226,7 +1226,7 @@ async def do_spend( return result -@pytest.mark.asyncio() +@pytest.mark.anyio async def test_singleton_aggregator() -> None: async with sim_and_client() as (sim, sim_client): aggregator = P2_SINGLETON_AGGREGATOR_MOD diff --git a/tests/wallet/dao_wallet/test_dao_wallets.py b/tests/wallet/dao_wallet/test_dao_wallets.py index 648ed76c1b8b..5c8aa06813db 100644 --- a/tests/wallet/dao_wallet/test_dao_wallets.py +++ b/tests/wallet/dao_wallet/test_dao_wallets.py @@ -81,7 +81,7 @@ puzzle_hash_0 = bytes32(32 * b"0") "trusted", [True, False], ) -@pytest.mark.asyncio +@pytest.mark.anyio async def test_dao_creation( self_hostname: str, three_wallet_nodes: SimulatorsAndWallets, trusted: bool, consensus_mode: ConsensusMode ) -> None: @@ -270,7 +270,7 @@ async def test_dao_creation( "trusted", [True, False], ) -@pytest.mark.asyncio +@pytest.mark.anyio async def test_dao_funding( self_hostname: str, three_wallet_nodes: SimulatorsAndWallets, trusted: bool, consensus_mode: ConsensusMode ) -> None: @@ -453,7 +453,7 @@ async def test_dao_funding( "trusted", [True, False], ) -@pytest.mark.asyncio +@pytest.mark.anyio async def test_dao_proposals( self_hostname: str, three_wallet_nodes: SimulatorsAndWallets, trusted: bool, consensus_mode: ConsensusMode ) -> None: @@ -1021,7 +1021,7 @@ async def test_dao_proposals( "trusted", [True, False], ) -@pytest.mark.asyncio +@pytest.mark.anyio async def test_dao_proposal_partial_vote( self_hostname: str, three_wallet_nodes: SimulatorsAndWallets, trusted: bool, consensus_mode: ConsensusMode ) -> None: @@ -1271,7 +1271,7 @@ async def test_dao_proposal_partial_vote( "trusted", [True, False], ) -@pytest.mark.asyncio +@pytest.mark.anyio async def test_dao_rpc_api( self_hostname: str, two_wallet_nodes: Any, trusted: Any, consensus_mode: ConsensusMode ) -> None: @@ -1800,7 +1800,7 @@ async def test_dao_rpc_api( "trusted", [True, False], ) -@pytest.mark.asyncio +@pytest.mark.anyio async def test_dao_rpc_client( two_wallet_nodes_services: SimulatorsAndWalletsServices, trusted: bool, @@ -2215,7 +2215,7 @@ async def test_dao_rpc_client( "trusted", [True, False], ) -@pytest.mark.asyncio +@pytest.mark.anyio async def test_dao_complex_spends( two_wallet_nodes_services: SimulatorsAndWalletsServices, trusted: bool, @@ -2588,7 +2588,7 @@ async def test_dao_complex_spends( "trusted", [True, False], ) -@pytest.mark.asyncio +@pytest.mark.anyio async def test_dao_concurrency( self_hostname: str, three_wallet_nodes: SimulatorsAndWallets, trusted: bool, consensus_mode: ConsensusMode ) -> None: @@ -2861,7 +2861,7 @@ async def test_dao_concurrency( "trusted", [True, False], ) -@pytest.mark.asyncio +@pytest.mark.anyio async def test_dao_cat_exits( two_wallet_nodes_services: SimulatorsAndWalletsServices, trusted: bool, @@ -3077,7 +3077,7 @@ async def test_dao_cat_exits( "trusted", [True, False], ) -@pytest.mark.asyncio +@pytest.mark.anyio async def test_dao_reorgs( self_hostname: str, two_wallet_nodes: SimulatorsAndWallets, trusted: bool, consensus_mode: ConsensusMode ) -> None: @@ -3376,7 +3376,7 @@ async def test_dao_reorgs( "trusted", [True, False], ) -@pytest.mark.asyncio +@pytest.mark.anyio async def test_dao_votes( self_hostname: str, three_wallet_nodes: SimulatorsAndWallets, trusted: bool, consensus_mode: ConsensusMode ) -> None: diff --git a/tests/wallet/db_wallet/test_db_graftroot.py b/tests/wallet/db_wallet/test_db_graftroot.py index 61792cbcefeb..e0b0a391a577 100644 --- a/tests/wallet/db_wallet/test_db_graftroot.py +++ b/tests/wallet/db_wallet/test_db_graftroot.py @@ -38,7 +38,7 @@ ACS_PH = ACS.get_tree_hash() NIL_PH = Program.to(None).get_tree_hash() -@pytest.mark.asyncio +@pytest.mark.anyio async def test_graftroot(cost_logger: CostLogger) -> None: async with sim_and_client() as (sim, sim_client): # Create the coin we're testing diff --git a/tests/wallet/db_wallet/test_dl_offers.py b/tests/wallet/db_wallet/test_dl_offers.py index fc4d0d99e6e8..0c5b81616cbc 100644 --- a/tests/wallet/db_wallet/test_dl_offers.py +++ b/tests/wallet/db_wallet/test_dl_offers.py @@ -40,7 +40,7 @@ def get_parent_branch(value: bytes32, proof: Tuple[int, List[bytes32]]) -> Tuple @pytest.mark.limit_consensus_modes(allowed=[ConsensusMode.PLAIN, ConsensusMode.HARD_FORK_2_0], reason="save time") @pytest.mark.parametrize("trusted", [True, False]) -@pytest.mark.asyncio +@pytest.mark.anyio async def test_dl_offers(wallets_prefarm: Any, trusted: bool) -> None: ( [wallet_node_maker, maker_funds], @@ -241,7 +241,7 @@ async def test_dl_offers(wallets_prefarm: Any, trusted: bool) -> None: "trusted", [True, False], ) -@pytest.mark.asyncio +@pytest.mark.anyio async def test_dl_offer_cancellation(wallets_prefarm: Any, trusted: bool) -> None: [wallet_node, _], [_, _], full_node_api = wallets_prefarm assert wallet_node.wallet_state_manager is not None @@ -303,7 +303,7 @@ async def test_dl_offer_cancellation(wallets_prefarm: Any, trusted: bool) -> Non @pytest.mark.limit_consensus_modes(allowed=[ConsensusMode.PLAIN, ConsensusMode.HARD_FORK_2_0], reason="save time") @pytest.mark.parametrize("trusted", [True, False]) -@pytest.mark.asyncio +@pytest.mark.anyio async def test_multiple_dl_offers(wallets_prefarm: Any, trusted: bool) -> None: ( [wallet_node_maker, maker_funds], diff --git a/tests/wallet/db_wallet/test_dl_wallet.py b/tests/wallet/db_wallet/test_dl_wallet.py index 3fc7485c0027..a8fd59bcea49 100644 --- a/tests/wallet/db_wallet/test_dl_wallet.py +++ b/tests/wallet/db_wallet/test_dl_wallet.py @@ -43,7 +43,7 @@ class TestDLWallet: (False, False), ], ) - @pytest.mark.asyncio + @pytest.mark.anyio async def test_initial_creation( self, self_hostname: str, simulator_and_wallet: SimulatorsAndWallets, trusted: bool, reuse_puzhash: bool ) -> None: @@ -93,7 +93,7 @@ class TestDLWallet: "trusted", [True, False], ) - @pytest.mark.asyncio + @pytest.mark.anyio async def test_get_owned_singletons( self, self_hostname: str, simulator_and_wallet: SimulatorsAndWallets, trusted: bool ) -> None: @@ -145,7 +145,7 @@ class TestDLWallet: @pytest.mark.limit_consensus_modes(allowed=[ConsensusMode.PLAIN, ConsensusMode.HARD_FORK_2_0], reason="save time") @pytest.mark.parametrize("trusted", [True, False]) - @pytest.mark.asyncio + @pytest.mark.anyio async def test_tracking_non_owned( self, self_hostname: str, two_wallet_nodes: SimulatorsAndWallets, trusted: bool ) -> None: @@ -230,7 +230,7 @@ class TestDLWallet: "trusted", [True, False], ) - @pytest.mark.asyncio + @pytest.mark.anyio async def test_lifecycle( self, self_hostname: str, simulator_and_wallet: SimulatorsAndWallets, trusted: bool ) -> None: @@ -333,7 +333,7 @@ class TestDLWallet: "trusted", [True, False], ) - @pytest.mark.asyncio + @pytest.mark.anyio async def test_rebase( self, self_hostname: str, @@ -534,7 +534,7 @@ async def is_singleton_confirmed_and_root(dl_wallet: DataLayerWallet, lid: bytes "trusted", [True, False], ) -@pytest.mark.asyncio +@pytest.mark.anyio async def test_mirrors(wallets_prefarm: Any, trusted: bool) -> None: ( [wallet_node_1, _], diff --git a/tests/wallet/did_wallet/test_did.py b/tests/wallet/did_wallet/test_did.py index f8a18cbba70a..3990c2040f76 100644 --- a/tests/wallet/did_wallet/test_did.py +++ b/tests/wallet/did_wallet/test_did.py @@ -40,7 +40,7 @@ class TestDIDWallet: "trusted", [True, False], ) - @pytest.mark.asyncio + @pytest.mark.anyio async def test_creation_from_coin_spend( self, self_hostname, two_nodes_two_wallets_with_same_keys: SimulatorsAndWallets, trusted ): @@ -121,7 +121,7 @@ class TestDIDWallet: "trusted", [True, False], ) - @pytest.mark.asyncio + @pytest.mark.anyio async def test_creation_from_backup_file(self, self_hostname, three_wallet_nodes, trusted): full_nodes, wallets, _ = three_wallet_nodes full_node_api = full_nodes[0] @@ -272,7 +272,7 @@ class TestDIDWallet: "trusted", [True, False], ) - @pytest.mark.asyncio + @pytest.mark.anyio async def test_did_recovery_with_multiple_backup_dids(self, self_hostname, two_wallet_nodes, trusted): full_nodes, wallets, _ = two_wallet_nodes full_node_api = full_nodes[0] @@ -417,7 +417,7 @@ class TestDIDWallet: "trusted", [True, False], ) - @pytest.mark.asyncio + @pytest.mark.anyio async def test_did_recovery_with_empty_set(self, self_hostname, two_wallet_nodes, trusted): full_nodes, wallets, _ = two_wallet_nodes full_node_api = full_nodes[0] @@ -473,7 +473,7 @@ class TestDIDWallet: "trusted", [True, False], ) - @pytest.mark.asyncio + @pytest.mark.anyio async def test_did_find_lost_did(self, self_hostname, two_wallet_nodes, trusted): full_nodes, wallets, _ = two_wallet_nodes full_node_api = full_nodes[0] @@ -556,7 +556,7 @@ class TestDIDWallet: "trusted", [True, False], ) - @pytest.mark.asyncio + @pytest.mark.anyio async def test_did_attest_after_recovery(self, self_hostname, two_wallet_nodes, trusted): full_nodes, wallets, _ = two_wallet_nodes full_node_api = full_nodes[0] @@ -717,7 +717,7 @@ class TestDIDWallet: "trusted", [True, False], ) - @pytest.mark.asyncio + @pytest.mark.anyio async def test_did_transfer(self, self_hostname, two_wallet_nodes, with_recovery, trusted): fee = uint64(1000) full_nodes, wallets, _ = two_wallet_nodes @@ -803,7 +803,7 @@ class TestDIDWallet: "trusted", [True, False], ) - @pytest.mark.asyncio + @pytest.mark.anyio async def test_update_recovery_list(self, self_hostname, two_wallet_nodes, trusted): full_nodes, wallets, _ = two_wallet_nodes full_node_api = full_nodes[0] @@ -852,7 +852,7 @@ class TestDIDWallet: "trusted", [True, False], ) - @pytest.mark.asyncio + @pytest.mark.anyio async def test_get_info(self, self_hostname, two_wallet_nodes, trusted): fee = uint64(1000) full_nodes, wallets, _ = two_wallet_nodes @@ -942,7 +942,7 @@ class TestDIDWallet: "trusted", [True, False], ) - @pytest.mark.asyncio + @pytest.mark.anyio async def test_message_spend(self, self_hostname, two_wallet_nodes, trusted): fee = uint64(1000) full_nodes, wallets, _ = two_wallet_nodes @@ -1001,7 +1001,7 @@ class TestDIDWallet: "trusted", [True, False], ) - @pytest.mark.asyncio + @pytest.mark.anyio async def test_update_metadata(self, self_hostname, two_wallet_nodes, trusted): fee = uint64(1000) full_nodes, wallets, _ = two_wallet_nodes @@ -1071,7 +1071,7 @@ class TestDIDWallet: "trusted", [True, False], ) - @pytest.mark.asyncio + @pytest.mark.anyio async def test_did_sign_message(self, self_hostname, two_wallet_nodes, trusted): fee = uint64(1000) full_nodes, wallets, _ = two_wallet_nodes @@ -1185,7 +1185,7 @@ class TestDIDWallet: "trusted", [True, False], ) - @pytest.mark.asyncio + @pytest.mark.anyio async def test_create_did_with_recovery_list(self, self_hostname, two_nodes_two_wallets_with_same_keys, trusted): """ A DID is created on-chain in client0, causing a DID Wallet to be created in client1, which shares the same key. @@ -1276,7 +1276,7 @@ class TestDIDWallet: "trusted", [True, False], ) - @pytest.mark.asyncio + @pytest.mark.anyio async def test_did_resync(self, self_hostname, two_wallet_nodes, trusted) -> None: full_nodes, wallets, _ = two_wallet_nodes full_node_api = full_nodes[0] diff --git a/tests/wallet/nft_wallet/test_nft_1_offers.py b/tests/wallet/nft_wallet/test_nft_1_offers.py index a2276fb42c95..fa7fab7e942f 100644 --- a/tests/wallet/nft_wallet/test_nft_1_offers.py +++ b/tests/wallet/nft_wallet/test_nft_1_offers.py @@ -70,7 +70,7 @@ def trusted_setup_helper( @pytest.mark.limit_consensus_modes(allowed=[ConsensusMode.PLAIN, ConsensusMode.HARD_FORK_2_0], reason="save time") @pytest.mark.parametrize("trusted", [True, False]) @pytest.mark.parametrize("zero_royalties", [True, False]) -@pytest.mark.asyncio +@pytest.mark.anyio async def test_nft_offer_sell_nft( self_hostname: str, two_wallet_nodes: Any, trusted: Any, zero_royalties: bool, seeded_random: random.Random ) -> None: @@ -206,7 +206,7 @@ async def test_nft_offer_sell_nft( @pytest.mark.limit_consensus_modes(allowed=[ConsensusMode.PLAIN, ConsensusMode.HARD_FORK_2_0], reason="save time") @pytest.mark.parametrize("trusted", [True, False]) @pytest.mark.parametrize("zero_royalties", [True, False]) -@pytest.mark.asyncio +@pytest.mark.anyio async def test_nft_offer_request_nft( self_hostname: str, two_wallet_nodes: Any, trusted: Any, zero_royalties: bool, seeded_random: random.Random ) -> None: @@ -340,7 +340,7 @@ async def test_nft_offer_request_nft( @pytest.mark.limit_consensus_modes(allowed=[ConsensusMode.PLAIN, ConsensusMode.HARD_FORK_2_0], reason="save time") @pytest.mark.parametrize("trusted", [True, False]) @pytest.mark.parametrize("zero_royalties", [True, False]) -@pytest.mark.asyncio +@pytest.mark.anyio async def test_nft_offer_sell_did_to_did( self_hostname: str, two_wallet_nodes: Any, trusted: Any, zero_royalties: bool, seeded_random: random.Random ) -> None: @@ -497,7 +497,7 @@ async def test_nft_offer_sell_did_to_did( @pytest.mark.limit_consensus_modes(allowed=[ConsensusMode.PLAIN, ConsensusMode.HARD_FORK_2_0], reason="save time") @pytest.mark.parametrize("trusted", [True, False]) @pytest.mark.parametrize("zero_royalties", [True, False]) -@pytest.mark.asyncio +@pytest.mark.anyio async def test_nft_offer_sell_nft_for_cat( self_hostname: str, two_wallet_nodes: Any, trusted: Any, zero_royalties: bool, seeded_random: random.Random ) -> None: @@ -676,7 +676,7 @@ async def test_nft_offer_sell_nft_for_cat( @pytest.mark.limit_consensus_modes(allowed=[ConsensusMode.PLAIN, ConsensusMode.HARD_FORK_2_0], reason="save time") @pytest.mark.parametrize("trusted", [True, False]) @pytest.mark.parametrize("test_change", [True, False]) -@pytest.mark.asyncio +@pytest.mark.anyio async def test_nft_offer_request_nft_for_cat( self_hostname: str, two_wallet_nodes: Any, trusted: bool, test_change: bool, seeded_random: random.Random ) -> None: @@ -865,7 +865,7 @@ async def test_nft_offer_request_nft_for_cat( "trusted", [True, False], ) -@pytest.mark.asyncio +@pytest.mark.anyio # @pytest.mark.skip async def test_nft_offer_sell_cancel( self_hostname: str, two_wallet_nodes: Any, trusted: Any, seeded_random: random.Random @@ -979,7 +979,7 @@ async def test_nft_offer_sell_cancel( "trusted", [True], ) -@pytest.mark.asyncio +@pytest.mark.anyio async def test_nft_offer_sell_cancel_in_batch( self_hostname: str, two_wallet_nodes: Any, trusted: Any, seeded_random: random.Random ) -> None: @@ -1106,7 +1106,7 @@ async def test_nft_offer_sell_cancel_in_batch( (100000, 10001, 10005), # 1000% shouldn't work ], ) -@pytest.mark.asyncio +@pytest.mark.anyio async def test_complex_nft_offer( self_hostname: str, two_wallet_nodes: Any, diff --git a/tests/wallet/nft_wallet/test_nft_bulk_mint.py b/tests/wallet/nft_wallet/test_nft_bulk_mint.py index 8ad3a7b59afb..232470da9b79 100644 --- a/tests/wallet/nft_wallet/test_nft_bulk_mint.py +++ b/tests/wallet/nft_wallet/test_nft_bulk_mint.py @@ -34,7 +34,7 @@ async def nft_count(wallet: NFTWallet) -> int: "trusted", [True, False], ) -@pytest.mark.asyncio +@pytest.mark.anyio async def test_nft_mint_from_did( self_hostname: str, two_wallet_nodes: Any, trusted: Any, seeded_random: random.Random ) -> None: @@ -150,7 +150,7 @@ async def test_nft_mint_from_did( "trusted", [True, False], ) -@pytest.mark.asyncio +@pytest.mark.anyio async def test_nft_mint_from_did_rpc( two_wallet_nodes_services: SimulatorsAndWalletsServices, trusted: Any, @@ -344,7 +344,7 @@ async def test_nft_mint_from_did_rpc( "trusted", [True, False], ) -@pytest.mark.asyncio +@pytest.mark.anyio async def test_nft_mint_from_did_rpc_no_royalties( two_wallet_nodes_services: SimulatorsAndWalletsServices, trusted: Any, @@ -518,7 +518,7 @@ async def test_nft_mint_from_did_rpc_no_royalties( "trusted", [True, False], ) -@pytest.mark.asyncio +@pytest.mark.anyio async def test_nft_mint_from_did_multiple_xch( self_hostname: str, two_wallet_nodes: Any, trusted: Any, seeded_random: random.Random ) -> None: @@ -634,7 +634,7 @@ async def test_nft_mint_from_did_multiple_xch( "trusted", [True, False], ) -@pytest.mark.asyncio +@pytest.mark.anyio async def test_nft_mint_from_xch( self_hostname: str, two_wallet_nodes: Any, trusted: Any, seeded_random: random.Random ) -> None: @@ -749,7 +749,7 @@ async def test_nft_mint_from_xch( "trusted", [True, False], ) -@pytest.mark.asyncio +@pytest.mark.anyio async def test_nft_mint_from_xch_rpc( two_wallet_nodes_services: SimulatorsAndWalletsServices, trusted: Any, @@ -934,7 +934,7 @@ async def test_nft_mint_from_xch_rpc( "trusted", [True, False], ) -@pytest.mark.asyncio +@pytest.mark.anyio async def test_nft_mint_from_xch_multiple_xch( self_hostname: str, two_wallet_nodes: Any, trusted: Any, seeded_random: random.Random ) -> None: diff --git a/tests/wallet/nft_wallet/test_nft_lifecycle.py b/tests/wallet/nft_wallet/test_nft_lifecycle.py index 1eaddd00c593..bd668bac4f20 100644 --- a/tests/wallet/nft_wallet/test_nft_lifecycle.py +++ b/tests/wallet/nft_wallet/test_nft_lifecycle.py @@ -26,7 +26,7 @@ ACS = Program.to(1) ACS_PH = ACS.get_tree_hash() -@pytest.mark.asyncio() +@pytest.mark.anyio @pytest.mark.parametrize("metadata_updater", ["default"]) async def test_state_layer(cost_logger: CostLogger, metadata_updater: str) -> None: async with sim_and_client() as (sim, sim_client): @@ -136,7 +136,7 @@ async def test_state_layer(cost_logger: CostLogger, metadata_updater: str) -> No state_layer_puzzle = create_nft_layer_puzzle_with_curry_params(metadata, METADATA_UPDATER_PUZZLE_HASH, ACS) -@pytest.mark.asyncio() +@pytest.mark.anyio async def test_ownership_layer(cost_logger: CostLogger) -> None: async with sim_and_client() as (sim, sim_client): TARGET_OWNER = bytes32([0] * 32) @@ -244,7 +244,7 @@ async def test_ownership_layer(cost_logger: CostLogger) -> None: ).get_tree_hash() -@pytest.mark.asyncio() +@pytest.mark.anyio async def test_default_transfer_program(cost_logger: CostLogger) -> None: async with sim_and_client() as (sim, sim_client): # Now make the ownership coin diff --git a/tests/wallet/nft_wallet/test_nft_offers.py b/tests/wallet/nft_wallet/test_nft_offers.py index f9ebfe3359b6..66f9c6300c33 100644 --- a/tests/wallet/nft_wallet/test_nft_offers.py +++ b/tests/wallet/nft_wallet/test_nft_offers.py @@ -39,7 +39,7 @@ async def get_trade_and_status(trade_manager, trade) -> TradeStatus: # type: ig "reuse_puzhash", [True, False], ) -@pytest.mark.asyncio +@pytest.mark.anyio async def test_nft_offer_with_fee( self_hostname: str, two_wallet_nodes: Any, trusted: Any, reuse_puzhash: bool, seeded_random: random.Random ) -> None: @@ -234,7 +234,7 @@ async def test_nft_offer_with_fee( "trusted", [False], ) -@pytest.mark.asyncio +@pytest.mark.anyio async def test_nft_offer_cancellations( self_hostname: str, two_wallet_nodes: Any, trusted: Any, seeded_random: random.Random ) -> None: @@ -347,7 +347,7 @@ async def test_nft_offer_cancellations( "trusted", [False], ) -@pytest.mark.asyncio +@pytest.mark.anyio async def test_nft_offer_with_metadata_update( self_hostname: str, two_wallet_nodes: Any, trusted: Any, seeded_random: random.Random ) -> None: @@ -486,7 +486,7 @@ async def test_nft_offer_with_metadata_update( @pytest.mark.limit_consensus_modes(allowed=[ConsensusMode.PLAIN, ConsensusMode.HARD_FORK_2_0], reason="save time") @pytest.mark.parametrize("trusted", [False]) @pytest.mark.parametrize("reuse_puzhash", [True, False]) -@pytest.mark.asyncio +@pytest.mark.anyio async def test_nft_offer_nft_for_cat( self_hostname: str, two_wallet_nodes: Any, @@ -748,7 +748,7 @@ async def test_nft_offer_nft_for_cat( "trusted", [False], ) -@pytest.mark.asyncio +@pytest.mark.anyio async def test_nft_offer_nft_for_nft( self_hostname: str, two_wallet_nodes: Any, trusted: Any, seeded_random: random.Random ) -> None: diff --git a/tests/wallet/nft_wallet/test_nft_wallet.py b/tests/wallet/nft_wallet/test_nft_wallet.py index 5f41cb54addc..f90a71925d3e 100644 --- a/tests/wallet/nft_wallet/test_nft_wallet.py +++ b/tests/wallet/nft_wallet/test_nft_wallet.py @@ -85,7 +85,7 @@ async def make_new_block_with( "trusted", [True, False], ) -@pytest.mark.asyncio +@pytest.mark.anyio async def test_nft_wallet_creation_automatically(self_hostname: str, two_wallet_nodes: Any, trusted: Any) -> None: num_blocks = 3 full_nodes, wallets, _ = two_wallet_nodes @@ -179,7 +179,7 @@ async def test_nft_wallet_creation_automatically(self_hostname: str, two_wallet_ @pytest.mark.limit_consensus_modes(allowed=[ConsensusMode.PLAIN, ConsensusMode.HARD_FORK_2_0], reason="save time") @pytest.mark.parametrize("trusted", [True, False]) -@pytest.mark.asyncio +@pytest.mark.anyio async def test_nft_wallet_creation_and_transfer(self_hostname: str, two_wallet_nodes: Any, trusted: Any) -> None: num_blocks = 2 full_nodes, wallets, _ = two_wallet_nodes @@ -338,7 +338,7 @@ async def test_nft_wallet_creation_and_transfer(self_hostname: str, two_wallet_n "trusted", [True, False], ) -@pytest.mark.asyncio +@pytest.mark.anyio async def test_nft_wallet_rpc_creation_and_list(self_hostname: str, two_wallet_nodes: Any, trusted: Any) -> None: num_blocks = 3 full_nodes, wallets, _ = two_wallet_nodes @@ -463,7 +463,7 @@ async def test_nft_wallet_rpc_creation_and_list(self_hostname: str, two_wallet_n "trusted", [True, False], ) -@pytest.mark.asyncio +@pytest.mark.anyio async def test_nft_wallet_rpc_update_metadata(self_hostname: str, two_wallet_nodes: Any, trusted: Any) -> None: from chia.types.blockchain_format.sized_bytes import bytes32 @@ -623,7 +623,7 @@ async def test_nft_wallet_rpc_update_metadata(self_hostname: str, two_wallet_nod "trusted", [True, False], ) -@pytest.mark.asyncio +@pytest.mark.anyio async def test_nft_with_did_wallet_creation(self_hostname: str, two_wallet_nodes: Any, trusted: Any) -> None: num_blocks = 3 full_nodes, wallets, _ = two_wallet_nodes @@ -790,7 +790,7 @@ async def test_nft_with_did_wallet_creation(self_hostname: str, two_wallet_nodes "trusted", [True, False], ) -@pytest.mark.asyncio +@pytest.mark.anyio async def test_nft_rpc_mint(self_hostname: str, two_wallet_nodes: Any, trusted: Any) -> None: num_blocks = 3 full_nodes, wallets, _ = two_wallet_nodes @@ -909,7 +909,7 @@ async def test_nft_rpc_mint(self_hostname: str, two_wallet_nodes: Any, trusted: "trusted", [True, False], ) -@pytest.mark.asyncio +@pytest.mark.anyio async def test_nft_transfer_nft_with_did(self_hostname: str, two_wallet_nodes: Any, trusted: Any) -> None: num_blocks = 3 fee = 100 @@ -1075,7 +1075,7 @@ async def test_nft_transfer_nft_with_did(self_hostname: str, two_wallet_nodes: A "trusted", [True, False], ) -@pytest.mark.asyncio +@pytest.mark.anyio async def test_update_metadata_for_nft_did(self_hostname: str, two_wallet_nodes: Any, trusted: Any) -> None: num_blocks = 3 full_nodes, wallets, _ = two_wallet_nodes @@ -1209,7 +1209,7 @@ async def test_update_metadata_for_nft_did(self_hostname: str, two_wallet_nodes: "trusted", [True, False], ) -@pytest.mark.asyncio +@pytest.mark.anyio async def test_nft_bulk_set_did(self_hostname: str, two_wallet_nodes: Any, trusted: Any) -> None: num_blocks = 2 full_nodes, wallets, _ = two_wallet_nodes @@ -1372,7 +1372,7 @@ async def test_nft_bulk_set_did(self_hostname: str, two_wallet_nodes: Any, trust "trusted", [True, False], ) -@pytest.mark.asyncio +@pytest.mark.anyio async def test_nft_bulk_transfer(two_wallet_nodes: Any, trusted: Any) -> None: num_blocks = 2 full_nodes, wallets, _ = two_wallet_nodes @@ -1525,7 +1525,7 @@ async def test_nft_bulk_transfer(two_wallet_nodes: Any, trusted: Any) -> None: @pytest.mark.limit_consensus_modes(allowed=[ConsensusMode.PLAIN, ConsensusMode.HARD_FORK_2_0], reason="save time") @pytest.mark.parametrize("trusted", [True, False]) -@pytest.mark.asyncio +@pytest.mark.anyio async def test_nft_set_did(self_hostname: str, two_wallet_nodes: Any, trusted: Any) -> None: num_blocks = 3 full_nodes, wallets, _ = two_wallet_nodes @@ -1693,7 +1693,7 @@ async def test_nft_set_did(self_hostname: str, two_wallet_nodes: Any, trusted: A "trusted", [True, False], ) -@pytest.mark.asyncio +@pytest.mark.anyio async def test_set_nft_status(self_hostname: str, two_wallet_nodes: Any, trusted: Any) -> None: num_blocks = 5 full_nodes, wallets, _ = two_wallet_nodes @@ -1779,7 +1779,7 @@ async def test_set_nft_status(self_hostname: str, two_wallet_nodes: Any, trusted "trusted", [True, False], ) -@pytest.mark.asyncio +@pytest.mark.anyio async def test_nft_sign_message(self_hostname: str, two_wallet_nodes: Any, trusted: Any) -> None: num_blocks = 5 full_nodes, wallets, _ = two_wallet_nodes diff --git a/tests/wallet/rpc/test_dl_wallet_rpc.py b/tests/wallet/rpc/test_dl_wallet_rpc.py index ea346c0ffa9f..5637746b672e 100644 --- a/tests/wallet/rpc/test_dl_wallet_rpc.py +++ b/tests/wallet/rpc/test_dl_wallet_rpc.py @@ -24,7 +24,7 @@ log = logging.getLogger(__name__) class TestWalletRpc: @pytest.mark.limit_consensus_modes(allowed=[ConsensusMode.PLAIN, ConsensusMode.HARD_FORK_2_0], reason="save time") @pytest.mark.parametrize("trusted", [True, False]) - @pytest.mark.asyncio + @pytest.mark.anyio async def test_wallet_make_transaction( self, two_wallet_nodes_services: SimulatorsAndWalletsServices, trusted: bool, self_hostname: str ) -> None: diff --git a/tests/wallet/rpc/test_wallet_rpc.py b/tests/wallet/rpc/test_wallet_rpc.py index b97d3d1e6040..2b8cb4991fc9 100644 --- a/tests/wallet/rpc/test_wallet_rpc.py +++ b/tests/wallet/rpc/test_wallet_rpc.py @@ -10,7 +10,6 @@ from typing import Any, Dict, List, Optional, Tuple, cast import aiosqlite import pytest -import pytest_asyncio from blspy import G2Element from chia.consensus.block_rewards import calculate_base_farmer_reward, calculate_pool_reward @@ -154,7 +153,7 @@ async def generate_funds(full_node_api: FullNodeSimulator, wallet_bundle: Wallet return generated_funds -@pytest_asyncio.fixture(scope="function", params=[True, False]) +@pytest.fixture(scope="function", params=[True, False]) async def wallet_rpc_environment(two_wallet_nodes_services, request, self_hostname): full_node, wallets, bt = two_wallet_nodes_services full_node_service = full_node[0] @@ -286,7 +285,7 @@ def update_verify_signature_request(request: Dict[str, Any], prefix_hex_values: @pytest.mark.limit_consensus_modes(allowed=[ConsensusMode.PLAIN, ConsensusMode.HARD_FORK_2_0], reason="save time") -@pytest.mark.asyncio +@pytest.mark.anyio async def test_send_transaction(wallet_rpc_environment: WalletRpcTestEnvironment): env: WalletRpcTestEnvironment = wallet_rpc_environment @@ -335,7 +334,7 @@ async def test_send_transaction(wallet_rpc_environment: WalletRpcTestEnvironment @pytest.mark.limit_consensus_modes(allowed=[ConsensusMode.PLAIN, ConsensusMode.HARD_FORK_2_0], reason="save time") -@pytest.mark.asyncio +@pytest.mark.anyio async def test_push_transactions(wallet_rpc_environment: WalletRpcTestEnvironment): env: WalletRpcTestEnvironment = wallet_rpc_environment @@ -365,7 +364,7 @@ async def test_push_transactions(wallet_rpc_environment: WalletRpcTestEnvironmen @pytest.mark.limit_consensus_modes(allowed=[ConsensusMode.PLAIN, ConsensusMode.HARD_FORK_2_0], reason="save time") -@pytest.mark.asyncio +@pytest.mark.anyio async def test_get_balance(wallet_rpc_environment: WalletRpcTestEnvironment): env = wallet_rpc_environment wallet: Wallet = env.wallet_1.wallet @@ -382,7 +381,7 @@ async def test_get_balance(wallet_rpc_environment: WalletRpcTestEnvironment): @pytest.mark.limit_consensus_modes(allowed=[ConsensusMode.PLAIN, ConsensusMode.HARD_FORK_2_0], reason="save time") -@pytest.mark.asyncio +@pytest.mark.anyio async def test_get_farmed_amount(wallet_rpc_environment: WalletRpcTestEnvironment): env = wallet_rpc_environment wallet: Wallet = env.wallet_1.wallet @@ -407,7 +406,7 @@ async def test_get_farmed_amount(wallet_rpc_environment: WalletRpcTestEnvironmen @pytest.mark.limit_consensus_modes(allowed=[ConsensusMode.PLAIN, ConsensusMode.HARD_FORK_2_0], reason="save time") -@pytest.mark.asyncio +@pytest.mark.anyio async def test_get_farmed_amount_with_fee(wallet_rpc_environment: WalletRpcTestEnvironment): env = wallet_rpc_environment wallet: Wallet = env.wallet_1.wallet @@ -436,7 +435,7 @@ async def test_get_farmed_amount_with_fee(wallet_rpc_environment: WalletRpcTestE @pytest.mark.limit_consensus_modes(allowed=[ConsensusMode.PLAIN, ConsensusMode.HARD_FORK_2_0], reason="save time") -@pytest.mark.asyncio +@pytest.mark.anyio async def test_get_timestamp_for_height(wallet_rpc_environment: WalletRpcTestEnvironment): env: WalletRpcTestEnvironment = wallet_rpc_environment @@ -466,7 +465,7 @@ async def test_get_timestamp_for_height(wallet_rpc_environment: WalletRpcTestEnv ([(120000000000, None), (120000000000, None)], 10000000000, True, False), ], ) -@pytest.mark.asyncio +@pytest.mark.anyio async def test_create_signed_transaction( wallet_rpc_environment: WalletRpcTestEnvironment, output_args: List[Tuple[int, Optional[List[str]]]], @@ -554,7 +553,7 @@ async def test_create_signed_transaction( @pytest.mark.limit_consensus_modes(allowed=[ConsensusMode.PLAIN, ConsensusMode.HARD_FORK_2_0], reason="save time") -@pytest.mark.asyncio +@pytest.mark.anyio async def test_create_signed_transaction_with_coin_announcement(wallet_rpc_environment: WalletRpcTestEnvironment): env: WalletRpcTestEnvironment = wallet_rpc_environment @@ -586,7 +585,7 @@ async def test_create_signed_transaction_with_coin_announcement(wallet_rpc_envir @pytest.mark.limit_consensus_modes(allowed=[ConsensusMode.PLAIN, ConsensusMode.HARD_FORK_2_0], reason="save time") -@pytest.mark.asyncio +@pytest.mark.anyio async def test_create_signed_transaction_with_puzzle_announcement(wallet_rpc_environment: WalletRpcTestEnvironment): env: WalletRpcTestEnvironment = wallet_rpc_environment @@ -618,7 +617,7 @@ async def test_create_signed_transaction_with_puzzle_announcement(wallet_rpc_env @pytest.mark.limit_consensus_modes(allowed=[ConsensusMode.PLAIN, ConsensusMode.HARD_FORK_2_0], reason="save time") -@pytest.mark.asyncio +@pytest.mark.anyio async def test_create_signed_transaction_with_excluded_coins(wallet_rpc_environment: WalletRpcTestEnvironment) -> None: env: WalletRpcTestEnvironment = wallet_rpc_environment wallet_1: Wallet = env.wallet_1.wallet @@ -666,7 +665,7 @@ async def test_create_signed_transaction_with_excluded_coins(wallet_rpc_environm @pytest.mark.limit_consensus_modes(allowed=[ConsensusMode.PLAIN, ConsensusMode.HARD_FORK_2_0], reason="save time") -@pytest.mark.asyncio +@pytest.mark.anyio async def test_spend_clawback_coins(wallet_rpc_environment: WalletRpcTestEnvironment): env: WalletRpcTestEnvironment = wallet_rpc_environment @@ -773,7 +772,7 @@ async def test_spend_clawback_coins(wallet_rpc_environment: WalletRpcTestEnviron @pytest.mark.limit_consensus_modes(allowed=[ConsensusMode.PLAIN, ConsensusMode.HARD_FORK_2_0], reason="save time") -@pytest.mark.asyncio +@pytest.mark.anyio async def test_send_transaction_multi(wallet_rpc_environment: WalletRpcTestEnvironment): env: WalletRpcTestEnvironment = wallet_rpc_environment @@ -823,7 +822,7 @@ async def test_send_transaction_multi(wallet_rpc_environment: WalletRpcTestEnvir @pytest.mark.limit_consensus_modes(allowed=[ConsensusMode.PLAIN, ConsensusMode.HARD_FORK_2_0], reason="save time") -@pytest.mark.asyncio +@pytest.mark.anyio async def test_get_transactions(wallet_rpc_environment: WalletRpcTestEnvironment): env: WalletRpcTestEnvironment = wallet_rpc_environment @@ -901,7 +900,7 @@ async def test_get_transactions(wallet_rpc_environment: WalletRpcTestEnvironment @pytest.mark.limit_consensus_modes(allowed=[ConsensusMode.PLAIN, ConsensusMode.HARD_FORK_2_0], reason="save time") -@pytest.mark.asyncio +@pytest.mark.anyio async def test_get_transaction_count(wallet_rpc_environment: WalletRpcTestEnvironment): env: WalletRpcTestEnvironment = wallet_rpc_environment @@ -924,7 +923,7 @@ async def test_get_transaction_count(wallet_rpc_environment: WalletRpcTestEnviro @pytest.mark.limit_consensus_modes(allowed=[ConsensusMode.PLAIN, ConsensusMode.HARD_FORK_2_0], reason="save time") -@pytest.mark.asyncio +@pytest.mark.anyio async def test_cat_endpoints(wallet_rpc_environment: WalletRpcTestEnvironment): env: WalletRpcTestEnvironment = wallet_rpc_environment @@ -1081,7 +1080,7 @@ async def test_cat_endpoints(wallet_rpc_environment: WalletRpcTestEnvironment): @pytest.mark.limit_consensus_modes(allowed=[ConsensusMode.PLAIN, ConsensusMode.HARD_FORK_2_0], reason="save time") -@pytest.mark.asyncio +@pytest.mark.anyio async def test_offer_endpoints(wallet_rpc_environment: WalletRpcTestEnvironment): env: WalletRpcTestEnvironment = wallet_rpc_environment @@ -1315,7 +1314,7 @@ async def test_offer_endpoints(wallet_rpc_environment: WalletRpcTestEnvironment) @pytest.mark.limit_consensus_modes(allowed=[ConsensusMode.PLAIN, ConsensusMode.HARD_FORK_2_0], reason="save time") -@pytest.mark.asyncio +@pytest.mark.anyio async def test_get_coin_records_by_names(wallet_rpc_environment: WalletRpcTestEnvironment) -> None: env: WalletRpcTestEnvironment = wallet_rpc_environment wallet_node: WalletNode = env.wallet_1.node @@ -1369,7 +1368,7 @@ async def test_get_coin_records_by_names(wallet_rpc_environment: WalletRpcTestEn @pytest.mark.limit_consensus_modes(allowed=[ConsensusMode.PLAIN, ConsensusMode.HARD_FORK_2_0], reason="save time") -@pytest.mark.asyncio +@pytest.mark.anyio async def test_did_endpoints(wallet_rpc_environment: WalletRpcTestEnvironment): env: WalletRpcTestEnvironment = wallet_rpc_environment @@ -1503,7 +1502,7 @@ async def test_did_endpoints(wallet_rpc_environment: WalletRpcTestEnvironment): @pytest.mark.limit_consensus_modes(allowed=[ConsensusMode.PLAIN, ConsensusMode.HARD_FORK_2_0], reason="save time") -@pytest.mark.asyncio +@pytest.mark.anyio async def test_nft_endpoints(wallet_rpc_environment: WalletRpcTestEnvironment): env: WalletRpcTestEnvironment = wallet_rpc_environment wallet_1_node: WalletNode = env.wallet_1.node @@ -1596,7 +1595,7 @@ async def test_nft_endpoints(wallet_rpc_environment: WalletRpcTestEnvironment): @pytest.mark.limit_consensus_modes(allowed=[ConsensusMode.PLAIN, ConsensusMode.HARD_FORK_2_0], reason="save time") -@pytest.mark.asyncio +@pytest.mark.anyio async def test_key_and_address_endpoints(wallet_rpc_environment: WalletRpcTestEnvironment): env: WalletRpcTestEnvironment = wallet_rpc_environment @@ -1726,7 +1725,7 @@ async def test_key_and_address_endpoints(wallet_rpc_environment: WalletRpcTestEn @pytest.mark.limit_consensus_modes(allowed=[ConsensusMode.PLAIN, ConsensusMode.HARD_FORK_2_0], reason="save time") -@pytest.mark.asyncio +@pytest.mark.anyio async def test_select_coins_rpc(wallet_rpc_environment: WalletRpcTestEnvironment): env: WalletRpcTestEnvironment = wallet_rpc_environment @@ -1847,7 +1846,7 @@ async def test_select_coins_rpc(wallet_rpc_environment: WalletRpcTestEnvironment @pytest.mark.limit_consensus_modes(allowed=[ConsensusMode.PLAIN, ConsensusMode.HARD_FORK_2_0], reason="save time") -@pytest.mark.asyncio +@pytest.mark.anyio async def test_get_coin_records_rpc(wallet_rpc_environment: WalletRpcTestEnvironment) -> None: env: WalletRpcTestEnvironment = wallet_rpc_environment wallet_node: WalletNode = env.wallet_1.node @@ -1894,7 +1893,7 @@ async def test_get_coin_records_rpc(wallet_rpc_environment: WalletRpcTestEnviron @pytest.mark.limit_consensus_modes(allowed=[ConsensusMode.PLAIN, ConsensusMode.HARD_FORK_2_0], reason="save time") -@pytest.mark.asyncio +@pytest.mark.anyio async def test_get_coin_records_rpc_limits( wallet_rpc_environment: WalletRpcTestEnvironment, seeded_random: random.Random, @@ -1970,7 +1969,7 @@ async def test_get_coin_records_rpc_limits( @pytest.mark.limit_consensus_modes(allowed=[ConsensusMode.PLAIN, ConsensusMode.HARD_FORK_2_0], reason="save time") -@pytest.mark.asyncio +@pytest.mark.anyio async def test_get_coin_records_rpc_failures( wallet_rpc_environment: WalletRpcTestEnvironment, seeded_random: random.Random, @@ -2019,7 +2018,7 @@ async def test_get_coin_records_rpc_failures( @pytest.mark.limit_consensus_modes(allowed=[ConsensusMode.PLAIN, ConsensusMode.HARD_FORK_2_0], reason="save time") -@pytest.mark.asyncio +@pytest.mark.anyio async def test_notification_rpcs(wallet_rpc_environment: WalletRpcTestEnvironment): env: WalletRpcTestEnvironment = wallet_rpc_environment @@ -2190,7 +2189,7 @@ async def test_notification_rpcs(wallet_rpc_environment: WalletRpcTestEnvironmen ], ) @pytest.mark.parametrize("prefix_hex_strings", [True, False], ids=["with 0x", "no 0x"]) -@pytest.mark.asyncio +@pytest.mark.anyio async def test_verify_signature( wallet_rpc_environment: WalletRpcTestEnvironment, rpc_request: Dict[str, Any], @@ -2205,7 +2204,7 @@ async def test_verify_signature( assert res == rpc_response -@pytest.mark.asyncio +@pytest.mark.anyio async def test_set_auto_claim(wallet_rpc_environment: WalletRpcTestEnvironment): env: WalletRpcTestEnvironment = wallet_rpc_environment full_node_api: FullNodeSimulator = env.full_node.api @@ -2228,7 +2227,7 @@ async def test_set_auto_claim(wallet_rpc_environment: WalletRpcTestEnvironment): assert res["batch_size"] == 50 -@pytest.mark.asyncio +@pytest.mark.anyio async def test_get_auto_claim(wallet_rpc_environment: WalletRpcTestEnvironment): env: WalletRpcTestEnvironment = wallet_rpc_environment full_node_api: FullNodeSimulator = env.full_node.api @@ -2244,7 +2243,7 @@ async def test_get_auto_claim(wallet_rpc_environment: WalletRpcTestEnvironment): @pytest.mark.limit_consensus_modes(allowed=[ConsensusMode.PLAIN, ConsensusMode.HARD_FORK_2_0], reason="save time") -@pytest.mark.asyncio +@pytest.mark.anyio async def test_set_wallet_resync_on_startup(wallet_rpc_environment: WalletRpcTestEnvironment): env: WalletRpcTestEnvironment = wallet_rpc_environment full_node_api: FullNodeSimulator = env.full_node.api @@ -2340,7 +2339,7 @@ async def test_set_wallet_resync_on_startup(wallet_rpc_environment: WalletRpcTes @pytest.mark.limit_consensus_modes(allowed=[ConsensusMode.PLAIN, ConsensusMode.HARD_FORK_2_0], reason="save time") -@pytest.mark.asyncio +@pytest.mark.anyio async def test_set_wallet_resync_on_startup_disable(wallet_rpc_environment: WalletRpcTestEnvironment): env: WalletRpcTestEnvironment = wallet_rpc_environment full_node_api: FullNodeSimulator = env.full_node.api @@ -2380,7 +2379,7 @@ async def test_set_wallet_resync_on_startup_disable(wallet_rpc_environment: Wall @pytest.mark.limit_consensus_modes(allowed=[ConsensusMode.PLAIN, ConsensusMode.HARD_FORK_2_0], reason="save time") -@pytest.mark.asyncio +@pytest.mark.anyio async def test_set_wallet_resync_schema(wallet_rpc_environment: WalletRpcTestEnvironment): env: WalletRpcTestEnvironment = wallet_rpc_environment full_node_api: FullNodeSimulator = env.full_node.api @@ -2409,7 +2408,7 @@ async def test_set_wallet_resync_schema(wallet_rpc_environment: WalletRpcTestEnv @pytest.mark.limit_consensus_modes(allowed=[ConsensusMode.PLAIN, ConsensusMode.HARD_FORK_2_0], reason="save time") -@pytest.mark.asyncio +@pytest.mark.anyio async def test_cat_spend_run_tail(wallet_rpc_environment: WalletRpcTestEnvironment): env: WalletRpcTestEnvironment = wallet_rpc_environment @@ -2487,7 +2486,7 @@ async def test_cat_spend_run_tail(wallet_rpc_environment: WalletRpcTestEnvironme @pytest.mark.limit_consensus_modes(allowed=[ConsensusMode.PLAIN, ConsensusMode.HARD_FORK_2_0], reason="save time") -@pytest.mark.asyncio +@pytest.mark.anyio async def test_get_balances(wallet_rpc_environment: WalletRpcTestEnvironment): env: WalletRpcTestEnvironment = wallet_rpc_environment diff --git a/tests/wallet/simple_sync/test_simple_sync_protocol.py b/tests/wallet/simple_sync/test_simple_sync_protocol.py index 605d962ba151..d2da32f1e5b7 100644 --- a/tests/wallet/simple_sync/test_simple_sync_protocol.py +++ b/tests/wallet/simple_sync/test_simple_sync_protocol.py @@ -51,7 +51,7 @@ async def get_all_messages_in_queue(queue): class TestSimpleSyncProtocol: - @pytest.mark.asyncio + @pytest.mark.anyio async def test_subscribe_for_ph(self, simulator_and_wallet, self_hostname): num_blocks = 4 full_nodes, wallets, _ = simulator_and_wallet @@ -230,7 +230,7 @@ class TestSimpleSyncProtocol: assert notified_state.coin == spent_coin assert notified_state.spent_height is not None - @pytest.mark.asyncio + @pytest.mark.anyio async def test_subscribe_for_coin_id(self, simulator_and_wallet, self_hostname): num_blocks = 4 full_nodes, wallets, _ = simulator_and_wallet @@ -331,7 +331,7 @@ class TestSimpleSyncProtocol: assert notified_state.coin == added_target assert notified_state.spent_height is None - @pytest.mark.asyncio + @pytest.mark.anyio async def test_subscribe_for_ph_reorg(self, simulator_and_wallet, self_hostname): num_blocks = 4 long_blocks = 20 @@ -406,7 +406,7 @@ class TestSimpleSyncProtocol: assert second_state_coin_2.spent_height is None assert second_state_coin_2.created_height is None - @pytest.mark.asyncio + @pytest.mark.anyio async def test_subscribe_for_coin_id_reorg(self, simulator_and_wallet, self_hostname): num_blocks = 4 long_blocks = 20 @@ -473,7 +473,7 @@ class TestSimpleSyncProtocol: assert second_coin.spent_height is None assert second_coin.created_height is None - @pytest.mark.asyncio + @pytest.mark.anyio async def test_subscribe_for_hint(self, simulator_and_wallet, self_hostname): num_blocks = 4 full_nodes, wallets, bt = simulator_and_wallet @@ -543,7 +543,7 @@ class TestSimpleSyncProtocol: # ignore the duplicate assert data_response.coin_states == [] - @pytest.mark.asyncio + @pytest.mark.anyio async def test_subscribe_for_puzzle_hash_coin_hint_duplicates( self, simulator_and_wallet: SimulatorsAndWallets, self_hostname: str ) -> None: @@ -577,7 +577,7 @@ class TestSimpleSyncProtocol: assert len(response.coin_states) > 0 assert len(set(response.coin_states)) == len(response.coin_states) - @pytest.mark.asyncio + @pytest.mark.anyio async def test_subscribe_for_hint_long_sync(self, wallet_two_node_simulator, self_hostname): num_blocks = 4 full_nodes, wallets, bt = wallet_two_node_simulator @@ -663,7 +663,7 @@ class TestSimpleSyncProtocol: check_messages_for_hint(all_messages) check_messages_for_hint(all_messages_1) - @pytest.mark.asyncio + @pytest.mark.anyio async def test_ph_subscribe_limits(self, simulator_and_wallet, self_hostname): full_nodes, wallets, _ = simulator_and_wallet full_node_api = full_nodes[0] @@ -703,7 +703,7 @@ class TestSimpleSyncProtocol: assert not s.has_ph_subscription(phs[4]) assert not s.has_ph_subscription(phs[5]) - @pytest.mark.asyncio + @pytest.mark.anyio async def test_coin_subscribe_limits(self, simulator_and_wallet, self_hostname): full_nodes, wallets, _ = simulator_and_wallet full_node_api = full_nodes[0] diff --git a/tests/wallet/sync/test_wallet_sync.py b/tests/wallet/sync/test_wallet_sync.py index dec09b5f0e0e..ed8525cabe4b 100644 --- a/tests/wallet/sync/test_wallet_sync.py +++ b/tests/wallet/sync/test_wallet_sync.py @@ -53,7 +53,7 @@ log = getLogger(__name__) class TestWalletSync: @pytest.mark.limit_consensus_modes(reason="save time") - @pytest.mark.asyncio + @pytest.mark.anyio async def test_request_block_headers(self, simulator_and_wallet, default_1000_blocks): # Tests the edge case of receiving funds right before the recent blocks in weight proof [full_node_api], [(wallet_node, _)], bt = simulator_and_wallet @@ -98,7 +98,7 @@ class TestWalletSync: # [(80, 99, False, ProtocolMessageTypes.respond_block_headers)], # [(10, 8, False, None)], # ) - @pytest.mark.asyncio + @pytest.mark.anyio async def test_request_block_headers_rejected(self, simulator_and_wallet, default_1000_blocks): # Tests the edge case of receiving funds right before the recent blocks in weight proof [full_node_api], _, bt = simulator_and_wallet @@ -155,7 +155,7 @@ class TestWalletSync: indirect=True, ) @pytest.mark.limit_consensus_modes(reason="save time") - @pytest.mark.asyncio + @pytest.mark.anyio async def test_basic_sync_wallet(self, two_wallet_nodes, default_400_blocks, self_hostname): full_nodes, wallets, bt = two_wallet_nodes full_node_api = full_nodes[0] @@ -207,7 +207,7 @@ class TestWalletSync: indirect=True, ) @pytest.mark.limit_consensus_modes(reason="save time") - @pytest.mark.asyncio + @pytest.mark.anyio async def test_almost_recent(self, two_wallet_nodes, default_400_blocks, self_hostname, blockchain_constants): # Tests the edge case of receiving funds right before the recent blocks in weight proof full_nodes, wallets, bt = two_wallet_nodes @@ -246,7 +246,7 @@ class TestWalletSync: await wallet_server.start_client(PeerInfo(self_hostname, full_node_server.get_port()), None) await time_out_assert(30, wallet.get_confirmed_balance, 10 * calculate_pool_reward(uint32(1000))) - @pytest.mark.asyncio + @pytest.mark.anyio async def test_backtrack_sync_wallet(self, two_wallet_nodes, default_400_blocks, self_hostname): full_nodes, wallets, _ = two_wallet_nodes full_node_api = full_nodes[0] @@ -268,7 +268,7 @@ class TestWalletSync: await time_out_assert(100, wallet_height_at_least, True, wallet_node, 19) # Tests a reorg with the wallet - @pytest.mark.asyncio + @pytest.mark.anyio async def test_short_batch_sync_wallet(self, two_wallet_nodes, default_400_blocks, self_hostname): full_nodes, wallets, _ = two_wallet_nodes full_node_api = full_nodes[0] @@ -290,7 +290,7 @@ class TestWalletSync: await time_out_assert(100, wallet_height_at_least, True, wallet_node, 199) @pytest.mark.limit_consensus_modes(reason="save time") - @pytest.mark.asyncio + @pytest.mark.anyio async def test_long_sync_wallet(self, two_wallet_nodes, default_1000_blocks, default_400_blocks, self_hostname): full_nodes, wallets, bt = two_wallet_nodes full_node_api = full_nodes[0] @@ -338,7 +338,7 @@ class TestWalletSync: ) @pytest.mark.limit_consensus_modes(reason="save time") - @pytest.mark.asyncio + @pytest.mark.anyio async def test_wallet_reorg_sync(self, two_wallet_nodes, default_400_blocks, self_hostname): num_blocks = 5 full_nodes, wallets, bt = two_wallet_nodes @@ -395,7 +395,7 @@ class TestWalletSync: await time_out_assert(60, wallet.get_confirmed_balance, 0) @pytest.mark.limit_consensus_modes(reason="save time") - @pytest.mark.asyncio + @pytest.mark.anyio async def test_wallet_reorg_get_coinbase(self, two_wallet_nodes, default_400_blocks, self_hostname): full_nodes, wallets, bt = two_wallet_nodes full_node_api = full_nodes[0] @@ -457,7 +457,7 @@ class TestWalletSync: await time_out_assert(20, get_tx_count, 2, wallet_node.wallet_state_manager, 1) await time_out_assert(20, wallet.get_confirmed_balance, funds) - @pytest.mark.asyncio + @pytest.mark.anyio async def test_request_additions_errors(self, simulator_and_wallet, self_hostname): full_nodes, wallets, _ = simulator_and_wallet wallet_node, wallet_server = wallets[0] @@ -498,7 +498,7 @@ class TestWalletSync: assert response.proofs[0][1] is not None assert response.proofs[0][2] is None - @pytest.mark.asyncio + @pytest.mark.anyio async def test_request_additions_success(self, simulator_and_wallet, self_hostname): full_nodes, wallets, _ = simulator_and_wallet wallet_node, wallet_server = wallets[0] @@ -586,7 +586,7 @@ class TestWalletSync: assert response.proofs == [] assert len(response.coins) == 0 - @pytest.mark.asyncio + @pytest.mark.anyio async def test_get_wp_fork_point(self, default_10000_blocks, blockchain_constants): blocks = default_10000_blocks header_cache, height_to_hash, sub_blocks, summaries = await load_blocks_dont_validate( @@ -659,7 +659,7 @@ class TestWalletSync: Send the NFT to the dust wallet. The NFT should not be filtered. """ - @pytest.mark.asyncio + @pytest.mark.anyio @pytest.mark.parametrize( "spam_filter_after_n_txs, xch_spam_amount, dust_value", [ @@ -1176,7 +1176,7 @@ class TestWalletSync: await time_out_assert(15, get_nft_count, 0, farm_nft_wallet) await time_out_assert(15, get_nft_count, 1, dust_nft_wallet) - @pytest.mark.asyncio + @pytest.mark.anyio async def test_retry_store(self, two_wallet_nodes, self_hostname): full_nodes, wallets, bt = two_wallet_nodes full_node_api = full_nodes[0] @@ -1308,7 +1308,7 @@ class TestWalletSync: await time_out_assert(30, wallet.get_confirmed_balance, 1_000_000_000_000) @pytest.mark.limit_consensus_modes(reason="save time") - @pytest.mark.asyncio + @pytest.mark.anyio async def test_bad_peak_mismatch(self, two_wallet_nodes, default_1000_blocks, self_hostname, blockchain_constants): full_nodes, wallets, bt = two_wallet_nodes wallet_node, wallet_server = wallets[0] @@ -1362,7 +1362,7 @@ class TestWalletSync: @pytest.mark.limit_consensus_modes(reason="save time") -@pytest.mark.asyncio +@pytest.mark.anyio async def test_long_sync_untrusted_break( setup_two_nodes_and_wallet, default_1000_blocks, default_400_blocks, self_hostname, caplog ): diff --git a/tests/wallet/test_coin_selection.py b/tests/wallet/test_coin_selection.py index e5ff74821e92..60e6a4324ed6 100644 --- a/tests/wallet/test_coin_selection.py +++ b/tests/wallet/test_coin_selection.py @@ -68,7 +68,7 @@ class TestCoinSelection: selected_sum = sum(coin.amount for coin in list(knapsack)) assert 265 <= selected_sum <= 281 # Selects a set of coins which does exceed by too much - @pytest.mark.asyncio + @pytest.mark.anyio async def test_coin_selection_randomly(self, a_hash: bytes32) -> None: coin_base_amounts = [3, 6, 20, 40, 80, 150, 160, 203, 202, 201, 320] coin_amounts = [] @@ -98,7 +98,7 @@ class TestCoinSelection: assert sum([coin.amount for coin in result]) >= target_amount assert len(result) <= 500 - @pytest.mark.asyncio + @pytest.mark.anyio async def test_coin_selection_with_dust(self, a_hash: bytes32) -> None: spendable_amount = uint128(5000000000000 + 10000) coin_list: List[WalletCoinRecord] = [ @@ -204,7 +204,7 @@ class TestCoinSelection: assert coin.amount == 5000 assert len(dusty_below_target) <= 500 - @pytest.mark.asyncio + @pytest.mark.anyio async def test_dust_and_one_large_coin(self, a_hash: bytes32) -> None: # test when we have a lot of dust and 1 large coin spendable_amount = uint128(50000 + 10000) @@ -239,7 +239,7 @@ class TestCoinSelection: assert sum([coin.amount for coin in dusty_below_target]) >= target_amount assert len(dusty_below_target) <= 500 - @pytest.mark.asyncio + @pytest.mark.anyio async def test_coin_selection_failure(self, a_hash: bytes32) -> None: spendable_amount = uint128(10000) coin_list: List[WalletCoinRecord] = [] @@ -279,7 +279,7 @@ class TestCoinSelection: uint128(target_amount), ) - @pytest.mark.asyncio + @pytest.mark.anyio async def test_coin_selection(self, a_hash: bytes32) -> None: coin_amounts = [3, 6, 20, 40, 80, 150, 160, 203, 202, 201, 320] coin_list: List[WalletCoinRecord] = [ @@ -402,7 +402,7 @@ class TestCoinSelection: assert sum([coin.amount for coin in multiple_greater_result]) == 90000 assert len(multiple_greater_result) == 1 - @pytest.mark.asyncio + @pytest.mark.anyio async def test_coin_selection_difficult(self, a_hash: bytes32) -> None: num_coins = 40 spendable_amount = uint128(num_coins * 1000) @@ -432,7 +432,7 @@ class TestCoinSelection: print(sum([c.amount for c in result])) assert sum([coin.amount for coin in result]) >= target_amount - @pytest.mark.asyncio + @pytest.mark.anyio async def test_smallest_coin_over_amount(self, a_hash: bytes32) -> None: coin_list: List[Coin] = [ Coin(a_hash, std_hash(i.to_bytes(4, "big")), uint64((39 - i) * 1000)) for i in range(40) @@ -444,7 +444,7 @@ class TestCoinSelection: assert select_smallest_coin_over_target(uint128(39000), coin_list) == coin_list[39 - 39] assert select_smallest_coin_over_target(uint128(39001), coin_list) is None - @pytest.mark.asyncio + @pytest.mark.anyio async def test_sum_largest_coins(self, a_hash: bytes32) -> None: coin_list: List[Coin] = list( reversed([Coin(a_hash, std_hash(i.to_bytes(4, "big")), uint64(i)) for i in range(41)]) @@ -453,7 +453,7 @@ class TestCoinSelection: assert sum_largest_coins(uint128(79), coin_list) == {coin_list[0], coin_list[1]} assert sum_largest_coins(uint128(40000), coin_list) is None - @pytest.mark.asyncio + @pytest.mark.anyio async def test_knapsack_perf(self, a_hash: bytes32) -> None: start = time.time() coin_list: List[Coin] = [ @@ -464,7 +464,7 @@ class TestCoinSelection: # Just a sanity check, it's actually much faster than this time assert time.time() - start < 10000 - @pytest.mark.asyncio + @pytest.mark.anyio async def test_coin_selection_min_coin(self, a_hash: bytes32) -> None: spendable_amount = uint128(5000000 + 500 + 40050) coin_list: List[WalletCoinRecord] = [ @@ -511,7 +511,7 @@ class TestCoinSelection: assert not coin.amount < min_coin_amount assert len(result) <= 500 - @pytest.mark.asyncio + @pytest.mark.anyio async def test_coin_selection_with_excluded_coins(self) -> None: a_hash = std_hash(b"a") b_hash = std_hash(b"b") @@ -555,7 +555,7 @@ class TestCoinSelection: amount=target_amount, ) - @pytest.mark.asyncio + @pytest.mark.anyio async def test_coin_selection_with_zero_amount(self, a_hash: bytes32) -> None: coin_amounts = [3, 6, 20, 40, 80, 150, 160, 203, 202, 201, 320] coin_list: List[WalletCoinRecord] = [ diff --git a/tests/wallet/test_nft_store.py b/tests/wallet/test_nft_store.py index 2efaad9d447c..723fac038fd6 100644 --- a/tests/wallet/test_nft_store.py +++ b/tests/wallet/test_nft_store.py @@ -38,7 +38,7 @@ class DummyNFTs: class TestNftStore: - @pytest.mark.asyncio + @pytest.mark.anyio async def test_nft_insert(self) -> None: async with DBConnection(1) as wrapper: db = await WalletNftStore.create(wrapper) @@ -92,7 +92,7 @@ class TestNftStore: assert (await db.get_nft_by_coin_id(bytes32(b"0" * 32))) is None assert not await db.exists(bytes32(b"0" * 32)) - @pytest.mark.asyncio + @pytest.mark.anyio async def test_nft_remove(self) -> None: async with DBConnection(1) as wrapper: db = await WalletNftStore.create(wrapper) @@ -123,7 +123,7 @@ class TestNftStore: assert not await db.delete_nft_by_coin_id(a_bytes32, uint32(11)) assert not await db.exists(a_bytes32) - @pytest.mark.asyncio + @pytest.mark.anyio async def test_nft_reorg(self) -> None: async with DBConnection(1) as wrapper: db = await WalletNftStore.create(wrapper) @@ -171,7 +171,7 @@ class TestNftStore: assert await db.is_empty(wallet_id=uint32(1)) -@pytest.mark.asyncio +@pytest.mark.anyio async def test_delete_wallet(seeded_random: random.Random) -> None: dummy_nfts = DummyNFTs(seeded_random=seeded_random) for i in range(5): diff --git a/tests/wallet/test_notifications.py b/tests/wallet/test_notifications.py index aecc9faceaf5..0330b2f7ae48 100644 --- a/tests/wallet/test_notifications.py +++ b/tests/wallet/test_notifications.py @@ -20,7 +20,7 @@ from chia.wallet.util.tx_config import DEFAULT_TX_CONFIG # For testing backwards compatibility with a DB change to add height -@pytest.mark.asyncio +@pytest.mark.anyio async def test_notification_store_backwards_compat() -> None: # First create the DB the way it would have otheriwse been created db_name = Path(tempfile.TemporaryDirectory().name).joinpath("test.sqlite") @@ -53,7 +53,7 @@ async def test_notification_store_backwards_compat() -> None: "trusted", [True, False], ) -@pytest.mark.asyncio +@pytest.mark.anyio async def test_notifications( self_hostname: str, two_wallet_nodes: Any, trusted: Any, seeded_random: random.Random ) -> None: diff --git a/tests/wallet/test_puzzle_store.py b/tests/wallet/test_puzzle_store.py index f2f46fec9afe..bf1c569beb11 100644 --- a/tests/wallet/test_puzzle_store.py +++ b/tests/wallet/test_puzzle_store.py @@ -43,7 +43,7 @@ class DummyDerivationRecords: class TestPuzzleStore: - @pytest.mark.asyncio + @pytest.mark.anyio async def test_puzzle_store(self, seeded_random: random.Random): async with DBConnection(1) as wrapper: db = await WalletPuzzleStore.create(wrapper) @@ -99,7 +99,7 @@ class TestPuzzleStore: assert await db.get_unused_derivation_path() == 250 -@pytest.mark.asyncio +@pytest.mark.anyio async def test_delete_wallet(seeded_random: random.Random) -> None: dummy_records = DummyDerivationRecords(seeded_random=seeded_random) for i in range(5): diff --git a/tests/wallet/test_sign_coin_spends.py b/tests/wallet/test_sign_coin_spends.py index d883bd8f23dd..6ed6b80daabb 100644 --- a/tests/wallet/test_sign_coin_spends.py +++ b/tests/wallet/test_sign_coin_spends.py @@ -63,7 +63,7 @@ spend_u: CoinSpend = CoinSpend( ) -@pytest.mark.asyncio +@pytest.mark.anyio async def test_sign_coin_spends() -> None: def derive_ph(pk: G1Element) -> bytes32: return bytes32([0] * 32) @@ -145,7 +145,7 @@ async def test_sign_coin_spends() -> None: assert signature2 == signature -@pytest.mark.asyncio +@pytest.mark.anyio async def test_wsm_sign_transaction() -> None: async with manage_connection("file:temp.db?mode=memory&cache=shared", uri=True, name="writer") as writer_conn: async with manage_connection("file:temp.db?mode=memory&cache=shared", uri=True, name="reader") as reader_conn: diff --git a/tests/wallet/test_singleton_lifecycle.py b/tests/wallet/test_singleton_lifecycle.py index d475d71657d6..51a7ff3c10b3 100644 --- a/tests/wallet/test_singleton_lifecycle.py +++ b/tests/wallet/test_singleton_lifecycle.py @@ -94,7 +94,7 @@ def p2_singleton_puzzle_hash(launcher_id: Program, launcher_puzzle_hash: bytes32 return p2_singleton_puzzle(launcher_id, launcher_puzzle_hash).get_tree_hash() -@pytest.mark.asyncio +@pytest.mark.anyio async def test_only_odd_coins_0(bt): blocks = await initial_blocks(bt) farmed_coin = list(blocks[-1].get_included_reward_coins())[0] diff --git a/tests/wallet/test_singleton_store.py b/tests/wallet/test_singleton_store.py index 9f0359eb9d83..5a9cc4436a39 100644 --- a/tests/wallet/test_singleton_store.py +++ b/tests/wallet/test_singleton_store.py @@ -48,7 +48,7 @@ def get_record(wallet_id: uint32 = uint32(2)) -> SingletonRecord: class TestSingletonStore: - @pytest.mark.asyncio + @pytest.mark.anyio async def test_singleton_insert(self) -> None: async with DBConnection(1) as wrapper: db = await WalletSingletonStore.create(wrapper) @@ -66,7 +66,7 @@ class TestSingletonStore: assert record_to_check.pending is False assert record_to_check.custom_data == "{'key': 'value'}" - @pytest.mark.asyncio + @pytest.mark.anyio async def test_singleton_add_spend(self) -> None: async with DBConnection(1) as wrapper: db = await WalletSingletonStore.create(wrapper) @@ -89,7 +89,7 @@ class TestSingletonStore: await db.add_spend(uint32(2), bad_coinspend, uint32(10)) assert e_info.value.args[0] == "Coin to add is not a valid singleton" - @pytest.mark.asyncio + @pytest.mark.anyio async def test_singleton_remove(self) -> None: async with DBConnection(1) as wrapper: db = await WalletSingletonStore.create(wrapper) @@ -113,7 +113,7 @@ class TestSingletonStore: resp_4 = await db.delete_singleton_by_singleton_id(fake_id, uint32(10)) assert not resp_4 - @pytest.mark.asyncio + @pytest.mark.anyio async def test_singleton_delete_wallet(self) -> None: async with DBConnection(1) as wrapper: db = await WalletSingletonStore.create(wrapper) @@ -135,7 +135,7 @@ class TestSingletonStore: assert await db.is_empty() - @pytest.mark.asyncio + @pytest.mark.anyio async def test_singleton_reorg(self) -> None: async with DBConnection(1) as wrapper: db = await WalletSingletonStore.create(wrapper) diff --git a/tests/wallet/test_transaction_store.py b/tests/wallet/test_transaction_store.py index e231087d9fb5..f776aebb3938 100644 --- a/tests/wallet/test_transaction_store.py +++ b/tests/wallet/test_transaction_store.py @@ -46,7 +46,7 @@ tr1 = TransactionRecord( ) -@pytest.mark.asyncio +@pytest.mark.anyio async def test_add() -> None: async with DBConnection(1) as db_wrapper: store = await WalletTransactionStore.create(db_wrapper) @@ -56,7 +56,7 @@ async def test_add() -> None: assert await store.get_transaction_record(tr1.name) == tr1 -@pytest.mark.asyncio +@pytest.mark.anyio async def test_delete() -> None: async with DBConnection(1) as db_wrapper: store = await WalletTransactionStore.create(db_wrapper) @@ -67,7 +67,7 @@ async def test_delete() -> None: assert await store.get_transaction_record(tr1.name) is None -@pytest.mark.asyncio +@pytest.mark.anyio async def test_set_confirmed() -> None: async with DBConnection(1) as db_wrapper: store = await WalletTransactionStore.create(db_wrapper) @@ -80,7 +80,7 @@ async def test_set_confirmed() -> None: ) -@pytest.mark.asyncio +@pytest.mark.anyio async def test_increment_sent_noop(seeded_random: random.Random) -> None: async with DBConnection(1) as db_wrapper: store = await WalletTransactionStore.create(db_wrapper) @@ -93,7 +93,7 @@ async def test_increment_sent_noop(seeded_random: random.Random) -> None: ) -@pytest.mark.asyncio +@pytest.mark.anyio async def test_increment_sent() -> None: async with DBConnection(1) as db_wrapper: store = await WalletTransactionStore.create(db_wrapper) @@ -119,7 +119,7 @@ async def test_increment_sent() -> None: assert tr.sent_to == [("peer1", uint8(2), None), ("peer1", uint8(1), None), ("peer2", uint8(1), None)] -@pytest.mark.asyncio +@pytest.mark.anyio async def test_increment_sent_error() -> None: async with DBConnection(1) as db_wrapper: store = await WalletTransactionStore.create(db_wrapper) @@ -149,7 +149,7 @@ def test_filter_ok_mempool_status() -> None: assert filter_ok_mempool_status([("peer1", uint8(2), "message does not matter")]) == [] -@pytest.mark.asyncio +@pytest.mark.anyio async def test_tx_reorged_update() -> None: async with DBConnection(1) as db_wrapper: store = await WalletTransactionStore.create(db_wrapper) @@ -166,7 +166,7 @@ async def test_tx_reorged_update() -> None: assert tr.sent_to == [] -@pytest.mark.asyncio +@pytest.mark.anyio async def test_tx_reorged_add() -> None: async with DBConnection(1) as db_wrapper: store = await WalletTransactionStore.create(db_wrapper) @@ -180,7 +180,7 @@ async def test_tx_reorged_add() -> None: assert tr.sent_to == [] -@pytest.mark.asyncio +@pytest.mark.anyio async def test_get_tx_record(seeded_random: random.Random) -> None: async with DBConnection(1) as db_wrapper: store = await WalletTransactionStore.create(db_wrapper) @@ -205,7 +205,7 @@ async def test_get_tx_record(seeded_random: random.Random) -> None: assert await store.get_transaction_record(tr3.name) == tr3 -@pytest.mark.asyncio +@pytest.mark.anyio async def test_get_farming_rewards(seeded_random: random.Random) -> None: async with DBConnection(1) as db_wrapper: store = await WalletTransactionStore.create(db_wrapper) @@ -242,7 +242,7 @@ async def test_get_farming_rewards(seeded_random: random.Random) -> None: assert test_trs[3] in rewards -@pytest.mark.asyncio +@pytest.mark.anyio async def test_get_all_unconfirmed(seeded_random: random.Random) -> None: async with DBConnection(1) as db_wrapper: store = await WalletTransactionStore.create(db_wrapper) @@ -256,7 +256,7 @@ async def test_get_all_unconfirmed(seeded_random: random.Random) -> None: assert await store.get_all_unconfirmed() == [tr1] -@pytest.mark.asyncio +@pytest.mark.anyio async def test_get_unconfirmed_for_wallet(seeded_random: random.Random) -> None: async with DBConnection(1) as db_wrapper: store = await WalletTransactionStore.create(db_wrapper) @@ -275,7 +275,7 @@ async def test_get_unconfirmed_for_wallet(seeded_random: random.Random) -> None: assert await store.get_unconfirmed_for_wallet(2) == [tr3] -@pytest.mark.asyncio +@pytest.mark.anyio async def test_transaction_count_for_wallet(seeded_random: random.Random) -> None: async with DBConnection(1) as db_wrapper: store = await WalletTransactionStore.create(db_wrapper) @@ -315,7 +315,7 @@ async def test_transaction_count_for_wallet(seeded_random: random.Random) -> Non ) -@pytest.mark.asyncio +@pytest.mark.anyio async def test_all_transactions_for_wallet(seeded_random: random.Random) -> None: async with DBConnection(1) as db_wrapper: store = await WalletTransactionStore.create(db_wrapper) @@ -366,7 +366,7 @@ def cmp(lhs: List[Any], rhs: List[Any]) -> bool: return True -@pytest.mark.asyncio +@pytest.mark.anyio async def test_get_all_transactions(seeded_random: random.Random) -> None: async with DBConnection(1) as db_wrapper: store = await WalletTransactionStore.create(db_wrapper) @@ -383,7 +383,7 @@ async def test_get_all_transactions(seeded_random: random.Random) -> None: assert cmp(all_trs, test_trs) -@pytest.mark.asyncio +@pytest.mark.anyio async def test_get_transaction_above(seeded_random: random.Random) -> None: async with DBConnection(1) as db_wrapper: store = await WalletTransactionStore.create(db_wrapper) @@ -403,7 +403,7 @@ async def test_get_transaction_above(seeded_random: random.Random) -> None: assert cmp(trs, test_trs[height + 1 :]) -@pytest.mark.asyncio +@pytest.mark.anyio async def test_get_tx_by_trade_id(seeded_random: random.Random) -> None: async with DBConnection(1) as db_wrapper: store = await WalletTransactionStore.create(db_wrapper) @@ -435,7 +435,7 @@ async def test_get_tx_by_trade_id(seeded_random: random.Random) -> None: assert cmp(await store.get_transactions_by_trade_id(tr4.trade_id), [tr1, tr4]) -@pytest.mark.asyncio +@pytest.mark.anyio async def test_rollback_to_block(seeded_random: random.Random) -> None: async with DBConnection(1) as db_wrapper: store = await WalletTransactionStore.create(db_wrapper) @@ -458,7 +458,7 @@ async def test_rollback_to_block(seeded_random: random.Random) -> None: assert cmp(all_trs, test_trs[:6]) -@pytest.mark.asyncio +@pytest.mark.anyio async def test_delete_unconfirmed(seeded_random: random.Random) -> None: async with DBConnection(1) as db_wrapper: store = await WalletTransactionStore.create(db_wrapper) @@ -486,7 +486,7 @@ async def test_delete_unconfirmed(seeded_random: random.Random) -> None: assert cmp(await store.get_all_transactions(), [tr2, tr3, tr5]) -@pytest.mark.asyncio +@pytest.mark.anyio async def test_get_transactions_between_confirmed(seeded_random: random.Random) -> None: async with DBConnection(1) as db_wrapper: store = await WalletTransactionStore.create(db_wrapper) @@ -578,7 +578,7 @@ async def test_get_transactions_between_confirmed(seeded_random: random.Random) ) == [tr6, tr5, tr4, tr3, tr2, tr1] -@pytest.mark.asyncio +@pytest.mark.anyio async def test_get_transactions_between_relevance(seeded_random: random.Random) -> None: async with DBConnection(1) as db_wrapper: store = await WalletTransactionStore.create(db_wrapper) @@ -709,7 +709,7 @@ async def test_get_transactions_between_relevance(seeded_random: random.Random) ] -@pytest.mark.asyncio +@pytest.mark.anyio async def test_get_transactions_between_to_puzzle_hash(seeded_random: random.Random) -> None: async with DBConnection(1) as db_wrapper: store = await WalletTransactionStore.create(db_wrapper) @@ -755,7 +755,7 @@ async def test_get_transactions_between_to_puzzle_hash(seeded_random: random.Ran assert await store.get_transactions_between(1, 1, 100, to_puzzle_hash=ph2, reverse=True) == [tr4] -@pytest.mark.asyncio +@pytest.mark.anyio async def test_get_not_sent(seeded_random: random.Random) -> None: async with DBConnection(1) as db_wrapper: store = await WalletTransactionStore.create(db_wrapper) @@ -796,7 +796,7 @@ async def test_get_not_sent(seeded_random: random.Random) -> None: # TODO: also cover include_accepted_txs=True -@pytest.mark.asyncio +@pytest.mark.anyio async def test_transaction_record_is_valid() -> None: invalid_attempts: List[Tuple[str, uint8, Optional[str]]] = [] # The tx should be valid as long as we don't have minimum_send_attempts failed attempts @@ -819,7 +819,7 @@ async def test_transaction_record_is_valid() -> None: assert dataclasses.replace(tr1, sent_to=invalid_attempts + [close_to_zero]).is_valid() -@pytest.mark.asyncio +@pytest.mark.anyio async def test_valid_times_migration() -> None: async with DBConnection(1) as db_wrapper: async with db_wrapper.writer_maybe_transaction() as conn: @@ -883,7 +883,7 @@ async def test_valid_times_migration() -> None: assert rec.valid_times == ConditionValidTimes() -@pytest.mark.asyncio +@pytest.mark.anyio async def test_large_tx_record_query() -> None: async with DBConnection(1) as db_wrapper: store = await WalletTransactionStore.create(db_wrapper) diff --git a/tests/wallet/test_wallet.py b/tests/wallet/test_wallet.py index 78df9d474dfe..6aea9a840923 100644 --- a/tests/wallet/test_wallet.py +++ b/tests/wallet/test_wallet.py @@ -42,7 +42,7 @@ class TestWalletSimulator: "trusted", [True, False], ) - @pytest.mark.asyncio + @pytest.mark.anyio async def test_wallet_coinbase( self, simulator_and_wallet: Tuple[List[FullNodeSimulator], List[Tuple[WalletNode, ChiaServer]], BlockTools], @@ -87,7 +87,7 @@ class TestWalletSimulator: "trusted", [True, False], ) - @pytest.mark.asyncio + @pytest.mark.anyio async def test_wallet_make_transaction( self, two_wallet_nodes: Tuple[List[FullNodeSimulator], List[Tuple[WalletNode, ChiaServer]], BlockTools], @@ -140,7 +140,7 @@ class TestWalletSimulator: "trusted", [True, False], ) - @pytest.mark.asyncio + @pytest.mark.anyio async def test_wallet_reuse_address( self, two_wallet_nodes: Tuple[List[FullNodeSimulator], List[Tuple[WalletNode, ChiaServer]], BlockTools], @@ -193,7 +193,7 @@ class TestWalletSimulator: "trusted", [True, False], ) - @pytest.mark.asyncio + @pytest.mark.anyio async def test_wallet_clawback_claim_auto( self, two_wallet_nodes: Tuple[List[FullNodeSimulator], List[Tuple[WalletNode, ChiaServer]], BlockTools], @@ -301,7 +301,7 @@ class TestWalletSimulator: "trusted", [True, False], ) - @pytest.mark.asyncio + @pytest.mark.anyio async def test_wallet_clawback_clawback( self, two_wallet_nodes: Tuple[List[FullNodeSimulator], List[Tuple[WalletNode, ChiaServer]], BlockTools], @@ -424,7 +424,7 @@ class TestWalletSimulator: @pytest.mark.limit_consensus_modes(allowed=[ConsensusMode.PLAIN, ConsensusMode.HARD_FORK_2_0], reason="save time") @pytest.mark.parametrize("trusted", [True, False]) - @pytest.mark.asyncio + @pytest.mark.anyio async def test_wallet_clawback_sent_self( self, two_wallet_nodes: Tuple[List[FullNodeSimulator], List[Tuple[WalletNode, ChiaServer]], BlockTools], @@ -510,7 +510,7 @@ class TestWalletSimulator: @pytest.mark.limit_consensus_modes(allowed=[ConsensusMode.PLAIN, ConsensusMode.HARD_FORK_2_0], reason="save time") @pytest.mark.parametrize("trusted", [True, False]) - @pytest.mark.asyncio + @pytest.mark.anyio async def test_wallet_clawback_claim_manual( self, two_wallet_nodes: Tuple[List[FullNodeSimulator], List[Tuple[WalletNode, ChiaServer]], BlockTools], @@ -602,7 +602,7 @@ class TestWalletSimulator: @pytest.mark.limit_consensus_modes(allowed=[ConsensusMode.PLAIN, ConsensusMode.HARD_FORK_2_0], reason="save time") @pytest.mark.parametrize("trusted", [True, False]) - @pytest.mark.asyncio + @pytest.mark.anyio async def test_wallet_clawback_reorg( self, two_wallet_nodes: Tuple[List[FullNodeSimulator], List[Tuple[WalletNode, ChiaServer]], BlockTools], @@ -700,7 +700,7 @@ class TestWalletSimulator: "trusted", [True, False], ) - @pytest.mark.asyncio + @pytest.mark.anyio async def test_get_clawback_coins( self, two_wallet_nodes: Tuple[List[FullNodeSimulator], List[Tuple[WalletNode, ChiaServer]], BlockTools], @@ -760,7 +760,7 @@ class TestWalletSimulator: @pytest.mark.limit_consensus_modes(allowed=[ConsensusMode.PLAIN, ConsensusMode.HARD_FORK_2_0], reason="save time") @pytest.mark.parametrize("trusted", [True, False]) - @pytest.mark.asyncio + @pytest.mark.anyio async def test_clawback_resync( self, two_wallet_nodes: Tuple[List[FullNodeSimulator], List[Tuple[WalletNode, ChiaServer]], BlockTools], @@ -956,7 +956,7 @@ class TestWalletSimulator: @pytest.mark.limit_consensus_modes(allowed=[ConsensusMode.PLAIN, ConsensusMode.HARD_FORK_2_0], reason="save time") @pytest.mark.parametrize("trusted", [True, False]) - @pytest.mark.asyncio + @pytest.mark.anyio async def test_wallet_coinbase_reorg( self, simulator_and_wallet: Tuple[List[FullNodeSimulator], List[Tuple[WalletNode, ChiaServer]], BlockTools], @@ -995,7 +995,7 @@ class TestWalletSimulator: @pytest.mark.limit_consensus_modes(allowed=[ConsensusMode.PLAIN, ConsensusMode.HARD_FORK_2_0], reason="save time") @pytest.mark.parametrize("trusted", [True, False]) - @pytest.mark.asyncio + @pytest.mark.anyio async def test_wallet_send_to_three_peers( self, three_sim_two_wallets: Tuple[List[FullNodeSimulator], List[Tuple[WalletNode, ChiaServer]], BlockTools], @@ -1062,7 +1062,7 @@ class TestWalletSimulator: "trusted", [True, False], ) - @pytest.mark.asyncio + @pytest.mark.anyio async def test_wallet_make_transaction_hop( self, two_wallet_nodes: Tuple[List[FullNodeSimulator], List[Tuple[WalletNode, ChiaServer]], BlockTools], @@ -1140,7 +1140,7 @@ class TestWalletSimulator: "trusted", [True, False], ) - @pytest.mark.asyncio + @pytest.mark.anyio async def test_wallet_make_transaction_with_fee( self, two_wallet_nodes: Tuple[List[FullNodeSimulator], List[Tuple[WalletNode, ChiaServer]], BlockTools], @@ -1204,7 +1204,7 @@ class TestWalletSimulator: "trusted", [True, False], ) - @pytest.mark.asyncio + @pytest.mark.anyio async def test_wallet_make_transaction_with_memo( self, two_wallet_nodes: Tuple[List[FullNodeSimulator], List[Tuple[WalletNode, ChiaServer]], BlockTools], @@ -1276,7 +1276,7 @@ class TestWalletSimulator: "trusted", [True, False], ) - @pytest.mark.asyncio + @pytest.mark.anyio async def test_wallet_create_hit_max_send_amount( self, two_wallet_nodes: Tuple[List[FullNodeSimulator], List[Tuple[WalletNode, ChiaServer]], BlockTools], @@ -1353,7 +1353,7 @@ class TestWalletSimulator: "trusted", [True, False], ) - @pytest.mark.asyncio + @pytest.mark.anyio async def test_wallet_prevent_fee_theft( self, two_wallet_nodes: Tuple[List[FullNodeSimulator], List[Tuple[WalletNode, ChiaServer]], BlockTools], @@ -1440,7 +1440,7 @@ class TestWalletSimulator: "trusted", [True, False], ) - @pytest.mark.asyncio + @pytest.mark.anyio async def test_wallet_tx_reorg( self, two_wallet_nodes: Tuple[List[FullNodeSimulator], List[Tuple[WalletNode, ChiaServer]], BlockTools], @@ -1546,7 +1546,7 @@ class TestWalletSimulator: "trusted", [True, False], ) - @pytest.mark.asyncio + @pytest.mark.anyio async def test_address_sliding_window( self, wallet_node_100_pk: Tuple[List[FullNodeSimulator], List[Tuple[WalletNode, ChiaServer]], BlockTools], @@ -1609,7 +1609,7 @@ class TestWalletSimulator: "trusted", [True, False], ) - @pytest.mark.asyncio + @pytest.mark.anyio async def test_sign_message( self, two_wallet_nodes: Tuple[List[FullNodeSimulator], List[Tuple[WalletNode, ChiaServer]], BlockTools], @@ -1694,7 +1694,7 @@ class TestWalletSimulator: "trusted", [True, False], ) - @pytest.mark.asyncio + @pytest.mark.anyio async def test_wallet_transaction_options( self, two_wallet_nodes: Tuple[List[FullNodeSimulator], List[Tuple[WalletNode, ChiaServer]], BlockTools], @@ -1800,7 +1800,7 @@ def test_get_wallet_db_path_testnet() -> None: assert wallet_db_path == root_path.joinpath("wallet/db/blockchain_wallet_v2_r1_testnet_1234567890.sqlite") -@pytest.mark.asyncio +@pytest.mark.anyio async def test_wallet_has_no_server( simulator_and_wallet: Tuple[List[FullNodeSimulator], List[Tuple[WalletNode, ChiaServer]], BlockTools], ) -> None: diff --git a/tests/wallet/test_wallet_blockchain.py b/tests/wallet/test_wallet_blockchain.py index 0309d4527c7b..4364c5a83aa4 100644 --- a/tests/wallet/test_wallet_blockchain.py +++ b/tests/wallet/test_wallet_blockchain.py @@ -17,7 +17,7 @@ from tests.util.db_connection import DBConnection class TestWalletBlockchain: @pytest.mark.limit_consensus_modes(allowed=[ConsensusMode.PLAIN, ConsensusMode.HARD_FORK_2_0], reason="save time") - @pytest.mark.asyncio + @pytest.mark.anyio async def test_wallet_blockchain(self, simulator_and_wallet, default_1000_blocks): [full_node_api], [(wallet_node, _)], bt = simulator_and_wallet diff --git a/tests/wallet/test_wallet_coin_store.py b/tests/wallet/test_wallet_coin_store.py index dcf428b40676..0082466eb6f5 100644 --- a/tests/wallet/test_wallet_coin_store.py +++ b/tests/wallet/test_wallet_coin_store.py @@ -170,7 +170,7 @@ def test_wallet_coin_record_json_parsed(coin_record: WalletCoinRecord) -> None: } -@pytest.mark.asyncio +@pytest.mark.anyio async def test_add_replace_get() -> None: async with DBConnection(1) as db_wrapper: store = await WalletCoinStore.create(db_wrapper) @@ -187,7 +187,7 @@ async def test_add_replace_get() -> None: assert await store.get_coin_record(coin_1.name()) == record_replaced -@pytest.mark.asyncio +@pytest.mark.anyio async def test_persistance() -> None: async with DBConnection(1) as db_wrapper: store = await WalletCoinStore.create(db_wrapper) @@ -197,7 +197,7 @@ async def test_persistance() -> None: assert await store.get_coin_record(coin_1.name()) == record_1 -@pytest.mark.asyncio +@pytest.mark.anyio async def test_set_spent() -> None: async with DBConnection(1) as db_wrapper: store = await WalletCoinStore.create(db_wrapper) @@ -209,7 +209,7 @@ async def test_set_spent() -> None: assert (await store.get_coin_record(coin_1.name())).spent_block_height == 12 -@pytest.mark.asyncio +@pytest.mark.anyio async def test_get_records_by_puzzle_hash(seeded_random: random.Random) -> None: async with DBConnection(1) as db_wrapper: store = await WalletCoinStore.create(db_wrapper) @@ -228,7 +228,7 @@ async def test_get_records_by_puzzle_hash(seeded_random: random.Random) -> None: assert await store.get_coin_record(bytes32.random(seeded_random)) is None -@pytest.mark.asyncio +@pytest.mark.anyio async def test_get_unspent_coins_for_wallet() -> None: async with DBConnection(1) as db_wrapper: store = await WalletCoinStore.create(db_wrapper) @@ -266,7 +266,7 @@ async def test_get_unspent_coins_for_wallet() -> None: assert await store.get_unspent_coins_for_wallet(1, coin_type=CoinType.CLAWBACK) == {record_8} -@pytest.mark.asyncio +@pytest.mark.anyio async def test_get_all_unspent_coins() -> None: async with DBConnection(1) as db_wrapper: store = await WalletCoinStore.create(db_wrapper) @@ -303,7 +303,7 @@ async def test_get_all_unspent_coins() -> None: assert await store.get_all_unspent_coins(coin_type=CoinType.CLAWBACK) == {record_8} -@pytest.mark.asyncio +@pytest.mark.anyio async def test_get_records_by_parent_id() -> None: async with DBConnection(1) as db_wrapper: store = await WalletCoinStore.create(db_wrapper) @@ -325,7 +325,7 @@ async def test_get_records_by_parent_id() -> None: assert await store.get_coin_records_by_parent_id(coin_7.parent_coin_info) == [record_7] -@pytest.mark.asyncio +@pytest.mark.anyio async def test_delete_coin_record() -> None: async with DBConnection(1) as db_wrapper: store = await WalletCoinStore.create(db_wrapper) @@ -665,37 +665,37 @@ async def run_get_coin_records_test( @pytest.mark.parametrize("coins_request, records", [*get_coin_records_offset_limit_tests]) -@pytest.mark.asyncio +@pytest.mark.anyio async def test_get_coin_records_offset_limit(coins_request: GetCoinRecords, records: List[WalletCoinRecord]) -> None: await run_get_coin_records_test(coins_request, None, records) @pytest.mark.parametrize("coins_request, records", [*get_coin_records_wallet_id_tests]) -@pytest.mark.asyncio +@pytest.mark.anyio async def test_get_coin_records_wallet_id(coins_request: GetCoinRecords, records: List[WalletCoinRecord]) -> None: await run_get_coin_records_test(coins_request, None, records) @pytest.mark.parametrize("coins_request, records", [*get_coin_records_wallet_type_tests]) -@pytest.mark.asyncio +@pytest.mark.anyio async def test_get_coin_records_wallet_type(coins_request: GetCoinRecords, records: List[WalletCoinRecord]) -> None: await run_get_coin_records_test(coins_request, None, records) @pytest.mark.parametrize("coins_request, records", [*get_coin_records_coin_type_tests]) -@pytest.mark.asyncio +@pytest.mark.anyio async def test_get_coin_records_coin_type(coins_request: GetCoinRecords, records: List[WalletCoinRecord]) -> None: await run_get_coin_records_test(coins_request, None, records) @pytest.mark.parametrize("coins_request, records", [*get_coin_records_coin_id_filter_tests]) -@pytest.mark.asyncio +@pytest.mark.anyio async def test_get_coin_records_coin_id_filter(coins_request: GetCoinRecords, records: List[WalletCoinRecord]) -> None: await run_get_coin_records_test(coins_request, None, records) @pytest.mark.parametrize("coins_request, records", [*get_coin_records_puzzle_hash_filter_tests]) -@pytest.mark.asyncio +@pytest.mark.anyio async def test_get_coin_records_puzzle_hash_filter( coins_request: GetCoinRecords, records: List[WalletCoinRecord] ) -> None: @@ -703,7 +703,7 @@ async def test_get_coin_records_puzzle_hash_filter( @pytest.mark.parametrize("coins_request, records", [*get_coin_records_parent_coin_id_filter_tests]) -@pytest.mark.asyncio +@pytest.mark.anyio async def test_get_coin_records_parent_coin_id_filter( coins_request: GetCoinRecords, records: List[WalletCoinRecord] ) -> None: @@ -711,43 +711,43 @@ async def test_get_coin_records_parent_coin_id_filter( @pytest.mark.parametrize("coins_request, records", [*get_coin_records_amount_filter_tests]) -@pytest.mark.asyncio +@pytest.mark.anyio async def test_get_coin_records_amount_filter(coins_request: GetCoinRecords, records: List[WalletCoinRecord]) -> None: await run_get_coin_records_test(coins_request, None, records) @pytest.mark.parametrize("coins_request, records", [*get_coin_records_confirmed_range_tests]) -@pytest.mark.asyncio +@pytest.mark.anyio async def test_get_coin_records_confirmed_range(coins_request: GetCoinRecords, records: List[WalletCoinRecord]) -> None: await run_get_coin_records_test(coins_request, None, records) @pytest.mark.parametrize("coins_request, records", [*get_coin_records_spent_range_tests]) -@pytest.mark.asyncio +@pytest.mark.anyio async def test_get_coin_records_spent_range(coins_request: GetCoinRecords, records: List[WalletCoinRecord]) -> None: await run_get_coin_records_test(coins_request, None, records) @pytest.mark.parametrize("coins_request, records", [*get_coin_records_amount_range_tests]) -@pytest.mark.asyncio +@pytest.mark.anyio async def test_get_coin_records_amount_range(coins_request: GetCoinRecords, records: List[WalletCoinRecord]) -> None: await run_get_coin_records_test(coins_request, None, records) @pytest.mark.parametrize("coins_request, records", [*get_coin_records_order_tests]) -@pytest.mark.asyncio +@pytest.mark.anyio async def test_get_coin_records_order(coins_request: GetCoinRecords, records: List[WalletCoinRecord]) -> None: await run_get_coin_records_test(coins_request, None, records) @pytest.mark.parametrize("coins_request, records", [*get_coin_records_reverse_tests]) -@pytest.mark.asyncio +@pytest.mark.anyio async def test_get_coin_records_reverse(coins_request: GetCoinRecords, records: List[WalletCoinRecord]) -> None: await run_get_coin_records_test(coins_request, None, records) @pytest.mark.parametrize("coins_request, total_count, records", [*get_coin_records_include_total_count_tests]) -@pytest.mark.asyncio +@pytest.mark.anyio async def test_get_coin_records_total_count( coins_request: GetCoinRecords, total_count: int, records: List[WalletCoinRecord] ) -> None: @@ -755,14 +755,14 @@ async def test_get_coin_records_total_count( @pytest.mark.parametrize("coins_request, total_count, records", [*get_coin_records_mixed_tests]) -@pytest.mark.asyncio +@pytest.mark.anyio async def test_get_coin_records_mixed( coins_request: GetCoinRecords, total_count: int, records: List[WalletCoinRecord] ) -> None: await run_get_coin_records_test(coins_request, total_count, records) -@pytest.mark.asyncio +@pytest.mark.anyio async def test_get_coin_records_total_count_cache() -> None: async with DBConnection(1) as db_wrapper: store = await WalletCoinStore.create(db_wrapper) @@ -792,7 +792,7 @@ async def test_get_coin_records_total_count_cache() -> None: assert (await store.get_coin_records(include_total_count=True)).total_count == 0 -@pytest.mark.asyncio +@pytest.mark.anyio async def test_get_coin_records_total_count_cache_reset() -> None: async with DBConnection(1) as db_wrapper: store = await WalletCoinStore.create(db_wrapper) @@ -842,7 +842,7 @@ def record(c: Coin, *, confirmed: int, spent: int) -> WalletCoinRecord: return WalletCoinRecord(c, uint32(confirmed), uint32(spent), spent != 0, False, WalletType.STANDARD_WALLET, 0) -@pytest.mark.asyncio +@pytest.mark.anyio async def test_get_first_coin_height() -> None: r1 = record(coin_1, confirmed=1, spent=0) r2 = record(coin_2, confirmed=2, spent=4) @@ -867,7 +867,7 @@ async def test_get_first_coin_height() -> None: assert await store.get_first_coin_height() == 1 -@pytest.mark.asyncio +@pytest.mark.anyio async def test_rollback_to_block() -> None: r1 = record(coin_1, confirmed=1, spent=0) r2 = record(coin_2, confirmed=2, spent=4) @@ -924,7 +924,7 @@ async def test_rollback_to_block() -> None: assert new_r4 != r4 -@pytest.mark.asyncio +@pytest.mark.anyio async def test_count_small_unspent(seeded_random: random.Random) -> None: async with DBConnection(1) as db_wrapper: store = await WalletCoinStore.create(db_wrapper) @@ -960,7 +960,7 @@ async def test_count_small_unspent(seeded_random: random.Random) -> None: assert await store.count_small_unspent(1) == 0 -@pytest.mark.asyncio +@pytest.mark.anyio async def test_get_coin_records_between() -> None: async with DBConnection(1) as db_wrapper: store = await WalletCoinStore.create(db_wrapper) @@ -982,7 +982,7 @@ async def test_get_coin_records_between() -> None: assert records[0] == record_8 -@pytest.mark.asyncio +@pytest.mark.anyio async def test_delete_wallet(seeded_random: random.Random) -> None: dummy_records = DummyWalletCoinRecords(seeded_random=seeded_random) for i in range(5): diff --git a/tests/wallet/test_wallet_interested_store.py b/tests/wallet/test_wallet_interested_store.py index 54ca1c86270b..71caad376abd 100644 --- a/tests/wallet/test_wallet_interested_store.py +++ b/tests/wallet/test_wallet_interested_store.py @@ -12,7 +12,7 @@ from tests.util.db_connection import DBConnection class TestWalletInterestedStore: - @pytest.mark.asyncio + @pytest.mark.anyio async def test_store(self, seeded_random: random.Random): async with DBConnection(1) as db_wrapper: store = await WalletInterestedStore.create(db_wrapper) diff --git a/tests/wallet/test_wallet_key_val_store.py b/tests/wallet/test_wallet_key_val_store.py index 9e442a4f8f67..c1c06380489f 100644 --- a/tests/wallet/test_wallet_key_val_store.py +++ b/tests/wallet/test_wallet_key_val_store.py @@ -9,7 +9,7 @@ from tests.util.db_connection import DBConnection class TestWalletKeyValStore: - @pytest.mark.asyncio + @pytest.mark.anyio async def test_store(self, bt): async with DBConnection(1) as db_wrapper: store = await KeyValStore.create(db_wrapper) diff --git a/tests/wallet/test_wallet_node.py b/tests/wallet/test_wallet_node.py index 9cc69b90e4f8..8c3a11d6b317 100644 --- a/tests/wallet/test_wallet_node.py +++ b/tests/wallet/test_wallet_node.py @@ -33,7 +33,7 @@ from tests.conftest import ConsensusMode from tests.util.misc import CoinGenerator -@pytest.mark.asyncio +@pytest.mark.anyio async def test_get_private_key(root_path_populated_with_config: Path, get_temp_keyring: Keychain) -> None: root_path: Path = root_path_populated_with_config keychain: Keychain = get_temp_keyring @@ -48,7 +48,7 @@ async def test_get_private_key(root_path_populated_with_config: Path, get_temp_k assert key.get_g1().get_fingerprint() == fingerprint -@pytest.mark.asyncio +@pytest.mark.anyio async def test_get_private_key_default_key(root_path_populated_with_config: Path, get_temp_keyring: Keychain) -> None: root_path: Path = root_path_populated_with_config keychain: Keychain = get_temp_keyring @@ -68,7 +68,7 @@ async def test_get_private_key_default_key(root_path_populated_with_config: Path assert key.get_g1().get_fingerprint() == fingerprint -@pytest.mark.asyncio +@pytest.mark.anyio @pytest.mark.parametrize("fingerprint", [None, 1234567890]) async def test_get_private_key_missing_key( root_path_populated_with_config: Path, get_temp_keyring: Keychain, fingerprint: Optional[int] @@ -84,7 +84,7 @@ async def test_get_private_key_missing_key( assert key is None -@pytest.mark.asyncio +@pytest.mark.anyio async def test_get_private_key_missing_key_use_default( root_path_populated_with_config: Path, get_temp_keyring: Keychain ) -> None: @@ -328,7 +328,7 @@ def test_timestamp_in_sync(root_path_populated_with_config: Path, testing: bool, assert wallet_node.is_timestamp_in_sync(uint64(now - offset)) == expected -@pytest.mark.asyncio +@pytest.mark.anyio async def test_get_timestamp_for_height_from_peer( simulator_and_wallet: SimulatorsAndWallets, self_hostname: str, caplog: pytest.LogCaptureFixture ) -> None: @@ -383,7 +383,7 @@ async def test_get_timestamp_for_height_from_peer( assert f"get_timestamp_for_height_from_peer use cached block for height {1}" in caplog.text -@pytest.mark.asyncio +@pytest.mark.anyio async def test_unique_puzzle_hash_subscriptions(simulator_and_wallet: SimulatorsAndWallets) -> None: _, [(node, _)], bt = simulator_and_wallet puzzle_hashes = await node.get_puzzle_hashes_to_subscribe() @@ -392,7 +392,7 @@ async def test_unique_puzzle_hash_subscriptions(simulator_and_wallet: Simulators @pytest.mark.limit_consensus_modes(allowed=[ConsensusMode.PLAIN, ConsensusMode.HARD_FORK_2_0], reason="save time") -@pytest.mark.asyncio +@pytest.mark.anyio async def test_get_balance( simulator_and_wallet: SimulatorsAndWallets, self_hostname: str, default_400_blocks: List[FullBlock] ) -> None: @@ -470,7 +470,7 @@ async def test_get_balance( assert await wallet_node.get_balance(wallet_id) == expected_more_balance -@pytest.mark.asyncio +@pytest.mark.anyio async def test_add_states_from_peer_reorg_failure( simulator_and_wallet: SimulatorsAndWallets, self_hostname: str, caplog: pytest.LogCaptureFixture ) -> None: @@ -488,7 +488,7 @@ async def test_add_states_from_peer_reorg_failure( assert "Processing reorged states failed" in caplog.text -@pytest.mark.asyncio +@pytest.mark.anyio async def test_add_states_from_peer_untrusted_shutdown( simulator_and_wallet: SimulatorsAndWallets, self_hostname: str, caplog: pytest.LogCaptureFixture ) -> None: @@ -507,7 +507,7 @@ async def test_add_states_from_peer_untrusted_shutdown( @pytest.mark.limit_consensus_modes(reason="consensus rules irrelevant") -@pytest.mark.asyncio +@pytest.mark.anyio async def test_transaction_send_cache( self_hostname: str, simulator_and_wallet: SimulatorsAndWallets, monkeypatch: pytest.MonkeyPatch ) -> None: diff --git a/tests/wallet/test_wallet_retry.py b/tests/wallet/test_wallet_retry.py index 69e877ea5a02..e85e38549798 100644 --- a/tests/wallet/test_wallet_retry.py +++ b/tests/wallet/test_wallet_retry.py @@ -43,7 +43,7 @@ def evict_from_pool(node: FullNodeAPI, sb: SpendBundle) -> None: node.full_node.mempool_manager.remove_seen(sb.name()) -@pytest.mark.asyncio +@pytest.mark.anyio async def test_wallet_tx_retry( setup_two_nodes_and_wallet_fast_retry: Tuple[List[FullNodeSimulator], List[Tuple[Any, Any]], BlockTools], self_hostname: str, diff --git a/tests/wallet/test_wallet_state_manager.py b/tests/wallet/test_wallet_state_manager.py index 38823e505400..7bd7ffa5258b 100644 --- a/tests/wallet/test_wallet_state_manager.py +++ b/tests/wallet/test_wallet_state_manager.py @@ -36,7 +36,7 @@ async def assert_sync_mode(wallet_state_manager: WalletStateManager, target_heig assert wallet_state_manager.sync_target is None -@pytest.mark.asyncio +@pytest.mark.anyio async def test_set_sync_mode(simulator_and_wallet: SimulatorsAndWallets) -> None: _, [(wallet_node, _)], _ = simulator_and_wallet async with assert_sync_mode(wallet_node.wallet_state_manager, uint32(1)): @@ -47,7 +47,7 @@ async def test_set_sync_mode(simulator_and_wallet: SimulatorsAndWallets) -> None pass -@pytest.mark.asyncio +@pytest.mark.anyio async def test_set_sync_mode_exception(simulator_and_wallet: SimulatorsAndWallets) -> None: _, [(wallet_node, _)], _ = simulator_and_wallet async with assert_sync_mode(wallet_node.wallet_state_manager, uint32(1)): @@ -55,7 +55,7 @@ async def test_set_sync_mode_exception(simulator_and_wallet: SimulatorsAndWallet @pytest.mark.parametrize("hardened", [True, False]) -@pytest.mark.asyncio +@pytest.mark.anyio async def test_get_private_key(simulator_and_wallet: SimulatorsAndWallets, hardened: bool) -> None: _, [(wallet_node, _)], _ = simulator_and_wallet wallet_state_manager: WalletStateManager = wallet_node.wallet_state_manager @@ -74,7 +74,7 @@ async def test_get_private_key(simulator_and_wallet: SimulatorsAndWallets, harde assert await wallet_state_manager.get_private_key(record.puzzle_hash) == expected_private_key -@pytest.mark.asyncio +@pytest.mark.anyio async def test_get_private_key_failure(simulator_and_wallet: SimulatorsAndWallets) -> None: _, [(wallet_node, _)], _ = simulator_and_wallet wallet_state_manager: WalletStateManager = wallet_node.wallet_state_manager @@ -83,7 +83,7 @@ async def test_get_private_key_failure(simulator_and_wallet: SimulatorsAndWallet await wallet_state_manager.get_private_key(bytes32(b"1" * 32)) -@pytest.mark.asyncio +@pytest.mark.anyio async def test_determine_coin_type(simulator_and_wallet: SimulatorsAndWallets, self_hostname: str) -> None: full_nodes, wallets, _ = simulator_and_wallet full_node_api = full_nodes[0] diff --git a/tests/wallet/test_wallet_test_framework.py b/tests/wallet/test_wallet_test_framework.py index 18e6bb6184cc..69a5e7b7420c 100644 --- a/tests/wallet/test_wallet_test_framework.py +++ b/tests/wallet/test_wallet_test_framework.py @@ -20,7 +20,7 @@ from tests.wallet.conftest import BalanceCheckingError, WalletEnvironment, Walle ], indirect=True, ) -@pytest.mark.asyncio +@pytest.mark.anyio async def test_basic_functionality(wallet_environments: WalletTestFramework) -> None: env_0: WalletEnvironment = wallet_environments.environments[0] env_1: WalletEnvironment = wallet_environments.environments[1] @@ -53,7 +53,7 @@ async def test_basic_functionality(wallet_environments: WalletTestFramework) -> ], indirect=True, ) -@pytest.mark.asyncio +@pytest.mark.anyio async def test_balance_checking( wallet_environments: WalletTestFramework, ) -> None: diff --git a/tests/wallet/test_wallet_trade_store.py b/tests/wallet/test_wallet_trade_store.py index 4bd8eb51af56..22ebe09d19e4 100644 --- a/tests/wallet/test_wallet_trade_store.py +++ b/tests/wallet/test_wallet_trade_store.py @@ -31,7 +31,7 @@ record_2 = WalletCoinRecord(coin_2, uint32(5), uint32(0), False, True, WalletTyp record_3 = WalletCoinRecord(coin_3, uint32(6), uint32(0), False, True, WalletType.STANDARD_WALLET, 0) -@pytest.mark.asyncio +@pytest.mark.anyio async def test_get_coins_of_interest_with_trade_statuses(seeded_random: random.Random) -> None: async with DBConnection(1) as db_wrapper: coin_store = await WalletCoinStore.create(db_wrapper) @@ -117,7 +117,7 @@ async def test_get_coins_of_interest_with_trade_statuses(seeded_random: random.R } -@pytest.mark.asyncio +@pytest.mark.anyio async def test_valid_times_migration() -> None: async with DBConnection(1) as db_wrapper: async with db_wrapper.writer_maybe_transaction() as conn: @@ -171,7 +171,7 @@ async def test_valid_times_migration() -> None: assert rec.valid_times == ConditionValidTimes() -@pytest.mark.asyncio +@pytest.mark.anyio async def test_large_trade_record_query() -> None: async with DBConnection(1) as db_wrapper: store = await TradeStore.create(db_wrapper) diff --git a/tests/wallet/test_wallet_user_store.py b/tests/wallet/test_wallet_user_store.py index ff938f63a9f2..6bb7dd03abce 100644 --- a/tests/wallet/test_wallet_user_store.py +++ b/tests/wallet/test_wallet_user_store.py @@ -7,7 +7,7 @@ from chia.wallet.wallet_user_store import WalletUserStore from tests.util.db_connection import DBConnection -@pytest.mark.asyncio +@pytest.mark.anyio async def test_store(): async with DBConnection(1) as db_wrapper: store = await WalletUserStore.create(db_wrapper) diff --git a/tests/wallet/vc_wallet/test_vc_lifecycle.py b/tests/wallet/vc_wallet/test_vc_lifecycle.py index d0d9a99ba669..be6b33911ddd 100644 --- a/tests/wallet/vc_wallet/test_vc_lifecycle.py +++ b/tests/wallet/vc_wallet/test_vc_lifecycle.py @@ -55,7 +55,7 @@ MOCK_SINGLETON: Program = MOCK_SINGLETON_MOD.curry( ) -@pytest.mark.asyncio +@pytest.mark.anyio async def test_covenant_layer(cost_logger: CostLogger) -> None: async with sim_and_client() as (sim, client): # Create a puzzle that will not pass the initial covenant check @@ -185,7 +185,7 @@ async def test_covenant_layer(cost_logger: CostLogger) -> None: assert result == (MempoolInclusionStatus.SUCCESS, None) -@pytest.mark.asyncio +@pytest.mark.anyio async def test_did_tp(cost_logger: CostLogger) -> None: async with sim_and_client() as (sim, client): # Make a mock exigent metadata layer @@ -310,7 +310,7 @@ async def test_did_tp(cost_logger: CostLogger) -> None: assert remark_condition == Program.to([1, (MOCK_LAUNCHER_ID, new_metadata), new_tp_hash]) -@pytest.mark.asyncio +@pytest.mark.anyio async def test_viral_backdoor(cost_logger: CostLogger) -> None: async with sim_and_client() as (sim, client): # Setup and farm the puzzle @@ -395,7 +395,7 @@ async def test_viral_backdoor(cost_logger: CostLogger) -> None: assert len(await client.get_coin_records_by_puzzle_hashes([wrapped_brick_hash], include_spent_coins=False)) > 0 -@pytest.mark.asyncio +@pytest.mark.anyio @pytest.mark.parametrize("num_proofs", range(1, 6)) async def test_proofs_checker(cost_logger: CostLogger, num_proofs: int) -> None: async with sim_and_client() as (sim, client): @@ -435,7 +435,7 @@ async def test_proofs_checker(cost_logger: CostLogger, num_proofs: int) -> None: await sim.rewind(block_height) -@pytest.mark.asyncio +@pytest.mark.anyio @pytest.mark.parametrize("test_syncing", [True, False]) async def test_vc_lifecycle(test_syncing: bool, cost_logger: CostLogger) -> None: async with sim_and_client() as (sim, client): diff --git a/tests/wallet/vc_wallet/test_vc_wallet.py b/tests/wallet/vc_wallet/test_vc_wallet.py index 9e6f84042e2b..d3377ca39817 100644 --- a/tests/wallet/vc_wallet/test_vc_wallet.py +++ b/tests/wallet/vc_wallet/test_vc_wallet.py @@ -128,7 +128,7 @@ async def mint_cr_cat( ], indirect=True, ) -@pytest.mark.asyncio +@pytest.mark.anyio async def test_vc_lifecycle(wallet_environments: WalletTestFramework) -> None: full_node_api: FullNodeSimulator = wallet_environments.full_node wallet_node_0 = wallet_environments.environments[0].wallet_node @@ -395,7 +395,7 @@ async def test_vc_lifecycle(wallet_environments: WalletTestFramework) -> None: "trusted", [True, False], ) -@pytest.mark.asyncio +@pytest.mark.anyio async def test_self_revoke( self_hostname: str, one_wallet_and_one_simulator_services: Any, @@ -474,7 +474,7 @@ async def test_self_revoke( "trusted", [True, False], ) -@pytest.mark.asyncio +@pytest.mark.anyio async def test_cat_wallet_conversion( self_hostname: str, one_wallet_and_one_simulator_services: Any, diff --git a/tests/weight_proof/test_weight_proof.py b/tests/weight_proof/test_weight_proof.py index 5b5e17124b7c..96ba47c3cd61 100644 --- a/tests/weight_proof/test_weight_proof.py +++ b/tests/weight_proof/test_weight_proof.py @@ -109,7 +109,7 @@ async def _test_map_summaries( class TestWeightProof: - @pytest.mark.asyncio + @pytest.mark.anyio async def test_weight_proof_map_summaries_1( self, default_400_blocks: List[FullBlock], blockchain_constants: ConsensusConstants ) -> None: @@ -120,7 +120,7 @@ class TestWeightProof: default_400_blocks, header_cache, height_to_hash, sub_blocks, summaries, blockchain_constants ) - @pytest.mark.asyncio + @pytest.mark.anyio async def test_weight_proof_map_summaries_2( self, default_1000_blocks: List[FullBlock], blockchain_constants: ConsensusConstants ) -> None: @@ -131,7 +131,7 @@ class TestWeightProof: default_1000_blocks, header_cache, height_to_hash, sub_blocks, summaries, blockchain_constants ) - @pytest.mark.asyncio + @pytest.mark.anyio async def test_weight_proof_summaries_1000_blocks( self, default_1000_blocks: List[FullBlock], blockchain_constants: ConsensusConstants ) -> None: @@ -151,7 +151,7 @@ class TestWeightProof: assert _validate_summaries_weight(blockchain_constants, sub_epoch_data_weight, summaries_here, wp) # assert res is not None - @pytest.mark.asyncio + @pytest.mark.anyio async def test_weight_proof_bad_peak_hash( self, default_1000_blocks: List[FullBlock], blockchain_constants: ConsensusConstants ) -> None: @@ -163,7 +163,7 @@ class TestWeightProof: wp = await wpf.get_proof_of_weight(bytes32(b"a" * 32)) assert wp is None - @pytest.mark.asyncio + @pytest.mark.anyio @pytest.mark.skip(reason="broken") async def test_weight_proof_from_genesis( self, default_400_blocks: List[FullBlock], blockchain_constants: ConsensusConstants @@ -178,7 +178,7 @@ class TestWeightProof: wp = await wpf.get_proof_of_weight(blocks[-1].header_hash) assert wp is not None - @pytest.mark.asyncio + @pytest.mark.anyio async def test_weight_proof_edge_cases(self, bt: BlockTools, default_400_blocks: List[FullBlock]) -> None: blocks = default_400_blocks @@ -264,7 +264,7 @@ class TestWeightProof: assert valid assert fork_point == 0 - @pytest.mark.asyncio + @pytest.mark.anyio async def test_weight_proof1000( self, default_1000_blocks: List[FullBlock], blockchain_constants: ConsensusConstants ) -> None: @@ -281,7 +281,7 @@ class TestWeightProof: assert valid assert fork_point == 0 - @pytest.mark.asyncio + @pytest.mark.anyio async def test_weight_proof1000_pre_genesis_empty_slots( self, pre_genesis_empty_slots_1000_blocks: List[FullBlock], blockchain_constants: ConsensusConstants ) -> None: @@ -299,7 +299,7 @@ class TestWeightProof: assert valid assert fork_point == 0 - @pytest.mark.asyncio + @pytest.mark.anyio async def test_weight_proof10000__blocks_compact( self, default_10000_blocks_compact: List[FullBlock], blockchain_constants: ConsensusConstants ) -> None: @@ -316,7 +316,7 @@ class TestWeightProof: assert valid assert fork_point == 0 - @pytest.mark.asyncio + @pytest.mark.anyio async def test_weight_proof1000_partial_blocks_compact( self, bt: BlockTools, default_10000_blocks_compact: List[FullBlock] ) -> None: @@ -338,7 +338,7 @@ class TestWeightProof: assert valid assert fork_point == 0 - @pytest.mark.asyncio + @pytest.mark.anyio async def test_weight_proof10000( self, default_10000_blocks: List[FullBlock], blockchain_constants: ConsensusConstants ) -> None: @@ -356,7 +356,7 @@ class TestWeightProof: assert valid assert fork_point == 0 - @pytest.mark.asyncio + @pytest.mark.anyio async def test_check_num_of_samples( self, default_10000_blocks: List[FullBlock], blockchain_constants: ConsensusConstants ) -> None: @@ -375,7 +375,7 @@ class TestWeightProof: samples += 1 assert samples <= wpf.MAX_SAMPLES - @pytest.mark.asyncio + @pytest.mark.anyio async def test_weight_proof_extend_no_ses( self, default_1000_blocks: List[FullBlock], blockchain_constants: ConsensusConstants ) -> None: @@ -403,7 +403,7 @@ class TestWeightProof: assert valid assert fork_point == 0 - @pytest.mark.asyncio + @pytest.mark.anyio async def test_weight_proof_extend_new_ses( self, default_1000_blocks: List[FullBlock], blockchain_constants: ConsensusConstants ) -> None: @@ -445,7 +445,7 @@ class TestWeightProof: assert valid assert fork_point != 0 - @pytest.mark.asyncio + @pytest.mark.anyio async def test_weight_proof_extend_multiple_ses( self, default_1000_blocks: List[FullBlock], blockchain_constants: ConsensusConstants ) -> None: