Skip to content

Commit 63cd893

Browse files
committed
make test_conditions.py use the farmer reward, and not the pool reward, for its tests. This prepares this test to work with v2 plots, since they don't support redirecting the pool reward
1 parent eed4283 commit 63cd893

File tree

1 file changed

+16
-16
lines changed

1 file changed

+16
-16
lines changed

chia/_tests/core/full_node/test_conditions.py

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
from chia._tests.blockchain.blockchain_test_utils import _validate_and_add_block
1616
from chia._tests.conftest import ConsensusMode
1717
from chia._tests.core.full_node.ram_db import create_ram_blockchain
18+
from chia._tests.core.full_node.test_full_node import find_reward_coin
1819
from chia.consensus.condition_tools import agg_sig_additional_data
1920
from chia.simulator.block_tools import BlockTools
2021
from chia.simulator.keyring import TempKeyring
@@ -47,7 +48,6 @@ async def initial_blocks(bt: BlockTools, block_count: int = 4) -> list[FullBlock
4748
block_count,
4849
guarantee_transaction_block=True,
4950
farmer_reward_puzzle_hash=EASY_PUZZLE_HASH,
50-
pool_reward_puzzle_hash=EASY_PUZZLE_HASH,
5151
genesis_timestamp=uint64(10000),
5252
time_per_block=10,
5353
)
@@ -101,7 +101,7 @@ async def check_conditions(
101101
aggsig: G2Element = G2Element(),
102102
) -> tuple[list[CoinRecord], list[CoinRecord], FullBlock]:
103103
blocks = await initial_blocks(bt)
104-
coin = blocks[spend_reward_index].get_included_reward_coins()[0]
104+
coin = find_reward_coin(blocks[spend_reward_index], EASY_PUZZLE_HASH)
105105

