Skip to content

Commit

Permalink
pass augmented in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
almogdepaz committed Jan 20, 2025
1 parent 5a918d7 commit 5cf019f
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 0 deletions.
3 changes: 3 additions & 0 deletions chia/_tests/util/full_sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
from chia.types.full_block import FullBlock
from chia.types.peer_info import PeerInfo
from chia.types.validation_state import ValidationState
from chia.util.augmented_chain import AugmentedBlockchain
from chia.util.config import load_config
from chia.util.ints import uint16

Expand Down Expand Up @@ -184,6 +185,7 @@ async def run_sync_test(
worst_batch_height = None
worst_batch_time_per_block = None
peer_info = peer.get_peer_logging()
blockchain = AugmentedBlockchain(full_node.blockchain)
async for r in rows:
batch_start_time = time.monotonic()
with enable_profiler(profile, height):
Expand Down Expand Up @@ -216,6 +218,7 @@ async def run_sync_test(
peer_info,
ForkInfo(fork_height, fork_height, header_hash),
ValidationState(ssi, diff, None),
blockchain
)
end_height = block_batch[-1].height
full_node.blockchain.clean_block_record(end_height - full_node.constants.BLOCKS_CACHE_SIZE)
Expand Down
5 changes: 5 additions & 0 deletions chia/_tests/wallet/sync/test_wallet_sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
from chia.types.peer_info import PeerInfo
from chia.types.spend_bundle import SpendBundle
from chia.types.validation_state import ValidationState
from chia.util.augmented_chain import AugmentedBlockchain
from chia.util.hash import std_hash
from chia.util.ints import uint32, uint64, uint128
from chia.wallet.nft_wallet.nft_wallet import NFTWallet
Expand Down Expand Up @@ -431,11 +432,13 @@ async def test_long_sync_wallet(
full_node.constants, True, block_record, full_node.blockchain
)
fork_height = blocks_reorg[-num_blocks - 10].height - 1
blockchain = AugmentedBlockchain(full_node.blockchain)
await full_node.add_block_batch(
blocks_reorg[-num_blocks - 10 : -1],
PeerInfo("0.0.0.0", 0),
ForkInfo(fork_height, fork_height, blocks_reorg[-num_blocks - 10].prev_header_hash),
ValidationState(sub_slot_iters, difficulty, None),
blockchain,
)
await full_node.add_block(blocks_reorg[-1])

Expand Down Expand Up @@ -559,11 +562,13 @@ async def test_wallet_reorg_get_coinbase(
sub_slot_iters, difficulty = get_next_sub_slot_iters_and_difficulty(
full_node.constants, True, block_record, full_node.blockchain
)
blockchain = AugmentedBlockchain(full_node.blockchain)
await full_node.add_block_batch(
blocks_reorg_2[-44:],
PeerInfo("0.0.0.0", 0),
ForkInfo(blocks_reorg_2[-45].height, blocks_reorg_2[-45].height, blocks_reorg_2[-45].header_hash),
ValidationState(sub_slot_iters, difficulty, None),
blockchain,
)

for wallet_node, wallet_server in wallets:
Expand Down
4 changes: 4 additions & 0 deletions tools/test_full_sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
from chia.server.ws_connection import WSChiaConnection
from chia.types.full_block import FullBlock
from chia.types.validation_state import ValidationState
from chia.util.augmented_chain import AugmentedBlockchain
from chia.util.config import load_config


Expand Down Expand Up @@ -149,6 +150,7 @@ async def run_sync_checkpoint(

block_batch = []
peer_info = peer.get_peer_logging()
blockchain = AugmentedBlockchain(full_node.blockchain)
async for r in rows:
block = FullBlock.from_bytes_unchecked(zstd.decompress(r[0]))
block_batch.append(block)
Expand All @@ -169,6 +171,7 @@ async def run_sync_checkpoint(
peer_info,
ForkInfo(fork_height, fork_height, header_hash),
ValidationState(ssi, diff, None),
blockchain
)
end_height = block_batch[-1].height
full_node.blockchain.clean_block_record(end_height - full_node.constants.BLOCKS_CACHE_SIZE)
Expand All @@ -192,6 +195,7 @@ async def run_sync_checkpoint(
peer_info,
ForkInfo(fork_height, fork_height, fork_header_hash),
ValidationState(ssi, diff, None),
blockchain
)
if not success:
raise RuntimeError("failed to ingest block batch")
Expand Down

0 comments on commit 5cf019f

Please sign in to comment.