aucoin/tests/test_wallet.py
Casper V. Kristensen b7053ad014
Publish
2018-07-15 23:30:55 +02:00

31 lines
794 B
Python

import logging
import unittest
from aucoin import dsa
from aucoin.blockchain import Blockchain
from aucoin.wallet import Wallet
logging.basicConfig(level=logging.DEBUG)
class TestWallet(unittest.TestCase):
def setUp(self):
self.wallet = Wallet(Blockchain())
self.data = b"Hello, world!"
def test_sign(self):
signature = self.wallet.sign(self.data)
self.assertTrue(dsa.verify(self.wallet._public_key, self.data, signature))
def test_save_load(self):
public_key_old = self.wallet.public_key
self.wallet.save()
self.wallet._private_key = None
self.wallet._public_key = None
self.wallet.load()
self.assertEqual(self.wallet.public_key, public_key_old)
if __name__ == '__main__':
unittest.main()