Skip to content

Commit

Permalink
Port test_trades.py to WalletTestFramework (#18590)
Browse files Browse the repository at this point in the history
* Port `test_trade_cancellation`

* Delete obsolete test

* Port `test_trade_conflict`

* Port `test_trade_bad_spend`

* Port `test_trade_high_fee`

* Port `test_aggregated_trade_state`

* Remove DEFAULT_TX_CONFIG

* Remove accidental comments

* Use fee in our respond_to_offer call.

* Minor readability tweak.

---------

Co-authored-by: Amine Khaldi <[email protected]>
  • Loading branch information
Quexington and AmineKhaldi authored Sep 20, 2024
1 parent 8b96b23 commit 111b0e5
Show file tree
Hide file tree
Showing 3 changed files with 717 additions and 239 deletions.
13 changes: 10 additions & 3 deletions chia/_tests/environments/wallet.py
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,9 @@ class WalletTestFramework:
environments: List[WalletEnvironment]
tx_config: TXConfig = DEFAULT_TX_CONFIG

async def process_pending_states(self, state_transitions: List[WalletStateTransition]) -> None:
async def process_pending_states(
self, state_transitions: List[WalletStateTransition], invalid_transactions: List[bytes32] = []
) -> None:
"""
This is the main entry point for processing state in wallet tests. It does the following things:
Expand Down Expand Up @@ -302,7 +304,11 @@ async def process_pending_states(self, state_transitions: List[WalletStateTransi
for i, env in enumerate(self.environments):
await self.full_node.wait_for_wallet_synced(wallet_node=env.node, timeout=20)
try:
pending_txs.append(await env.wait_for_transactions_to_settle(self.full_node))
pending_txs.append(
await env.wait_for_transactions_to_settle(
self.full_node, _exclude_from_mempool_check=invalid_transactions
)
)
except TimeoutError: # pragma: no cover
raise TimeoutError(f"All TXs for env-{i} were not found in mempool or marked as in mempool")
for i, (env, transition) in enumerate(zip(self.environments, state_transitions)):
Expand All @@ -328,7 +334,8 @@ async def process_pending_states(self, state_transitions: List[WalletStateTransi
)
try:
await env.wait_for_transactions_to_settle(
self.full_node, _exclude_from_mempool_check=[tx.name for tx in local_pending_txs]
self.full_node,
_exclude_from_mempool_check=invalid_transactions + [tx.name for tx in local_pending_txs],
)
except TimeoutError: # pragma: no cover
raise TimeoutError(f"All TXs for env-{i} were not found in mempool or marked as in mempool")
Expand Down
Loading

0 comments on commit 111b0e5

Please sign in to comment.