Skip to content

Commit

Permalink
Check tests
Browse files Browse the repository at this point in the history
  • Loading branch information
KoalaSat committed Jun 25, 2024
1 parent 5bdef8e commit 188e3ff
Showing 1 changed file with 41 additions and 20 deletions.
61 changes: 41 additions & 20 deletions tests/test_trade_pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -352,11 +352,6 @@ def test_publish_order(self):
self.assertIsInstance(public_data["price_now"], float)
self.assertIsInstance(data["satoshis_now"], int)

# Cancel order to avoid leaving pending HTLCs after a successful test
trade.cancel_order()

self.assert_order_logs(data["id"])

maker_headers = trade.get_robot_auth(trade.maker_index)
response = self.client.get(reverse("notifications"), **maker_headers)
self.assertResponse(response)
Expand All @@ -367,6 +362,11 @@ def test_publish_order(self):
f"✅ Hey {data['maker_nick']}, your order with ID {trade.order_id} is public in the order book.",
)

# Cancel order to avoid leaving pending HTLCs after a successful test
trade.cancel_order()

self.assert_order_logs(data["id"])

def test_pause_unpause_order(self):
"""
Tests pausing and unpausing a public order
Expand Down Expand Up @@ -440,21 +440,30 @@ def test_make_and_take_order(self):
self.assertFalse(data["taker_locked"])
self.assertFalse(data["escrow_locked"])

# Cancel order to avoid leaving pending HTLCs after a successful test
trade.cancel_order()

self.assert_order_logs(data["id"])

maker_headers = trade.get_robot_auth(trade.maker_index)
response = self.client.get(reverse("notifications"), **maker_headers)
self.assertResponse(response)
notifications_data = list(response.json())
self.assertEqual(notifications_data[0]["order_id"], trade.order_id)
self.assertEqual(
notifications_data[0]["title"],
f"✅ Hey {data['maker_nick']}, your order with ID {trade.order_id} is public in the order book.",
f"✅ Hey {data['maker_nick']}, your or",
)
taker_headers = trade.get_robot_auth(trade.taker_index)
response = self.client.get(reverse("notifications"), **taker_headers)
self.assertResponse(response)
notifications_data = list(response.json())
self.assertEqual(notifications_data[0]["order_id"], trade.order_id)
self.assertEqual(
notifications_data[0]["title"],
"cor",
)

# Cancel order to avoid leaving pending HTLCs after a successful test
trade.cancel_order()

self.assert_order_logs(data["id"])

def test_make_and_lock_contract(self):
"""
Tests a trade from order creation to taker bond locked.
Expand Down Expand Up @@ -485,7 +494,7 @@ def test_make_and_lock_contract(self):
self.assertEqual(notifications_data[0]["order_id"], trade.order_id)
self.assertEqual(
notifications_data[0]["title"],
f"✅ Hey {data['maker_nick']}, your order with ID {trade.order_id} is public in the order book.",
f"✅ Hey {data['maker_nick']}, your order wi",
)

# Maker GET
Expand Down Expand Up @@ -551,7 +560,7 @@ def test_trade_to_locked_escrow(self):
self.assertEqual(notifications_data[0]["order_id"], trade.order_id)
self.assertEqual(
notifications_data[0]["title"],
f"✅ Hey {data['maker_nick']}, your order with ID {trade.order_id} is public in the order book.",
f"✅ Hey {data['maker_nick']}, your order wit.",
)

# Cancel order to avoid leaving pending HTLCs after a successful test
Expand Down Expand Up @@ -584,7 +593,7 @@ def test_trade_to_submitted_address(self):
self.assertEqual(notifications_data[0]["order_id"], trade.order_id)
self.assertEqual(
notifications_data[0]["title"],
f"✅ Hey {data['maker_nick']}, your order with ID {trade.order_id} is public in the order book.",
f"✅ Hey {data['maker_nick']}, your order wi",
)

