Rewrite TestAddressGenerator as a subclass of TestPartialRun,
edit docstrings and add more checks. Closes: #1895
This commit is contained in:
parent
d427c27e7e
commit
799aadc9bc
|
@ -1,35 +1,37 @@
|
||||||
import unittest
|
"""Tests for AddressGenerator (with thread or not)"""
|
||||||
|
|
||||||
from binascii import unhexlify
|
from binascii import unhexlify
|
||||||
|
|
||||||
from pybitmessage import pathmagic
|
from .partial import TestPartialRun
|
||||||
|
|
||||||
from .samples import (
|
from .samples import (
|
||||||
sample_seed, sample_deterministic_addr3, sample_deterministic_addr4,
|
sample_seed, sample_deterministic_addr3, sample_deterministic_addr4,
|
||||||
sample_deterministic_ripe)
|
sample_deterministic_ripe)
|
||||||
|
|
||||||
|
|
||||||
class TestAddressGenerator(unittest.TestCase):
|
class TestAddressGenerator(TestPartialRun):
|
||||||
"""Test case for AddressGenerator (with thread or not)"""
|
"""Test case for AddressGenerator thread"""
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def setUpClass(cls):
|
def setUpClass(cls):
|
||||||
pathmagic.setup() # need this because of import state in network ):
|
super(TestAddressGenerator, cls).setUpClass()
|
||||||
import queues
|
|
||||||
import state
|
|
||||||
|
|
||||||
state.enableGUI = False
|
import defaults
|
||||||
|
import queues
|
||||||
from class_addressGenerator import addressGenerator
|
from class_addressGenerator import addressGenerator
|
||||||
|
|
||||||
# import helper_startup
|
cls.state.enableGUI = False
|
||||||
# from bmconfigparser import BMConfigParser
|
|
||||||
|
|
||||||
# helper_startup.loadConfig()
|
|
||||||
# config = BMConfigParser()
|
|
||||||
|
|
||||||
cls.command_queue = queues.addressGeneratorQueue
|
cls.command_queue = queues.addressGeneratorQueue
|
||||||
cls.return_queue = queues.apiAddressGeneratorReturnQueue
|
cls.return_queue = queues.apiAddressGeneratorReturnQueue
|
||||||
cls.worker_queue = queues.workerQueue
|
cls.worker_queue = queues.workerQueue
|
||||||
|
|
||||||
|
cls.config.set(
|
||||||
|
'bitmessagesettings', 'defaultnoncetrialsperbyte',
|
||||||
|
str(defaults.networkDefaultProofOfWorkNonceTrialsPerByte))
|
||||||
|
cls.config.set(
|
||||||
|
'bitmessagesettings', 'defaultpayloadlengthextrabytes',
|
||||||
|
str(defaults.networkDefaultPayloadLengthExtraBytes))
|
||||||
|
|
||||||
thread = addressGenerator()
|
thread = addressGenerator()
|
||||||
thread.daemon = True
|
thread.daemon = True
|
||||||
thread.start()
|
thread.start()
|
||||||
|
@ -52,3 +54,12 @@ class TestAddressGenerator(unittest.TestCase):
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
sample_deterministic_addr4,
|
sample_deterministic_addr4,
|
||||||
self._execute('createChan', 4, 1, 'test', sample_seed, True))
|
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'))
|
||||||
|
|
Reference in New Issue
Block a user