Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions chia/_tests/blockchain/blockchain_test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,11 +116,10 @@ async def _validate_and_add_block(
if err is not None:
# Got an error
raise AssertionError(err)
else:
# Here we will enforce checking of the exact error
if err != expected_error:
# Did not get the right error, or did not get an error
raise AssertionError(f"Expected {expected_error} but got {err}")
# Here we will enforce checking of the exact error
elif err != expected_error:
# Did not get the right error, or did not get an error
raise AssertionError(f"Expected {expected_error} but got {err}")

if expected_result is not None and expected_result != result:
raise AssertionError(f"Expected {expected_result} but got {result}")
Expand Down
7 changes: 3 additions & 4 deletions chia/_tests/core/data_layer/test_data_store.py
Original file line number Diff line number Diff line change
Expand Up @@ -2385,11 +2385,10 @@ async def test_get_leaf_at_minimum_height(
if isinstance(node, InternalNode):
heights[node.left_hash] = heights[node.hash] + 1
heights[node.right_hash] = heights[node.hash] + 1
elif min_leaf_height is not None:
min_leaf_height = min(min_leaf_height, heights[node.hash])
else:
if min_leaf_height is not None:
min_leaf_height = min(min_leaf_height, heights[node.hash])
else:
min_leaf_height = heights[node.hash]
min_leaf_height = heights[node.hash]

assert min_leaf_height is not None
if pre > 0:
Expand Down
34 changes: 16 additions & 18 deletions chia/_tests/core/full_node/test_full_node.py
Original file line number Diff line number Diff line change
Expand Up @@ -2678,16 +2678,15 @@ async def test_long_reorg_nodes(
blocks = default_10000_blocks[: 1600 - chain_length]
reorg_blocks = test_long_reorg_blocks_light[: 1600 - chain_length]
reorg_height = 2000
else:
if fork_point == 1500:
blocks = default_10000_blocks[: 1900 - chain_length]
reorg_blocks = test_long_reorg_1500_blocks[: 1900 - chain_length]
reorg_height = 2300
else: # pragma: no cover
pytest.skip("We rely on the light-blocks test for a 0 forkpoint")
blocks = default_10000_blocks[: 1100 - chain_length]
# reorg_blocks = test_long_reorg_blocks[: 1100 - chain_length]
reorg_height = 1600
elif fork_point == 1500:
blocks = default_10000_blocks[: 1900 - chain_length]
reorg_blocks = test_long_reorg_1500_blocks[: 1900 - chain_length]
reorg_height = 2300
else: # pragma: no cover
pytest.skip("We rely on the light-blocks test for a 0 forkpoint")
blocks = default_10000_blocks[: 1100 - chain_length]
# reorg_blocks = test_long_reorg_blocks[: 1100 - chain_length]
reorg_height = 1600

# this is a pre-requisite for a reorg to happen
assert default_10000_blocks[reorg_height].weight > reorg_blocks[-1].weight
Expand Down Expand Up @@ -3163,15 +3162,14 @@ async def declare_pos_unfinished_block(
challenge_chain_sp = block.reward_chain_block.challenge_chain_sp_vdf.output.get_hash()
if block.reward_chain_block.reward_chain_sp_vdf is not None:
reward_chain_sp = block.reward_chain_block.reward_chain_sp_vdf.output.get_hash()
elif len(block.finished_sub_slots) > 0:
reward_chain_sp = block.finished_sub_slots[-1].reward_chain.get_hash()
else:
if len(block.finished_sub_slots) > 0:
reward_chain_sp = block.finished_sub_slots[-1].reward_chain.get_hash()
else:
curr = blockchain.block_record(block.prev_header_hash)
while not curr.first_in_sub_slot:
curr = blockchain.block_record(curr.prev_hash)
assert curr.finished_reward_slot_hashes is not None
reward_chain_sp = curr.finished_reward_slot_hashes[-1]
curr = blockchain.block_record(block.prev_header_hash)
while not curr.first_in_sub_slot:
curr = blockchain.block_record(curr.prev_hash)
assert curr.finished_reward_slot_hashes is not None
reward_chain_sp = curr.finished_reward_slot_hashes[-1]
farmer_reward_address = block.foliage.foliage_block_data.farmer_reward_puzzle_hash
pool_target = block.foliage.foliage_block_data.pool_target
pool_target_signature = block.foliage.foliage_block_data.pool_signature
Expand Down
7 changes: 3 additions & 4 deletions chia/_tests/plotting/test_plot_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,10 +117,9 @@ def refresh_callback(self, event: PlotRefreshEvents, refresh_result: PlotRefresh
if plot_info.prover.get_filename() == value.prover.get_filename():
values_found += 1
continue
else:
if value in expected_list:
values_found += 1
continue
elif value in expected_list:
values_found += 1
continue
if values_found != len(expected_list):
log.error(f"{name} invalid: values_found {values_found} expected {len(expected_list)}")
return
Expand Down
7 changes: 3 additions & 4 deletions chia/_tests/wallet/test_singleton_lifecycle_fast.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,9 @@ def satisfies_hint(obj: T, type_hint: type[T]) -> bool:
object_hint_pairs.extend((v, args[1]) for v in obj.values())
else:
raise NotImplementedError(f"Type {origin} is not yet supported")
else:
# Handle concrete types
if type(obj) is not type_hint:
return False
# Handle concrete types
elif type(obj) is not type_hint:
return False
return True


Expand Down
18 changes: 8 additions & 10 deletions chia/cmds/keys_funcs.py
Original file line number Diff line number Diff line change
Expand Up @@ -743,11 +743,10 @@ def derive_child_key(
if non_observer_derivation:
assert current_sk is not None # semantics above guarantee this
current_sk = _derive_path(current_sk, path_indices)
elif current_sk is not None:
current_sk = _derive_path_unhardened(current_sk, path_indices)
else:
if current_sk is not None:
current_sk = _derive_path_unhardened(current_sk, path_indices)
else:
current_pk = _derive_pk_unhardened(current_pk, path_indices)
current_pk = _derive_pk_unhardened(current_pk, path_indices)

derivation_root_sk = current_sk
derivation_root_pk = current_pk
Expand All @@ -768,13 +767,12 @@ def derive_child_key(
assert derivation_root_sk is not None # semantics above guarantee this
sk = _derive_path(derivation_root_sk, [i])
pk = sk.get_g1()
elif derivation_root_sk is not None:
sk = _derive_path_unhardened(derivation_root_sk, [i])
pk = sk.get_g1()
else:
if derivation_root_sk is not None:
sk = _derive_path_unhardened(derivation_root_sk, [i])
pk = sk.get_g1()
else:
sk = None
pk = _derive_pk_unhardened(derivation_root_pk, [i])
sk = None
pk = _derive_pk_unhardened(derivation_root_pk, [i])
hd_path: str = (
" (" + hd_path_root + str(i) + ("n" if non_observer_derivation else "") + ")" if show_hd_path else ""
)
Expand Down
5 changes: 2 additions & 3 deletions chia/cmds/wallet_funcs.py
Original file line number Diff line number Diff line change
Expand Up @@ -1244,9 +1244,8 @@ async def mint_nft(
raise ValueError("Disabling DID ownership is not supported for this NFT wallet, it does have a DID")
else:
did_id = None
else:
if not wallet_has_did:
did_id = ""
elif not wallet_has_did:
did_id = ""

mint_response = await wallet_client.mint_nft(
request=NFTMintNFTRequest(
Expand Down
5 changes: 2 additions & 3 deletions chia/consensus/block_body_validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -334,9 +334,8 @@ async def validate_block_body(
if block.transactions_generator is not None:
if std_hash(bytes(block.transactions_generator)) != block.transactions_info.generator_root:
return Err.INVALID_TRANSACTIONS_GENERATOR_HASH
else:
if block.transactions_info.generator_root != bytes([0] * 32):
return Err.INVALID_TRANSACTIONS_GENERATOR_HASH
elif block.transactions_info.generator_root != bytes([0] * 32):
return Err.INVALID_TRANSACTIONS_GENERATOR_HASH

# 8a. The generator_ref_list must be the hash of the serialized bytes of
# the generator ref list for this block (or 'one' bytes [0x01] if no generator)
Expand Down
19 changes: 9 additions & 10 deletions chia/consensus/block_creation.py
Original file line number Diff line number Diff line change
Expand Up @@ -354,17 +354,16 @@ def create_unfinished_block(
else:
if new_sub_slot:
rc_sp_hash = finished_sub_slots[-1].reward_chain.get_hash()
elif is_genesis:
rc_sp_hash = constants.GENESIS_CHALLENGE
else:
if is_genesis:
rc_sp_hash = constants.GENESIS_CHALLENGE
else:
assert prev_block is not None
assert blocks is not None
curr = prev_block
while not curr.first_in_sub_slot:
curr = blocks.block_record(curr.prev_hash)
assert curr.finished_reward_slot_hashes is not None
rc_sp_hash = curr.finished_reward_slot_hashes[-1]
assert prev_block is not None
assert blocks is not None
curr = prev_block
while not curr.first_in_sub_slot:
curr = blocks.block_record(curr.prev_hash)
assert curr.finished_reward_slot_hashes is not None
rc_sp_hash = curr.finished_reward_slot_hashes[-1]
signage_point = SignagePoint(None, None, None, None)

cc_sp_signature: Optional[G2Element] = get_plot_signature(cc_sp_hash, proof_of_space.plot_public_key)
Expand Down
Loading
Loading