fixes up code
This commit is contained in:
parent
4d35bf3b9d
commit
bdaa9b00d1
3 changed files with 8 additions and 5 deletions
|
@ -94,9 +94,8 @@ def insert_comment(conn: sqlite3.Connection, claim_id: str = None, comment: str
|
||||||
channel_id: str = None, signature: str = None, signing_ts: str = None,
|
channel_id: str = None, signature: str = None, signing_ts: str = None,
|
||||||
parent_id: str = None) -> str:
|
parent_id: str = None) -> str:
|
||||||
timestamp = int(time.time())
|
timestamp = int(time.time())
|
||||||
prehash = ':'.join((claim_id, comment, str(timestamp),))
|
prehash = b':'.join((claim_id.encode(), comment.encode(), str(timestamp).encode(),))
|
||||||
prehash = bytes(prehash.encode('utf-8'))
|
comment_id = nacl.hash.sha256(prehash).decode()
|
||||||
comment_id = nacl.hash.sha256(prehash).decode('utf-8')
|
|
||||||
with conn:
|
with conn:
|
||||||
conn.execute(
|
conn.execute(
|
||||||
"""
|
"""
|
||||||
|
|
|
@ -2,8 +2,10 @@ import logging
|
||||||
import sqlite3
|
import sqlite3
|
||||||
|
|
||||||
from src.database import get_comment_or_none
|
from src.database import get_comment_or_none
|
||||||
from src.database import insert_comment, insert_channel
|
from src.database import insert_comment
|
||||||
from src.misc import validate_channel, validate_signature
|
from src.database import insert_channel
|
||||||
|
from src.misc import validate_channel
|
||||||
|
from src.misc import validate_signature
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
|
@ -75,6 +75,7 @@ class TestCommentCreation(DatabaseTestCase):
|
||||||
signing_ts='asdasd'
|
signing_ts='asdasd'
|
||||||
)
|
)
|
||||||
self.assertIsNotNone(comment)
|
self.assertIsNotNone(comment)
|
||||||
|
self.assertIn('signing_ts', comment)
|
||||||
previous_id = comment['comment_id']
|
previous_id = comment['comment_id']
|
||||||
reply = create_comment(
|
reply = create_comment(
|
||||||
conn=self.conn,
|
conn=self.conn,
|
||||||
|
@ -88,6 +89,7 @@ class TestCommentCreation(DatabaseTestCase):
|
||||||
)
|
)
|
||||||
self.assertIsNotNone(reply)
|
self.assertIsNotNone(reply)
|
||||||
self.assertEqual(reply['parent_id'], comment['comment_id'])
|
self.assertEqual(reply['parent_id'], comment['comment_id'])
|
||||||
|
self.assertIn('signing_ts', reply)
|
||||||
|
|
||||||
def test04UsernameVariations(self):
|
def test04UsernameVariations(self):
|
||||||
self.assertRaises(
|
self.assertRaises(
|
||||||
|
|
Loading…
Reference in a new issue