mirror of
https://github.com/Chia-Network/chia-blockchain.git
synced 2024-11-11 01:28:17 +03:00
Ms.fix puzzle store (#9606)
* Fix puzzle store to 100 addresses * Remove unnecessary function call * Lint
This commit is contained in:
parent
234d121c2a
commit
2f86d0eee1
@ -198,7 +198,6 @@ class WalletNode:
|
||||
if backup_settings.user_initialized is False:
|
||||
if new_wallet is True:
|
||||
await self.wallet_state_manager.user_settings.user_created_new_wallet()
|
||||
self.wallet_state_manager.new_wallet = True
|
||||
elif skip_backup_import is True:
|
||||
await self.wallet_state_manager.user_settings.user_skipped_backup_import()
|
||||
elif backup_file is not None:
|
||||
|
@ -129,7 +129,6 @@ class WalletStateManager:
|
||||
name: str = None,
|
||||
):
|
||||
self = WalletStateManager()
|
||||
self.new_wallet = False
|
||||
self.config = config
|
||||
self.constants = constants
|
||||
self.server = server
|
||||
@ -283,10 +282,7 @@ class WalletStateManager:
|
||||
# This handles the case where the database is empty
|
||||
unused = uint32(0)
|
||||
|
||||
if self.new_wallet:
|
||||
to_generate = self.config["initial_num_public_keys_new_wallet"]
|
||||
else:
|
||||
to_generate = self.config["initial_num_public_keys"]
|
||||
to_generate = self.config["initial_num_public_keys"]
|
||||
|
||||
for wallet_id in targets:
|
||||
target_wallet = self.wallets[wallet_id]
|
||||
|
@ -130,6 +130,7 @@ async def setup_wallet_node(
|
||||
introducer_port=None,
|
||||
key_seed=None,
|
||||
starting_height=None,
|
||||
initial_num_public_keys=5,
|
||||
):
|
||||
with TempKeyring() as keychain:
|
||||
config = bt.config["wallet"]
|
||||
@ -137,7 +138,7 @@ async def setup_wallet_node(
|
||||
config["rpc_port"] = port + 1000
|
||||
if starting_height is not None:
|
||||
config["starting_height"] = starting_height
|
||||
config["initial_num_public_keys"] = 5
|
||||
config["initial_num_public_keys"] = initial_num_public_keys
|
||||
|
||||
entropy = token_bytes(32)
|
||||
if key_seed is None:
|
||||
@ -413,6 +414,7 @@ async def setup_simulators_and_wallets(
|
||||
starting_height=None,
|
||||
key_seed=None,
|
||||
starting_port=50000,
|
||||
initial_num_public_keys=5,
|
||||
):
|
||||
with TempKeyring() as keychain1, TempKeyring() as keychain2:
|
||||
simulators: List[FullNodeAPI] = []
|
||||
@ -452,6 +454,7 @@ async def setup_simulators_and_wallets(
|
||||
None,
|
||||
key_seed=seed,
|
||||
starting_height=starting_height,
|
||||
initial_num_public_keys=initial_num_public_keys,
|
||||
)
|
||||
wallets.append(await wlt.__anext__())
|
||||
node_iters.append(wlt)
|
||||
|
@ -5,8 +5,11 @@ from chia.consensus.block_rewards import calculate_base_farmer_reward, calculate
|
||||
from chia.protocols.full_node_protocol import RespondBlock
|
||||
from chia.server.server import ChiaServer
|
||||
from chia.simulator.simulator_protocol import FarmNewBlockProtocol, ReorgProtocol
|
||||
from chia.types.blockchain_format.program import Program
|
||||
from chia.types.blockchain_format.sized_bytes import bytes32
|
||||
from chia.types.peer_info import PeerInfo
|
||||
from chia.util.ints import uint16, uint32, uint64
|
||||
from chia.wallet.derive_keys import master_sk_to_wallet_sk
|
||||
from chia.wallet.util.transaction_type import TransactionType
|
||||
from chia.wallet.transaction_record import TransactionRecord
|
||||
from chia.wallet.wallet_node import WalletNode
|
||||
@ -28,6 +31,11 @@ class TestWalletSimulator:
|
||||
async for _ in setup_simulators_and_wallets(1, 1, {}):
|
||||
yield _
|
||||
|
||||
@pytest.fixture(scope="function")
|
||||
async def wallet_node_100_pk(self):
|
||||
async for _ in setup_simulators_and_wallets(1, 1, {}, initial_num_public_keys=100):
|
||||
yield _
|
||||
|
||||
@pytest.fixture(scope="function")
|
||||
async def two_wallet_nodes(self):
|
||||
async for _ in setup_simulators_and_wallets(1, 2, {}):
|
||||
@ -626,3 +634,40 @@ class TestWalletSimulator:
|
||||
add_2_coin_record_full_node = await full_node_api.full_node.coin_store.get_coin_record(added_1.name())
|
||||
assert add_2_coin_record_full_node is not None
|
||||
assert add_2_coin_record_full_node.confirmed_block_index > 0
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_address_sliding_window(self, wallet_node_100_pk):
|
||||
full_nodes, wallets = wallet_node_100_pk
|
||||
full_node_api = full_nodes[0]
|
||||
server_1: ChiaServer = full_node_api.full_node.server
|
||||
wallet_node, server_2 = wallets[0]
|
||||
|
||||
wallet = wallet_node.wallet_state_manager.main_wallet
|
||||
|
||||
await server_2.start_client(PeerInfo(self_hostname, uint16(server_1._port)), None)
|
||||
|
||||
puzzle_hashes = []
|
||||
for i in range(211):
|
||||
pubkey = master_sk_to_wallet_sk(wallet_node.wallet_state_manager.private_key, i).get_g1()
|
||||
puzzle: Program = wallet.puzzle_for_pk(bytes(pubkey))
|
||||
puzzle_hash: bytes32 = puzzle.get_tree_hash()
|
||||
puzzle_hashes.append(puzzle_hash)
|
||||
|
||||
# TODO: fix after merging new wallet. These 210 and 114 should be found
|
||||
await full_node_api.farm_new_transaction_block(FarmNewBlockProtocol(32 * b"0"))
|
||||
await full_node_api.farm_new_transaction_block(FarmNewBlockProtocol(puzzle_hashes[0]))
|
||||
await full_node_api.farm_new_transaction_block(FarmNewBlockProtocol(puzzle_hashes[210]))
|
||||
await full_node_api.farm_new_transaction_block(FarmNewBlockProtocol(puzzle_hashes[114]))
|
||||
await full_node_api.farm_new_transaction_block(FarmNewBlockProtocol(32 * b"0"))
|
||||
|
||||
await time_out_assert(5, wallet.get_confirmed_balance, 2 * 10 ** 12)
|
||||
|
||||
await full_node_api.farm_new_transaction_block(FarmNewBlockProtocol(puzzle_hashes[50]))
|
||||
await full_node_api.farm_new_transaction_block(FarmNewBlockProtocol(32 * b"0"))
|
||||
await time_out_assert(5, wallet.get_confirmed_balance, 4 * 10 ** 12)
|
||||
|
||||
await full_node_api.farm_new_transaction_block(FarmNewBlockProtocol(puzzle_hashes[113]))
|
||||
await full_node_api.farm_new_transaction_block(FarmNewBlockProtocol(puzzle_hashes[209]))
|
||||
await full_node_api.farm_new_transaction_block(FarmNewBlockProtocol(32 * b"0"))
|
||||
|
||||
await time_out_assert(5, wallet.get_confirmed_balance, 8 * 10 ** 12)
|
||||
|
Loading…
Reference in New Issue
Block a user