示例#1
0
def testIsValidBlockJumpDifficulty(lastBlock, block):
    jumpDifficulty = 10
    block.dificulty = jumpDifficulty
    block.hash = f'{"0" * jumpDifficulty}111abc'

    with pytest.raises(Exception, match='difficulty must only adjust by 1'):
        Block.isValidBlock(lastBlock, block)
示例#2
0
def testIsValidBadProofOfWork(lastBlock, block):
    block.hash = 'fff'

    with pytest.raises(Exception,
                       match='proof of work requirement was not met'):
        Block.isValidBlock(lastBlock, block)
示例#3
0
def testIsValidBlock(lastBlock, block):
    Block.isValidBlock(lastBlock, block)
示例#4
0
def testIsValidBlockBadLastHash(lastBlock, block):
    block.lasthash = 'evil_LastHash'

    with pytest.raises(Exception, match='lastHash must be correct'):
        Block.isValidBlock(lastBlock, block)
示例#5
0
def testIsValidBlockBadHash(lastBlock, block):
    block.hash = '0000000000000000bbbabc'

    with pytest.raises(Exception, match='block hash must be correct'):
        Block.isValidBlock(lastBlock, block)