mirror of
https://github.com/Chia-Network/chia-blockchain.git
synced 2026-09-07 10:05:06 -05:00
mypy
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import asyncio
|
||||
import itertools
|
||||
from typing import Collection, List, Optional
|
||||
from typing import Collection, List, Optional, Set
|
||||
|
||||
from chia.consensus.block_record import BlockRecord
|
||||
from chia.consensus.block_rewards import calculate_pool_reward, calculate_base_farmer_reward
|
||||
@@ -182,6 +182,9 @@ class FullNodeSimulator(FullNodeAPI):
|
||||
await self.process_blocks(count=1)
|
||||
|
||||
peak_height = self.full_node.blockchain.get_peak_height()
|
||||
if peak_height is None:
|
||||
raise RuntimeError("Peak height still None after processing at least one block")
|
||||
|
||||
coin_records = await self.full_node.coin_store.get_coins_added_at_height(height=peak_height)
|
||||
|
||||
# TODO: handle timeouts
|
||||
@@ -235,7 +238,12 @@ class FullNodeSimulator(FullNodeAPI):
|
||||
clock = asyncio.get_event_loop().time
|
||||
end = clock() + timeout
|
||||
|
||||
ids_to_check = set(record.spend_bundle.name() for record in records)
|
||||
ids_to_check: Set[bytes32] = set()
|
||||
for record in records:
|
||||
if record.spend_bundle is None:
|
||||
raise ValueError(f"Transaction record has no spend bundle: {record!r}")
|
||||
|
||||
ids_to_check.add(record.spend_bundle.name())
|
||||
|
||||
# TODO: can we avoid polling
|
||||
while True:
|
||||
@@ -260,7 +268,12 @@ class FullNodeSimulator(FullNodeAPI):
|
||||
clock = asyncio.get_event_loop().time
|
||||
end = clock() + timeout
|
||||
|
||||
ids_to_check = set(record.spend_bundle.name() for record in records)
|
||||
ids_to_check: Set[bytes32] = set()
|
||||
for record in records:
|
||||
if record.spend_bundle is None:
|
||||
raise ValueError(f"Transaction record has no spend bundle: {record!r}")
|
||||
|
||||
ids_to_check.add(record.spend_bundle.name())
|
||||
|
||||
await self.wait_transaction_records_entered_mempool(records=records, timeout=end - clock())
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@ from chia.types.peer_info import PeerInfo
|
||||
from tests.block_tools import create_block_tools_async
|
||||
from chia.server.server import ChiaServer
|
||||
from chia.simulator.full_node_simulator import FullNodeSimulator
|
||||
from chia.util.ints import uint16
|
||||
from chia.util.ints import uint16, uint32
|
||||
from chia.wallet.wallet_node import WalletNode
|
||||
from tests.core.node_height import node_height_at_least
|
||||
from tests.setup_nodes import (
|
||||
@@ -156,7 +156,7 @@ class TestSimulation:
|
||||
|
||||
peak_height = full_node_api.full_node.blockchain.get_peak_height()
|
||||
if peak_height is None:
|
||||
peak_height = 0
|
||||
peak_height = uint32(0)
|
||||
|
||||
assert peak_height == expected_height
|
||||
|
||||
|
||||
@@ -180,8 +180,10 @@ class TestDLWallet:
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_dlo_wallet(self, three_wallet_nodes) -> None:
|
||||
time_lock = 10
|
||||
full_nodes, wallets = three_wallet_nodes
|
||||
full_node_api = full_nodes[0]
|
||||
full_node_api.time_per_block = 2 * time_lock
|
||||
full_node_server = full_node_api.server
|
||||
wallet_node_0, server_0 = wallets[0]
|
||||
wallet_node_1, server_1 = wallets[1]
|
||||
@@ -229,18 +231,14 @@ class TestDLWallet:
|
||||
|
||||
await time_out_assert(15, dlo_wallet_1.get_confirmed_balance, 0)
|
||||
await time_out_assert(15, dlo_wallet_1.get_unconfirmed_balance, 0)
|
||||
# leaf_reveal: bytes,
|
||||
# host_genesis_id: bytes32,
|
||||
# claim_target: bytes32,
|
||||
# recovery_target: bytes32,
|
||||
# recovery_timelock: uint64,
|
||||
assert dl_wallet_0.dl_info.origin_coin is not None
|
||||
tr = await dlo_wallet_1.generate_datalayer_offer_spend(
|
||||
uint64(201),
|
||||
Program.to("thing").get_tree_hash(),
|
||||
dl_wallet_0.dl_info.origin_coin.name(),
|
||||
await wallet_2.get_new_puzzlehash(),
|
||||
await wallet_1.get_new_puzzlehash(),
|
||||
10,
|
||||
amount=uint64(201),
|
||||
leaf_reveal=Program.to("thing").get_tree_hash(),
|
||||
host_genesis_id=dl_wallet_0.dl_info.origin_coin.name(),
|
||||
claim_target=await wallet_2.get_new_puzzlehash(),
|
||||
recovery_target=await wallet_1.get_new_puzzlehash(),
|
||||
recovery_timelock=time_lock,
|
||||
)
|
||||
await wallet_1.push_transaction(tr)
|
||||
await full_node_api.process_transaction_records(records=[tr])
|
||||
@@ -262,6 +260,7 @@ class TestDLWallet:
|
||||
if len(inclusion_proof) == 1:
|
||||
inclusion_proof = inclusion_proof[0]
|
||||
# breakpoint()
|
||||
assert db_innerpuz is not None
|
||||
sb2 = await dlo_wallet_2.claim_dl_offer(
|
||||
offer_coin,
|
||||
offer_full_puzzle,
|
||||
@@ -347,18 +346,14 @@ class TestDLWallet:
|
||||
|
||||
await time_out_assert(15, dlo_wallet_1.get_confirmed_balance, 0)
|
||||
await time_out_assert(15, dlo_wallet_1.get_unconfirmed_balance, 0)
|
||||
# leaf_reveal: bytes,
|
||||
# host_genesis_id: bytes32,
|
||||
# claim_target: bytes32,
|
||||
# recovery_target: bytes32,
|
||||
# recovery_timelock: uint64,
|
||||
assert dl_wallet_0.dl_info.origin_coin is not None
|
||||
tr = await dlo_wallet_1.generate_datalayer_offer_spend(
|
||||
uint64(offer_amount),
|
||||
Program.to("thing").get_tree_hash(),
|
||||
dl_wallet_0.dl_info.origin_coin.name(),
|
||||
await wallet_2.get_new_puzzlehash(),
|
||||
await wallet_1.get_new_puzzlehash(),
|
||||
time_lock,
|
||||
amount=uint64(offer_amount),
|
||||
leaf_reveal=Program.to("thing").get_tree_hash(),
|
||||
host_genesis_id=dl_wallet_0.dl_info.origin_coin.name(),
|
||||
claim_target=await wallet_2.get_new_puzzlehash(),
|
||||
recovery_target=await wallet_1.get_new_puzzlehash(),
|
||||
recovery_timelock=time_lock,
|
||||
)
|
||||
await wallet_1.push_transaction(tr)
|
||||
await full_node_api.process_transaction_records(records=[tr])
|
||||
|
||||
Reference in New Issue
Block a user