mirror of
https://github.com/basicswap/basicswap.git
synced 2025-11-05 10:28:10 +01:00
Disable duplicate (proof of funds) balance check when sending offer.
Fix for blinded Particl offers. Add fee to reverse offer balance check.
This commit is contained in:
@@ -1734,6 +1734,22 @@ class BasicSwapTest(TestFunctions):
|
||||
|
||||
amt_swap: int = ci_from.make_int(balance_from_before, r=1)
|
||||
rate_swap: int = ci_to.make_int(2.0, r=1)
|
||||
|
||||
try:
|
||||
offer_id = swap_clients[id_offerer].postOffer(
|
||||
coin_from,
|
||||
coin_to,
|
||||
amt_swap,
|
||||
rate_swap,
|
||||
amt_swap,
|
||||
SwapTypes.XMR_SWAP,
|
||||
auto_accept_bids=True,
|
||||
)
|
||||
except Exception as e:
|
||||
assert "Insufficient funds" in str(e)
|
||||
else:
|
||||
assert False, "Should fail"
|
||||
amt_swap -= ci_from.make_int(1)
|
||||
offer_id = swap_clients[id_offerer].postOffer(
|
||||
coin_from,
|
||||
coin_to,
|
||||
@@ -1745,26 +1761,32 @@ class BasicSwapTest(TestFunctions):
|
||||
)
|
||||
wait_for_offer(test_delay_event, swap_clients[id_bidder], offer_id)
|
||||
|
||||
# First bid should work
|
||||
bid_id = swap_clients[id_bidder].postXmrBid(offer_id, amt_swap)
|
||||
|
||||
event = wait_for_event(
|
||||
test_delay_event,
|
||||
swap_clients[id_offerer],
|
||||
Concepts.BID,
|
||||
bid_id,
|
||||
event_type=EventLogTypes.ERROR,
|
||||
wait_for=60,
|
||||
)
|
||||
assert "Insufficient funds" in event.event_msg
|
||||
|
||||
wait_for_bid(
|
||||
test_delay_event,
|
||||
swap_clients[id_offerer],
|
||||
bid_id,
|
||||
BidStates.BID_RECEIVED,
|
||||
wait_for=20,
|
||||
(BidStates.BID_ACCEPTED, BidStates.XMR_SWAP_SCRIPT_COIN_LOCKED),
|
||||
wait_for=40,
|
||||
)
|
||||
|
||||
# Should be out of funds for second bid (over remaining offer value causes a hard auto accept fail)
|
||||
bid_id = swap_clients[id_bidder].postXmrBid(offer_id, amt_swap)
|
||||
wait_for_bid(
|
||||
test_delay_event,
|
||||
swap_clients[id_offerer],
|
||||
bid_id,
|
||||
BidStates.BID_AACCEPT_FAIL,
|
||||
wait_for=40,
|
||||
)
|
||||
try:
|
||||
swap_clients[id_offerer].acceptBid(bid_id)
|
||||
except Exception as e:
|
||||
assert "Insufficient funds" in str(e)
|
||||
else:
|
||||
assert False, "Should fail"
|
||||
|
||||
def test_08_insufficient_funds_rev(self):
|
||||
tla_from = self.test_coin_from.name
|
||||
logging.info("---------- Test {} Insufficient Funds (reverse)".format(tla_from))
|
||||
|
||||
@@ -1793,7 +1793,9 @@ class Test(BaseTest):
|
||||
self.prepare_balance(Coins.XMR, 20.0, 1800, 1801)
|
||||
js_w1_before = read_json_api(1801, "wallets")
|
||||
ci1_btc = swap_clients[1].ci(Coins.BTC)
|
||||
btc_total = ci1_btc.make_int(js_w1_before["BTC"]["balance"]) + ci1_btc.make_int(js_w1_before["BTC"]["unconfirmed"])
|
||||
btc_total = ci1_btc.make_int(js_w1_before["BTC"]["balance"]) + ci1_btc.make_int(
|
||||
js_w1_before["BTC"]["unconfirmed"]
|
||||
)
|
||||
|
||||
try:
|
||||
offer_id = swap_clients[1].postOffer(
|
||||
@@ -1803,7 +1805,7 @@ class Test(BaseTest):
|
||||
0,
|
||||
10 * COIN,
|
||||
SwapTypes.XMR_SWAP,
|
||||
extra_options={"amount_to": 10 * XMR_COIN}
|
||||
extra_options={"amount_to": 10 * XMR_COIN},
|
||||
)
|
||||
except Exception as e:
|
||||
assert "Insufficient funds" in str(e)
|
||||
@@ -1817,7 +1819,7 @@ class Test(BaseTest):
|
||||
0,
|
||||
10 * COIN,
|
||||
SwapTypes.XMR_SWAP,
|
||||
extra_options={"amount_to": 10 * XMR_COIN}
|
||||
extra_options={"amount_to": 10 * XMR_COIN},
|
||||
)
|
||||
|
||||
wait_for_offer(test_delay_event, swap_clients[0], offer_id)
|
||||
|
||||
Reference in New Issue
Block a user