def next_block_branch2(chain):
    block_information = chain.genesis_block.get_block_information()
    next_block_branch2 = Block(block_information, PUBLIC_KEY)
    next_block_branch2.timestamp = chain.genesis_block.timestamp + CONFIG.block_time + 1
    next_block_branch2.sign(PRIVATE_KEY)
    next_block_branch2.update_hash()
    yield next_block_branch2
def new_block(genesis):
    new_block = Block(genesis.get_block_information(), PUBLIC_KEY)
    new_block.add_transaction("tx1")
    new_block.add_transaction("tx2")
    new_block.sign(PRIVATE_KEY)
    new_block.update_hash()
    yield new_block
def dangling_block(chain):
    dangling_block = Block({"index": 4, "hash": "ab1234"}, PUBLIC_KEY)
    dangling_block.timestamp = chain.genesis_block.timestamp + 2 * CONFIG.block_time + 1
    dangling_block.sign(PRIVATE_KEY)
    dangling_block.update_hash()
    chain.add_dangling_block(dangling_block)
    yield dangling_block
Esempio n. 4
0
def test_received_new_block(full_client):
    block_information = full_client.chain.genesis_block.get_block_information()
    next_block = Block(block_information, PUBLIC_KEY)
    next_block.sign(PRIVATE_KEY)
    next_block.update_hash()
    full_client.received_new_block(repr(next_block))
    assert os.path.exists(os.path.join(CONFIG.persistance_folder,
                                       "_".join([str(next_block.index), next_block.previous_block, next_block.hash])))
def next_block_branch1(chain):
    block_information = chain.genesis_block.get_block_information()
    next_block_branch1 = Block(block_information, PUBLIC_KEY)
    next_block_branch1.sign(PRIVATE_KEY)
    next_block_branch1.update_hash()
    yield next_block_branch1