Skip to content

Commit

Permalink
test
Browse files Browse the repository at this point in the history
  • Loading branch information
arvidn committed Jul 12, 2024
1 parent 3304ee1 commit d63b037
Showing 1 changed file with 3 additions and 46 deletions.
49 changes: 3 additions & 46 deletions chia/_tests/blockchain/test_blockchain.py
Original file line number Diff line number Diff line change
Expand Up @@ -2537,52 +2537,9 @@ async def test_invalid_transactions_ref_list(
)
block = blocks[-1]
if consensus_mode >= ConsensusMode.HARD_FORK_2_0:
# once the hard for activates, we don't use this form of block
# compression anymore
assert len(block.transactions_generator_ref_list) == 0
# the remaining tests assume a reflist
return
else:
assert len(block.transactions_generator_ref_list) > 0

block_2 = recursive_replace(block, "transactions_info.generator_refs_root", bytes([1] * 32))
block_2 = recursive_replace(
block_2, "foliage_transaction_block.transactions_info_hash", block_2.transactions_info.get_hash()
)
block_2 = recursive_replace(
block_2, "foliage.foliage_transaction_block_hash", block_2.foliage_transaction_block.get_hash()
)
new_m = block_2.foliage.foliage_transaction_block_hash
assert new_m is not None
new_fsb_sig = bt.get_plot_signature(new_m, block.reward_chain_block.proof_of_space.plot_public_key)
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_REFS_ROOT, skip_prevalidation=True
)

# Too many heights
block_2 = recursive_replace(block, "transactions_generator_ref_list", [block.height - 2, block.height - 1])
# Fails preval
await _validate_and_add_block(b, block_2, expected_error=Err.FAILED_GETTING_GENERATOR_MULTIPROCESSING)
# Fails add_block
await _validate_and_add_block_multi_error(
b,
block_2,
[Err.GENERATOR_REF_HAS_NO_GENERATOR, Err.INVALID_TRANSACTIONS_GENERATOR_REFS_ROOT],
skip_prevalidation=True,
)

# Not tx block
for h in range(0, block.height - 1):
block_2 = recursive_replace(block, "transactions_generator_ref_list", [h])
await _validate_and_add_block(b, block_2, expected_error=Err.FAILED_GETTING_GENERATOR_MULTIPROCESSING)
await _validate_and_add_block_multi_error(
b,
block_2,
[Err.GENERATOR_REF_HAS_NO_GENERATOR, Err.INVALID_TRANSACTIONS_GENERATOR_REFS_ROOT],
skip_prevalidation=True,
)
# once the hard fork activated, we no longer use this form of block
# compression anymore
assert len(block.transactions_generator_ref_list) == 0

@pytest.mark.anyio
async def test_cost_exceeds_max(
Expand Down

0 comments on commit d63b037

Please sign in to comment.