Solved all TestAPI issues
This commit is contained in:
parent
74d043bd21
commit
550be6e4ec
60
src/api.py
60
src/api.py
|
@ -451,12 +451,13 @@ class MySimpleXMLRPCRequestHandler(SimpleXMLRPCRequestHandler):
|
||||||
smallMessageDifficulty)
|
smallMessageDifficulty)
|
||||||
else:
|
else:
|
||||||
raise APIError(0, 'Too many parameters!')
|
raise APIError(0, 'Too many parameters!')
|
||||||
label = self._decode(label.data, "base64")
|
label = self._decode(label.data, "base64").decode()
|
||||||
queues.apiAddressGeneratorReturnQueue.queue.clear()
|
queues.apiAddressGeneratorReturnQueue.queue.clear()
|
||||||
streamNumberForAddress = 1
|
streamNumberForAddress = 1
|
||||||
queues.addressGeneratorQueue.put((
|
queues.addressGeneratorQueue.put((
|
||||||
'createRandomAddress', 4, streamNumberForAddress, label, 1, "",
|
'createRandomAddress', 4, streamNumberForAddress, label, 1, "",
|
||||||
eighteenByteRipe, nonceTrialsPerByte, payloadLengthExtraBytes
|
eighteenByteRipe, int(nonceTrialsPerByte),
|
||||||
|
int(payloadLengthExtraBytes)
|
||||||
))
|
))
|
||||||
return queues.apiAddressGeneratorReturnQueue.get()
|
return queues.apiAddressGeneratorReturnQueue.get()
|
||||||
|
|
||||||
|
@ -575,7 +576,7 @@ class MySimpleXMLRPCRequestHandler(SimpleXMLRPCRequestHandler):
|
||||||
queues.addressGeneratorQueue.put((
|
queues.addressGeneratorQueue.put((
|
||||||
'createDeterministicAddresses', addressVersionNumber, streamNumber,
|
'createDeterministicAddresses', addressVersionNumber, streamNumber,
|
||||||
'unused API address', numberOfAddresses, passphrase,
|
'unused API address', numberOfAddresses, passphrase,
|
||||||
eighteenByteRipe, nonceTrialsPerByte, payloadLengthExtraBytes
|
eighteenByteRipe, int(nonceTrialsPerByte), int(payloadLengthExtraBytes)
|
||||||
))
|
))
|
||||||
data = '{"addresses":['
|
data = '{"addresses":['
|
||||||
queueReturn = queues.apiAddressGeneratorReturnQueue.get()
|
queueReturn = queues.apiAddressGeneratorReturnQueue.get()
|
||||||
|
@ -595,7 +596,7 @@ class MySimpleXMLRPCRequestHandler(SimpleXMLRPCRequestHandler):
|
||||||
eighteenByteRipe = False
|
eighteenByteRipe = False
|
||||||
if not passphrase:
|
if not passphrase:
|
||||||
raise APIError(1, 'The specified passphrase is blank.')
|
raise APIError(1, 'The specified passphrase is blank.')
|
||||||
passphrase = self._decode(passphrase.data, "base64")
|
passphrase = self._decode(passphrase.data, "base64").decode()
|
||||||
# if addressVersionNumber != 3 and addressVersionNumber != 4:
|
# if addressVersionNumber != 3 and addressVersionNumber != 4:
|
||||||
if addressVersionNumber not in (3, 4):
|
if addressVersionNumber not in (3, 4):
|
||||||
raise APIError(
|
raise APIError(
|
||||||
|
@ -623,32 +624,19 @@ class MySimpleXMLRPCRequestHandler(SimpleXMLRPCRequestHandler):
|
||||||
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").decode()
|
||||||
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.
|
|
||||||
# try:
|
label = str_chan + ' ' + passphrase
|
||||||
# unicode(passphrase, 'utf-8')
|
|
||||||
# label = str_chan + ' ' + passphrase
|
|
||||||
# except BaseException:
|
|
||||||
label = str_chan + ' ' + passphrase.decode()
|
|
||||||
addressVersionNumber = 4
|
addressVersionNumber = 4
|
||||||
streamNumber = 1
|
streamNumber = 1
|
||||||
try:
|
|
||||||
queues.addressGeneratorQueue.put((
|
queues.addressGeneratorQueue.put((
|
||||||
'createChan', addressVersionNumber, streamNumber, label,
|
'createChan', addressVersionNumber, streamNumber, label,
|
||||||
passphrase.decode(), True
|
passphrase, True
|
||||||
))
|
))
|
||||||
logger.info(
|
|
||||||
'@@@@@@@@ before printing the queueReturn @@@@@@@@@')
|
|
||||||
queueReturn = queues.apiAddressGeneratorReturnQueue.get()
|
queueReturn = queues.apiAddressGeneratorReturnQueue.get()
|
||||||
logger.info('***********************************')
|
|
||||||
logger.info('queueReturn-{}'.format(queueReturn))
|
|
||||||
logger.info('***********************************')
|
|
||||||
|
|
||||||
except Exception as e:
|
|
||||||
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]
|
||||||
|
@ -661,23 +649,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.data, "base64")
|
passphrase = self._decode(passphrase.data, "base64").decode()
|
||||||
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
|
label = str_chan + ' ' + passphrase
|
||||||
# possible that the passphrase contains non-utf-8 characters.
|
|
||||||
# try:
|
|
||||||
# unicode(passphrase, 'utf-8')
|
|
||||||
# label = str_chan + ' ' + passphrase
|
|
||||||
# except BaseException:
|
|
||||||
# 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)
|
||||||
queues.apiAddressGeneratorReturnQueue.queue.clear()
|
queues.apiAddressGeneratorReturnQueue.queue.clear()
|
||||||
queues.addressGeneratorQueue.put((
|
queues.addressGeneratorQueue.put((
|
||||||
'joinChan', suppliedAddress, label, passphrase, True
|
'joinChan', suppliedAddress, label,
|
||||||
|
passphrase, True
|
||||||
))
|
))
|
||||||
addressGeneratorReturnValue = \
|
addressGeneratorReturnValue = \
|
||||||
queues.apiAddressGeneratorReturnQueue.get()
|
queues.apiAddressGeneratorReturnQueue.get()
|
||||||
|
@ -707,7 +689,7 @@ class MySimpleXMLRPCRequestHandler(SimpleXMLRPCRequestHandler):
|
||||||
25, 'Specified address is not a chan address.'
|
25, 'Specified address is not a chan address.'
|
||||||
' Use deleteAddress API call instead.')
|
' Use deleteAddress API call instead.')
|
||||||
BMConfigParser().remove_section(address)
|
BMConfigParser().remove_section(address)
|
||||||
with open(state.appdata + 'keys.dat', 'wb') as configfile:
|
with open(state.appdata + 'keys.dat', 'w') as configfile:
|
||||||
BMConfigParser().write(configfile)
|
BMConfigParser().write(configfile)
|
||||||
return 'success'
|
return 'success'
|
||||||
|
|
||||||
|
@ -725,7 +707,7 @@ class MySimpleXMLRPCRequestHandler(SimpleXMLRPCRequestHandler):
|
||||||
raise APIError(
|
raise APIError(
|
||||||
13, 'Could not find this address in your keys.dat file.')
|
13, 'Could not find this address in your keys.dat file.')
|
||||||
BMConfigParser().remove_section(address)
|
BMConfigParser().remove_section(address)
|
||||||
with open(state.appdata + 'keys.dat', 'wb') as configfile:
|
with open(state.appdata + 'keys.dat', 'w') as configfile:
|
||||||
BMConfigParser().write(configfile)
|
BMConfigParser().write(configfile)
|
||||||
queues.UISignalQueue.put(('writeNewAddressToTable', ('', '', '')))
|
queues.UISignalQueue.put(('writeNewAddressToTable', ('', '', '')))
|
||||||
shared.reloadMyAddressHashes()
|
shared.reloadMyAddressHashes()
|
||||||
|
@ -1096,10 +1078,9 @@ class MySimpleXMLRPCRequestHandler(SimpleXMLRPCRequestHandler):
|
||||||
|
|
||||||
def HandleSendBroadcast(self, params):
|
def HandleSendBroadcast(self, params):
|
||||||
"""Handle a request to send a broadcast message"""
|
"""Handle a request to send a broadcast message"""
|
||||||
|
|
||||||
if not params:
|
if not params:
|
||||||
raise APIError(0, 'I need parameters!')
|
raise APIError(0, 'I need parameters!')
|
||||||
|
logger.error('HandleSendBroadcast 1085')
|
||||||
if len(params) == 3:
|
if len(params) == 3:
|
||||||
fromAddress, subject, message = params
|
fromAddress, subject, message = params
|
||||||
encodingType = 2
|
encodingType = 2
|
||||||
|
@ -1113,10 +1094,11 @@ class MySimpleXMLRPCRequestHandler(SimpleXMLRPCRequestHandler):
|
||||||
|
|
||||||
if encodingType not in [2, 3]:
|
if encodingType not in [2, 3]:
|
||||||
raise APIError(6, 'The encoding type must be 2 or 3.')
|
raise APIError(6, 'The encoding type must be 2 or 3.')
|
||||||
|
subject = self._decode(subject.data, "base64").decode()
|
||||||
subject = self._decode(subject, "base64")
|
message = self._decode(message.data, "base64").decode()
|
||||||
message = self._decode(message, "base64")
|
logger.error('HandleSendBroadcast 1106')
|
||||||
if len(subject + message) > (2 ** 18 - 500):
|
if len(subject + message) > (2 ** 18 - 500):
|
||||||
|
logger.error('HandleSendBroadcast 1108')
|
||||||
raise APIError(27, 'Message is too long.')
|
raise APIError(27, 'Message is too long.')
|
||||||
if TTL < 60 * 60:
|
if TTL < 60 * 60:
|
||||||
TTL = 60 * 60
|
TTL = 60 * 60
|
||||||
|
@ -1133,7 +1115,6 @@ class MySimpleXMLRPCRequestHandler(SimpleXMLRPCRequestHandler):
|
||||||
ackdata = genAckPayload(streamNumber, 0)
|
ackdata = genAckPayload(streamNumber, 0)
|
||||||
toAddress = '[Broadcast subscribers]'
|
toAddress = '[Broadcast subscribers]'
|
||||||
ripe = ''
|
ripe = ''
|
||||||
|
|
||||||
t = ('',
|
t = ('',
|
||||||
toAddress,
|
toAddress,
|
||||||
ripe,
|
ripe,
|
||||||
|
@ -1150,7 +1131,6 @@ class MySimpleXMLRPCRequestHandler(SimpleXMLRPCRequestHandler):
|
||||||
2,
|
2,
|
||||||
TTL)
|
TTL)
|
||||||
helper_sent.insert(t)
|
helper_sent.insert(t)
|
||||||
|
|
||||||
toLabel = '[Broadcast subscribers]'
|
toLabel = '[Broadcast subscribers]'
|
||||||
queues.UISignalQueue.put(('displayNewSentMessage', (
|
queues.UISignalQueue.put(('displayNewSentMessage', (
|
||||||
toAddress, toLabel, fromAddress, subject, message, ackdata)))
|
toAddress, toLabel, fromAddress, subject, message, ackdata)))
|
||||||
|
|
|
@ -118,22 +118,27 @@ class addressGenerator(StoppableThread):
|
||||||
numberOfNullBytesDemandedOnFrontOfRipeHash = 1
|
numberOfNullBytesDemandedOnFrontOfRipeHash = 1
|
||||||
elif len(queueValue) == 9:
|
elif len(queueValue) == 9:
|
||||||
|
|
||||||
logger.info(
|
logger.error('createRandomAddress 122')
|
||||||
'33333333333333333333333333333333333333')
|
|
||||||
command, addressVersionNumber, streamNumber, label, \
|
command, addressVersionNumber, streamNumber, label, \
|
||||||
numberOfAddressesToMake, deterministicPassphrase, \
|
numberOfAddressesToMake, deterministicPassphrase, \
|
||||||
eighteenByteRipe, nonceTrialsPerByte, \
|
eighteenByteRipe, nonceTrialsPerByte, \
|
||||||
payloadLengthExtraBytes = queueValue
|
payloadLengthExtraBytes = queueValue
|
||||||
|
logger.error('createRandomAddress 126')
|
||||||
try:
|
try:
|
||||||
|
logger.error('createRandomAddress 128')
|
||||||
numberOfNullBytesDemandedOnFrontOfRipeHash = \
|
numberOfNullBytesDemandedOnFrontOfRipeHash = \
|
||||||
BMConfigParser().getint(
|
BMConfigParser().getint(
|
||||||
'bitmessagesettings',
|
'bitmessagesettings',
|
||||||
'numberofnullbytesonaddress'
|
'numberofnullbytesonaddress'
|
||||||
)
|
)
|
||||||
|
logger.error('createRandomAddress 134')
|
||||||
except:
|
except:
|
||||||
|
logger.error('createRandomAddress 136')
|
||||||
if eighteenByteRipe:
|
if eighteenByteRipe:
|
||||||
|
logger.error('createRandomAddress 138')
|
||||||
numberOfNullBytesDemandedOnFrontOfRipeHash = 2
|
numberOfNullBytesDemandedOnFrontOfRipeHash = 2
|
||||||
else:
|
else:
|
||||||
|
logger.error('createRandomAddress 141')
|
||||||
# the default
|
# the default
|
||||||
numberOfNullBytesDemandedOnFrontOfRipeHash = 1
|
numberOfNullBytesDemandedOnFrontOfRipeHash = 1
|
||||||
elif queueValue[0] == 'stopThread':
|
elif queueValue[0] == 'stopThread':
|
||||||
|
@ -145,46 +150,63 @@ class addressGenerator(StoppableThread):
|
||||||
'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)
|
||||||
|
logger.error('createRandomAddress 153')
|
||||||
if addressVersionNumber < 3 or addressVersionNumber > 4:
|
if addressVersionNumber < 3 or addressVersionNumber > 4:
|
||||||
self.logger.error(
|
self.logger.error(
|
||||||
'Program error: For some reason the address generator'
|
'Program error: For some reason the address generator'
|
||||||
' queue has been given a request to create at least'
|
' queue has been given a request to create at least'
|
||||||
' one version %s address which it cannot do.\n',
|
' one version %s address which it cannot do.\n',
|
||||||
addressVersionNumber)
|
addressVersionNumber)
|
||||||
|
logger.error('createRandomAddress 160')
|
||||||
if nonceTrialsPerByte == 0:
|
if nonceTrialsPerByte == 0:
|
||||||
logger.error('++++++++++++170++++++++++++')
|
logger.error('++++++++++++170++++++++++++')
|
||||||
nonceTrialsPerByte = BMConfigParser().getint(
|
nonceTrialsPerByte = BMConfigParser().getint(
|
||||||
'bitmessagesettings', 'defaultnoncetrialsperbyte')
|
'bitmessagesettings', 'defaultnoncetrialsperbyte')
|
||||||
|
logger.error('createRandomAddress 165')
|
||||||
|
try:
|
||||||
if nonceTrialsPerByte < \
|
if nonceTrialsPerByte < \
|
||||||
defaults.networkDefaultProofOfWorkNonceTrialsPerByte:
|
defaults.networkDefaultProofOfWorkNonceTrialsPerByte:
|
||||||
logger.error('++++++++++++175++++++++++++')
|
logger.error('++++++++++++175++++++++++++')
|
||||||
nonceTrialsPerByte = \
|
nonceTrialsPerByte = \
|
||||||
defaults.networkDefaultProofOfWorkNonceTrialsPerByte
|
defaults.networkDefaultProofOfWorkNonceTrialsPerByte
|
||||||
|
except Exception as e:
|
||||||
|
logger.error('type(nonceTrialsPerByte) -{}'.format(
|
||||||
|
type(nonceTrialsPerByte)))
|
||||||
|
logger.error('type(defaults.networkDefaultProofOfWorkNonceTrialsPerByte) -{}'.format(
|
||||||
|
type(defaults.networkDefaultProofOfWorkNonceTrialsPerByte)))
|
||||||
|
logger.error('createRandomAddress except')
|
||||||
|
logger.error(str(e))
|
||||||
|
logger.error('createRandomAddress 171')
|
||||||
if payloadLengthExtraBytes == 0:
|
if payloadLengthExtraBytes == 0:
|
||||||
logger.error('++++++++++++179++++++++++++')
|
logger.error('++++++++++++179++++++++++++')
|
||||||
payloadLengthExtraBytes = BMConfigParser().getint(
|
payloadLengthExtraBytes = BMConfigParser().getint(
|
||||||
'bitmessagesettings', 'defaultpayloadlengthextrabytes')
|
'bitmessagesettings', 'defaultpayloadlengthextrabytes')
|
||||||
|
logger.error('createRandomAddress 176')
|
||||||
if payloadLengthExtraBytes < \
|
if payloadLengthExtraBytes < \
|
||||||
defaults.networkDefaultPayloadLengthExtraBytes:
|
defaults.networkDefaultPayloadLengthExtraBytes:
|
||||||
logger.error('++++++++++++184++++++++++++')
|
logger.error('++++++++++++184++++++++++++')
|
||||||
payloadLengthExtraBytes = \
|
payloadLengthExtraBytes = \
|
||||||
defaults.networkDefaultPayloadLengthExtraBytes
|
defaults.networkDefaultPayloadLengthExtraBytes
|
||||||
|
logger.error('createRandomAddress 181')
|
||||||
if command == 'createRandomAddress':
|
if command == 'createRandomAddress':
|
||||||
logger.error('++++++++++++188++++++++++++')
|
logger.error('++++++++++++188++++++++++++')
|
||||||
queues.UISignalQueue.put((
|
queues.UISignalQueue.put((
|
||||||
'updateStatusBar', ""
|
'updateStatusBar', ""
|
||||||
))
|
))
|
||||||
logger.info('&&&&&&&&&&&&&&&&&&&&&&&')
|
logger.error('&&&&&&&&&&&&&&&&&&&&&&&')
|
||||||
logger.info('---------144--------------')
|
logger.error('---------144--------------')
|
||||||
logger.info('&&&&&&&&&&&&&&&&&&&&&&&\n')
|
logger.error('&&&&&&&&&&&&&&&&&&&&&&&')
|
||||||
# This next section is a little bit strange. We're going
|
# This next section is a little bit strange. We're going
|
||||||
# to generate keys over and over until we find one
|
# to generate keys over and over until we find one
|
||||||
# that starts with either \x00 or \x00\x00. Then when
|
# that starts with either \x00 or \x00\x00. Then when
|
||||||
# we pack them into a Bitmessage address, we won't store
|
# we pack them into a Bitmessage address, we won't store
|
||||||
# the \x00 or \x00\x00 bytes thus making the address shorter.
|
# the \x00 or \x00\x00 bytes thus making the address shorter.
|
||||||
|
logger.error('createRandomAddress 190')
|
||||||
startTime = time.time()
|
startTime = time.time()
|
||||||
numberOfAddressesWeHadToMakeBeforeWeFoundOneWithTheCorrectRipePrefix = 0
|
numberOfAddressesWeHadToMakeBeforeWeFoundOneWithTheCorrectRipePrefix = 0
|
||||||
|
logger.error('createRandomAddress 193')
|
||||||
potentialPrivSigningKey = OpenSSL.rand(32)
|
potentialPrivSigningKey = OpenSSL.rand(32)
|
||||||
|
logger.error('createRandomAddress 194')
|
||||||
potentialPubSigningKey = highlevelcrypto.pointMult(
|
potentialPubSigningKey = highlevelcrypto.pointMult(
|
||||||
potentialPrivSigningKey)
|
potentialPrivSigningKey)
|
||||||
logger.error('&&&&&&&&&&&&&&&&&&&&&&&')
|
logger.error('&&&&&&&&&&&&&&&&&&&&&&&')
|
||||||
|
|
|
@ -21,22 +21,12 @@ class TestAPIProto(TestProcessProto):
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def setUpClass(cls):
|
def setUpClass(cls):
|
||||||
print('@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@')
|
|
||||||
print('is this TestAPIProto')
|
|
||||||
print('@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@')
|
|
||||||
|
|
||||||
"""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:
|
||||||
print('(((((((((((((((((((((((')
|
pass
|
||||||
print('except block because of this condition are getting failed')
|
|
||||||
print('))))))))))))))))))))))))')
|
|
||||||
|
|
||||||
cls.addresses = []
|
cls.addresses = []
|
||||||
cls.api = xmlrpclib.ServerProxy(
|
cls.api = xmlrpclib.ServerProxy(
|
||||||
"http://username:password@127.0.0.1:8442/")
|
"http://username:password@127.0.0.1:8442/")
|
||||||
|
@ -125,7 +115,6 @@ class TestAPI(TestAPIProto):
|
||||||
self.assertEqual(result['streamNumber'], 1)
|
self.assertEqual(result['streamNumber'], 1)
|
||||||
|
|
||||||
def test_create_deterministic_addresses(self):
|
def test_create_deterministic_addresses(self):
|
||||||
#11111111111111111111111111
|
|
||||||
"""API command 'getDeterministicAddress': with various params"""
|
"""API command 'getDeterministicAddress': with various params"""
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
self.api.getDeterministicAddress(self._seed, 4, 1),
|
self.api.getDeterministicAddress(self._seed, 4, 1),
|
||||||
|
@ -135,23 +124,22 @@ class TestAPI(TestAPIProto):
|
||||||
self.api.getDeterministicAddress(self._seed, 3, 1),
|
self.api.getDeterministicAddress(self._seed, 3, 1),
|
||||||
'BM-2DBPTgeSawWYZceFD69AbDT5q4iUWtj1ZN'
|
'BM-2DBPTgeSawWYZceFD69AbDT5q4iUWtj1ZN'
|
||||||
)
|
)
|
||||||
self.assertRegexpMatches(
|
self.assertRegex(
|
||||||
self.api.getDeterministicAddress(self._seed, 2, 1),
|
self.api.getDeterministicAddress(self._seed, 2, 1),
|
||||||
r'^API Error 0002:'
|
r'^API Error 0002:'
|
||||||
)
|
)
|
||||||
# This is here until the streams will be implemented
|
# This is here until the streams will be implemented
|
||||||
self.assertRegexpMatches(
|
self.assertRegex(
|
||||||
self.api.getDeterministicAddress(self._seed, 3, 2),
|
self.api.getDeterministicAddress(self._seed, 3, 2),
|
||||||
r'API Error 0003:'
|
r'API Error 0003:'
|
||||||
)
|
)
|
||||||
|
|
||||||
#currently working on this condition
|
#currently working on this condition
|
||||||
def test_create_random_address(self):
|
def test_create_random_address(self):
|
||||||
#22222222222222222222222222222222
|
|
||||||
"""API command 'createRandomAddress': basic BM-address validation"""
|
"""API command 'createRandomAddress': basic BM-address validation"""
|
||||||
addr = self._add_random_address('random_1'.encode())
|
addr = self._add_random_address('random_1'.encode())
|
||||||
self.assertRegexpMatches(addr, r'^BM-')
|
self.assertRegex(addr, r'^BM-')
|
||||||
self.assertRegexpMatches(addr[3:], r'[a-zA-Z1-9]+$')
|
self.assertRegex(addr[3:], r'[a-zA-Z1-9]+$')
|
||||||
# Whitepaper says "around 36 character"
|
# Whitepaper says "around 36 character"
|
||||||
self.assertLessEqual(len(addr[3:]), 40)
|
self.assertLessEqual(len(addr[3:]), 40)
|
||||||
self.assertEqual(self.api.deleteAddress(addr), 'success')
|
self.assertEqual(self.api.deleteAddress(addr), 'success')
|
||||||
|
@ -159,6 +147,7 @@ class TestAPI(TestAPIProto):
|
||||||
def test_addressbook(self):
|
def test_addressbook(self):
|
||||||
"""Testing API commands for addressbook manipulations"""
|
"""Testing API commands for addressbook manipulations"""
|
||||||
# Initially it's empty
|
# Initially it's empty
|
||||||
|
#
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
json.loads(self.api.listAddressBookEntries()).get('addresses'),
|
json.loads(self.api.listAddressBookEntries()).get('addresses'),
|
||||||
[]
|
[]
|
||||||
|
@ -188,9 +177,9 @@ class TestAPI(TestAPIProto):
|
||||||
"""API command 'sendBroadcast': ensure it returns ackData"""
|
"""API command 'sendBroadcast': ensure it returns ackData"""
|
||||||
addr = self._add_random_address('random_2'.encode())
|
addr = self._add_random_address('random_2'.encode())
|
||||||
ack = self.api.sendBroadcast(
|
ack = self.api.sendBroadcast(
|
||||||
addr, base64.encodestring('test_subject'),
|
addr, base64.encodebytes('test_subject'.encode()),
|
||||||
base64.encodestring('test message')
|
base64.encodebytes('test message'.encode())
|
||||||
)
|
).data
|
||||||
try:
|
try:
|
||||||
int(ack, 16)
|
int(ack, 16)
|
||||||
except ValueError:
|
except ValueError:
|
||||||
|
@ -206,19 +195,20 @@ class TestAPI(TestAPIProto):
|
||||||
'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 (
|
#Today
|
||||||
# 'BM-2cWzSnwjJ7yRP3nLEWUV5LisTZyREWSzUK',
|
for addr in (
|
||||||
# 'BM-2DBPTgeSawWYZceFD69AbDT5q4iUWtj1ZN'
|
'BM-2cWzSnwjJ7yRP3nLEWUV5LisTZyREWSzUK',
|
||||||
# ):
|
'BM-2DBPTgeSawWYZceFD69AbDT5q4iUWtj1ZN'
|
||||||
# self.assertEqual(self.api.joinChan(self._seed, addr), 'success')
|
):
|
||||||
# self.assertEqual(self.api.leaveChan(addr), 'success')
|
self.assertEqual(self.api.joinChan(self._seed, addr), 'success')
|
||||||
|
self.assertEqual(self.api.leaveChan(addr), 'success')
|
||||||
# # Joining with wrong address should fail
|
# # Joining with wrong address should fail
|
||||||
# self.assertRegexpMatches(
|
self.assertRegex(
|
||||||
# self.api.joinChan(self._seed, 'BM-2cWzSnwjJ7yRP3nLEW'),
|
self.api.joinChan(self._seed, 'BM-2cWzSnwjJ7yRP3nLEW'),
|
||||||
# r'^API Error 0008:'
|
r'^API Error 0008:'
|
||||||
# )
|
)
|
||||||
|
|
|
@ -74,37 +74,8 @@ class TestProcessProto(unittest.TestCase):
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def _cleanup_files(cls):
|
def _cleanup_files(cls):
|
||||||
print('the printing _cleanup_files -{}'.format(cls._files))
|
|
||||||
for pfile in cls._files:
|
for pfile in cls._files:
|
||||||
try:
|
try:
|
||||||
if pfile == 'debug.log':
|
|
||||||
print('***************************')
|
|
||||||
print('72727272727272772727272727')
|
|
||||||
print('going to open the debug.log file-{}'.format(pfile))
|
|
||||||
print(os.path.join(cls.home, pfile))
|
|
||||||
print('75757575757575757575757')
|
|
||||||
try:
|
|
||||||
with open(os.path.join(cls.home, pfile), 'r') as outfile:
|
|
||||||
print(outfile.readlines())
|
|
||||||
print('with with with with ')
|
|
||||||
print('is coming inside the open function')
|
|
||||||
print('with with with with ')
|
|
||||||
except:
|
|
||||||
print('!!!!!!!!!!!!!!!!!!!!!!!!!')
|
|
||||||
print('expectation are occured ')
|
|
||||||
print('!!!!!!!!!!!!!!!!!!!!!!!!!')
|
|
||||||
print('***************************')
|
|
||||||
print('----------------------------')
|
|
||||||
print(' pfile pfile pfile -{}'.format(pfile))
|
|
||||||
try:
|
|
||||||
with open(os.path.join(cls.home, pfile), 'r') as outfile:
|
|
||||||
pass
|
|
||||||
# print(outfile.read())
|
|
||||||
print('----------------------------')
|
|
||||||
except:
|
|
||||||
print('``````````````````````````````````````')
|
|
||||||
print('exceptation are occured while working opening th file-{}'.format(pfile))
|
|
||||||
print('``````````````````````````````````````')
|
|
||||||
os.remove(os.path.join(cls.home, pfile))
|
os.remove(os.path.join(cls.home, pfile))
|
||||||
except OSError:
|
except OSError:
|
||||||
pass
|
pass
|
||||||
|
@ -112,9 +83,6 @@ class TestProcessProto(unittest.TestCase):
|
||||||
@classmethod
|
@classmethod
|
||||||
def tearDownClass(cls):
|
def tearDownClass(cls):
|
||||||
"""Ensures that pybitmessage stopped and removes files"""
|
"""Ensures that pybitmessage stopped and removes files"""
|
||||||
print('######################################')
|
|
||||||
print('is this are even called tearDownClass')
|
|
||||||
print('######################################')
|
|
||||||
try:
|
try:
|
||||||
if not cls._stop_process():
|
if not cls._stop_process():
|
||||||
cls.process.kill()
|
cls.process.kill()
|
||||||
|
|
Reference in New Issue
Block a user