From 188e3ff6c93a6217e06a825e598a42388c57c462 Mon Sep 17 00:00:00 2001 From: KoalaSat Date: Tue, 25 Jun 2024 11:47:02 +0200 Subject: [PATCH] Check tests --- tests/test_trade_pipeline.py | 61 ++++++++++++++++++++++++------------ 1 file changed, 41 insertions(+), 20 deletions(-) diff --git a/tests/test_trade_pipeline.py b/tests/test_trade_pipeline.py index 492da75b7..90c22a6d3 100644 --- a/tests/test_trade_pipeline.py +++ b/tests/test_trade_pipeline.py @@ -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) @@ -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 @@ -440,11 +440,6 @@ 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) @@ -452,9 +447,23 @@ def test_make_and_take_order(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", + ) + 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. @@ -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 @@ -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 @@ -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 @@ -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 @@ -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): @@ -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 @@ -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): @@ -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): @@ -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): @@ -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