Skip to content

Commit 095c47c

Browse files
committed
fix the issue Bitmessage#1215
1 parent 62e80e9 commit 095c47c

File tree

3 files changed

+46
-4
lines changed

3 files changed

+46
-4
lines changed

src/bitmessagemain.py

100755100644
+5-4
Original file line numberDiff line numberDiff line change
@@ -354,9 +354,10 @@ def start(self):
354354

355355
if daemon:
356356
if state.testmode:
357-
sleep(30)
358-
# make testing
359-
self.stop()
357+
# sleep(30)
358+
# Generate Random Numner and wait until synchronisation finishes
359+
if rndm().generateRandomNumber():
360+
self.stop()
360361
while state.shutdown == 0:
361362
sleep(1)
362363

@@ -423,7 +424,7 @@ def usage(self):
423424
-h, --help show this help message and exit
424425
-c, --curses use curses (text mode) interface
425426
-d, --daemon run in daemon (background) mode
426-
-t, --test dryrun, make testing
427+
-t, --test this is only for developers for testing purpose
427428
428429
All parameters are optional.
429430
'''

src/class_objectProcessor.py

+1
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
import tr
2929
from debug import logger
3030
import l10n
31+
from addresses import calculateInventoryHash
3132

3233
class objectProcessor(threading.Thread):
3334
"""

src/helper_test.py

+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
"""Helper test used for generate random address and send message."""
2+
import xmlrpclib
3+
import time
4+
import base64
5+
import network.stats
6+
from network.stats import pendingDownload
7+
8+
9+
class RandomNumber(object):
10+
"""docstring for RandomNumber."""
11+
12+
def __init__(self):
13+
"""Initialize the variables."""
14+
super(RandomNumber, self).__init__()
15+
16+
def generateRandomNumber(self):
17+
"""Generate random address and send messages."""
18+
api = xmlrpclib.ServerProxy("http://username:password@localhost:8442/")
19+
label = 'Test-' + str(time.time())
20+
random_address = api.createRandomAddress(base64.encodestring(label))
21+
fromsend = random_address
22+
tosend = "BM-2cWyUfBdY2FbgyuCb7abFZ49JYxSzUhNFe"
23+
subject = 'subject!'.encode('base64')
24+
message = 'Hello, this is the new asasf message'.encode('base64')
25+
26+
try:
27+
ack_data = api.sendMessage(tosend, fromsend, subject, message)
28+
connectedhosts = len(network.stats.connectedHostsList())
29+
print "synchronisation in progress..."
30+
print "Connection Status: ", connectedhosts
31+
while pendingDownload() > 0:
32+
print "synchronisation in progress..."
33+
print "Connection Status: ", connectedhosts
34+
time.sleep(10)
35+
if ack_data:
36+
return True
37+
else:
38+
return False
39+
except:
40+
return False

0 commit comments

Comments
 (0)