add block tests

master
Arinerron 2018-05-19 15:21:35 -07:00
parent 007d7ad9fb
commit 0ac27ad0e2
No known key found for this signature in database
GPG Key ID: 99383627861C62F0
2 changed files with 20 additions and 1 deletions

View File

@ -163,7 +163,7 @@ class Block:
else: else:
self.hash = self.getCore().insertBlock(self.getContent(), header = self.getType(), sign = sign) self.hash = self.getCore().insertBlock(self.getContent(), header = self.getType(), sign = sign)
self.update() self.update()
return True return self.getHash()
else: else:
logger.warn('Not writing block; it is invalid.') logger.warn('Not writing block; it is invalid.')
except Exception as e: except Exception as e:

View File

@ -117,6 +117,25 @@ class OnionrTests(unittest.TestCase):
self.assertTrue(True) self.assertTrue(True)
def testBlockAPI(self):
logger.debug('-'*26 + '\n')
logger.info('Running BlockAPI test...')
content = 'Onionr test block'
from onionrblockapi import Block
hash = Block('test', content).save()
block = Block(hash) # test init
if len(Block.getBlocks(type = 'test')) == 0:
logger.warn('Failed to find test block.')
self.assertTrue(False)
if not block.getContent() == content:
logger.warn('Test block content is invalid! (%s != %s)' % (block.getContent(), content))
self.assertTrue(False)
def testBitcoinNode(self): def testBitcoinNode(self):
# temporarily disabled- this takes a lot of time the CI doesn't have # temporarily disabled- this takes a lot of time the CI doesn't have
self.assertTrue(True) self.assertTrue(True)