Skip to content

Commit

Permalink
Added tests to wxdai deposit/withdraw random account (#460)
Browse files Browse the repository at this point in the history
  • Loading branch information
gabrielfior authored Oct 3, 2024
1 parent 3a0883a commit b48f8f1
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions tests_integration_with_local_chain/markets/omen/test_omen.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
HexStr,
OutcomeStr,
Wei,
private_key_type,
xDai,
xdai_type,
)
Expand Down Expand Up @@ -59,6 +60,7 @@
from prediction_market_agent_tooling.tools.hexbytes_custom import HexBytes
from prediction_market_agent_tooling.tools.utils import utcnow
from prediction_market_agent_tooling.tools.web3_utils import wei_to_xdai, xdai_to_wei
from tests_integration_with_local_chain.conftest import create_and_fund_random_account

DEFAULT_REASON = "Test logic need to be rewritten for usage of local chain, see ToDos"

Expand Down Expand Up @@ -355,6 +357,35 @@ def get_market_outcome_tokens() -> TokenAmount:
assert tx["from"] == api_keys.bet_from_address


def test_deposit_and_withdraw_wxdai(local_web3: Web3, test_keys: APIKeys) -> None:
deposit_amount = xDai(10)
fresh_account = create_and_fund_random_account(
private_key=test_keys.bet_from_private_key,
web3=local_web3,
deposit_amount=xDai(deposit_amount * 2), # 2* for safety
)

api_keys = APIKeys(
BET_FROM_PRIVATE_KEY=private_key_type(fresh_account.key.hex()),
SAFE_ADDRESS=None,
)
wxdai = WrappedxDaiContract()
wxdai.deposit(
api_keys=api_keys, amount_wei=xdai_to_wei(deposit_amount), web3=local_web3
)
balance = get_balances(address=fresh_account.address, web3=local_web3)
assert balance.wxdai == deposit_amount

wxdai.withdraw(
api_keys=api_keys,
amount_wei=xdai_to_wei(balance.wxdai),
web3=local_web3,
)

balance = get_balances(address=fresh_account.address, web3=local_web3)
assert balance.wxdai == xDai(0)


@pytest.mark.parametrize(
"collateral_token_address, expected_symbol",
[
Expand Down

0 comments on commit b48f8f1

Please sign in to comment.