def testMineBlockDicifultyLimitRaTE_1(): lastblock = Block(time.time_ns(), 'testLastHash', 'testHash', 'testData', 1, 0) time.sleep(MINE_RATE / SEC) mineBlock = Block.mineBlock(lastblock, "bar") assert mineBlock.dificulty == 1
def testMineBlock(): lastBlock = Block.genesis() data = 'test-data' block = Block.mineBlock(lastBlock, data) assert isinstance(block, Block) assert block.data == data assert block.lasthash == lastBlock.hash assert HexToBinary(block.hash)[0:block.dificulty] == '0' * block.dificulty
def block(lastBlock): return Block.mineBlock(lastBlock, 'test-data')
def testSlowlyMineBlock(): lastBlock = Block.mineBlock(Block.genesis(), 'foo') time.sleep(MINE_RATE / SEC) mineBlock = Block.mineBlock(lastBlock, 'bar') assert mineBlock.dificulty == lastBlock.dificulty - 1
def testQuicklyMineBlock(): lastBlock = Block.mineBlock(Block.genesis(), 'foo') mineBlock = Block.mineBlock(lastBlock, 'bar') assert mineBlock.dificulty == lastBlock.dificulty + 1