From 4c93901395922e497c1a7fd78e913469a8bb4ab6 Mon Sep 17 00:00:00 2001 From: Keri Date: Fri, 4 Oct 2019 11:20:33 -0600 Subject: [PATCH] Remove eth-account deprecation warnings --- newsfragments/1468.misc.rst | 1 + tests/core/eth-module/test_accounts.py | 87 ++++++++++--------- .../middleware/test_transaction_signing.py | 2 +- 3 files changed, 48 insertions(+), 42 deletions(-) create mode 100644 newsfragments/1468.misc.rst diff --git a/newsfragments/1468.misc.rst b/newsfragments/1468.misc.rst new file mode 100644 index 0000000000..caabf670ab --- /dev/null +++ b/newsfragments/1468.misc.rst @@ -0,0 +1 @@ +Remove deprecation warnings from eth-account dependency upgrade diff --git a/tests/core/eth-module/test_accounts.py b/tests/core/eth-module/test_accounts.py index a2b0044d52..df60a06a6d 100644 --- a/tests/core/eth-module/test_accounts.py +++ b/tests/core/eth-module/test_accounts.py @@ -3,7 +3,7 @@ import pytest from eth_account.messages import ( - defunct_hash_message, + encode_defunct, ) from eth_utils import ( is_checksum_address, @@ -96,37 +96,37 @@ def test_eth_account_create_variation(acct): assert account1 != account2 -def test_eth_account_privateKeyToAccount_reproducible(acct, PRIVATE_BYTES): - account1 = acct.privateKeyToAccount(PRIVATE_BYTES) - account2 = acct.privateKeyToAccount(PRIVATE_BYTES) +def test_eth_account_from_key_reproducible(acct, PRIVATE_BYTES): + account1 = acct.from_key(PRIVATE_BYTES) + account2 = acct.from_key(PRIVATE_BYTES) assert bytes(account1) == PRIVATE_BYTES assert bytes(account1) == bytes(account2) assert isinstance(str(account1), str) -def test_eth_account_privateKeyToAccount_diverge(acct, PRIVATE_BYTES, PRIVATE_BYTES_ALT): - account1 = acct.privateKeyToAccount(PRIVATE_BYTES) - account2 = acct.privateKeyToAccount(PRIVATE_BYTES_ALT) +def test_eth_account_from_key_diverge(acct, PRIVATE_BYTES, PRIVATE_BYTES_ALT): + account1 = acct.from_key(PRIVATE_BYTES) + account2 = acct.from_key(PRIVATE_BYTES_ALT) assert bytes(account2) == PRIVATE_BYTES_ALT assert bytes(account1) != bytes(account2) -def test_eth_account_privateKeyToAccount_seed_restrictions(acct): +def test_eth_account_from_key_seed_restrictions(acct): with pytest.raises(ValueError): - acct.privateKeyToAccount(b'') + acct.from_key(b'') with pytest.raises(ValueError): - acct.privateKeyToAccount(b'\xff' * 31) + acct.from_key(b'\xff' * 31) with pytest.raises(ValueError): - acct.privateKeyToAccount(b'\xff' * 33) + acct.from_key(b'\xff' * 33) -def test_eth_account_privateKeyToAccount_properties(acct, PRIVATE_BYTES): - account = acct.privateKeyToAccount(PRIVATE_BYTES) +def test_eth_account_from_key_properties(acct, PRIVATE_BYTES): + account = acct.from_key(PRIVATE_BYTES) assert callable(account.signHash) assert callable(account.sign_transaction) assert is_checksum_address(account.address) assert account.address == '0xa79F6f349C853F9Ea0B29636779ae3Cb4E3BA729' - assert account.privateKey == PRIVATE_BYTES + assert account.key == PRIVATE_BYTES def test_eth_account_create_properties(acct): @@ -134,18 +134,18 @@ def test_eth_account_create_properties(acct): assert callable(account.signHash) assert callable(account.sign_transaction) assert is_checksum_address(account.address) - assert isinstance(account.privateKey, bytes) and len(account.privateKey) == 32 + assert isinstance(account.key, bytes) and len(account.key) == 32 def test_eth_account_recover_transaction_example(acct): raw_tx_hex = '0xf8640d843b9aca00830e57e0945b2063246f2191f18f2675cedb8b28102e957458018025a00c753084e5a8290219324c1a3a86d4064ded2d15979b1ea790734aaa2ceaafc1a0229ca4538106819fd3a5509dd383e8fe4b731c6870339556a5c06feb9cf330bb' # noqa: E501 - from_account = acct.recoverTransaction(raw_tx_hex) + from_account = acct.recover_transaction(raw_tx_hex) assert from_account == '0xFeC2079e80465cc8C687fFF9EE6386ca447aFec4' def test_eth_account_recover_transaction_with_literal(acct): raw_tx = 0xf8640d843b9aca00830e57e0945b2063246f2191f18f2675cedb8b28102e957458018025a00c753084e5a8290219324c1a3a86d4064ded2d15979b1ea790734aaa2ceaafc1a0229ca4538106819fd3a5509dd383e8fe4b731c6870339556a5c06feb9cf330bb # noqa: E501 - from_account = acct.recoverTransaction(raw_tx) + from_account = acct.recover_transaction(raw_tx) assert from_account == '0xFeC2079e80465cc8C687fFF9EE6386ca447aFec4' @@ -156,8 +156,8 @@ def test_eth_account_recover_message(acct): '0x3e5bfbbf4d3e39b1a2fd816a7680c19ebebaf3a141b239934ad43cb33fcec8ce', ) message = "I♥SF" - message_hash = defunct_hash_message(text=message) - from_account = acct.recoverHash(message_hash, vrs=(v, r, s)) + message_hash = encode_defunct(text=message) + from_account = acct.recover_message(message_hash, vrs=(v, r, s)) assert from_account == '0x5ce9454909639D2D17A3F753ce7d93fa0b9aB12E' @@ -172,9 +172,9 @@ def test_eth_account_recover_message(acct): ids=['test_sig_bytes_standard_v', 'test_sig_bytes_chain_naive_v'] ) def test_eth_account_recover_signature_bytes(acct, signature_bytes): - msg_hash = b'\xbb\r\x8a\xba\x9f\xf7\xa1