Skip to content

Commit

Permalink
fix: show first 4 bytes in transaction str
Browse files Browse the repository at this point in the history
  • Loading branch information
antazoey committed Feb 19, 2025
1 parent eb164c1 commit 5bae0b2
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
17 changes: 17 additions & 0 deletions tests/functional/test_accounts.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,23 @@ def test_sign_message(signer, message):
assert signer.check_signature(message, signature)


def test_sign_transaction(signer, message, ethereum):
transaction = ethereum.create_transaction(nonce=0, max_fee=0, max_priority_fee=0)
signed_transaction = signer.sign_transaction(transaction)
assert signed_transaction.signature is not None


def test_sign_transaction_using_keyfile_account(keyfile_account, message, ethereum, runner):
transaction = ethereum.create_transaction(
nonce=0, max_fee=0, max_priority_fee=0, data="0x21314135413451"
)

with runner.isolation(f"y\n{PASSPHRASE}\ny"):
signed_transaction = keyfile_account.sign_transaction(transaction)

assert signed_transaction.signature is not None


def test_sign_string(signer):
message = "Hello Apes!"
signature = signer.sign_message(message)
Expand Down
11 changes: 11 additions & 0 deletions tests/functional/test_transaction.py
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,17 @@ def test_str_when_data_is_bytes(ethereum):
assert isinstance(actual, str)


def test_str_when_data_is_long_shows_first_4_bytes(vyper_contract_instance):
"""
Tests against a condition that would cause transactions to
fail with string-encoding errors.
"""
txn = vyper_contract_instance.setNumber.as_transaction(123)
actual = str(txn)
assert isinstance(actual, str)
assert "data: 0x30783366..." in actual


def test_receipt_when_none(ethereum):
txn = ethereum.create_transaction(data=HexBytes("0x123"))
assert txn.receipt is None
Expand Down

0 comments on commit 5bae0b2

Please sign in to comment.