mirror of
https://github.com/RoboSats/robosats.git
synced 2025-07-19 01:03:20 +00:00
Fix tests review
This commit is contained in:
@ -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))
|
||||
|
12
api/views.py
12
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"},
|
||||
|
@ -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()
|
||||
|
Reference in New Issue
Block a user