add block tests
This commit is contained in:
parent
007d7ad9fb
commit
0ac27ad0e2
@ -163,7 +163,7 @@ class Block:
|
||||
else:
|
||||
self.hash = self.getCore().insertBlock(self.getContent(), header = self.getType(), sign = sign)
|
||||
self.update()
|
||||
return True
|
||||
return self.getHash()
|
||||
else:
|
||||
logger.warn('Not writing block; it is invalid.')
|
||||
except Exception as e:
|
||||
|
@ -117,6 +117,25 @@ class OnionrTests(unittest.TestCase):
|
||||
|
||||
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):
|
||||
# temporarily disabled- this takes a lot of time the CI doesn't have
|
||||
self.assertTrue(True)
|
||||
|
Loading…
Reference in New Issue
Block a user