Merge pull request #12095 from Chia-Network/ms.not_synced

Return not synced if no conncetions
This commit is contained in:
William Allen
2022-06-27 09:59:37 -05:00
committed by GitHub
3 changed files with 15 additions and 3 deletions
+3
View File
@@ -450,6 +450,9 @@ class WalletStateManager:
self.pending_tx_callback()
async def synced(self):
if len(self.server.get_full_node_connections()) == 0:
return False
latest = await self.blockchain.get_peak_block()
if latest is None:
return False
+5 -1
View File
@@ -20,10 +20,14 @@ from tests.time_out_assert import time_out_assert
log = logging.getLogger(__name__)
async def disconnect_all_and_reconnect(server: ChiaServer, reconnect_to: ChiaServer, self_hostname: str) -> bool:
async def disconnect_all(server: ChiaServer) -> None:
cons = list(server.all_connections.values())[:]
for con in cons:
await con.close()
async def disconnect_all_and_reconnect(server: ChiaServer, reconnect_to: ChiaServer, self_hostname: str) -> bool:
await disconnect_all(server)
return await server.start_client(PeerInfo(self_hostname, uint16(reconnect_to._port)), None)
+7 -2
View File
@@ -6,7 +6,7 @@ from chia.protocols import full_node_protocol
from chia.simulator.simulator_protocol import FarmNewBlockProtocol
from chia.types.peer_info import PeerInfo
from chia.util.ints import uint16, uint32
from tests.connection_utils import disconnect_all_and_reconnect
from tests.connection_utils import disconnect_all, disconnect_all_and_reconnect
from tests.pools.test_pool_rpc import wallet_is_synced
from tests.setup_nodes import test_constants
from tests.time_out_assert import time_out_assert
@@ -46,7 +46,9 @@ class TestWalletSync:
# Tests a reorg with the wallet
num_blocks = 30
blocks_reorg = bt.get_consecutive_blocks(num_blocks, block_list_input=default_400_blocks[:-5])
blocks_reorg = bt.get_consecutive_blocks(
num_blocks, block_list_input=default_400_blocks[:-5], current_time=True
)
for i in range(1, len(blocks_reorg)):
await full_node_api.full_node.respond_block(full_node_protocol.RespondBlock(blocks_reorg[i]))
@@ -57,6 +59,9 @@ class TestWalletSync:
await time_out_assert(
100, wallet_height_at_least, True, wallet_node, len(default_400_blocks) + num_blocks - 5 - 1
)
await time_out_assert(20, wallet_node.wallet_state_manager.synced)
await disconnect_all(wallet_server)
assert not (await wallet_node.wallet_state_manager.synced())
@pytest.mark.asyncio
async def test_almost_recent(self, bt, two_wallet_nodes, default_400_blocks, self_hostname):