From a845aecda125f8f31679d1c56c918cd0509682e7 Mon Sep 17 00:00:00 2001 From: nolash Date: Wed, 5 Aug 2020 19:51:22 +0200 Subject: [PATCH] Add password to test --- src/keystore/postgres.py | 8 +++++++- test/test_database.py | 2 +- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/keystore/postgres.py b/src/keystore/postgres.py index c7c0c16..fc3b8ec 100644 --- a/src/keystore/postgres.py +++ b/src/keystore/postgres.py @@ -15,6 +15,11 @@ logging.basicConfig(level=logging.DEBUG) logg = logging.getLogger(__file__) + +def to_bytes(x): + return x.encode('utf-8') + + class ReferenceDatabase: @@ -52,7 +57,8 @@ class ReferenceDatabase: h = sha3.keccak_256() h.update(self.symmetric_key) if password != None: - h.update(password) + password_bytes = to_bytes(password) + h.update(password_bytes) g = h.digest() return Fernet(base64.b64encode(g)) diff --git a/test/test_database.py b/test/test_database.py index c6356f8..777b882 100644 --- a/test/test_database.py +++ b/test/test_database.py @@ -40,7 +40,7 @@ class TestDatabase(unittest.TestCase): """) self.db.cur.execute("CREATE UNIQUE INDEX ethereum_address_idx ON ethereum ( wallet_address_hex );") self.db.conn.commit() - self.db.new(self.address_hex) + self.db.new(self.address_hex, 'foo') def tearDown(self):