示例#1
0
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
示例#2
0
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
示例#3
0
def block(lastBlock):
    return Block.mineBlock(lastBlock, 'test-data')
示例#4
0
def testSlowlyMineBlock():
    lastBlock = Block.mineBlock(Block.genesis(), 'foo')
    time.sleep(MINE_RATE / SEC)
    mineBlock = Block.mineBlock(lastBlock, 'bar')

    assert mineBlock.dificulty == lastBlock.dificulty - 1
示例#5
0
def testQuicklyMineBlock():
    lastBlock = Block.mineBlock(Block.genesis(), 'foo')
    mineBlock = Block.mineBlock(lastBlock, 'bar')

    assert mineBlock.dificulty == lastBlock.dificulty + 1