Added mock code #1883

Open
kdcis wants to merge 10 commits from kdcis/mock-test into v0.6
4 changed files with 8 additions and 11 deletions
Showing only changes of commit fbfbc560c6 - Show all commits

View File

@ -8,7 +8,7 @@ from pybitmessage.inventory import Inventory
PeterSurda commented 2021-12-13 06:46:41 +01:00 (Migrated from github.com)
Review

here it can start launching the mock threads.

here it can start launching the mock threads.
PeterSurda commented 2021-12-13 06:46:41 +01:00 (Migrated from github.com)
Review

here it can start launching the mock threads.

here it can start launching the mock threads.
from pybitmessage.bmconfigparser import BMConfigParser from pybitmessage.bmconfigparser import BMConfigParser
# pylint: disable=too-few-public-methods # pylint: disable=too-few-public-methods,no-init,old-style-class
PeterSurda commented 2021-12-13 06:46:41 +01:00 (Migrated from github.com)
Review

here it can start launching the mock threads.

here it can start launching the mock threads.
PeterSurda commented 2021-12-13 06:46:41 +01:00 (Migrated from github.com)
Review

here it can start launching the mock threads.

here it can start launching the mock threads.
class MockMain: class MockMain:
"""Mock main function""" """Mock main function"""

PeterSurda commented 2021-12-13 06:46:41 +01:00 (Migrated from github.com)
Review

here it can start launching the mock threads.

here it can start launching the mock threads.
PeterSurda commented 2021-12-13 06:46:41 +01:00 (Migrated from github.com)
Review

here it can start launching the mock threads.

here it can start launching the mock threads.

View File

@ -69,6 +69,7 @@ class BMConfigParser(SafeConfigParser):
raise ValueError("Invalid value %s" % value) raise ValueError("Invalid value %s" % value)
return SafeConfigParser.set(self, section, option, value) return SafeConfigParser.set(self, section, option, value)
# pylint: disable=redefined-builtinm, too-many-return-statements
def get(self, section, option, raw=False, vars=None): def get(self, section, option, raw=False, vars=None):
if sys.version_info[0] == 3: if sys.version_info[0] == 3:
# pylint: disable=arguments-differ # pylint: disable=arguments-differ
@ -185,6 +186,7 @@ class BMConfigParser(SafeConfigParser):
for section in self.sections(): for section in self.sections():
for option in self.options(section): for option in self.options(section):
try: try:
# pylint: disable=unsubscriptable-object
if not self.validate( if not self.validate(
section, option, section, option,
self[section][option] self[section][option]

View File

@ -2,10 +2,6 @@
A thread for creating addresses A thread for creating addresses
""" """
import logging
import random
import threading
from six.moves import queue from six.moves import queue
from pybitmessage import state from pybitmessage import state
@ -46,19 +42,18 @@ class addressGenerator(StoppableThread):
address_list = list(fake_addresses.keys()) address_list = list(fake_addresses.keys())
def stopThread(self): def stopThread(self):
""""To stop address generator thread"""
try: try:
queues.addressGeneratorQueue.put(("stopThread", "data")) queues.addressGeneratorQueue.put(("stopThread", "data"))
except queue.Full: except queue.Full:
self.logger.warning('addressGeneratorQueue is Full') self.logger.warning('addressGeneratorQueue is Full')
super(FakeAddressGenerator, self).stopThread() super(addressGenerator, self).stopThread()
def run(self): def run(self):
""" """
Process the requests for addresses generation Process the requests for addresses generation
from `.queues.addressGeneratorQueue` from `.queues.addressGeneratorQueue`
""" """
import pdb;pdb.set_trace()
while state.shutdown == 0: while state.shutdown == 0:
queueValue = queues.addressGeneratorQueue.get() queueValue = queues.addressGeneratorQueue.get()
try: try:

View File

@ -4,11 +4,11 @@ Thread for performing PoW
from __future__ import division from __future__ import division
from six.moves import queue
from pybitmessage import state from pybitmessage import state
from pybitmessage import queues from pybitmessage import queues
from pybitmessage.threads import StoppableThread from pybitmessage.threads import StoppableThread
from six.moves import queue
class singleWorker(StoppableThread): class singleWorker(StoppableThread):
@ -28,7 +28,7 @@ class singleWorker(StoppableThread):
super(singleWorker, self).stopThread() super(singleWorker, self).stopThread()
def run(self): def run(self):
"""To run single worker thread"""
if state.shutdown > 0: if state.shutdown > 0:
return return