diff --git a/src/tests/mock/bitmessagemock.py b/src/tests/mock/bitmessagemock.py index 71055c62..24491a5a 100644 --- a/src/tests/mock/bitmessagemock.py +++ b/src/tests/mock/bitmessagemock.py @@ -1,3 +1,36 @@ +from class_addressGenerator import FakeAddressGenerator +from class_singleWorker import MockSingleWorker +from class_objectProcessor import MockObjectProcessor +from inventory import MockInventory + + def main(): """Mock main function""" - pass + def start(self): + """Start main application""" + # pylint: disable=too-many-statements,too-many-branches,too-many-locals + + config = BMConfigParser() + daemon = config.safeGetBoolean('bitmessagesettings', 'daemon') + + # Start the address generation thread + addressGeneratorThread = addressGenerator() + # close the main program even if there are threads left + addressGeneratorThread.daemon = True + addressGeneratorThread.start() + + # Start the thread that calculates POWs + singleWorkerThread = MockSingleWorker() + # close the main program even if there are threads left + singleWorkerThread.daemon = True + singleWorkerThread.start() + + # Start the thread that calculates POWs + objectProcessorThread = MockObjectProcessor() + # DON'T close the main program even the thread remains. + # This thread checks the shutdown variable after processing + # each object. + objectProcessorThread.daemon = False + objectProcessorThread.start() + + MockInventory() # init diff --git a/src/tests/mock/class_objectProcessor.py b/src/tests/mock/class_objectProcessor.py index 09120fc6..c418abc6 100644 --- a/src/tests/mock/class_objectProcessor.py +++ b/src/tests/mock/class_objectProcessor.py @@ -15,7 +15,7 @@ from network import bmproto logger = logging.getLogger('default') -class objectProcessor(threading.Thread): +class MockObjectProcessor(threading.Thread): """ The objectProcessor thread, of which there is only one, receives network objects (msg, broadcast, pubkey, getpubkey) from the receiveDataThreads.