Repository: Chia-Network/chia-blockchain
File: chia/_tests/core/full_node/test_full_node.py (Python)

Code before:
        )
        for block in blocks:
            await full_node_api.full_node.add_block(block)
        peak = full_node_api.full_node.blockchain.get_peak()
        assert peak is not None
        current_height = peak.height
        # Create a transaction with a height condition that makes it pending
        coin = blocks[-1].get_included_reward_coins()[0]
        if condition == ConditionOpcode.ASSERT_HEIGHT_RELATIVE:
            condition_height = 1
        else:
            condition_height = current_height + 1
        condition_dic = {condition: [ConditionWithArgs(condition, [int_to_bytes(condition_height)])]}
        sb = wallet.generate_signed_transaction(uint64(42), ph, coin, condition_dic)
        sb_name = sb.name()
        # Send the transaction
        res = await full_node_api.send_transaction(SendTransaction(sb))
        assert res is not None
        assert ProtocolMessageTypes(res.type) == ProtocolMessageTypes.transaction_ack
        transaction_ack = TransactionAck.from_bytes(res.data)
        assert transaction_ack.status == MempoolInclusionStatus.PENDING.value
        assert transaction_ack.error == error
        # Make sure it ends up in the pending cache, not the mempool
        assert full_node_api.full_node.mempool_manager.get_mempool_item(sb_name, include_pending=False) is None
        assert full_node_api.full_node.mempool_manager.get_mempool_item(sb_name, include_pending=True) is not None
        # Advance to meet the condition
        with caplog.at_level(logging.DEBUG):
            blocks = bt.get_consecutive_blocks(2, block_list_input=blocks, guarantee_transaction_block=True)
            for block in blocks:
                await full_node_api.full_node.add_block(block)
        # This should trigger peak post processing with the added transaction
        assert f"Added transaction to mempool: {sb_name}\n" in caplog.text
        # Make sure the transaction was retried and got added to the mempool
        assert full_node_api.full_node.mempool_manager.get_mempool_item(sb_name, include_pending=False) is not None


Review comment (suggestion):
```suggestion
        # Advance peak to meet the condition
```

Code after:
        )
        for block in blocks:
            await full_node_api.full_node.add_block(block)
        peak = full_node_api.full_node.blockchain.get_peak()
        assert peak is not None
        current_height = peak.height
        # Create a transaction with a height condition that makes it pending
        coin = blocks[-1].get_included_reward_coins()[0]
        if condition == ConditionOpcode.ASSERT_HEIGHT_RELATIVE:
            condition_height = 1
        else:
            condition_height = current_height + 1
        condition_dic = {condition: [ConditionWithArgs(condition, [int_to_bytes(condition_height)])]}
        sb = wallet.generate_signed_transaction(uint64(42), ph, coin, condition_dic)
        sb_name = sb.name()
        # Send the transaction
        res = await full_node_api.send_transaction(SendTransaction(sb))
        assert res is not None
        assert ProtocolMessageTypes(res.type) == ProtocolMessageTypes.transaction_ack
        transaction_ack = TransactionAck.from_bytes(res.data)
        assert transaction_ack.status == MempoolInclusionStatus.PENDING.value
        assert transaction_ack.error == error
        # Make sure it ends up in the pending cache, not the mempool
        assert full_node_api.full_node.mempool_manager.get_mempool_item(sb_name, include_pending=False) is None
        assert full_node_api.full_node.mempool_manager.get_mempool_item(sb_name, include_pending=True) is not None
        # Advance peak to meet the asserted height condition
        with caplog.at_level(logging.DEBUG):
            blocks = bt.get_consecutive_blocks(2, block_list_input=blocks, guarantee_transaction_block=True)
            for block in blocks:
                await full_node_api.full_node.add_block(block)
        # This should trigger peak post processing with the added transaction
        assert f"Added transaction to mempool: {sb_name}\n" in caplog.text
        # Make sure the transaction was retried and got added to the mempool
        assert full_node_api.full_node.mempool_manager.get_mempool_item(sb_name, include_pending=False) is not None