mirror of
https://github.com/RoboSats/robosats.git
synced 2025-07-21 02:03:14 +00:00
Fix tests review
This commit is contained in:
@ -4,7 +4,7 @@ import uuid
|
|||||||
|
|
||||||
from secp256k1 import PrivateKey
|
from secp256k1 import PrivateKey
|
||||||
from asgiref.sync import sync_to_async
|
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 api.models import Order
|
||||||
from decouple import config
|
from decouple import config
|
||||||
|
|
||||||
@ -115,13 +115,6 @@ class Nostr:
|
|||||||
return ["lightning"]
|
return ["lightning"]
|
||||||
return False
|
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:
|
def sign_message(text: str) -> str:
|
||||||
try:
|
try:
|
||||||
keys = Keys.parse(config("NOSTR_NSEC", cast=str))
|
keys = Keys.parse(config("NOSTR_NSEC", cast=str))
|
||||||
|
@ -1066,15 +1066,9 @@ class ReviewView(APIView):
|
|||||||
status.HTTP_400_BAD_REQUEST,
|
status.HTTP_400_BAD_REQUEST,
|
||||||
)
|
)
|
||||||
if not request.user.robot.nostr_pubkey:
|
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.nostr_pubkey = pubkey
|
||||||
request.user.robot.save(update_fields=["nostr_pubkey"])
|
request.user.robot.save(update_fields=["nostr_pubkey"])
|
||||||
else:
|
|
||||||
return Response(
|
|
||||||
{"bad_request": "Invalid hex pubkey"},
|
|
||||||
status.HTTP_400_BAD_REQUEST,
|
|
||||||
)
|
|
||||||
if request.user.robot.nostr_pubkey != pubkey:
|
if request.user.robot.nostr_pubkey != pubkey:
|
||||||
return Response(
|
return Response(
|
||||||
{"bad_request": "Wrong hex pubkey"},
|
{"bad_request": "Wrong hex pubkey"},
|
||||||
|
@ -992,6 +992,8 @@ class TradeTest(BaseAPITestCase):
|
|||||||
trade.process_payouts(mine_a_block=True)
|
trade.process_payouts(mine_a_block=True)
|
||||||
|
|
||||||
trade.get_review(trade.maker_index)
|
trade.get_review(trade.maker_index)
|
||||||
|
data = trade.response.json()
|
||||||
|
print(data)
|
||||||
self.assertEqual(trade.response.status_code, 200)
|
self.assertEqual(trade.response.status_code, 200)
|
||||||
nostr_pubkey = read_file(f"tests/robots/{trade.maker_index}/nostr_pubkey")
|
nostr_pubkey = read_file(f"tests/robots/{trade.maker_index}/nostr_pubkey")
|
||||||
data = trade.response.json()
|
data = trade.response.json()
|
||||||
|
Reference in New Issue
Block a user