Skip to content

Commit

Permalink
update long-reorg tests along with the reorg test chains, to make the…
Browse files Browse the repository at this point in the history
… fork point be at a height > 0
  • Loading branch information
arvidn committed Aug 23, 2024
1 parent 344f645 commit 1477c93
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 16 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/benchmarks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ jobs:
python-version: ["3.10"]
env:
CHIA_ROOT: ${{ github.workspace }}/.chia/mainnet
BLOCKS_AND_PLOTS_VERSION: 0.38.0
BLOCKS_AND_PLOTS_VERSION: 0.39.0

steps:
- name: Clean workspace
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test-single.yml
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ jobs:
CHIA_ROOT: ${{ github.workspace }}/.chia/mainnet
CHIA_SIMULATOR_ROOT: ${{ github.workspace }}/.chia/simulator
JOB_FILE_NAME: tests_${{ matrix.os.file_name }}_python-${{ matrix.python.file_name }}_${{ matrix.configuration.module_import_path }}${{ matrix.configuration.file_name_index }}
BLOCKS_AND_PLOTS_VERSION: 0.38.0
BLOCKS_AND_PLOTS_VERSION: 0.39.0

steps:
- name: Configure git
Expand Down
8 changes: 4 additions & 4 deletions chia/_tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -359,9 +359,9 @@ def test_long_reorg_blocks(bt, consensus_mode, default_10000_blocks):

return persistent_blocks(
4500,
f"test_blocks_long_reorg_{saved_blocks_version}{version}.db",
f"test_blocks_long_reorg_{saved_blocks_version}{version}-2.db",
bt,
block_list_input=default_10000_blocks[:500],
block_list_input=default_10000_blocks[:1500],
seed=b"reorg_blocks",
time_per_block=8,
dummy_block_references=True,
Expand All @@ -381,9 +381,9 @@ def test_long_reorg_blocks_light(bt, consensus_mode, default_10000_blocks):

return persistent_blocks(
4500,
f"test_blocks_long_reorg_light_{saved_blocks_version}{version}.db",
f"test_blocks_long_reorg_light_{saved_blocks_version}{version}-2.db",
bt,
block_list_input=default_10000_blocks[:500],
block_list_input=default_10000_blocks[:1500],
seed=b"reorg_blocks2",
dummy_block_references=True,
include_transactions=True,
Expand Down
20 changes: 10 additions & 10 deletions chia/_tests/core/full_node/test_full_node.py
Original file line number Diff line number Diff line change
Expand Up @@ -2262,15 +2262,15 @@ async def test_long_reorg(
):
node, server, bt = one_node_one_block

fork_point = 499
blocks = default_10000_blocks[:1600]
fork_point = 1499
blocks = default_10000_blocks[:3000]

if light_blocks:
# if the blocks have lighter weight, we need more height to compensate,
# to force a reorg
reorg_blocks = test_long_reorg_blocks_light[:1650]
reorg_blocks = test_long_reorg_blocks_light[:3050]
else:
reorg_blocks = test_long_reorg_blocks[:1200]
reorg_blocks = test_long_reorg_blocks[:2700]

for block_batch in to_batches(blocks, 64):
b = block_batch.entries[0]
Expand Down Expand Up @@ -2325,9 +2325,9 @@ async def test_long_reorg(
# when using add_block manualy we must warmup the cache
await node.full_node.blockchain.warmup(fork_point - 100)
if light_blocks:
blocks = default_10000_blocks[fork_point - 100 : 1800]
blocks = default_10000_blocks[fork_point - 100 : 3200]
else:
blocks = default_10000_blocks[fork_point - 100 : 2600]
blocks = default_10000_blocks[fork_point - 100 : 5500]

fork_block = blocks[0]
fork_info = ForkInfo(fork_block.height - 1, fork_block.height - 1, fork_block.prev_header_hash)
Expand All @@ -2346,7 +2346,7 @@ async def test_long_reorg(
@pytest.mark.anyio
@pytest.mark.parametrize("light_blocks", [True, False])
@pytest.mark.parametrize("chain_length", [0, 100])
@pytest.mark.limit_consensus_modes(allowed=[ConsensusMode.PLAIN], reason="save time")
@pytest.mark.limit_consensus_modes(allowed=[ConsensusMode.HARD_FORK_2_0], reason="save time")
async def test_long_reorg_nodes(
light_blocks: bool,
chain_length: int,
Expand All @@ -2359,12 +2359,12 @@ async def test_long_reorg_nodes(
):
full_node_1, full_node_2, full_node_3 = three_nodes

blocks = default_10000_blocks[: 1600 - chain_length]
blocks = default_10000_blocks[: 3600 - chain_length]

if light_blocks:
reorg_blocks = test_long_reorg_blocks_light[: 1600 - chain_length]
reorg_blocks = test_long_reorg_blocks_light[: 3600 - chain_length]
else:
reorg_blocks = test_long_reorg_blocks[: 1200 - chain_length]
reorg_blocks = test_long_reorg_blocks[: 3200 - chain_length]

# full node 1 has the original chain
for block_batch in to_batches(blocks, 64):
Expand Down

0 comments on commit 1477c93

Please sign in to comment.