From 2ee48f3108f48d97feeb2cb3ddc8e505a4aa571e Mon Sep 17 00:00:00 2001 From: koalasat Date: Sat, 26 Apr 2025 18:49:37 +0200 Subject: [PATCH] Fix tests review --- api/nostr.py | 9 +-------- api/views.py | 12 +++--------- tests/test_trade_pipeline.py | 2 ++ 3 files changed, 6 insertions(+), 17 deletions(-) diff --git a/api/nostr.py b/api/nostr.py index 64b50cb2..63174c7e 100644 --- a/api/nostr.py +++ b/api/nostr.py @@ -4,7 +4,7 @@ import uuid from secp256k1 import PrivateKey from asgiref.sync import sync_to_async -from nostr_sdk import Keys, Client, EventBuilder, NostrSigner, Kind, Tag, PublicKey +from nostr_sdk import Keys, Client, EventBuilder, NostrSigner, Kind, Tag from api.models import Order from decouple import config @@ -115,13 +115,6 @@ class Nostr: return ["lightning"] return False - def is_valid_public_key(public_key_hex): - try: - PublicKey.from_hex(public_key_hex) - return True - except Exception: - return False - def sign_message(text: str) -> str: try: keys = Keys.parse(config("NOSTR_NSEC", cast=str)) diff --git a/api/views.py b/api/views.py index e078b532..e6d17971 100644 --- a/api/views.py +++ b/api/views.py @@ -1066,15 +1066,9 @@ class ReviewView(APIView): status.HTTP_400_BAD_REQUEST, ) if not request.user.robot.nostr_pubkey: - verified = Nostr.is_valid_public_key(pubkey) - if verified: - request.user.robot.nostr_pubkey = pubkey - request.user.robot.save(update_fields=["nostr_pubkey"]) - else: - return Response( - {"bad_request": "Invalid hex pubkey"}, - status.HTTP_400_BAD_REQUEST, - ) + request.user.robot.nostr_pubkey = pubkey + request.user.robot.save(update_fields=["nostr_pubkey"]) + if request.user.robot.nostr_pubkey != pubkey: return Response( {"bad_request": "Wrong hex pubkey"}, diff --git a/tests/test_trade_pipeline.py b/tests/test_trade_pipeline.py index e9c0e9cd..d02b4b43 100644 --- a/tests/test_trade_pipeline.py +++ b/tests/test_trade_pipeline.py @@ -992,6 +992,8 @@ class TradeTest(BaseAPITestCase): trade.process_payouts(mine_a_block=True) trade.get_review(trade.maker_index) + data = trade.response.json() + print(data) self.assertEqual(trade.response.status_code, 200) nostr_pubkey = read_file(f"tests/robots/{trade.maker_index}/nostr_pubkey") data = trade.response.json()