added hash validation test and cleaned up output

This commit is contained in:
Kevin Froman 2018-02-22 02:41:05 -06:00
parent 15400432b1
commit f39ab33517
No known key found for this signature in database
GPG Key ID: 0D414D0FE405B63B
3 changed files with 17 additions and 5 deletions

View File

@ -62,7 +62,8 @@ class API:
bindPort = int(self.config['CLIENT']['PORT'])
self.bindPort = bindPort
self.clientToken = self.config['CLIENT']['CLIENT HMAC']
logger.debug('Your HMAC token: ' + logger.colors.underline + self.clientToken)
if not os.environ.get("WERKZEUG_RUN_MAIN") == "true":
logger.debug('Your HMAC token: ' + logger.colors.underline + self.clientToken)
if not debug and not self._developmentMode:
hostNums = [random.randint(1, 255), random.randint(1, 255), random.randint(1, 255)]
@ -174,7 +175,7 @@ class API:
return resp
if not os.environ.get("WERKZEUG_RUN_MAIN") == "true":
logger.info('Starting client on ' + self.host + ':' + str(bindPort) + '...')
logger.debug('Client token: ' + logger.colors.underline + self.clientToken)
#logger.debug('Client token: ' + logger.colors.underline + self.clientToken)
app.run(host=self.host, port=bindPort, debug=True, threaded=True)

View File

@ -35,7 +35,7 @@ class OnionrCommunicate:
blockProcessTimer = 0
blockProcessAmount = 5
heartBeatTimer = 0
heartBeatRate = 10
heartBeatRate = 100
logger.debug('Communicator debugging enabled.')
torID = open('data/hs/hostname').read()
@ -87,7 +87,8 @@ class OnionrCommunicate:
blocks += self.performGet('getBlockHashes', i)
if self._utils.validateHash(currentDB):
self._core.setPeerInfo(i, "blockDBHash", currentDB)
logger.debug('BLOCKS: \n' + blocks)
if len(blocks.strip()) != 0:
logger.debug('BLOCKS:' + blocks)
blockList = blocks.split('\n')
for i in blockList:
if len(i.strip()) == 0:

View File

@ -105,5 +105,15 @@ class OnionrTests(unittest.TestCase):
if command[0] == 'testCommand':
if myCore.daemonQueue() == False:
logger.info('Succesfully added and read command')
def testHashValidation(self):
logger.debug('--------------------------')
logger.info('Running hash validation test...')
import core
myCore = core.Core()
if not myCore._utils.validateHash("$324dfgfdg") and myCore._utils.validateHash("f2ca1bb6c7e907d06dafe4687e579fce76b37e4e93b7605022da52e6ccc26fd2") and not myCore._utils.validateHash("f2ca1bb6c7e907d06dafe4687e579fce76b37e4e93b7605022da52e6ccc26fd$"):
self.assertTrue(True)
else:
self.assertTrue(False)
unittest.main()