diff --git a/src/bitmessagemain.py b/src/bitmessagemain.py old mode 100755 new mode 100644 index 11f71b47..7ec9c9de --- a/src/bitmessagemain.py +++ b/src/bitmessagemain.py @@ -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. ''' diff --git a/src/class_objectProcessor.py b/src/class_objectProcessor.py index 181ce30e..afc5bbfd 100644 --- a/src/class_objectProcessor.py +++ b/src/class_objectProcessor.py @@ -28,6 +28,7 @@ import state import tr from debug import logger import l10n +from addresses import calculateInventoryHash class objectProcessor(threading.Thread): """ diff --git a/src/helper_test.py b/src/helper_test.py new file mode 100644 index 00000000..18d1ac63 --- /dev/null +++ b/src/helper_test.py @@ -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