def test_transaction_update_in_sufficient_balance(): sender_wallet = Wallet() recipient = "abcd" amount = 500 transaction = Transaction(sender_wallet, recipient, amount) with pytest.raises(Exception, match="In sufficient balance"): transaction.update_transaction(sender_wallet, "abcde", 1000)
def test_transaction_update_balance(): sender_wallet = Wallet() recipient = "recipient" amount = 100 transaction = Transaction(sender_wallet, recipient, amount) with pytest.raises(Exception, match="Amount exceeds balance"): transaction.update_transaction(sender_wallet, recipient, 1000000)
def test_transaction_update(): sender_wallet = Wallet() recipient = "abcd" amount = 500 transaction = Transaction(sender_wallet, recipient, amount) transaction.update_transaction(sender_wallet, "abcde", 300) transaction.update_transaction(sender_wallet, "abcd", 700) assert transaction.output[recipient] == 700 assert transaction.output[sender_wallet.address] == 0 assert Wallet.verify_signature(transaction.input['public_key'], transaction.output, transaction.input['signature'])
def test_transaction_update_existing_recipient(): sender_wallet = Wallet() recipient = 'recipient' amount = 100 transaction = Transaction(sender_wallet, recipient, amount) new_amount = 100 transaction.update_transaction(sender_wallet, recipient, new_amount) assert transaction.output[recipient] == amount + new_amount assert transaction.output[ sender_wallet.wallet_id] == sender_wallet.balance - (amount + new_amount) assert sender_wallet.verify(transaction.input['public_key'], transaction.output, transaction.input['signature'])