Пример #1
0
def test_replace_chain_bad_chain(blockchain_three_blocks):
    blockchain = Blockchain()  #blockchain solo con genesis
    blockchain_three_blocks.chain[
        1].hash = 'evil-hash'  #cambiando el hash a un bloque para que sea una cadena mala
    with pytest.raises(Exception,
                       match='Cannot replace.Incoming chain is invalid'
                       ):  #mismo error que se pone en raise Exception
        blockchain.replace_chain(blockchain_three_blocks.chain)
Пример #2
0
def test_replace_chain(blockchain_three_blocks):
    blockchain = Blockchain()  #blockchain solo con genesis
    blockchain.replace_chain(
        blockchain_three_blocks.chain
    )  #como blockchain_three_blocks es mas lago lo reemplaza
    assert blockchain.chain == blockchain_three_blocks.chain  #comprobando que paso la longitud