Esempio n. 1
0
def test_is_valid_transaction_chain_multiple_rewards(blockchain_three_blocks):
    reward_1 = Transaction.reward_transaction(Wallet()).to_json()
    reward_2 = Transaction.reward_transaction(Wallet()).to_json()
    blockchain_three_blocks.add_block([reward_1, reward_2])

    with pytest.raises(Exception, match='one mining reward per block'):
        Blockchain.is_valid_transaction_chain(blockchain_three_blocks.chain)
Esempio n. 2
0
def route_blockchain_mine():
    transaction_data = transaction_pool.transaction_data()
    transaction_data.append(Transaction.reward_transaction(wallet).to_json())
    blockchain.add_block(transaction_data)
    block = blockchain.chain[-1]
    pubsub.broadcast_block(block)
    transaction_pool.clear_blockchain_transactions(blockchain)

    return jsonify(block.to_json())
Esempio n. 3
0
def test_valid_reward_transaction():
    reward_transaction = Transaction.reward_transaction(Wallet())
    Transaction.transaction_is_valid(reward_transaction)
Esempio n. 4
0
def test_reward_transaction():
    miner_wallet = Wallet()
    transaction = Transaction.reward_transaction(miner_wallet)

    assert transaction.input == MINING_REWARD_INPUT
    assert transaction.output[miner_wallet.address] == MINING_REWARD
Esempio n. 5
0
def test_invalid_reward_transaction_invalid_amount():
    miner_wallet = Wallet()
    reward_transaction = Transaction.reward_transaction(miner_wallet)
    reward_transaction.output[miner_wallet.address] = 1998
    with pytest.raises(Exception, match='Invalid Mining Reward'):
        Transaction.transaction_is_valid(reward_transaction)
Esempio n. 6
0
def test_invalid_reward_transaction_extra_reciepient():
    reward_transaction = Transaction.reward_transaction(Wallet())
    reward_transaction.output['extra_reciepient'] = 60

    with pytest.raises(Exception, match='Invalid Mining Reward'):
        Transaction.transaction_is_valid(reward_transaction)