diff --git a/onionr/onionrblockapi.py b/onionr/onionrblockapi.py index a20a4853..13d3fc84 100644 --- a/onionr/onionrblockapi.py +++ b/onionr/onionrblockapi.py @@ -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: diff --git a/onionr/tests.py b/onionr/tests.py index db62dcb3..ac4ff36b 100755 --- a/onionr/tests.py +++ b/onionr/tests.py @@ -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)