mirror of
https://github.com/RoboSats/robosats.git
synced 2025-01-18 12:11:35 +00:00
Add pause/unpause tests
This commit is contained in:
parent
f3e1e576d4
commit
f271d59172
@ -739,7 +739,9 @@ class Logics:
|
||||
return True, context
|
||||
|
||||
context["swap_allowed"] = True
|
||||
context["suggested_mining_fee_rate"] = order.payout_tx.suggested_mining_fee_rate
|
||||
context["suggested_mining_fee_rate"] = float(
|
||||
order.payout_tx.suggested_mining_fee_rate
|
||||
)
|
||||
context["swap_fee_rate"] = order.payout_tx.swap_fee_rate
|
||||
|
||||
return True, context
|
||||
|
@ -298,7 +298,7 @@ class OrderDetailSerializer(serializers.ModelSerializer):
|
||||
swap_failure_reason = serializers.CharField(
|
||||
required=False, help_text="Reason for why on-chain swap is not available"
|
||||
)
|
||||
suggested_mining_fee_rate = serializers.IntegerField(
|
||||
suggested_mining_fee_rate = serializers.FloatField(
|
||||
required=False, help_text="fee in sats/vbyte for the on-chain swap"
|
||||
)
|
||||
swap_fee_rate = serializers.FloatField(
|
||||
|
@ -1581,7 +1581,8 @@ components:
|
||||
type: string
|
||||
description: Reason for why on-chain swap is not available
|
||||
suggested_mining_fee_rate:
|
||||
type: integer
|
||||
type: number
|
||||
format: double
|
||||
description: fee in sats/vbyte for the on-chain swap
|
||||
swap_fee_rate:
|
||||
type: number
|
||||
|
@ -272,7 +272,9 @@ def pay_invoice(node_name, invoice):
|
||||
f'http://localhost:{node["port"]}/v1/channels/transactions',
|
||||
json=data,
|
||||
headers=node["headers"],
|
||||
timeout=0.3, # 0.15s is enough for LND to LND hodl ACCEPT.
|
||||
# 0.15s is enough for LND to LND hodl ACCEPT
|
||||
# 0.4s is enough for LND to CLN hodl ACCEPT
|
||||
timeout=0.2 if LNVENDOR == "LND" else 0.8,
|
||||
)
|
||||
except ReadTimeout:
|
||||
# Request to pay hodl invoice has timed out: that's good!
|
||||
|
@ -107,7 +107,7 @@ class TradeTest(BaseAPITestCase):
|
||||
self.assertIsInstance(balance_log.time, datetime)
|
||||
self.assertTrue(balance_log.total > 0)
|
||||
self.assertTrue(balance_log.ln_local > 0)
|
||||
self.assertEqual(balance_log.ln_local_unsettled, 0)
|
||||
self.assertTrue(balance_log.ln_local_unsettled >= 0)
|
||||
self.assertTrue(balance_log.ln_remote > 0)
|
||||
self.assertEqual(balance_log.ln_remote_unsettled, 0)
|
||||
self.assertTrue(balance_log.onchain_total > 0)
|
||||
@ -306,6 +306,15 @@ class TradeTest(BaseAPITestCase):
|
||||
|
||||
return response
|
||||
|
||||
def pause_order(self, order_id, robot_index=1):
|
||||
path = reverse("order")
|
||||
params = f"?order_id={order_id}"
|
||||
headers = self.get_robot_auth(robot_index)
|
||||
body = {"action": "pause"}
|
||||
response = self.client.post(path + params, body, **headers)
|
||||
|
||||
return response
|
||||
|
||||
def test_get_order_created(self):
|
||||
"""
|
||||
Tests the creation of an order and the first request to see details,
|
||||
@ -403,6 +412,31 @@ class TradeTest(BaseAPITestCase):
|
||||
# Cancel order to avoid leaving pending HTLCs after a successful test
|
||||
self.cancel_order(data["id"])
|
||||
|
||||
def test_pause_unpause_order(self):
|
||||
"""
|
||||
Tests pausing and unpausing a public order
|
||||
"""
|
||||
maker_form = self.maker_form_buy_with_range
|
||||
# Get order
|
||||
response = self.make_and_publish_order(maker_form)
|
||||
|
||||
# PAUSE
|
||||
response = self.pause_order(response.json()["id"])
|
||||
data = response.json()
|
||||
|
||||
self.assertResponse(response)
|
||||
self.assertEqual(data["status_message"], Order.Status(Order.Status.PAU).label)
|
||||
|
||||
# UNPAUSE
|
||||
response = self.pause_order(response.json()["id"])
|
||||
data = response.json()
|
||||
|
||||
self.assertResponse(response)
|
||||
self.assertEqual(data["status_message"], Order.Status(Order.Status.PUB).label)
|
||||
|
||||
# Cancel order to avoid leaving pending HTLCs after a successful test
|
||||
self.cancel_order(data["id"])
|
||||
|
||||
def take_order(self, order_id, amount, robot_index=2):
|
||||
path = reverse("order")
|
||||
params = f"?order_id={order_id}"
|
||||
@ -513,7 +547,7 @@ class TradeTest(BaseAPITestCase):
|
||||
|
||||
self.assertEqual(data["status_message"], Order.Status(Order.Status.WF2).label)
|
||||
self.assertTrue(data["swap_allowed"])
|
||||
self.assertIsInstance(data["suggested_mining_fee_rate"], int)
|
||||
self.assertIsInstance(data["suggested_mining_fee_rate"], float)
|
||||
self.assertIsInstance(data["swap_fee_rate"], float)
|
||||
self.assertTrue(data["suggested_mining_fee_rate"] > 0)
|
||||
self.assertTrue(data["swap_fee_rate"] > 0)
|
||||
|
Loading…
Reference in New Issue
Block a user