Ejemplo n.º 1
0
def test_is_transaction_chain_valid_corrupt_transaction(blockchain_ten_blocks):
    corrupt_transaction = Transaction(Wallet(), 'recipient', 1)

    corrupt_transaction.input['signature'] = Wallet().sign({"a": "b"})
    blockchain_ten_blocks.add_block([corrupt_transaction.to_json()])
    with pytest.raises(Exception):
        BlockChain.is_transaction_chain_valid(blockchain_ten_blocks.chain)
Ejemplo n.º 2
0
def test_is_transaction_chain_valid_multiple_rewards(blockchain_ten_blocks):
    reward1 = Transaction.reward(Wallet()).to_json()
    reward2 = Transaction.reward(Wallet()).to_json()
    blockchain_ten_blocks.add_block([reward1, reward2])

    with pytest.raises(Exception, match="Duplicate mining reward in block"):
        BlockChain.is_transaction_chain_valid(blockchain_ten_blocks.chain)
Ejemplo n.º 3
0
def test_is_transaction_chain_valid_balance_tillnow(blockchain_ten_blocks):
    wallet = Wallet()
    corrupt_transaction = Transaction(wallet, "abcd", 10)
    corrupt_transaction.output[wallet.address] = 9000
    corrupt_transaction.input['amount'] = 9010
    corrupt_transaction.input['signature'] = wallet.sign(
        corrupt_transaction.output)

    blockchain_ten_blocks.add_block([corrupt_transaction.to_json()])

    with pytest.raises(Exception):
        BlockChain.is_transaction_chain_valid(blockchain_ten_blocks.chain)
Ejemplo n.º 4
0
def test_is_transaction_chain_valid_duplicate_transactions(
        blockchain_ten_blocks):
    blockchain_ten_blocks.chain.append(blockchain_ten_blocks.chain[3])
    with pytest.raises(Exception, match="is not unique"):
        BlockChain.is_transaction_chain_valid(blockchain_ten_blocks.chain)
Ejemplo n.º 5
0
def test_is_transaction_chain_valid(blockchain_ten_blocks):
    BlockChain.is_transaction_chain_valid(blockchain_ten_blocks.chain)