From ddf024a1fa0ca701c2865ac036dbae1a2563da01 Mon Sep 17 00:00:00 2001 From: nolash Date: Sat, 9 Jan 2021 20:37:16 +0100 Subject: [PATCH] Use hex in signer test text message, dictkeystore store pk as bytes --- test/test_keystore_dict.py | 16 ++++++++++++---- test/test_sign.py | 2 +- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/test/test_keystore_dict.py b/test/test_keystore_dict.py index 1f1effb..8094d09 100644 --- a/test/test_keystore_dict.py +++ b/test/test_keystore_dict.py @@ -14,6 +14,7 @@ from cryptography.fernet import Fernet, InvalidToken # local imports from crypto_dev_signer.keystore import DictKeystore from crypto_dev_signer.error import UnknownAccountError +from crypto_dev_signer.eth.signer import ReferenceSigner logging.basicConfig(level=logging.DEBUG) logg = logging.getLogger() @@ -45,7 +46,7 @@ class TestDatabase(unittest.TestCase): #s = f.read() #f.close() - self.address_hex = self.db.import_keystore_file(keystore_filepath, '')[2:] + self.address_hex = self.db.import_keystore_file(keystore_filepath, '') def tearDown(self): @@ -53,15 +54,22 @@ class TestDatabase(unittest.TestCase): def test_get_key(self): - logg.debug('getting {}'.format(self.address_hex)) - pk = self.db.get(self.address_hex, '') + logg.debug('getting {}'.format(self.address_hex[2:])) + pk = self.db.get(self.address_hex[2:], '') - self.assertEqual(pk.public_key.to_checksum_address()[2:], self.address_hex) + self.assertEqual(self.address_hex.lower(), '0x00a329c0648769a73afac7f9381e08fb43dbea72') bogus_account = os.urandom(20).hex() with self.assertRaises(UnknownAccountError): self.db.get(bogus_account, '') + + def test_sign_message(self): + s = ReferenceSigner(self.db) + z = s.signEthereumMessage(self.address_hex[2:], b'foo') + logg.debug('zzz {}'.format(str(z))) + + if __name__ == '__main__': unittest.main() diff --git a/test/test_sign.py b/test/test_sign.py index 4d0676b..505d3f0 100644 --- a/test/test_sign.py +++ b/test/test_sign.py @@ -89,7 +89,7 @@ class TestSign(unittest.TestCase): def test_sign_message(self): s = ReferenceSigner(self.pk_getter) - z = s.signEthereumMessage(tx_ints['from'], 'foo') + z = s.signEthereumMessage(tx_ints['from'], '666f6f') z = s.signEthereumMessage(tx_ints['from'], b'foo') logg.debug('zzz {}'.format(str(z)))