|
12 | 12 | import pytest
|
13 | 13 | from chia_rs import (
|
14 | 14 | AugSchemeMPL,
|
| 15 | + ConsensusConstants, |
15 | 16 | Foliage,
|
16 | 17 | FoliageTransactionBlock,
|
17 | 18 | FullBlock,
|
|
38 | 39 | from chia._tests.core.make_block_generator import make_spend_bundle
|
39 | 40 | from chia._tests.core.node_height import node_height_at_least
|
40 | 41 | from chia._tests.util.misc import wallet_height_at_least
|
41 |
| -from chia._tests.util.setup_nodes import OldSimulatorsAndWallets, SimulatorsAndWalletsServices |
| 42 | +from chia._tests.util.setup_nodes import ( |
| 43 | + OldSimulatorsAndWallets, |
| 44 | + SimulatorsAndWalletsServices, |
| 45 | + setup_simulators_and_wallets, |
| 46 | +) |
42 | 47 | from chia._tests.util.time_out_assert import time_out_assert, time_out_assert_custom_interval, time_out_messages
|
43 | 48 | from chia.consensus.augmented_chain import AugmentedBlockchain
|
44 | 49 | from chia.consensus.block_body_validation import ForkInfo
|
@@ -2912,87 +2917,97 @@ async def test_eviction_from_bls_cache(one_node_one_block: tuple[FullNodeSimulat
|
2912 | 2917 |
|
2913 | 2918 |
|
2914 | 2919 | @pytest.mark.limit_consensus_modes(allowed=[ConsensusMode.HARD_FORK_2_0], reason="irrelevant")
|
| 2920 | +@pytest.mark.parametrize("block_creation", [0, 1, 2]) |
2915 | 2921 | @pytest.mark.anyio
|
2916 | 2922 | async def test_declare_proof_of_space_no_overflow(
|
2917 |
| - wallet_nodes: tuple[ |
2918 |
| - FullNodeSimulator, FullNodeSimulator, ChiaServer, ChiaServer, WalletTool, WalletTool, BlockTools |
2919 |
| - ], |
| 2923 | + blockchain_constants: ConsensusConstants, |
2920 | 2924 | self_hostname: str,
|
2921 |
| - bt: BlockTools, |
| 2925 | + block_creation: int, |
2922 | 2926 | ) -> None:
|
2923 |
| - full_node_api, _, server_1, _, _, _, _ = wallet_nodes |
2924 |
| - wallet = WalletTool(test_constants) |
2925 |
| - coinbase_puzzlehash = wallet.get_new_puzzlehash() |
2926 |
| - blocks = bt.get_consecutive_blocks( |
2927 |
| - num_blocks=10, |
2928 |
| - skip_overflow=True, |
2929 |
| - force_overflow=False, |
2930 |
| - farmer_reward_puzzle_hash=coinbase_puzzlehash, |
2931 |
| - guarantee_transaction_block=True, |
2932 |
| - ) |
2933 |
| - await add_blocks_in_batches(blocks, full_node_api.full_node) |
2934 |
| - _, dummy_node_id = await add_dummy_connection(server_1, self_hostname, 12312) |
2935 |
| - dummy_peer = server_1.all_connections[dummy_node_id] |
2936 |
| - assert full_node_api.full_node.blockchain.get_peak_height() == blocks[-1].height |
2937 |
| - for i in range(10, 100): |
2938 |
| - sb = await add_tx_to_mempool( |
2939 |
| - full_node_api, wallet, blocks[-8], coinbase_puzzlehash, bytes32(i.to_bytes(32, "big")), uint64(i) |
2940 |
| - ) |
| 2927 | + async with setup_simulators_and_wallets( |
| 2928 | + 1, 1, blockchain_constants, config_overrides={"full_node.block_creation": block_creation} |
| 2929 | + ) as new: |
| 2930 | + full_node_api = new.simulators[0].peer_api |
| 2931 | + server_1 = full_node_api.full_node.server |
| 2932 | + bt = new.bt |
| 2933 | + |
| 2934 | + wallet = WalletTool(test_constants) |
| 2935 | + coinbase_puzzlehash = wallet.get_new_puzzlehash() |
2941 | 2936 | blocks = bt.get_consecutive_blocks(
|
2942 |
| - block_list_input=blocks, |
2943 |
| - num_blocks=1, |
| 2937 | + num_blocks=10, |
| 2938 | + skip_overflow=True, |
| 2939 | + force_overflow=False, |
2944 | 2940 | farmer_reward_puzzle_hash=coinbase_puzzlehash,
|
2945 | 2941 | guarantee_transaction_block=True,
|
2946 |
| - transaction_data=sb, |
2947 | 2942 | )
|
2948 |
| - block = blocks[-1] |
2949 |
| - unfinised_block = await declare_pos_unfinished_block(full_node_api, dummy_peer, block) |
2950 |
| - compare_unfinished_blocks(unfinished_from_full_block(block), unfinised_block) |
2951 |
| - await full_node_api.full_node.add_block(block) |
2952 |
| - assert full_node_api.full_node.blockchain.get_peak_height() == block.height |
| 2943 | + await add_blocks_in_batches(blocks, full_node_api.full_node) |
| 2944 | + _, dummy_node_id = await add_dummy_connection(server_1, self_hostname, 12312) |
| 2945 | + dummy_peer = server_1.all_connections[dummy_node_id] |
| 2946 | + assert full_node_api.full_node.blockchain.get_peak_height() == blocks[-1].height |
| 2947 | + for i in range(10, 100): |
| 2948 | + sb = await add_tx_to_mempool( |
| 2949 | + full_node_api, wallet, blocks[-8], coinbase_puzzlehash, bytes32(i.to_bytes(32, "big")), uint64(i) |
| 2950 | + ) |
| 2951 | + blocks = bt.get_consecutive_blocks( |
| 2952 | + block_list_input=blocks, |
| 2953 | + num_blocks=1, |
| 2954 | + farmer_reward_puzzle_hash=coinbase_puzzlehash, |
| 2955 | + guarantee_transaction_block=True, |
| 2956 | + transaction_data=sb, |
| 2957 | + ) |
| 2958 | + block = blocks[-1] |
| 2959 | + unfinised_block = await declare_pos_unfinished_block(full_node_api, dummy_peer, block) |
| 2960 | + compare_unfinished_blocks(unfinished_from_full_block(block), unfinised_block) |
| 2961 | + await full_node_api.full_node.add_block(block) |
| 2962 | + assert full_node_api.full_node.blockchain.get_peak_height() == block.height |
2953 | 2963 |
|
2954 | 2964 |
|
2955 | 2965 | @pytest.mark.limit_consensus_modes(allowed=[ConsensusMode.HARD_FORK_2_0], reason="irrelevant")
|
| 2966 | +@pytest.mark.parametrize("block_creation", [0, 1, 2]) |
2956 | 2967 | @pytest.mark.anyio
|
2957 | 2968 | async def test_declare_proof_of_space_overflow(
|
2958 |
| - wallet_nodes: tuple[ |
2959 |
| - FullNodeSimulator, FullNodeSimulator, ChiaServer, ChiaServer, WalletTool, WalletTool, BlockTools |
2960 |
| - ], |
| 2969 | + blockchain_constants: ConsensusConstants, |
2961 | 2970 | self_hostname: str,
|
2962 |
| - bt: BlockTools, |
| 2971 | + block_creation: int, |
2963 | 2972 | ) -> None:
|
2964 |
| - full_node_api, _, server_1, _, _, _, _ = wallet_nodes |
2965 |
| - wallet = WalletTool(test_constants) |
2966 |
| - coinbase_puzzlehash = wallet.get_new_puzzlehash() |
2967 |
| - blocks = bt.get_consecutive_blocks( |
2968 |
| - num_blocks=10, |
2969 |
| - farmer_reward_puzzle_hash=coinbase_puzzlehash, |
2970 |
| - guarantee_transaction_block=True, |
2971 |
| - ) |
2972 |
| - await add_blocks_in_batches(blocks, full_node_api.full_node) |
2973 |
| - _, dummy_node_id = await add_dummy_connection(server_1, self_hostname, 12312) |
2974 |
| - dummy_peer = server_1.all_connections[dummy_node_id] |
2975 |
| - assert full_node_api.full_node.blockchain.get_peak_height() == blocks[-1].height |
2976 |
| - for i in range(10, 100): |
2977 |
| - sb = await add_tx_to_mempool( |
2978 |
| - full_node_api, wallet, blocks[-8], coinbase_puzzlehash, bytes32(i.to_bytes(32, "big")), uint64(i) |
2979 |
| - ) |
2980 |
| - |
| 2973 | + async with setup_simulators_and_wallets( |
| 2974 | + 1, 1, blockchain_constants, config_overrides={"full_node.block_creation": block_creation} |
| 2975 | + ) as new: |
| 2976 | + full_node_api = new.simulators[0].peer_api |
| 2977 | + server_1 = full_node_api.full_node.server |
| 2978 | + bt = new.bt |
| 2979 | + |
| 2980 | + wallet = WalletTool(test_constants) |
| 2981 | + coinbase_puzzlehash = wallet.get_new_puzzlehash() |
2981 | 2982 | blocks = bt.get_consecutive_blocks(
|
2982 |
| - block_list_input=blocks, |
2983 |
| - num_blocks=1, |
2984 |
| - skip_overflow=False, |
2985 |
| - force_overflow=(i % 10 == 0), |
| 2983 | + num_blocks=10, |
2986 | 2984 | farmer_reward_puzzle_hash=coinbase_puzzlehash,
|
2987 | 2985 | guarantee_transaction_block=True,
|
2988 |
| - transaction_data=sb, |
2989 | 2986 | )
|
| 2987 | + await add_blocks_in_batches(blocks, full_node_api.full_node) |
| 2988 | + _, dummy_node_id = await add_dummy_connection(server_1, self_hostname, 12312) |
| 2989 | + dummy_peer = server_1.all_connections[dummy_node_id] |
| 2990 | + assert full_node_api.full_node.blockchain.get_peak_height() == blocks[-1].height |
| 2991 | + for i in range(10, 100): |
| 2992 | + sb = await add_tx_to_mempool( |
| 2993 | + full_node_api, wallet, blocks[-8], coinbase_puzzlehash, bytes32(i.to_bytes(32, "big")), uint64(i) |
| 2994 | + ) |
| 2995 | + |
| 2996 | + blocks = bt.get_consecutive_blocks( |
| 2997 | + block_list_input=blocks, |
| 2998 | + num_blocks=1, |
| 2999 | + skip_overflow=False, |
| 3000 | + force_overflow=(i % 10 == 0), |
| 3001 | + farmer_reward_puzzle_hash=coinbase_puzzlehash, |
| 3002 | + guarantee_transaction_block=True, |
| 3003 | + transaction_data=sb, |
| 3004 | + ) |
2990 | 3005 |
|
2991 |
| - block = blocks[-1] |
2992 |
| - unfinised_block = await declare_pos_unfinished_block(full_node_api, dummy_peer, block) |
2993 |
| - compare_unfinished_blocks(unfinished_from_full_block(block), unfinised_block) |
2994 |
| - await full_node_api.full_node.add_block(block) |
2995 |
| - assert full_node_api.full_node.blockchain.get_peak_height() == block.height |
| 3006 | + block = blocks[-1] |
| 3007 | + unfinised_block = await declare_pos_unfinished_block(full_node_api, dummy_peer, block) |
| 3008 | + compare_unfinished_blocks(unfinished_from_full_block(block), unfinised_block) |
| 3009 | + await full_node_api.full_node.add_block(block) |
| 3010 | + assert full_node_api.full_node.blockchain.get_peak_height() == block.height |
2996 | 3011 |
|
2997 | 3012 |
|
2998 | 3013 | @pytest.mark.anyio
|
|
0 commit comments