Override the get and put of addressGeneratorQueue
This commit is contained in:
parent
39dde3f961
commit
4606f55e2f
53
src/api.py
53
src/api.py
|
@ -618,16 +618,12 @@ class MySimpleXMLRPCRequestHandler(SimpleXMLRPCRequestHandler):
|
||||||
def HandleCreateChan(self, params):
|
def HandleCreateChan(self, params):
|
||||||
"""Handle a request to create a chan"""
|
"""Handle a request to create a chan"""
|
||||||
|
|
||||||
|
queueReturn = ''
|
||||||
if not params:
|
if not params:
|
||||||
raise APIError(0, 'I need parameters.')
|
raise APIError(0, 'I need parameters.')
|
||||||
|
|
||||||
elif len(params) == 1:
|
elif len(params) == 1:
|
||||||
passphrase, = params
|
passphrase, = params
|
||||||
passphrase = self._decode(passphrase.data, "base64")
|
passphrase = self._decode(passphrase.data, "base64")
|
||||||
logger.info('****************************')
|
|
||||||
logger.info('the value of the passphrase -{}'.format(passphrase))
|
|
||||||
logger.info('the value of the str_chan-{}'.format(type(str_chan)))
|
|
||||||
logger.info('****************************')
|
|
||||||
if not passphrase:
|
if not passphrase:
|
||||||
raise APIError(1, 'The specified passphrase is blank.')
|
raise APIError(1, 'The specified passphrase is blank.')
|
||||||
# It would be nice to make the label the passphrase but it is
|
# It would be nice to make the label the passphrase but it is
|
||||||
|
@ -637,26 +633,22 @@ class MySimpleXMLRPCRequestHandler(SimpleXMLRPCRequestHandler):
|
||||||
# label = str_chan + ' ' + passphrase
|
# label = str_chan + ' ' + passphrase
|
||||||
# except BaseException:
|
# except BaseException:
|
||||||
label = str_chan + ' ' + passphrase.decode()
|
label = str_chan + ' ' + passphrase.decode()
|
||||||
logger.info('111111111111111111111111111111111111')
|
|
||||||
logger.info('************************************')
|
|
||||||
logger.info('Is flow are coming then value of-{}'.format(label))
|
|
||||||
logger.info('* ***********************************')
|
|
||||||
addressVersionNumber = 4
|
addressVersionNumber = 4
|
||||||
streamNumber = 1
|
streamNumber = 1
|
||||||
queues.apiAddressGeneratorReturnQueue.queue.clear()
|
try:
|
||||||
logger.info(
|
queues.addressGeneratorQueue.put((
|
||||||
'Requesting that the addressGenerator create chan {}.'.format(passphrase))
|
'createChan', addressVersionNumber, streamNumber, label,
|
||||||
logger.info('!!!!!!!!!!!55555555!!!!!!!!!!!!!!!!!!!!!')
|
passphrase, True
|
||||||
logger.info('createChan')
|
))
|
||||||
logger.info('addressVersionNumber-{}'.format(addressVersionNumber))
|
logger.info(
|
||||||
logger.info('passphrase-{}'.format(passphrase.decode()))
|
'@@@@@@@@ before printing the queueReturn @@@@@@@@@')
|
||||||
logger.info('label-{}'.format(label))
|
queueReturn = queues.apiAddressGeneratorReturnQueue.get()
|
||||||
logger.info('!!!!!!!!!!!55555555!!!!!!!!!!!!!!!!!!!!!')
|
logger.info('***********************************')
|
||||||
queues.addressGeneratorQueue.put((
|
logger.info('queueReturn-{}'.format(queueReturn))
|
||||||
'createChan', addressVersionNumber, streamNumber, label,
|
logger.info('***********************************')
|
||||||
passphrase, True
|
|
||||||
))
|
except Exception as e:
|
||||||
queueReturn = queues.apiAddressGeneratorReturnQueue.get()
|
logger.info(e)
|
||||||
if not queueReturn:
|
if not queueReturn:
|
||||||
raise APIError(24, 'Chan address is already present.')
|
raise APIError(24, 'Chan address is already present.')
|
||||||
address = queueReturn[0]
|
address = queueReturn[0]
|
||||||
|
@ -669,16 +661,17 @@ class MySimpleXMLRPCRequestHandler(SimpleXMLRPCRequestHandler):
|
||||||
raise APIError(0, 'I need two parameters.')
|
raise APIError(0, 'I need two parameters.')
|
||||||
elif len(params) == 2:
|
elif len(params) == 2:
|
||||||
passphrase, suppliedAddress = params
|
passphrase, suppliedAddress = params
|
||||||
passphrase = self._decode(passphrase, "base64")
|
passphrase = self._decode(passphrase.data, "base64")
|
||||||
if not passphrase:
|
if not passphrase:
|
||||||
raise APIError(1, 'The specified passphrase is blank.')
|
raise APIError(1, 'The specified passphrase is blank.')
|
||||||
# It would be nice to make the label the passphrase but it is
|
# It would be nice to make the label the passphrase but it is
|
||||||
# possible that the passphrase contains non-utf-8 characters.
|
# possible that the passphrase contains non-utf-8 characters.
|
||||||
try:
|
# try:
|
||||||
unicode(passphrase, 'utf-8')
|
# unicode(passphrase, 'utf-8')
|
||||||
label = str_chan + ' ' + passphrase
|
# label = str_chan + ' ' + passphrase
|
||||||
except BaseException:
|
# except BaseException:
|
||||||
label = str_chan + ' ' + repr(passphrase)
|
# label = str_chan + ' ' + repr(passphrase)
|
||||||
|
label = str_chan + ' ' + passphrase.decode()
|
||||||
status, addressVersionNumber, streamNumber, toRipe = (
|
status, addressVersionNumber, streamNumber, toRipe = (
|
||||||
self._verifyAddress(suppliedAddress))
|
self._verifyAddress(suppliedAddress))
|
||||||
suppliedAddress = addBMIfNotPresent(suppliedAddress)
|
suppliedAddress = addBMIfNotPresent(suppliedAddress)
|
||||||
|
|
|
@ -18,6 +18,7 @@ try:
|
||||||
from pyelliptic import arithmetic
|
from pyelliptic import arithmetic
|
||||||
from pyelliptic.openssl import OpenSSL
|
from pyelliptic.openssl import OpenSSL
|
||||||
from network.threads import StoppableThread
|
from network.threads import StoppableThread
|
||||||
|
from debug import logger
|
||||||
except ModuleNotFoundError:
|
except ModuleNotFoundError:
|
||||||
from pybitmessage import defaults
|
from pybitmessage import defaults
|
||||||
from pybitmessage.debug import logger
|
from pybitmessage.debug import logger
|
||||||
|
@ -51,23 +52,38 @@ class addressGenerator(StoppableThread):
|
||||||
"""
|
"""
|
||||||
# pylint: disable=too-many-locals, too-many-branches
|
# pylint: disable=too-many-locals, too-many-branches
|
||||||
# pylint: disable=protected-access, too-many-statements
|
# pylint: disable=protected-access, too-many-statements
|
||||||
|
# logger.info('@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@')
|
||||||
|
# logger.info('inside the class_addressGenerator\n')
|
||||||
|
# logger.info('current thread -{}'.format(threading.current_thread().name))
|
||||||
|
# logger.info('&&&&&&&&&&&&&&&&&&&&&&&')
|
||||||
|
import time
|
||||||
|
time.sleep(1)
|
||||||
|
# logger.info('MMMMMMMMMMMMMMMMM33333333333333333333333333')
|
||||||
|
# logger.info(
|
||||||
|
# 'queues.addressGeneratorQueue.queue -{}'.format(
|
||||||
|
# queues.addressGeneratorQueue.queue
|
||||||
|
# )
|
||||||
|
# )
|
||||||
|
# logger.info('state.shutdown-{}'.format(state.shutdown))
|
||||||
|
# logger.info('MMMMMMMMMMMMMMMMM33333333333333333333333333')
|
||||||
|
# state.shutdown = 0
|
||||||
while state.shutdown == 0:
|
while state.shutdown == 0:
|
||||||
queueValue = queues.addressGeneratorQueue.get()
|
queueValue = queues.addressGeneratorQueue.get()
|
||||||
# logger.info('&&&&&&&&&&&&&&&&&&&&&&&')
|
|
||||||
# logger.info('inside the class_addressGenerator\n')
|
|
||||||
# logger.info('current thread -{}'.format(threading.current_thread().name))
|
|
||||||
# logger.info('$$$$$$$$$$$$ queueValue $$$$$$$$$$$$-{}'.format(queueValue))
|
|
||||||
# logger.info('&&&&&&&&&&&&&&&&&&&&&&&')
|
|
||||||
nonceTrialsPerByte = 0
|
nonceTrialsPerByte = 0
|
||||||
|
logger.info('$$$$$$$$$$$$ queueValue @@@@@@@@@@@-{}'.format(queueValue))
|
||||||
payloadLengthExtraBytes = 0
|
payloadLengthExtraBytes = 0
|
||||||
live = True
|
live = True
|
||||||
if queueValue[0] == 'createChan':
|
if queueValue[0] == 'createChan':
|
||||||
|
logger.info(
|
||||||
|
'OOOOOOOOOOOOOOOOOOOOOOOOOOOOO')
|
||||||
command, addressVersionNumber, streamNumber, label, \
|
command, addressVersionNumber, streamNumber, label, \
|
||||||
deterministicPassphrase, live = queueValue
|
deterministicPassphrase, live = queueValue
|
||||||
eighteenByteRipe = False
|
eighteenByteRipe = False
|
||||||
numberOfAddressesToMake = 1
|
numberOfAddressesToMake = 1
|
||||||
numberOfNullBytesDemandedOnFrontOfRipeHash = 1
|
numberOfNullBytesDemandedOnFrontOfRipeHash = 1
|
||||||
elif queueValue[0] == 'joinChan':
|
elif queueValue[0] == 'joinChan':
|
||||||
|
logger.info(
|
||||||
|
'111111111111111111111111111111111111111')
|
||||||
command, chanAddress, label, deterministicPassphrase, \
|
command, chanAddress, label, deterministicPassphrase, \
|
||||||
live = queueValue
|
live = queueValue
|
||||||
eighteenByteRipe = False
|
eighteenByteRipe = False
|
||||||
|
@ -76,6 +92,8 @@ class addressGenerator(StoppableThread):
|
||||||
numberOfAddressesToMake = 1
|
numberOfAddressesToMake = 1
|
||||||
numberOfNullBytesDemandedOnFrontOfRipeHash = 1
|
numberOfNullBytesDemandedOnFrontOfRipeHash = 1
|
||||||
elif len(queueValue) == 7:
|
elif len(queueValue) == 7:
|
||||||
|
logger.info(
|
||||||
|
'22222222222222222222222222222222222222')
|
||||||
command, addressVersionNumber, streamNumber, label, \
|
command, addressVersionNumber, streamNumber, label, \
|
||||||
numberOfAddressesToMake, deterministicPassphrase, \
|
numberOfAddressesToMake, deterministicPassphrase, \
|
||||||
eighteenByteRipe = queueValue
|
eighteenByteRipe = queueValue
|
||||||
|
@ -92,9 +110,9 @@ class addressGenerator(StoppableThread):
|
||||||
# the default
|
# the default
|
||||||
numberOfNullBytesDemandedOnFrontOfRipeHash = 1
|
numberOfNullBytesDemandedOnFrontOfRipeHash = 1
|
||||||
elif len(queueValue) == 9:
|
elif len(queueValue) == 9:
|
||||||
logger.info('&&&&&&&&&&&&&&&&&&&&&&&')
|
|
||||||
logger.info('---------94--------------')
|
logger.info(
|
||||||
logger.info('&&&&&&&&&&&&&&&&&&&&&&&\n')
|
'33333333333333333333333333333333333333')
|
||||||
command, addressVersionNumber, streamNumber, label, \
|
command, addressVersionNumber, streamNumber, label, \
|
||||||
numberOfAddressesToMake, deterministicPassphrase, \
|
numberOfAddressesToMake, deterministicPassphrase, \
|
||||||
eighteenByteRipe, nonceTrialsPerByte, \
|
eighteenByteRipe, nonceTrialsPerByte, \
|
||||||
|
@ -112,12 +130,11 @@ class addressGenerator(StoppableThread):
|
||||||
# the default
|
# the default
|
||||||
numberOfNullBytesDemandedOnFrontOfRipeHash = 1
|
numberOfNullBytesDemandedOnFrontOfRipeHash = 1
|
||||||
elif queueValue[0] == 'stopThread':
|
elif queueValue[0] == 'stopThread':
|
||||||
logger.info('!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!')
|
logger.info(
|
||||||
logger.info('queueValue[0] == stopThread is this condition are true')
|
'444444444444444444444444444444444444444444')
|
||||||
logger.info('!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!')
|
|
||||||
break
|
break
|
||||||
else:
|
else:
|
||||||
self.logger.info(
|
logger.info(
|
||||||
'Programming error: A structure with the wrong number'
|
'Programming error: A structure with the wrong number'
|
||||||
' of values was passed into the addressGeneratorQueue.'
|
' of values was passed into the addressGeneratorQueue.'
|
||||||
' Here is the queueValue: %r\n', queueValue)
|
' Here is the queueValue: %r\n', queueValue)
|
||||||
|
|
|
@ -937,10 +937,10 @@ class objectProcessor(threading.Thread):
|
||||||
return
|
return
|
||||||
readPosition += sendersStreamLength
|
readPosition += sendersStreamLength
|
||||||
readPosition += 4
|
readPosition += 4
|
||||||
sendersPubSigningKey = '\x04' + \
|
sendersPubSigningKey = '\x04'.encode() + \
|
||||||
decryptedData[readPosition:readPosition + 64]
|
decryptedData[readPosition:readPosition + 64]
|
||||||
readPosition += 64
|
readPosition += 64
|
||||||
sendersPubEncryptionKey = '\x04' + \
|
sendersPubEncryptionKey = '\x04'.encode() + \
|
||||||
decryptedData[readPosition:readPosition + 64]
|
decryptedData[readPosition:readPosition + 64]
|
||||||
readPosition += 64
|
readPosition += 64
|
||||||
if sendersAddressVersion >= 3:
|
if sendersAddressVersion >= 3:
|
||||||
|
|
|
@ -55,6 +55,7 @@ except ModuleNotFoundError:
|
||||||
from pybitmessage.helper_sql import sqlExecute, sqlQuery
|
from pybitmessage.helper_sql import sqlExecute, sqlQuery
|
||||||
from pybitmessage.inventory import Inventory
|
from pybitmessage.inventory import Inventory
|
||||||
from pybitmessage.network.threads import StoppableThread
|
from pybitmessage.network.threads import StoppableThread
|
||||||
|
from pybitmessage.debug import logger
|
||||||
# This thread, of which there is only one, does the heavy lifting:
|
# This thread, of which there is only one, does the heavy lifting:
|
||||||
# calculating POWs.
|
# calculating POWs.
|
||||||
|
|
||||||
|
@ -83,17 +84,19 @@ class singleWorker(StoppableThread):
|
||||||
queues.workerQueue.put(("stopThread", "data"))
|
queues.workerQueue.put(("stopThread", "data"))
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
super(singleWorker, self).stopThread()
|
super(singleWorker, self).stopThread()
|
||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
# pylint: disable=attribute-defined-outside-init
|
# pylint: disable=attribute-defined-outside-init
|
||||||
|
|
||||||
|
logger.error
|
||||||
while not state.sqlReady and state.shutdown == 0:
|
while not state.sqlReady and state.shutdown == 0:
|
||||||
self.stop.wait(2)
|
self.stop.wait(2)
|
||||||
if state.shutdown > 0:
|
if state.shutdown > 0:
|
||||||
return
|
return
|
||||||
|
|
||||||
# Initialize the neededPubkeys dictionary.
|
# Initialize the neededPubkeys dictionary.
|
||||||
|
|
||||||
queryreturn = sqlQuery(
|
queryreturn = sqlQuery(
|
||||||
'''SELECT DISTINCT toaddress FROM sent'''
|
'''SELECT DISTINCT toaddress FROM sent'''
|
||||||
''' WHERE (status='awaitingpubkey' AND folder LIKE '%sent%')''')
|
''' WHERE (status='awaitingpubkey' AND folder LIKE '%sent%')''')
|
||||||
|
|
|
@ -52,7 +52,7 @@ helper_startup.loadConfig()
|
||||||
# logging.config.fileConfig interface
|
# logging.config.fileConfig interface
|
||||||
# examples are here:
|
# examples are here:
|
||||||
# https://bitmessage.org/forum/index.php/topic,4820.msg11163.html#msg11163
|
# https://bitmessage.org/forum/index.php/topic,4820.msg11163.html#msg11163
|
||||||
log_level = 'INFO'
|
log_level = 'DEBUG'
|
||||||
|
|
||||||
def log_uncaught_exceptions(ex_cls, ex, tb):
|
def log_uncaught_exceptions(ex_cls, ex, tb):
|
||||||
"""The last resort logging function used for sys.excepthook"""
|
"""The last resort logging function used for sys.excepthook"""
|
||||||
|
|
|
@ -124,6 +124,9 @@ def createDefaultKnownNodes():
|
||||||
def readKnownNodes():
|
def readKnownNodes():
|
||||||
"""Load knownnodes from filesystem"""
|
"""Load knownnodes from filesystem"""
|
||||||
try:
|
try:
|
||||||
|
logger.info('~~~~~~~~~~~~~~~~~~~~~~~~~~')
|
||||||
|
logger.info('pppp state.appdata -{} pppp'.format(state.appdata))
|
||||||
|
logger.info('~~~~~~~~~~~~~~~~~~~~~~~~~~')
|
||||||
with open(state.appdata + 'knownnodes.dat', 'rb') as source:
|
with open(state.appdata + 'knownnodes.dat', 'rb') as source:
|
||||||
with knownNodesLock:
|
with knownNodesLock:
|
||||||
try:
|
try:
|
||||||
|
|
|
@ -495,7 +495,7 @@ class ECC(object):
|
||||||
blocksize = OpenSSL.get_cipher(ciphername).get_blocksize()
|
blocksize = OpenSSL.get_cipher(ciphername).get_blocksize()
|
||||||
iv = data[:blocksize]
|
iv = data[:blocksize]
|
||||||
i = blocksize
|
i = blocksize
|
||||||
_, pubkey_x, pubkey_y, i2 = ECC._decode_pubkey(data[i:])
|
_, pubkey_x, pubkey_y, i2 = ECC._decode_pubkey(bytes(data[i:]))
|
||||||
i += i2
|
i += i2
|
||||||
ciphertext = data[i:len(data) - 32]
|
ciphertext = data[i:len(data) - 32]
|
||||||
i += len(ciphertext)
|
i += len(ciphertext)
|
||||||
|
|
|
@ -725,9 +725,9 @@ class _OpenSSL(object):
|
||||||
if data != 0:
|
if data != 0:
|
||||||
if sys.version_info.major == 3 and isinstance(data, type('')):
|
if sys.version_info.major == 3 and isinstance(data, type('')):
|
||||||
data = data.encode()
|
data = data.encode()
|
||||||
buffer_ = self.create_string_buffer(data, size)
|
buffer_ = self.create_string_buffer(bytes(data), size)
|
||||||
else:
|
else:
|
||||||
buffer_ = self.create_string_buffer(size)
|
buffer_ = self.create_string_buffer(bytes(size))
|
||||||
return buffer_
|
return buffer_
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,8 @@
|
||||||
import queue as Queue
|
import queue as Queue
|
||||||
|
|
||||||
import threading
|
import threading
|
||||||
import time
|
import time
|
||||||
|
import traceback
|
||||||
|
|
||||||
try:
|
try:
|
||||||
from multiqueue import MultiQueue
|
from multiqueue import MultiQueue
|
||||||
|
@ -37,10 +38,34 @@ class ObjectProcessorQueue(Queue.Queue):
|
||||||
self.curSize -= len(item[1])
|
self.curSize -= len(item[1])
|
||||||
return item
|
return item
|
||||||
|
|
||||||
|
class addressGeneratorQueueClass(Queue.Queue):
|
||||||
|
|
||||||
|
debug_file = open("/tmp/addressgenerator.log", "a")
|
||||||
|
|
||||||
|
def __init__(self):
|
||||||
|
Queue.Queue.__init__(self)
|
||||||
|
|
||||||
|
def put(self, item, block =True, timeout=None):
|
||||||
|
self.debug_file.write('-------------------\n')
|
||||||
|
self.debug_file.write('this put condition- ')
|
||||||
|
self.debug_file.write(threading.current_thread().name)
|
||||||
|
self.debug_file.write(traceback.print_exc())
|
||||||
|
Queue.Queue.put(self, item, block, timeout)
|
||||||
|
self.debug_file.write('-------------------\n')
|
||||||
|
|
||||||
|
|
||||||
|
def get(self, item, block =True, timeout=None):
|
||||||
|
self.debug_file.write('-------------------\n')
|
||||||
|
self.debug_file.write('this get condition -')
|
||||||
|
self.debug_file.write(threading.current_thread().name)
|
||||||
|
self.debug_file.write(traceback.print_exc())
|
||||||
|
item = Queue.Queue.get(self, block, timeout)
|
||||||
|
self.debug_file.write('-------------------\n')
|
||||||
|
return item
|
||||||
|
|
||||||
workerQueue = Queue.Queue()
|
workerQueue = Queue.Queue()
|
||||||
UISignalQueue = Queue.Queue()
|
UISignalQueue = Queue.Queue()
|
||||||
addressGeneratorQueue = Queue.Queue()
|
addressGeneratorQueue = addressGeneratorQueueClass()
|
||||||
#: `.network.ReceiveQueueThread` instances dump objects they hear
|
#: `.network.ReceiveQueueThread` instances dump objects they hear
|
||||||
#: on the network into this queue to be processed.
|
#: on the network into this queue to be processed.
|
||||||
objectProcessorQueue = ObjectProcessorQueue()
|
objectProcessorQueue = ObjectProcessorQueue()
|
||||||
|
@ -53,3 +78,6 @@ receiveDataQueue = Queue.Queue()
|
||||||
apiAddressGeneratorReturnQueue = Queue.Queue()
|
apiAddressGeneratorReturnQueue = Queue.Queue()
|
||||||
#: for exceptions
|
#: for exceptions
|
||||||
excQueue = Queue.Queue()
|
excQueue = Queue.Queue()
|
||||||
|
|
||||||
|
|
||||||
|
#new
|
|
@ -28,9 +28,14 @@ class TestAPIProto(TestProcessProto):
|
||||||
"""Setup XMLRPC proxy for pybitmessage API"""
|
"""Setup XMLRPC proxy for pybitmessage API"""
|
||||||
# super(TestAPIProto, cls).tearDownClass()
|
# super(TestAPIProto, cls).tearDownClass()
|
||||||
try:
|
try:
|
||||||
|
print('*****************************')
|
||||||
|
print('try block is I am successfully called the ')
|
||||||
|
print('*****************************')
|
||||||
super(TestAPIProto, cls).setUpClass()
|
super(TestAPIProto, cls).setUpClass()
|
||||||
except:
|
except:
|
||||||
pass
|
print('(((((((((((((((((((((((')
|
||||||
|
print('except block because of this condition are getting failed')
|
||||||
|
print('))))))))))))))))))))))))')
|
||||||
|
|
||||||
cls.addresses = []
|
cls.addresses = []
|
||||||
cls.api = xmlrpclib.ServerProxy(
|
cls.api = xmlrpclib.ServerProxy(
|
||||||
|
@ -62,9 +67,9 @@ class TestAPIShutdown(TestAPIProto, TestProcessShutdown):
|
||||||
|
|
||||||
class TestAPI(TestAPIProto):
|
class TestAPI(TestAPIProto):
|
||||||
"""Main API test case"""
|
"""Main API test case"""
|
||||||
_seed = base64.encodestring(
|
_seed = base64.encodebytes(
|
||||||
'TIGER, tiger, burning bright. In the forests of the night'.encode()
|
'TIGER, tiger, burning bright. In the forests of the night'.encode(
|
||||||
)
|
'raw_unicode_escape'))
|
||||||
|
|
||||||
def _add_random_address(self, label):
|
def _add_random_address(self, label):
|
||||||
return self.api.createRandomAddress(base64.encodestring(label))
|
return self.api.createRandomAddress(base64.encodestring(label))
|
||||||
|
@ -197,23 +202,23 @@ class TestAPI(TestAPIProto):
|
||||||
"""Testing chan creation/joining"""
|
"""Testing chan creation/joining"""
|
||||||
# Cheate chan with known address
|
# Cheate chan with known address
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
self.api.createChan(self._seed),
|
self.api.createChan(self._seed),
|
||||||
'BM-2cWzSnwjJ7yRP3nLEWUV5LisTZyREWSzUK'
|
'BM-2cWzSnwjJ7yRP3nLEWUV5LisTZyREWSzUK'
|
||||||
)
|
)
|
||||||
# cleanup
|
# # cleanup
|
||||||
self.assertEqual(
|
# self.assertEqual(
|
||||||
self.api.leaveChan('BM-2cWzSnwjJ7yRP3nLEWUV5LisTZyREWSzUK'),
|
# self.api.leaveChan('BM-2cWzSnwjJ7yRP3nLEWUV5LisTZyREWSzUK'),
|
||||||
'success'
|
# 'success'
|
||||||
)
|
# )
|
||||||
# Join chan with addresses of version 3 or 4
|
# # Join chan with addresses of version 3 or 4
|
||||||
for addr in (
|
# for addr in (
|
||||||
'BM-2cWzSnwjJ7yRP3nLEWUV5LisTZyREWSzUK',
|
# 'BM-2cWzSnwjJ7yRP3nLEWUV5LisTZyREWSzUK',
|
||||||
'BM-2DBPTgeSawWYZceFD69AbDT5q4iUWtj1ZN'
|
# 'BM-2DBPTgeSawWYZceFD69AbDT5q4iUWtj1ZN'
|
||||||
):
|
# ):
|
||||||
self.assertEqual(self.api.joinChan(self._seed, addr), 'success')
|
# self.assertEqual(self.api.joinChan(self._seed, addr), 'success')
|
||||||
self.assertEqual(self.api.leaveChan(addr), 'success')
|
# self.assertEqual(self.api.leaveChan(addr), 'success')
|
||||||
# Joining with wrong address should fail
|
# # Joining with wrong address should fail
|
||||||
self.assertRegexpMatches(
|
# self.assertRegexpMatches(
|
||||||
self.api.joinChan(self._seed, 'BM-2cWzSnwjJ7yRP3nLEW'),
|
# self.api.joinChan(self._seed, 'BM-2cWzSnwjJ7yRP3nLEW'),
|
||||||
r'^API Error 0008:'
|
# r'^API Error 0008:'
|
||||||
)
|
# )
|
||||||
|
|
|
@ -9,6 +9,8 @@ import tempfile
|
||||||
import time
|
import time
|
||||||
import unittest
|
import unittest
|
||||||
|
|
||||||
|
from pybitmessage.debug import logger
|
||||||
|
|
||||||
try:
|
try:
|
||||||
import psutil
|
import psutil
|
||||||
except ModuleNotFoundError:
|
except ModuleNotFoundError:
|
||||||
|
@ -19,15 +21,12 @@ def put_signal_file(path, filename):
|
||||||
"""Creates file, presence of which is a signal about some event."""
|
"""Creates file, presence of which is a signal about some event."""
|
||||||
with open(os.path.join(path, filename), 'wb') as outfile:
|
with open(os.path.join(path, filename), 'wb') as outfile:
|
||||||
outfile.write(str(time.time()).encode())
|
outfile.write(str(time.time()).encode())
|
||||||
print('************************************************')
|
|
||||||
with open(os.path.join(path, filename), 'r') as outfile:
|
|
||||||
print(outfile.read())
|
|
||||||
print('************************************************')
|
|
||||||
|
|
||||||
class TestProcessProto(unittest.TestCase):
|
class TestProcessProto(unittest.TestCase):
|
||||||
"""Test case implementing common logic for external testing:
|
"""Test case implementing common logic for external testing:
|
||||||
it starts pybitmessage in setUpClass() and stops it in tearDownClass()
|
it starts pybitmessage in setUpClass() and stops it in tearDownClass()
|
||||||
"""
|
"""
|
||||||
|
|
||||||
_process_cmd = ['pybitmessage', '-d']
|
_process_cmd = ['pybitmessage', '-d']
|
||||||
_threads_count = 15
|
_threads_count = 15
|
||||||
_files = (
|
_files = (
|
||||||
|
@ -45,6 +44,16 @@ class TestProcessProto(unittest.TestCase):
|
||||||
time.sleep(5)
|
time.sleep(5)
|
||||||
cls.pid = int(cls._get_readline('singleton.lock'))
|
cls.pid = int(cls._get_readline('singleton.lock'))
|
||||||
cls.process = psutil.Process(cls.pid)
|
cls.process = psutil.Process(cls.pid)
|
||||||
|
#comment
|
||||||
|
# logger.error('~~~$$$$$$$$^^^^&&&&&&&~~~')
|
||||||
|
# logger.info('cls.proccess_pid -{}'.format(
|
||||||
|
# cls.process.pid))
|
||||||
|
# logger.error('cls.proccess_name -{}'.format(
|
||||||
|
# cls.process.name))
|
||||||
|
# logger.error('cls.proccess_create_time -{}'.format(
|
||||||
|
# cls.process._create_time))
|
||||||
|
# logger.error('~~~$$$$$$$$^^^^&&&&&&&~~~')
|
||||||
|
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def _get_readline(cls, pfile):
|
def _get_readline(cls, pfile):
|
||||||
|
@ -74,7 +83,6 @@ class TestProcessProto(unittest.TestCase):
|
||||||
print('going to open the debug.log file-{}'.format(pfile))
|
print('going to open the debug.log file-{}'.format(pfile))
|
||||||
print(os.path.join(cls.home, pfile))
|
print(os.path.join(cls.home, pfile))
|
||||||
print('75757575757575757575757')
|
print('75757575757575757575757')
|
||||||
import pdb; pdb.set_trace()
|
|
||||||
try:
|
try:
|
||||||
with open(os.path.join(cls.home, pfile), 'r') as outfile:
|
with open(os.path.join(cls.home, pfile), 'r') as outfile:
|
||||||
print(outfile.readlines())
|
print(outfile.readlines())
|
||||||
|
|
Reference in New Issue
Block a user