diff --git a/src/tests/test_addressgenerator.py b/src/tests/test_addressgenerator.py index 0549242f..764286e8 100644 --- a/src/tests/test_addressgenerator.py +++ b/src/tests/test_addressgenerator.py @@ -1,35 +1,37 @@ -import unittest +"""Tests for AddressGenerator (with thread or not)""" + from binascii import unhexlify -from pybitmessage import pathmagic - +from .partial import TestPartialRun from .samples import ( sample_seed, sample_deterministic_addr3, sample_deterministic_addr4, sample_deterministic_ripe) -class TestAddressGenerator(unittest.TestCase): - """Test case for AddressGenerator (with thread or not)""" +class TestAddressGenerator(TestPartialRun): + """Test case for AddressGenerator thread""" @classmethod def setUpClass(cls): - pathmagic.setup() # need this because of import state in network ): - import queues - import state + super(TestAddressGenerator, cls).setUpClass() - state.enableGUI = False + import defaults + import queues from class_addressGenerator import addressGenerator - # import helper_startup - # from bmconfigparser import BMConfigParser - - # helper_startup.loadConfig() - # config = BMConfigParser() + cls.state.enableGUI = False cls.command_queue = queues.addressGeneratorQueue cls.return_queue = queues.apiAddressGeneratorReturnQueue cls.worker_queue = queues.workerQueue + cls.config.set( + 'bitmessagesettings', 'defaultnoncetrialsperbyte', + str(defaults.networkDefaultProofOfWorkNonceTrialsPerByte)) + cls.config.set( + 'bitmessagesettings', 'defaultpayloadlengthextrabytes', + str(defaults.networkDefaultPayloadLengthExtraBytes)) + thread = addressGenerator() thread.daemon = True thread.start() @@ -52,3 +54,12 @@ class TestAddressGenerator(unittest.TestCase): self.assertEqual( sample_deterministic_addr4, self._execute('createChan', 4, 1, 'test', sample_seed, True)) + self.assertEqual( + self.worker_queue.get(), + ('sendOutOrStoreMyV4Pubkey', sample_deterministic_addr4)) + self.assertEqual( + self.config.get(sample_deterministic_addr4, 'label'), 'test') + self.assertTrue( + self.config.getboolean(sample_deterministic_addr4, 'chan')) + self.assertTrue( + self.config.getboolean(sample_deterministic_addr4, 'enabled'))