# Cancel order to avoid leaving pending HTLCs after a successful test
Expand Down Expand Up @@ -650,7 +659,7 @@ def test_trade_to_confirm_fiat_sent_LN(self):
self.assertEqual(notifications_data[0]["order_id"], trade.order_id)
self.assertEqual(
notifications_data[0]["title"],
f"✅ Hey {data['maker_nick']}, your order with ID {trade.order_id} is public in the order book.",
f"✅ Hey {data['maker_nick']}, your order w",
)

# Cancel order to avoid leaving pending HTLCs after a successful test
Expand Down Expand Up @@ -699,7 +708,7 @@ def test_trade_to_confirm_fiat_received_LN(self):
self.assertEqual(notifications_data[0]["order_id"], trade.order_id)
self.assertEqual(
notifications_data[0]["title"],
f"✅ Hey {data['maker_nick']}, your order with ID {trade.order_id} is public in the order book.",
f"✅ Hey {data['maker_nick']}, your o",
)

def test_successful_LN(self):
Expand Down Expand Up @@ -777,6 +786,17 @@ def test_cancel_public_order(self):
data["bad_request"], "This order has been cancelled by the maker"
)

maker_headers = trade.get_robot_auth(trade.maker_index)
maker_nick = read_file(f"tests/robots/{trade.maker_index}/nickname")
response = self.client.get(reverse("notifications"), **maker_headers)
self.assertResponse(response)
notifications_data = list(response.json())
self.assertEqual(notifications_data[0]["order_id"], trade.order_id)
self.assertEqual(
notifications_data[0]["title"],
f"❌ Hey {maker_nick}, you have cancelled your public order with ID {trade.order_id}.",
)

def test_collaborative_cancel_order_in_chat(self):
"""
Tests the collaborative cancellation of an order in the chat state
Expand Down Expand Up @@ -810,13 +830,14 @@ def test_collaborative_cancel_order_in_chat(self):
)

maker_headers = trade.get_robot_auth(trade.maker_index)
maker_nick = read_file(f"tests/robots/{trade.maker_index}/nickname")
response = self.client.get(reverse("notifications"), **maker_headers)
self.assertResponse(response)
notifications_data = list(response.json())
self.assertEqual(notifications_data[0]["order_id"], trade.order_id)
self.assertEqual(
notifications_data[0]["title"],
f" Hey your order with ID {trade.order_id} is public in the order book.",
f" Hey {maker_nick}, your order with ID {trade.order_id} has been collaboratively cancelled.",
)

def test_created_order_expires(self):
Expand Down Expand Up @@ -891,7 +912,7 @@ def test_public_order_expires(self):
self.assertEqual(notifications_data[0]["order_id"], trade.order_id)
self.assertEqual(
notifications_data[0]["title"],
f"✅ Hey {data['maker_nick']}, your order with ID {trade.order_id} is public in the order book.",
f"✅ Hey {data['maker_nick']}, your order wit",
)

def test_taken_order_expires(self):
Expand Down Expand Up @@ -936,7 +957,7 @@ def test_taken_order_expires(self):
self.assertEqual(notifications_data[0]["order_id"], trade.order_id)
self.assertEqual(
notifications_data[0]["title"],
f"✅ Hey {data['maker_nick']}, your order with ID {trade.order_id} is public in the order book.",
f"✅ Hey {data['maker_nick']}, your or",
)

def test_escrow_locked_expires(self):
Expand Down Expand Up @@ -1034,7 +1055,7 @@ def test_chat(self):
self.assertEqual(notifications_data[0]["order_id"], trade.order_id)
self.assertEqual(
notifications_data[0]["title"],
f"✅ Hey your order with ID {trade.order_id} is public in the order book.",
"✅ Hey your order wit",
)

# Get the two chatroom messages as maker
Expand Down

0 comments on commit 188e3ff

Please sign in to comment.