106106
coin_spend = make_spend(coin, EASY_PUZZLE, condition_solution)
107107
spend_bundle = SpendBundle([coin_spend], aggsig)
@@ -143,9 +143,9 @@ async def test_unknown_conditions_with_cost(
143143
# once the hard fork activates, blocks no longer pay the cost of the ROM
144144
# generator (which includes hashing all puzzles).
145145
if consensus_mode >= ConsensusMode.HARD_FORK_2_0:
146-
block_base_cost = 756064
146+
block_base_cost = 756064 - 12000
147147
else:
148-
block_base_cost = 761056
148+
block_base_cost = 761056 - 12000
149149
assert new_block.transactions_info is not None
150150
assert new_block.transactions_info.cost - block_base_cost == expected_cost
151151

@@ -164,11 +164,11 @@ async def test_softfork_condition(
164164
_additions, _removals, new_block = await check_conditions(bt, conditions)
165165

166166
if consensus_mode < ConsensusMode.HARD_FORK_2_0:
167-
block_base_cost = 737056
167+
block_base_cost = 737056 - 12000
168168
else:
169169
# once the hard fork activates, blocks no longer pay the cost of the ROM
170170
# generator (which includes hashing all puzzles).
171-
block_base_cost = 732064
171+
block_base_cost = 732064 - 12000
172172

173173
# the block_base_cost includes the cost of the bytes for the condition
174174
# with 2 bytes argument. This test works as long as the conditions it's
@@ -267,7 +267,7 @@ async def test_condition(self, opcode: ConditionOpcode, value: int, expected: Er
267267
@pytest.mark.anyio
268268
async def test_invalid_my_id(self, bt: BlockTools) -> None:
269269
blocks = await initial_blocks(bt)
270-
coin = blocks[-2].get_included_reward_coins()[0]
270+
coin = find_reward_coin(blocks[-2], EASY_PUZZLE_HASH)
271271
wrong_name = bytearray(coin.name())
272272
wrong_name[-1] ^= 1
273273
conditions = Program.to(assemble(f"(({ConditionOpcode.ASSERT_MY_COIN_ID[0]} 0x{wrong_name.hex()}))"))
@@ -276,14 +276,14 @@ async def test_invalid_my_id(self, bt: BlockTools) -> None:
276276
@pytest.mark.anyio
277277
async def test_valid_my_id(self, bt: BlockTools) -> None:
278278
blocks = await initial_blocks(bt)
279-
coin = blocks[-2].get_included_reward_coins()[0]
279+
coin = find_reward_coin(blocks[-2], EASY_PUZZLE_HASH)
280280
conditions = Program.to(assemble(f"(({ConditionOpcode.ASSERT_MY_COIN_ID[0]} 0x{coin.name().hex()}))"))
281281
await check_conditions(bt, conditions)
282282

283283
@pytest.mark.anyio
284284
async def test_invalid_coin_announcement(self, bt: BlockTools) -> None:
285285
blocks = await initial_blocks(bt)
286-
coin = blocks[-2].get_included_reward_coins()[0]
286+
coin = find_reward_coin(blocks[-2], EASY_PUZZLE_HASH)
287287
announce = AssertCoinAnnouncement(asserted_id=coin.name(), asserted_msg=b"test_bad")
288288
conditions = Program.to(
289289
assemble(
@@ -296,7 +296,7 @@ async def test_invalid_coin_announcement(self, bt: BlockTools) -> None:
296296
@pytest.mark.anyio
297297
async def test_valid_coin_announcement(self, bt: BlockTools) -> None:
298298
blocks = await initial_blocks(bt)
299-
coin = blocks[-2].get_included_reward_coins()[0]
299+
coin = find_reward_coin(blocks[-2], EASY_PUZZLE_HASH)
300300
announce = AssertCoinAnnouncement(asserted_id=coin.name(), asserted_msg=b"test")
301301
conditions = Program.to(
302302
assemble(
@@ -374,7 +374,7 @@ async def test_announce_conditions_limit(
374374
"""
375375

376376
blocks = await initial_blocks(bt)
377-
coin = blocks[-2].get_included_reward_coins()[0]
377+
coin = find_reward_coin(blocks[-2], EASY_PUZZLE_HASH)
378378
coin_announcement = AssertCoinAnnouncement(asserted_id=coin.name(), asserted_msg=b"test")
379379
puzzle_announcement = AssertPuzzleAnnouncement(asserted_ph=EASY_PUZZLE_HASH, asserted_msg=b"test")
380380

@@ -404,7 +404,7 @@ async def test_announce_conditions_limit(
404404
@pytest.mark.anyio
405405
async def test_coin_messages(self, bt: BlockTools, consensus_mode: ConsensusMode) -> None:
406406
blocks = await initial_blocks(bt)
407-
coin = blocks[-2].get_included_reward_coins()[0]
407+
coin = find_reward_coin(blocks[-2], EASY_PUZZLE_HASH)
408408
conditions = Program.to(
409409
assemble(
410410
f"(({ConditionOpcode.SEND_MESSAGE[0]} 0x3f 'test' 0x{coin.name().hex()})"
@@ -416,7 +416,7 @@ async def test_coin_messages(self, bt: BlockTools, consensus_mode: ConsensusMode
416416
@pytest.mark.anyio
417417
async def test_parent_messages(self, bt: BlockTools, consensus_mode: ConsensusMode) -> None:
418418
blocks = await initial_blocks(bt)
419-
coin = blocks[-2].get_included_reward_coins()[0]
419+
coin = find_reward_coin(blocks[-2], EASY_PUZZLE_HASH)
420420
conditions = Program.to(
421421
assemble(
422422
f"(({ConditionOpcode.SEND_MESSAGE[0]} 0x24 'test' 0x{coin.parent_coin_info})"
@@ -437,7 +437,7 @@ async def test_parent_messages(self, bt: BlockTools, consensus_mode: ConsensusMo
437437
('(66 0x27 "foo" {coin}) (67 0x3f "foo" {coin})', Err.MESSAGE_NOT_SENT_OR_RECEIVED),
438438
('(66 0 "foo") (67 0 "foo")', None),
439439
('(66 0 "foobar") (67 0 "foo")', Err.MESSAGE_NOT_SENT_OR_RECEIVED),
440-
('(66 0x09 "foo" 1750000000000) (67 0x09 "foo" 1750000000000)', None),
440+
('(66 0x09 "foo" 250000000000) (67 0x09 "foo" 250000000000)', None),
441441
('(66 -1 "foo")', Err.INVALID_MESSAGE_MODE),
442442
('(67 -1 "foo")', Err.INVALID_MESSAGE_MODE),
443443
('(66 0x40 "foo")', Err.INVALID_MESSAGE_MODE),
@@ -448,7 +448,7 @@ async def test_message_conditions(
448448
self, bt: BlockTools, consensus_mode: ConsensusMode, conds: str, expected: Err | None
449449
) -> None:
450450
blocks = await initial_blocks(bt)
451-
coin = blocks[-2].get_included_reward_coins()[0]
451+
coin = find_reward_coin(blocks[-2], EASY_PUZZLE_HASH)
452452
conditions = Program.to(assemble("(" + conds.format(coin="0x" + coin.name().hex()) + ")"))
453453

454454
await check_conditions(bt, conditions, expected_err=expected)
@@ -521,7 +521,7 @@ async def test_agg_sig_illegal_suffix(
521521

522522
sk = AugSchemeMPL.key_gen(b"8" * 32)
523523
pubkey = sk.get_g1()
524-
coin = blocks[-2].get_included_reward_coins()[0]
524+
coin = find_reward_coin(blocks[-2], EASY_PUZZLE_HASH)
525525
for msg in [
526526
c.AGG_SIG_ME_ADDITIONAL_DATA,
527527
c.AGG_SIG_PARENT_ADDITIONAL_DATA,

0 commit comments

Comments
 (0)