Added mock code #1883
50
src/mock/class_objectProcessor.py
Normal file
|
@ -0,0 +1,50 @@
|
||||||
|
|||||||
|
"""
|
||||||
it will never happen it will never happen
This is not a mock class because it uses This is not a mock class because it uses `sqlQuery()` from `helper_sql`, thus depends on the `sqlThread`
#1794 contains a test sql class (runs in-memory database and allows custom schema initialization), that will be used here as well. #1794 contains a test sql class (runs in-memory database and allows custom schema initialization), that will be used here as well.
For the time being we can skip this, yes. For the time being we can skip this, yes.
|
|||||||
|
The objectProcessor thread, of which there is only one,
|
||||||
it will never happen it will never happen
This is not a mock class because it uses This is not a mock class because it uses `sqlQuery()` from `helper_sql`, thus depends on the `sqlThread`
#1794 contains a test sql class (runs in-memory database and allows custom schema initialization), that will be used here as well. #1794 contains a test sql class (runs in-memory database and allows custom schema initialization), that will be used here as well.
For the time being we can skip this, yes. For the time being we can skip this, yes.
|
|||||||
|
processes the network objects
|
||||||
it will never happen it will never happen
This is not a mock class because it uses This is not a mock class because it uses `sqlQuery()` from `helper_sql`, thus depends on the `sqlThread`
#1794 contains a test sql class (runs in-memory database and allows custom schema initialization), that will be used here as well. #1794 contains a test sql class (runs in-memory database and allows custom schema initialization), that will be used here as well.
For the time being we can skip this, yes. For the time being we can skip this, yes.
|
|||||||
|
"""
|
||||||
it will never happen it will never happen
This is not a mock class because it uses This is not a mock class because it uses `sqlQuery()` from `helper_sql`, thus depends on the `sqlThread`
#1794 contains a test sql class (runs in-memory database and allows custom schema initialization), that will be used here as well. #1794 contains a test sql class (runs in-memory database and allows custom schema initialization), that will be used here as well.
For the time being we can skip this, yes. For the time being we can skip this, yes.
|
|||||||
|
import logging
|
||||||
it will never happen it will never happen
This is not a mock class because it uses This is not a mock class because it uses `sqlQuery()` from `helper_sql`, thus depends on the `sqlThread`
#1794 contains a test sql class (runs in-memory database and allows custom schema initialization), that will be used here as well. #1794 contains a test sql class (runs in-memory database and allows custom schema initialization), that will be used here as well.
For the time being we can skip this, yes. For the time being we can skip this, yes.
|
|||||||
|
import random
|
||||||
it will never happen it will never happen
This is not a mock class because it uses This is not a mock class because it uses `sqlQuery()` from `helper_sql`, thus depends on the `sqlThread`
#1794 contains a test sql class (runs in-memory database and allows custom schema initialization), that will be used here as well. #1794 contains a test sql class (runs in-memory database and allows custom schema initialization), that will be used here as well.
For the time being we can skip this, yes. For the time being we can skip this, yes.
|
|||||||
|
import threading
|
||||||
it will never happen it will never happen
This is not a mock class because it uses This is not a mock class because it uses `sqlQuery()` from `helper_sql`, thus depends on the `sqlThread`
#1794 contains a test sql class (runs in-memory database and allows custom schema initialization), that will be used here as well. #1794 contains a test sql class (runs in-memory database and allows custom schema initialization), that will be used here as well.
For the time being we can skip this, yes. For the time being we can skip this, yes.
|
|||||||
|
|
||||||
it will never happen it will never happen
This is not a mock class because it uses This is not a mock class because it uses `sqlQuery()` from `helper_sql`, thus depends on the `sqlThread`
#1794 contains a test sql class (runs in-memory database and allows custom schema initialization), that will be used here as well. #1794 contains a test sql class (runs in-memory database and allows custom schema initialization), that will be used here as well.
For the time being we can skip this, yes. For the time being we can skip this, yes.
|
|||||||
|
import queues
|
||||||
it will never happen it will never happen
This is not a mock class because it uses This is not a mock class because it uses `sqlQuery()` from `helper_sql`, thus depends on the `sqlThread`
#1794 contains a test sql class (runs in-memory database and allows custom schema initialization), that will be used here as well. #1794 contains a test sql class (runs in-memory database and allows custom schema initialization), that will be used here as well.
For the time being we can skip this, yes. For the time being we can skip this, yes.
|
|||||||
|
import state
|
||||||
it will never happen it will never happen
This is not a mock class because it uses This is not a mock class because it uses `sqlQuery()` from `helper_sql`, thus depends on the `sqlThread`
#1794 contains a test sql class (runs in-memory database and allows custom schema initialization), that will be used here as well. #1794 contains a test sql class (runs in-memory database and allows custom schema initialization), that will be used here as well.
For the time being we can skip this, yes. For the time being we can skip this, yes.
|
|||||||
|
|
||||||
it will never happen it will never happen
This is not a mock class because it uses This is not a mock class because it uses `sqlQuery()` from `helper_sql`, thus depends on the `sqlThread`
#1794 contains a test sql class (runs in-memory database and allows custom schema initialization), that will be used here as well. #1794 contains a test sql class (runs in-memory database and allows custom schema initialization), that will be used here as well.
For the time being we can skip this, yes. For the time being we can skip this, yes.
|
|||||||
|
from helper_sql import sql_ready, sqlExecute, sqlQuery
|
||||||
it will never happen it will never happen
This is not a mock class because it uses This is not a mock class because it uses `sqlQuery()` from `helper_sql`, thus depends on the `sqlThread`
#1794 contains a test sql class (runs in-memory database and allows custom schema initialization), that will be used here as well. #1794 contains a test sql class (runs in-memory database and allows custom schema initialization), that will be used here as well.
For the time being we can skip this, yes. For the time being we can skip this, yes.
|
|||||||
|
from network import bmproto
|
||||||
it will never happen it will never happen
This is not a mock class because it uses This is not a mock class because it uses `sqlQuery()` from `helper_sql`, thus depends on the `sqlThread`
#1794 contains a test sql class (runs in-memory database and allows custom schema initialization), that will be used here as well. #1794 contains a test sql class (runs in-memory database and allows custom schema initialization), that will be used here as well.
For the time being we can skip this, yes. For the time being we can skip this, yes.
|
|||||||
|
|
||||||
it will never happen it will never happen
This is not a mock class because it uses This is not a mock class because it uses `sqlQuery()` from `helper_sql`, thus depends on the `sqlThread`
#1794 contains a test sql class (runs in-memory database and allows custom schema initialization), that will be used here as well. #1794 contains a test sql class (runs in-memory database and allows custom schema initialization), that will be used here as well.
For the time being we can skip this, yes. For the time being we can skip this, yes.
|
|||||||
|
logger = logging.getLogger('default')
|
||||||
it will never happen it will never happen
This is not a mock class because it uses This is not a mock class because it uses `sqlQuery()` from `helper_sql`, thus depends on the `sqlThread`
#1794 contains a test sql class (runs in-memory database and allows custom schema initialization), that will be used here as well. #1794 contains a test sql class (runs in-memory database and allows custom schema initialization), that will be used here as well.
For the time being we can skip this, yes. For the time being we can skip this, yes.
|
|||||||
|
|
||||||
it will never happen it will never happen
This is not a mock class because it uses This is not a mock class because it uses `sqlQuery()` from `helper_sql`, thus depends on the `sqlThread`
#1794 contains a test sql class (runs in-memory database and allows custom schema initialization), that will be used here as well. #1794 contains a test sql class (runs in-memory database and allows custom schema initialization), that will be used here as well.
For the time being we can skip this, yes. For the time being we can skip this, yes.
|
|||||||
|
|
||||||
it will never happen it will never happen
This is not a mock class because it uses This is not a mock class because it uses `sqlQuery()` from `helper_sql`, thus depends on the `sqlThread`
#1794 contains a test sql class (runs in-memory database and allows custom schema initialization), that will be used here as well. #1794 contains a test sql class (runs in-memory database and allows custom schema initialization), that will be used here as well.
For the time being we can skip this, yes. For the time being we can skip this, yes.
|
|||||||
|
class objectProcessor(threading.Thread):
|
||||||
it will never happen it will never happen
This is not a mock class because it uses This is not a mock class because it uses `sqlQuery()` from `helper_sql`, thus depends on the `sqlThread`
#1794 contains a test sql class (runs in-memory database and allows custom schema initialization), that will be used here as well. #1794 contains a test sql class (runs in-memory database and allows custom schema initialization), that will be used here as well.
For the time being we can skip this, yes. For the time being we can skip this, yes.
|
|||||||
|
"""
|
||||||
it will never happen it will never happen
This is not a mock class because it uses This is not a mock class because it uses `sqlQuery()` from `helper_sql`, thus depends on the `sqlThread`
#1794 contains a test sql class (runs in-memory database and allows custom schema initialization), that will be used here as well. #1794 contains a test sql class (runs in-memory database and allows custom schema initialization), that will be used here as well.
For the time being we can skip this, yes. For the time being we can skip this, yes.
|
|||||||
|
The objectProcessor thread, of which there is only one, receives network
|
||||||
it will never happen it will never happen
This is not a mock class because it uses This is not a mock class because it uses `sqlQuery()` from `helper_sql`, thus depends on the `sqlThread`
#1794 contains a test sql class (runs in-memory database and allows custom schema initialization), that will be used here as well. #1794 contains a test sql class (runs in-memory database and allows custom schema initialization), that will be used here as well.
For the time being we can skip this, yes. For the time being we can skip this, yes.
|
|||||||
|
objects (msg, broadcast, pubkey, getpubkey) from the receiveDataThreads.
|
||||||
it will never happen it will never happen
This is not a mock class because it uses This is not a mock class because it uses `sqlQuery()` from `helper_sql`, thus depends on the `sqlThread`
#1794 contains a test sql class (runs in-memory database and allows custom schema initialization), that will be used here as well. #1794 contains a test sql class (runs in-memory database and allows custom schema initialization), that will be used here as well.
For the time being we can skip this, yes. For the time being we can skip this, yes.
|
|||||||
|
"""
|
||||||
it will never happen it will never happen
This is not a mock class because it uses This is not a mock class because it uses `sqlQuery()` from `helper_sql`, thus depends on the `sqlThread`
#1794 contains a test sql class (runs in-memory database and allows custom schema initialization), that will be used here as well. #1794 contains a test sql class (runs in-memory database and allows custom schema initialization), that will be used here as well.
For the time being we can skip this, yes. For the time being we can skip this, yes.
|
|||||||
|
def __init__(self):
|
||||||
it will never happen it will never happen
This is not a mock class because it uses This is not a mock class because it uses `sqlQuery()` from `helper_sql`, thus depends on the `sqlThread`
#1794 contains a test sql class (runs in-memory database and allows custom schema initialization), that will be used here as well. #1794 contains a test sql class (runs in-memory database and allows custom schema initialization), that will be used here as well.
For the time being we can skip this, yes. For the time being we can skip this, yes.
|
|||||||
|
threading.Thread.__init__(self, name="objectProcessor")
|
||||||
it will never happen it will never happen
This is not a mock class because it uses This is not a mock class because it uses `sqlQuery()` from `helper_sql`, thus depends on the `sqlThread`
#1794 contains a test sql class (runs in-memory database and allows custom schema initialization), that will be used here as well. #1794 contains a test sql class (runs in-memory database and allows custom schema initialization), that will be used here as well.
For the time being we can skip this, yes. For the time being we can skip this, yes.
|
|||||||
|
random.seed()
|
||||||
it will never happen it will never happen
This is not a mock class because it uses This is not a mock class because it uses `sqlQuery()` from `helper_sql`, thus depends on the `sqlThread`
#1794 contains a test sql class (runs in-memory database and allows custom schema initialization), that will be used here as well. #1794 contains a test sql class (runs in-memory database and allows custom schema initialization), that will be used here as well.
For the time being we can skip this, yes. For the time being we can skip this, yes.
|
|||||||
|
# It may be the case that the last time Bitmessage was running,
|
||||||
it will never happen it will never happen
This is not a mock class because it uses This is not a mock class because it uses `sqlQuery()` from `helper_sql`, thus depends on the `sqlThread`
#1794 contains a test sql class (runs in-memory database and allows custom schema initialization), that will be used here as well. #1794 contains a test sql class (runs in-memory database and allows custom schema initialization), that will be used here as well.
For the time being we can skip this, yes. For the time being we can skip this, yes.
|
|||||||
|
# the user closed it before it finished processing everything in the
|
||||||
it will never happen it will never happen
This is not a mock class because it uses This is not a mock class because it uses `sqlQuery()` from `helper_sql`, thus depends on the `sqlThread`
#1794 contains a test sql class (runs in-memory database and allows custom schema initialization), that will be used here as well. #1794 contains a test sql class (runs in-memory database and allows custom schema initialization), that will be used here as well.
For the time being we can skip this, yes. For the time being we can skip this, yes.
|
|||||||
|
# objectProcessorQueue. Assuming that Bitmessage wasn't closed
|
||||||
it will never happen it will never happen
This is not a mock class because it uses This is not a mock class because it uses `sqlQuery()` from `helper_sql`, thus depends on the `sqlThread`
#1794 contains a test sql class (runs in-memory database and allows custom schema initialization), that will be used here as well. #1794 contains a test sql class (runs in-memory database and allows custom schema initialization), that will be used here as well.
For the time being we can skip this, yes. For the time being we can skip this, yes.
|
|||||||
|
# forcefully, it should have saved the data in the queue into the
|
||||||
it will never happen it will never happen
This is not a mock class because it uses This is not a mock class because it uses `sqlQuery()` from `helper_sql`, thus depends on the `sqlThread`
#1794 contains a test sql class (runs in-memory database and allows custom schema initialization), that will be used here as well. #1794 contains a test sql class (runs in-memory database and allows custom schema initialization), that will be used here as well.
For the time being we can skip this, yes. For the time being we can skip this, yes.
|
|||||||
|
# objectprocessorqueue table. Let's pull it out.
|
||||||
it will never happen it will never happen
This is not a mock class because it uses This is not a mock class because it uses `sqlQuery()` from `helper_sql`, thus depends on the `sqlThread`
#1794 contains a test sql class (runs in-memory database and allows custom schema initialization), that will be used here as well. #1794 contains a test sql class (runs in-memory database and allows custom schema initialization), that will be used here as well.
For the time being we can skip this, yes. For the time being we can skip this, yes.
|
|||||||
|
sql_ready.wait()
|
||||||
it will never happen it will never happen
This is not a mock class because it uses This is not a mock class because it uses `sqlQuery()` from `helper_sql`, thus depends on the `sqlThread`
#1794 contains a test sql class (runs in-memory database and allows custom schema initialization), that will be used here as well. #1794 contains a test sql class (runs in-memory database and allows custom schema initialization), that will be used here as well.
For the time being we can skip this, yes. For the time being we can skip this, yes.
|
|||||||
|
queryreturn = sqlQuery(
|
||||||
it will never happen it will never happen
This is not a mock class because it uses This is not a mock class because it uses `sqlQuery()` from `helper_sql`, thus depends on the `sqlThread`
#1794 contains a test sql class (runs in-memory database and allows custom schema initialization), that will be used here as well. #1794 contains a test sql class (runs in-memory database and allows custom schema initialization), that will be used here as well.
For the time being we can skip this, yes. For the time being we can skip this, yes.
|
|||||||
|
'SELECT objecttype, data FROM objectprocessorqueue')
|
||||||
it will never happen it will never happen
This is not a mock class because it uses This is not a mock class because it uses `sqlQuery()` from `helper_sql`, thus depends on the `sqlThread`
#1794 contains a test sql class (runs in-memory database and allows custom schema initialization), that will be used here as well. #1794 contains a test sql class (runs in-memory database and allows custom schema initialization), that will be used here as well.
For the time being we can skip this, yes. For the time being we can skip this, yes.
|
|||||||
|
for objectType, data in queryreturn:
|
||||||
it will never happen it will never happen
This is not a mock class because it uses This is not a mock class because it uses `sqlQuery()` from `helper_sql`, thus depends on the `sqlThread`
#1794 contains a test sql class (runs in-memory database and allows custom schema initialization), that will be used here as well. #1794 contains a test sql class (runs in-memory database and allows custom schema initialization), that will be used here as well.
For the time being we can skip this, yes. For the time being we can skip this, yes.
|
|||||||
|
queues.objectProcessorQueue.put((objectType, data))
|
||||||
it will never happen it will never happen
This is not a mock class because it uses This is not a mock class because it uses `sqlQuery()` from `helper_sql`, thus depends on the `sqlThread`
#1794 contains a test sql class (runs in-memory database and allows custom schema initialization), that will be used here as well. #1794 contains a test sql class (runs in-memory database and allows custom schema initialization), that will be used here as well.
For the time being we can skip this, yes. For the time being we can skip this, yes.
|
|||||||
|
sqlExecute('DELETE FROM objectprocessorqueue')
|
||||||
it will never happen it will never happen
This is not a mock class because it uses This is not a mock class because it uses `sqlQuery()` from `helper_sql`, thus depends on the `sqlThread`
#1794 contains a test sql class (runs in-memory database and allows custom schema initialization), that will be used here as well. #1794 contains a test sql class (runs in-memory database and allows custom schema initialization), that will be used here as well.
For the time being we can skip this, yes. For the time being we can skip this, yes.
|
|||||||
|
logger.debug(
|
||||||
it will never happen it will never happen
This is not a mock class because it uses This is not a mock class because it uses `sqlQuery()` from `helper_sql`, thus depends on the `sqlThread`
#1794 contains a test sql class (runs in-memory database and allows custom schema initialization), that will be used here as well. #1794 contains a test sql class (runs in-memory database and allows custom schema initialization), that will be used here as well.
For the time being we can skip this, yes. For the time being we can skip this, yes.
|
|||||||
|
'Loaded %s objects from disk into the objectProcessorQueue.',
|
||||||
it will never happen it will never happen
This is not a mock class because it uses This is not a mock class because it uses `sqlQuery()` from `helper_sql`, thus depends on the `sqlThread`
#1794 contains a test sql class (runs in-memory database and allows custom schema initialization), that will be used here as well. #1794 contains a test sql class (runs in-memory database and allows custom schema initialization), that will be used here as well.
For the time being we can skip this, yes. For the time being we can skip this, yes.
|
|||||||
|
len(queryreturn))
|
||||||
it will never happen it will never happen
This is not a mock class because it uses This is not a mock class because it uses `sqlQuery()` from `helper_sql`, thus depends on the `sqlThread`
#1794 contains a test sql class (runs in-memory database and allows custom schema initialization), that will be used here as well. #1794 contains a test sql class (runs in-memory database and allows custom schema initialization), that will be used here as well.
For the time being we can skip this, yes. For the time being we can skip this, yes.
|
|||||||
|
self._ack_obj = bmproto.BMStringParser()
|
||||||
it will never happen it will never happen
This is not a mock class because it uses This is not a mock class because it uses `sqlQuery()` from `helper_sql`, thus depends on the `sqlThread`
#1794 contains a test sql class (runs in-memory database and allows custom schema initialization), that will be used here as well. #1794 contains a test sql class (runs in-memory database and allows custom schema initialization), that will be used here as well.
For the time being we can skip this, yes. For the time being we can skip this, yes.
|
|||||||
|
self.successfullyDecryptMessageTimings = []
|
||||||
it will never happen it will never happen
This is not a mock class because it uses This is not a mock class because it uses `sqlQuery()` from `helper_sql`, thus depends on the `sqlThread`
#1794 contains a test sql class (runs in-memory database and allows custom schema initialization), that will be used here as well. #1794 contains a test sql class (runs in-memory database and allows custom schema initialization), that will be used here as well.
For the time being we can skip this, yes. For the time being we can skip this, yes.
|
|||||||
|
|
||||||
it will never happen it will never happen
This is not a mock class because it uses This is not a mock class because it uses `sqlQuery()` from `helper_sql`, thus depends on the `sqlThread`
#1794 contains a test sql class (runs in-memory database and allows custom schema initialization), that will be used here as well. #1794 contains a test sql class (runs in-memory database and allows custom schema initialization), that will be used here as well.
For the time being we can skip this, yes. For the time being we can skip this, yes.
|
|||||||
|
def run(self):
|
||||||
it will never happen it will never happen
This is not a mock class because it uses This is not a mock class because it uses `sqlQuery()` from `helper_sql`, thus depends on the `sqlThread`
#1794 contains a test sql class (runs in-memory database and allows custom schema initialization), that will be used here as well. #1794 contains a test sql class (runs in-memory database and allows custom schema initialization), that will be used here as well.
For the time being we can skip this, yes. For the time being we can skip this, yes.
|
|||||||
|
"""Process the objects from `.queues.objectProcessorQueue`"""
|
||||||
it will never happen it will never happen
This is not a mock class because it uses This is not a mock class because it uses `sqlQuery()` from `helper_sql`, thus depends on the `sqlThread`
#1794 contains a test sql class (runs in-memory database and allows custom schema initialization), that will be used here as well. #1794 contains a test sql class (runs in-memory database and allows custom schema initialization), that will be used here as well.
For the time being we can skip this, yes. For the time being we can skip this, yes.
|
|||||||
|
while True:
|
||||||
it will never happen it will never happen
This is not a mock class because it uses This is not a mock class because it uses `sqlQuery()` from `helper_sql`, thus depends on the `sqlThread`
#1794 contains a test sql class (runs in-memory database and allows custom schema initialization), that will be used here as well. #1794 contains a test sql class (runs in-memory database and allows custom schema initialization), that will be used here as well.
For the time being we can skip this, yes. For the time being we can skip this, yes.
|
|||||||
|
objectType, data = queues.objectProcessorQueue.get()
|
||||||
it will never happen it will never happen
This is not a mock class because it uses This is not a mock class because it uses `sqlQuery()` from `helper_sql`, thus depends on the `sqlThread`
#1794 contains a test sql class (runs in-memory database and allows custom schema initialization), that will be used here as well. #1794 contains a test sql class (runs in-memory database and allows custom schema initialization), that will be used here as well.
For the time being we can skip this, yes. For the time being we can skip this, yes.
|
|||||||
|
|
||||||
it will never happen it will never happen
This is not a mock class because it uses This is not a mock class because it uses `sqlQuery()` from `helper_sql`, thus depends on the `sqlThread`
#1794 contains a test sql class (runs in-memory database and allows custom schema initialization), that will be used here as well. #1794 contains a test sql class (runs in-memory database and allows custom schema initialization), that will be used here as well.
For the time being we can skip this, yes. For the time being we can skip this, yes.
|
|||||||
|
if state.shutdown:
|
||||||
it will never happen it will never happen
This is not a mock class because it uses This is not a mock class because it uses `sqlQuery()` from `helper_sql`, thus depends on the `sqlThread`
#1794 contains a test sql class (runs in-memory database and allows custom schema initialization), that will be used here as well. #1794 contains a test sql class (runs in-memory database and allows custom schema initialization), that will be used here as well.
For the time being we can skip this, yes. For the time being we can skip this, yes.
|
|||||||
|
state.shutdown = 2
|
||||||
it will never happen it will never happen
This is not a mock class because it uses This is not a mock class because it uses `sqlQuery()` from `helper_sql`, thus depends on the `sqlThread`
#1794 contains a test sql class (runs in-memory database and allows custom schema initialization), that will be used here as well. #1794 contains a test sql class (runs in-memory database and allows custom schema initialization), that will be used here as well.
For the time being we can skip this, yes. For the time being we can skip this, yes.
|
|||||||
|
break
|
||||||
it will never happen it will never happen
This is not a mock class because it uses This is not a mock class because it uses `sqlQuery()` from `helper_sql`, thus depends on the `sqlThread`
#1794 contains a test sql class (runs in-memory database and allows custom schema initialization), that will be used here as well. #1794 contains a test sql class (runs in-memory database and allows custom schema initialization), that will be used here as well.
For the time being we can skip this, yes. For the time being we can skip this, yes.
|
45
src/mock/class_singleWorker.py
Normal file
|
@ -0,0 +1,45 @@
|
||||||
|
"""
|
||||||
|
Thread for performing PoW
|
||||||
|
"""
|
||||||
|
|
||||||
|
from __future__ import division
|
||||||
|
|
||||||
|
import proofofwork
|
||||||
|
import queues
|
||||||
|
import state
|
||||||
|
|
||||||
|
from network import StoppableThread
|
||||||
|
from six.moves import queue
|
||||||
|
|
||||||
|
|
||||||
|
class MockSingleWorker(StoppableThread):
|
||||||
|
"""Thread for performing PoW"""
|
||||||
|
|
||||||
|
def __init__(self):
|
||||||
|
super(MockSingleWorker, self).__init__(name="singleWorker")
|
||||||
|
proofofwork.init()
|
||||||
|
|
||||||
|
def stopThread(self):
|
||||||
|
"""Signal through the queue that the thread should be stopped"""
|
||||||
|
|
||||||
|
try:
|
||||||
|
queues.workerQueue.put(("stopThread", "data"))
|
||||||
|
except queue.Full:
|
||||||
|
self.logger.error('workerQueue is Full')
|
||||||
|
super(MockSingleWorker, self).stopThread()
|
||||||
|
|
||||||
|
def run(self):
|
||||||
|
|
||||||
|
if state.shutdown > 0:
|
||||||
|
return
|
||||||
|
|
||||||
|
while state.shutdown == 0:
|
||||||
|
self.busy = 0
|
||||||
|
command, data = queues.workerQueue.get()
|
||||||
|
self.busy = 1
|
||||||
|
if command == 'stopThread':
|
||||||
|
self.busy = 0
|
||||||
|
return
|
||||||
|
|
||||||
|
queues.workerQueue.task_done()
|
||||||
|
self.logger.info("Quitting...")
|
14
src/mock/inventory.py
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
"""The Inventory singleton"""
|
||||||
|
|
||||||
|
# TODO make this dynamic, and watch out for frozen, like with messagetypes
|
||||||
|
from singleton import Singleton
|
||||||
|
|
||||||
|
|
||||||
|
@Singleton
|
||||||
|
class MockInventory():
|
||||||
|
"""
|
||||||
|
Inventory singleton class which uses storage backends
|
||||||
|
to manage the inventory.
|
||||||
|
"""
|
||||||
|
def __init__(self):
|
||||||
|
self.numberOfInventoryLookupsPerformed = 0
|
25
src/mock/network/connectionpool.py
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
"""
|
||||||
|
`BMConnectionPool` class definition
|
||||||
|
"""
|
||||||
|
import logging
|
||||||
|
|
||||||
|
import asyncore_pollchoose as asyncore
|
||||||
|
from bmconfigparser import BMConfigParser
|
||||||
|
from singleton import Singleton
|
||||||
|
|
||||||
|
logger = logging.getLogger('default')
|
||||||
|
|
||||||
|
|
||||||
|
@Singleton
|
||||||
|
class MockBMConnectionPool(object):
|
||||||
|
"""Pool of all existing connections"""
|
||||||
|
|
||||||
|
def __init__(self):
|
||||||
|
asyncore.set_rates(
|
||||||
|
BMConfigParser().safeGetInt(
|
||||||
|
"bitmessagesettings", "maxdownloadrate"),
|
||||||
|
BMConfigParser().safeGetInt(
|
||||||
|
"bitmessagesettings", "maxuploadrate")
|
||||||
|
)
|
||||||
|
self.outboundConnections = {}
|
||||||
|
self.inboundConnections = {}
|
13
src/mock/network/stats.py
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
"""
|
||||||
|
Network statistics
|
||||||
|
"""
|
||||||
|
|
||||||
|
|
||||||
|
def MockUploadSpeed():
|
||||||
|
"""Getting upload speed"""
|
||||||
|
return 0
|
||||||
|
|
||||||
|
|
||||||
|
def MockDownloadSpeed():
|
||||||
|
"""Getting download speed"""
|
||||||
|
return 0
|
it will never happen
it will never happen
This is not a mock class because it uses
sqlQuery()
fromhelper_sql
, thus depends on thesqlThread
This is not a mock class because it uses
sqlQuery()
fromhelper_sql
, thus depends on thesqlThread
#1794 contains a test sql class (runs in-memory database and allows custom schema initialization), that will be used here as well.
#1794 contains a test sql class (runs in-memory database and allows custom schema initialization), that will be used here as well.
For the time being we can skip this, yes.
For the time being we can skip this, yes.