|
14 | 14 | from chia.simulator.simulator_protocol import FarmNewBlockProtocol |
15 | 15 | from chia.types.announcement import Announcement |
16 | 16 | from chia.types.blockchain_format.coin import Coin |
| 17 | +from chia.types.blockchain_format.sized_bytes import bytes32 |
17 | 18 | from chia.types.coin_spend import CoinSpend |
18 | 19 | from chia.types.condition_opcodes import ConditionOpcode |
19 | 20 | from chia.types.condition_with_args import ConditionWithArgs |
|
30 | 31 | from chia.full_node.pending_tx_cache import PendingTxCache |
31 | 32 | from blspy import G2Element |
32 | 33 |
|
| 34 | +from chia.util.recursive_replace import recursive_replace |
33 | 35 | from tests.connection_utils import connect_and_get_peer |
34 | 36 | from tests.core.node_height import node_height_at_least |
35 | 37 | from tests.setup_nodes import bt, setup_simulators_and_wallets |
@@ -2179,3 +2181,26 @@ def test_many_create_coin(self): |
2179 | 2181 | assert len(npc_result.npc_list[0].conditions[0][1]) == 6094 |
2180 | 2182 | assert run_time < 1 |
2181 | 2183 | print(f"run time:{run_time}") |
| 2184 | + |
| 2185 | + @pytest.mark.asyncio |
| 2186 | + async def test_invalid_coin_spend_coin(self, two_nodes): |
| 2187 | + reward_ph = WALLET_A.get_new_puzzlehash() |
| 2188 | + blocks = bt.get_consecutive_blocks( |
| 2189 | + 5, |
| 2190 | + guarantee_transaction_block=True, |
| 2191 | + farmer_reward_puzzle_hash=reward_ph, |
| 2192 | + pool_reward_puzzle_hash=reward_ph, |
| 2193 | + ) |
| 2194 | + full_node_1, full_node_2, server_1, server_2 = two_nodes |
| 2195 | + |
| 2196 | + for block in blocks: |
| 2197 | + await full_node_1.full_node.respond_block(full_node_protocol.RespondBlock(block)) |
| 2198 | + |
| 2199 | + await time_out_assert(60, node_height_at_least, True, full_node_2, blocks[-1].height) |
| 2200 | + |
| 2201 | + spend_bundle = generate_test_spend_bundle(list(blocks[-1].get_included_reward_coins())[0]) |
| 2202 | + coin_spend_0 = recursive_replace(spend_bundle.coin_spends[0], "coin.puzzle_hash", bytes32([1] * 32)) |
| 2203 | + new_bundle = recursive_replace(spend_bundle, "coin_spends", [coin_spend_0] + spend_bundle.coin_spends[1:]) |
| 2204 | + assert spend_bundle is not None |
| 2205 | + res = await full_node_1.full_node.respond_transaction(new_bundle, new_bundle.name()) |
| 2206 | + assert res == (MempoolInclusionStatus.FAILED, Err.INVALID_SPEND_BUNDLE) |
0 commit comments