diff --git a/chia/_tests/core/test_full_node_rpc.py b/chia/_tests/core/test_full_node_rpc.py index d49bec65ced8..4af1c2d9e485 100644 --- a/chia/_tests/core/test_full_node_rpc.py +++ b/chia/_tests/core/test_full_node_rpc.py @@ -95,21 +95,22 @@ async def test1(two_nodes_sim_and_wallets_services, self_hostname, consensus_mod assert (await client.get_block_record_by_height(100)) is None - # TODO: Understand why the set() is required to make this work and address it. This shouldn't be needed. - # (seems to only happen on linux) - ph = next(iter(set(blocks[-1].get_included_reward_coins()))).puzzle_hash + # NOTE: indexing and hard coded values below depend on the ordering + included_reward_coins = sorted(blocks[-1].get_included_reward_coins(), key=lambda c: c.amount) + + ph = included_reward_coins[0].puzzle_hash coins = await client.get_coin_records_by_puzzle_hash(ph) print(coins) assert len(coins) >= 1 - pid = next(iter(set(blocks[-1].get_included_reward_coins()))).parent_coin_info - pid_2 = list(set(blocks[-1].get_included_reward_coins()))[1].parent_coin_info + pid = included_reward_coins[0].parent_coin_info + pid_2 = included_reward_coins[1].parent_coin_info coins = await client.get_coin_records_by_parent_ids([pid, pid_2]) print(coins) assert len(coins) == 2 - name = next(iter(set(blocks[-1].get_included_reward_coins()))).name() - name_2 = list(set(blocks[-1].get_included_reward_coins()))[1].name() + name = included_reward_coins[0].name() + name_2 = included_reward_coins[1].name() coins = await client.get_coin_records_by_names([name, name_2]) print(coins) assert len(coins) == 2 @@ -137,7 +138,10 @@ async def test1(two_nodes_sim_and_wallets_services, self_hostname, consensus_mod assert len(await client.get_coin_records_by_puzzle_hash(ph)) == 2 assert len(await client.get_coin_records_by_puzzle_hash(ph_receiver)) == 0 - coin_to_spend = next(iter(set(blocks[-1].get_included_reward_coins()))) + # NOTE: indexing and hard coded values below depend on the ordering + included_reward_coins = sorted(blocks[-1].get_included_reward_coins(), key=lambda c: c.amount) + + coin_to_spend = included_reward_coins[0] spend_bundle = wallet.generate_signed_transaction(coin_to_spend.amount, ph_receiver, coin_to_spend) @@ -167,7 +171,7 @@ async def test1(two_nodes_sim_and_wallets_services, self_hostname, consensus_mod assert (await client.get_coin_record_by_name(coin.name())) is None # Verify that the include_pending arg to get_mempool_item_by_tx_id works - coin_to_spend_pending = list(set(blocks[-1].get_included_reward_coins()))[1] + coin_to_spend_pending = included_reward_coins[1] ahr = ConditionOpcode.ASSERT_HEIGHT_RELATIVE # to force pending/potential condition_dic = {ahr: [ConditionWithArgs(ahr, [int_to_bytes(100)])]} spend_bundle_pending = wallet.generate_signed_transaction( @@ -361,7 +365,7 @@ async def test1(two_nodes_sim_and_wallets_services, self_hostname, consensus_mod state = await client.get_blockchain_state() block = await client.get_block(state["peak"].header_hash) - coin_to_spend = next(iter(set(block.get_included_reward_coins()))) + coin_to_spend = block.get_included_reward_coins()[0] spend_bundle = wallet.generate_signed_transaction(coin_to_spend.amount, ph_2, coin_to_spend, memo=memo) await client.push_tx(spend_bundle) @@ -771,7 +775,7 @@ async def test_coin_name_found_in_mempool(one_node, self_hostname): # empty mempool assert len(await client.get_all_mempool_items()) == 0 - coin_to_spend = next(iter(set(blocks[-1].get_included_reward_coins()))) + coin_to_spend = blocks[-1].get_included_reward_coins()[0] spend_bundle = wallet.generate_signed_transaction(coin_to_spend.amount, ph_receiver, coin_to_spend) await client.push_tx(spend_bundle)