Use hex in signer test text message, dictkeystore store pk as bytes
This commit is contained in:
parent
e1e585776d
commit
ddf024a1fa
@ -14,6 +14,7 @@ from cryptography.fernet import Fernet, InvalidToken
|
|||||||
# local imports
|
# local imports
|
||||||
from crypto_dev_signer.keystore import DictKeystore
|
from crypto_dev_signer.keystore import DictKeystore
|
||||||
from crypto_dev_signer.error import UnknownAccountError
|
from crypto_dev_signer.error import UnknownAccountError
|
||||||
|
from crypto_dev_signer.eth.signer import ReferenceSigner
|
||||||
|
|
||||||
logging.basicConfig(level=logging.DEBUG)
|
logging.basicConfig(level=logging.DEBUG)
|
||||||
logg = logging.getLogger()
|
logg = logging.getLogger()
|
||||||
@ -45,7 +46,7 @@ class TestDatabase(unittest.TestCase):
|
|||||||
#s = f.read()
|
#s = f.read()
|
||||||
#f.close()
|
#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):
|
def tearDown(self):
|
||||||
@ -53,15 +54,22 @@ class TestDatabase(unittest.TestCase):
|
|||||||
|
|
||||||
|
|
||||||
def test_get_key(self):
|
def test_get_key(self):
|
||||||
logg.debug('getting {}'.format(self.address_hex))
|
logg.debug('getting {}'.format(self.address_hex[2:]))
|
||||||
pk = self.db.get(self.address_hex, '')
|
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()
|
bogus_account = os.urandom(20).hex()
|
||||||
with self.assertRaises(UnknownAccountError):
|
with self.assertRaises(UnknownAccountError):
|
||||||
self.db.get(bogus_account, '')
|
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__':
|
if __name__ == '__main__':
|
||||||
unittest.main()
|
unittest.main()
|
||||||
|
@ -89,7 +89,7 @@ class TestSign(unittest.TestCase):
|
|||||||
|
|
||||||
def test_sign_message(self):
|
def test_sign_message(self):
|
||||||
s = ReferenceSigner(self.pk_getter)
|
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')
|
z = s.signEthereumMessage(tx_ints['from'], b'foo')
|
||||||
logg.debug('zzz {}'.format(str(z)))
|
logg.debug('zzz {}'.format(str(z)))
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user