fix the issue #1215

This commit is contained in:
Mahendra Garg 2018-04-13 17:24:44 +05:30
parent 62e80e9ca7
commit 095c47cf28
No known key found for this signature in database
GPG Key ID: A672D8FAAEE398B3
3 changed files with 46 additions and 4 deletions

9
src/bitmessagemain.py Executable file → Normal file
View File

@ -354,9 +354,10 @@ class Main:
if daemon:
if state.testmode:
sleep(30)
# make testing
self.stop()
# sleep(30)
# Generate Random Numner and wait until synchronisation finishes
if rndm().generateRandomNumber():
self.stop()
while state.shutdown == 0:
sleep(1)
@ -423,7 +424,7 @@ Options:
-h, --help show this help message and exit
-c, --curses use curses (text mode) interface
-d, --daemon run in daemon (background) mode
-t, --test dryrun, make testing
-t, --test this is only for developers for testing purpose
All parameters are optional.
'''

View File

@ -28,6 +28,7 @@ import state
import tr
from debug import logger
import l10n
from addresses import calculateInventoryHash
class objectProcessor(threading.Thread):
"""

40
src/helper_test.py Normal file
View File

@ -0,0 +1,40 @@
"""Helper test used for generate random address and send message."""
import xmlrpclib
import time
import base64
import network.stats
from network.stats import pendingDownload
class RandomNumber(object):
"""docstring for RandomNumber."""
def __init__(self):
"""Initialize the variables."""
super(RandomNumber, self).__init__()
def generateRandomNumber(self):
"""Generate random address and send messages."""
api = xmlrpclib.ServerProxy("http://username:password@localhost:8442/")
label = 'Test-' + str(time.time())
random_address = api.createRandomAddress(base64.encodestring(label))
fromsend = random_address
tosend = "BM-2cWyUfBdY2FbgyuCb7abFZ49JYxSzUhNFe"
subject = 'subject!'.encode('base64')
message = 'Hello, this is the new asasf message'.encode('base64')
try:
ack_data = api.sendMessage(tosend, fromsend, subject, message)
connectedhosts = len(network.stats.connectedHostsList())
print "synchronisation in progress..."
print "Connection Status: ", connectedhosts
while pendingDownload() > 0:
print "synchronisation in progress..."
print "Connection Status: ", connectedhosts
time.sleep(10)
if ack_data:
return True
else:
return False
except:
return False