Skip to content

Commit fd66810

Browse files
committed
fix tests and review comments
1 parent 18c7633 commit fd66810

File tree

5 files changed

+15
-14
lines changed

5 files changed

+15
-14
lines changed

chia/_tests/core/mempool/test_mempool.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -692,7 +692,10 @@ async def test_double_spend_with_higher_fee(
692692

693693
@pytest.mark.anyio
694694
async def test_invalid_signature(
695-
self, one_node_one_block: tuple[FullNodeSimulator, ChiaServer, BlockTools], wallet_a: WalletTool
695+
self,
696+
one_node_one_block: tuple[FullNodeSimulator, ChiaServer, BlockTools],
697+
wallet_a: WalletTool,
698+
caplog: pytest.LogCaptureFixture,
696699
) -> None:
697700
reward_ph = wallet_a.get_new_puzzlehash()
698701

@@ -716,11 +719,12 @@ async def test_invalid_signature(
716719
sb: SpendBundle = generate_test_spend_bundle(wallet_a, coin1)
717720
assert sb.aggregated_signature != G2Element.generator()
718721
sb = sb.replace(aggregated_signature=G2Element.generator())
722+
caplog.clear()
719723
res: Optional[Message] = await send_sb(full_node_1, sb)
720724
assert res is not None
721725
ack: TransactionAck = TransactionAck.from_bytes(res.data)
722-
assert ack.status == MempoolInclusionStatus.FAILED.value
723-
assert ack.error == Err.BAD_AGGREGATE_SIGNATURE.name
726+
assert ack.status != MempoolInclusionStatus.SUCCESS.value
727+
assert "chia.util.errors.ValidationError: Error code: BAD_AGGREGATE_SIGNATURE" in caplog.text
724728
invariant_check_mempool(full_node_1.full_node.mempool_manager.mempool)
725729

726730
async def condition_tester(

chia/full_node/full_node.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@
8888
from chia.util.db_synchronous import db_synchronous_on
8989
from chia.util.db_version import lookup_db_version, set_db_version_async
9090
from chia.util.db_wrapper import DBWrapper2, manage_connection
91-
from chia.util.errors import ConsensusError, Err, TimestampError
91+
from chia.util.errors import ConsensusError, Err, TimestampError, ValidationError
9292
from chia.util.limited_semaphore import LimitedSemaphore
9393
from chia.util.network import is_localhost
9494
from chia.util.path import path_from_root
@@ -503,11 +503,16 @@ async def _handle_one_transaction(self, entry: TransactionQueueEntry) -> None:
503503
except asyncio.CancelledError:
504504
error_stack = traceback.format_exc()
505505
self.log.debug(f"Cancelling _handle_one_transaction, closing: {error_stack}")
506+
except ValidationError as e:
507+
self.log.exception("Error in _handle_one_transaction, closing")
508+
if peer is not None:
509+
await peer.close(CONSENSUS_ERROR_BAN_SECONDS)
510+
entry.done.set((MempoolInclusionStatus.FAILED, e.code))
506511
except Exception:
507-
error_stack = traceback.format_exc()
508-
self.log.error(f"Error in _handle_one_transaction, closing: {error_stack}")
512+
self.log.exception("Error in _handle_one_transaction, closing")
509513
if peer is not None:
510514
await peer.close(CONSENSUS_ERROR_BAN_SECONDS)
515+
entry.done.set((MempoolInclusionStatus.FAILED, Err.UNKNOWN))
511516
finally:
512517
self.add_transaction_semaphore.release()
513518

chia/full_node/mempool_manager.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -460,7 +460,6 @@ async def pre_validate_spendbundle(
460460
)
461461
# validate_clvm_and_signature raises a ValueError with an error code
462462
except ValueError as e:
463-
log.warning(f"max CLVM cost: {self.max_tx_clvm_cost}")
464463
# Convert that to a ValidationError
465464
if len(e.args) > 1:
466465
error = Err(e.args[1])

chia/server/ws_connection.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -358,12 +358,6 @@ async def ban_peer_bad_protocol(self, log_err_msg: str) -> None:
358358
self.log.error(f"Banning peer for {ban_seconds} seconds: {self.peer_info.host} {log_err_msg}")
359359
await self.close(ban_seconds, WSCloseCode.PROTOCOL_ERROR, Err.INVALID_PROTOCOL_MESSAGE)
360360

361-
async def ban_peer_consensus_error(self, log_err_msg: str) -> None:
362-
"""Ban peer for consensus rule violation"""
363-
ban_seconds = CONSENSUS_ERROR_BAN_SECONDS
364-
self.log.error(f"Banning peer for {ban_seconds} seconds: {self.peer_info.host} {log_err_msg}")
365-
await self.close(ban_seconds)
366-
367361
def cancel_pending_requests(self) -> None:
368362
for message_id, event in self.pending_requests.items():
369363
try:

chia/simulator/block_tools.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -389,7 +389,6 @@ def setup_new_gen(
389389
program = simple_solution_generator(transaction_data).program
390390
block_refs = []
391391
cost = compute_block_cost(program, self.constants, uint32(curr.height + 1), prev_tx_height)
392-
print(f"computed cost: {cost} additions: {len(additions)} removals: {len(removals)}")
393392
return NewBlockGenerator(
394393
program,
395394
[],

0 commit comments

Comments
 (0)