diff --git a/src/cmds/init.py b/src/cmds/init.py index 86eebc9516..54c16b522c 100644 --- a/src/cmds/init.py +++ b/src/cmds/init.py @@ -127,16 +127,25 @@ def migrate_from( print(f"\n{old_root} found") print(f"Copying files from {old_root} to {new_root}\n") not_found = [] - for f in manifest: - old_path = old_root / f - new_path = new_root / f + + def copy_files_rec(old_path: Path, new_path: Path): if old_path.is_file(): print(f"{new_path}") mkdir(new_path.parent) shutil.copy(old_path, new_path) + elif old_path.is_dir(): + for old_path_child in old_path.iterdir(): + new_path_child = new_path / old_path_child.name + copy_files_rec(old_path_child, new_path_child) else: not_found.append(f) print(f"{old_path} not found, skipping") + + for f in manifest: + old_path = old_root / f + new_path = new_root / f + copy_files_rec(old_path, new_path) + # update config yaml with new keys config: Dict = load_config(new_root, "config.yaml") config_str: str = initial_config_file("config.yaml") @@ -146,9 +155,6 @@ def migrate_from( save_config(new_root, "config.yaml", config) - # migrate plots - # for now, we simply leave them where they are - # and make what may have been relative paths absolute if "config/trusted.key" in not_found or "config/trusted.key" in not_found: initialize_ssl(new_root) @@ -196,16 +202,13 @@ def chia_init(root_path: Path): # These are the files that will be migrated MANIFEST: List[str] = [ - "config/config.yaml", - "config/trusted.crt", - "config/trusted.key", + "config", + "db", + "wallet", ] PATH_MANIFEST_LIST: List[Tuple[Path, List[str]]] = [ - (Path(os.path.expanduser("~/.chia/beta-%s" % _)), MANIFEST) - for _ in [ - # "1.0b8", - ] + (Path(os.path.expanduser("~/.chia/beta-%s" % _)), MANIFEST) for _ in ["1.0b8"] ] for old_path, manifest in PATH_MANIFEST_LIST: diff --git a/src/server/start_service.py b/src/server/start_service.py index 590d83a834..a0b4619d9f 100644 --- a/src/server/start_service.py +++ b/src/server/start_service.py @@ -191,15 +191,13 @@ class Service: async def run(self): self.start() + await self._task await self.wait_closed() return 0 def stop(self): if not self._is_stopping: self._is_stopping = True - self._log.info("Calling service stop callback") - if self._stop_callback: - self._stop_callback() self._log.info("Closing server sockets") for _ in self._server_sockets: _.close() @@ -220,6 +218,11 @@ class Service: self._log.info("Waiting for ChiaServer to be closed") await self._server.await_closed() + + self._log.info("Calling service stop callback") + if self._stop_callback: + self._stop_callback() + if self._rpc_task: self._log.info("Waiting for RPC server") diff --git a/tests/cc_wallet/test_trades.py b/tests/cc_wallet/test_trades.py index 77062b84bb..bf81a03060 100644 --- a/tests/cc_wallet/test_trades.py +++ b/tests/cc_wallet/test_trades.py @@ -146,8 +146,8 @@ class TestCCTrades: await time_out_assert(15, cc_wallet_2.get_confirmed_balance, 30) await time_out_assert(15, cc_wallet_2.get_unconfirmed_balance, 30) - trade = await trade_manager_0.get_trade_by_id(trade_offer.trade_id) - assert TradeStatus(trade.status) is TradeStatus.CONFIRMED + trade_2 = await trade_manager_0.get_trade_by_id(trade_offer.trade_id) + assert TradeStatus(trade_2.status) is TradeStatus.CONFIRMED @pytest.mark.asyncio async def test_cc_trade_with_multiple_colours(self, wallets_prefarm): diff --git a/tests/wallet/test_backup.py b/tests/wallet/test_backup.py index f2815e536b..758530a1aa 100644 --- a/tests/wallet/test_backup.py +++ b/tests/wallet/test_backup.py @@ -1,5 +1,6 @@ import asyncio from pathlib import Path +from secrets import token_bytes import pytest @@ -60,7 +61,8 @@ class TestCCWalletBackup: await time_out_assert(15, cc_wallet.get_unconfirmed_balance, 100) # Write backup to file - file_path = Path("backup_file") + filename = f"test-backup-{token_bytes(16).hex()}" + file_path = Path(filename) await wallet_node.wallet_state_manager.create_wallet_backup(file_path) # Close wallet and restart @@ -81,3 +83,5 @@ class TestCCWalletBackup: cc_wallet_from_backup = wallet_node.wallet_state_manager.wallets[2] await time_out_assert(15, cc_wallet_from_backup.get_confirmed_balance, 100) + if file_path.exists(): + file_path.unlink()