7373from chia .wallet .trading .offer import Offer as TradingOffer
7474from chia .wallet .transaction_record import TransactionRecord
7575from chia .wallet .util .tx_config import DEFAULT_TX_CONFIG
76- from chia .wallet .wallet import Wallet
7776from chia .wallet .wallet_node import WalletNode
7877from chia .wallet .wallet_request_types import CheckOfferValidity , DLLatestSingleton
7978from chia .wallet .wallet_rpc_api import WalletRpcApi
@@ -763,6 +762,7 @@ async def test_get_owned_stores(
763762 ph = await action_scope .get_puzzle_hash (wallet_node .wallet_state_manager )
764763 for i in range (num_blocks ):
765764 await full_node_api .farm_new_transaction_block (FarmNewBlockProtocol (ph ))
765+ await full_node_api .wait_for_wallet_synced (wallet_node , timeout = 30 )
766766 funds = sum (
767767 calculate_pool_reward (uint32 (i )) + calculate_base_farmer_reward (uint32 (i )) for i in range (1 , num_blocks )
768768 )
@@ -845,6 +845,11 @@ class OfferSetup:
845845 maker : StoreSetup
846846 taker : StoreSetup
847847 full_node_api : FullNodeSimulator
848+ wallet_nodes : list [WalletNode ]
849+
850+ async def wait_for_wallets_synced (self , timeout : int = 30 ) -> None :
851+ for node in self .wallet_nodes :
852+ await self .full_node_api .wait_for_wallet_synced (wallet_node = node , timeout = timeout )
848853
849854
850855@pytest .fixture (name = "offer_setup" )
@@ -857,16 +862,17 @@ async def offer_setup_fixture(
857862 [full_node_service ], wallet_services , bt = two_wallet_nodes_services
858863 enable_batch_autoinsertion_settings = getattr (request , "param" , (True , True ))
859864 full_node_api = full_node_service ._api
860- wallets : list [Wallet ] = []
865+ wallets : list [WalletNode ] = []
861866 for wallet_service in wallet_services :
862867 wallet_node = wallet_service ._node
863868 assert wallet_node .server is not None
864869 await wallet_node .server .start_client (PeerInfo (self_hostname , full_node_api .server .get_port ()), None )
865870 assert wallet_node .wallet_state_manager is not None
866871 wallet = wallet_node .wallet_state_manager .main_wallet
867- wallets .append (wallet )
872+ wallets .append (wallet_node )
868873
869874 await full_node_api .farm_blocks_to_wallet (count = 1 , wallet = wallet , timeout = 60 )
875+ await full_node_api .wait_for_wallet_synced (wallet_node = wallet_node , timeout = 30 )
870876
871877 async with contextlib .AsyncExitStack () as exit_stack :
872878 store_setups : list [StoreSetup ] = []
@@ -951,6 +957,7 @@ async def offer_setup_fixture(
951957 data_rpc_client = taker .data_rpc_client ,
952958 ),
953959 full_node_api = full_node_api ,
960+ wallet_nodes = wallets ,
954961 )
955962
956963 maker .data_rpc_client .close ()
@@ -1018,6 +1025,7 @@ async def populate_offer_setup(offer_setup: OfferSetup, count: int) -> OfferSetu
10181025 data_rpc_client = offer_setup .taker .data_rpc_client ,
10191026 ),
10201027 full_node_api = offer_setup .full_node_api ,
1028+ wallet_nodes = offer_setup .wallet_nodes ,
10211029 )
10221030
10231031
@@ -1843,6 +1851,7 @@ async def test_make_and_cancel_offer(offer_setup: OfferSetup, reference: MakeAnd
18431851 # due to differences in chain progression, the exact offer and trade id may differ from the reference
18441852 # assert maker_response == {"success": True, "offer": reference.make_offer_response}
18451853 assert maker_response ["success" ] is True
1854+ await offer_setup .wait_for_wallets_synced ()
18461855
18471856 cancel_request = {
18481857 "trade_id" : maker_response ["offer" ]["trade_id" ],
@@ -1926,6 +1935,7 @@ async def test_make_and_cancel_offer_then_update(
19261935 # due to differences in chain progression, the exact offer and trade id may differ from the reference
19271936 # assert maker_response == {"success": True, "offer": reference.make_offer_response}
19281937 assert maker_response ["success" ] is True
1938+ await offer_setup .wait_for_wallets_synced ()
19291939
19301940 cancel_request = {
19311941 "trade_id" : maker_response ["offer" ]["trade_id" ],
@@ -2015,6 +2025,7 @@ async def test_make_and_cancel_offer_not_secure_clears_pending_roots(
20152025 # due to differences in chain progression, the exact offer and trade id may differ from the reference
20162026 # assert maker_response == {"success": True, "offer": reference.make_offer_response}
20172027 assert maker_response ["success" ] is True
2028+ await offer_setup .wait_for_wallets_synced ()
20182029
20192030 cancel_request = {
20202031 "trade_id" : maker_response ["offer" ]["trade_id" ],
@@ -2568,6 +2579,7 @@ async def populate_proof_setup(offer_setup: OfferSetup, count: int) -> OfferSetu
25682579 data_rpc_client = offer_setup .taker .data_rpc_client ,
25692580 ),
25702581 full_node_api = offer_setup .full_node_api ,
2582+ wallet_nodes = offer_setup .wallet_nodes ,
25712583 )
25722584
25732585
0 commit comments