Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Updated GethPersonal to snake_case #1470

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 36 additions & 12 deletions docs/web3.geth.rst
Original file line number Diff line number Diff line change
Expand Up @@ -211,19 +211,23 @@ GethPersonal API

The following methods are available on the ``web3.geth.personal`` namespace.

.. py:method:: listAccounts
.. py:method:: list_accounts

* Delegates to ``personal_listAccounts`` RPC Method

Returns the list of known accounts.

.. code-block:: python

>>> web3.geth.personal.listAccounts()
>>> web3.geth.personal.list_accounts()
['0xd3CdA913deB6f67967B99D67aCDFa1712C293601']

.. py:method:: listAccounts()

.. py:method:: importRawKey(self, private_key, passphrase)
.. warning:: Deprecated: This method is deprecated in favor of
:meth:`~web3.geth.personal.list_accounts()`

.. py:method:: import_raw_key(self, private_key, passphrase)

* Delegates to ``personal_importRawKey`` RPC Method

Expand All @@ -232,11 +236,15 @@ The following methods are available on the ``web3.geth.personal`` namespace.

.. code-block:: python

>>> web3.geth.personal.importRawKey(some_private_key, 'the-passphrase')
>>> web3.geth.personal.import_raw_key(some_private_key, 'the-passphrase')
'0xd3CdA913deB6f67967B99D67aCDFa1712C293601'

.. py:method:: importRawKey()

.. warning:: Deprecated: This method is deprecated in favor of
:meth:`~web3.geth.personal.import_raw_key()`

.. py:method:: newAccount(self, password)
.. py:method:: new_account(self, password)

* Delegates to ``personal_newAccount`` RPC Method

Expand All @@ -245,22 +253,30 @@ The following methods are available on the ``web3.geth.personal`` namespace.

.. code-block:: python

>>> web3.geth.personal.newAccount('the-passphrase')
>>> web3.geth.personal.new_account('the-passphrase')
'0xd3CdA913deB6f67967B99D67aCDFa1712C293601'

.. py:method:: newAccount()

.. warning:: Deprecated: This method is deprecated in favor of
:meth:`~web3.geth.personal.new_account()`

.. py:method:: lockAccount(self, account)
.. py:method:: lock_account(self, account)

* Delegates to ``personal_lockAccount`` RPC Method

Locks the given ``account``.

.. code-block:: python

>>> web3.geth.personal.lockAccount('0xd3CdA913deB6f67967B99D67aCDFa1712C293601')
>>> web3.geth.personal.lock_account('0xd3CdA913deB6f67967B99D67aCDFa1712C293601')

.. py:method:: lockAccount()

.. py:method:: unlockAccount(self, account, passphrase, duration=None)
.. warning:: Deprecated: This method is deprecated in favor of
:meth:`~web3.geth.personal.lock_account()`

.. py:method:: unlock_account(self, account, passphrase, duration=None)

* Delegates to ``personal_unlockAccount`` RPC Method

Expand All @@ -271,18 +287,26 @@ The following methods are available on the ``web3.geth.personal`` namespace.

.. code-block:: python

>>> web3.geth.personal.unlockAccount('0xd3CdA913deB6f67967B99D67aCDFa1712C293601', 'wrong-passphrase')
>>> web3.geth.personal.unlock_account('0xd3CdA913deB6f67967B99D67aCDFa1712C293601', 'wrong-passphrase')
False
>>> web3.geth.personal.unlockAccount('0xd3CdA913deB6f67967B99D67aCDFa1712C293601', 'the-passphrase')
>>> web3.geth.personal.unlock_account('0xd3CdA913deB6f67967B99D67aCDFa1712C293601', 'the-passphrase')
True

.. py:method:: unlockAccount()

.. warning:: Deprecated: This method is deprecated in favor of
:meth:`~web3.geth.personal.unlock_account()`

.. py:method:: sendTransaction(self, transaction, passphrase)
.. py:method:: send_transaction(self, transaction, passphrase)

* Delegates to ``personal_sendTransaction`` RPC Method

Sends the transaction.

.. py:method:: sendTransaction()

.. warning:: Deprecated: This method is deprecated in favor of
:meth:`~web3.geth.personal.send_transaction()`

.. py:module:: web3.geth.txpool

Expand Down
2 changes: 1 addition & 1 deletion tests/core/eth-module/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ def extra_accounts(web3, account_password):
num_accounts_to_create = 10 - len(web3.eth.accounts)

for i in range(num_accounts_to_create):
web3.personal.newAccount(account_password)
web3.personal.new_account(account_password)

return web3.eth.accounts

Expand Down
2 changes: 1 addition & 1 deletion tests/core/mining-module/test_setEtherBase.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
def test_miner_setEtherbase(web3_empty):
web3 = web3_empty
assert web3.eth.coinbase == web3.eth.accounts[0]
new_account = web3.personal.newAccount('this-is-a-password')
new_account = web3.personal.new_account('this-is-a-password')
web3.geth.miner.setEtherBase(new_account)
assert web3.eth.coinbase == new_account
4 changes: 2 additions & 2 deletions tests/generate_go_ethereum_fixture.py
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@ def mine_block(web3):


def deploy_contract(web3, name, factory):
web3.geth.personal.unlockAccount(web3.eth.coinbase, KEYFILE_PW)
web3.geth.personal.unlock_account(web3.eth.coinbase, KEYFILE_PW)
deploy_txn_hash = factory.constructor().transact({'from': web3.eth.coinbase})
print('{0}_CONTRACT_DEPLOY_HASH: '.format(name.upper()), deploy_txn_hash)
deploy_receipt = mine_transaction_hash(web3, deploy_txn_hash)
Expand Down Expand Up @@ -375,7 +375,7 @@ def setup_chain_state(web3):
#
# Block with Transaction
#
web3.geth.personal.unlockAccount(coinbase, KEYFILE_PW)
web3.geth.personal.unlock_account(coinbase, KEYFILE_PW)
web3.geth.miner.start(1)
mined_txn_hash = web3.eth.sendTransaction({
'from': coinbase,
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/generate_fixtures/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ def mine_transaction_hash(web3, txn_hash):


def deploy_contract(web3, name, factory):
web3.geth.personal.unlockAccount(web3.eth.coinbase, KEYFILE_PW)
web3.geth.personal.unlock_account(web3.eth.coinbase, KEYFILE_PW)
deploy_txn_hash = factory.constructor().transact({'from': web3.eth.coinbase})
print('{0}_CONTRACT_DEPLOY_HASH: '.format(name.upper()), deploy_txn_hash)
deploy_receipt = mine_transaction_hash(web3, deploy_txn_hash)
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/generate_fixtures/go_ethereum.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ def setup_chain_state(web3):
#
# Block with Transaction
#
web3.geth.personal.unlockAccount(coinbase, common.KEYFILE_PW)
web3.geth.personal.unlock_account(coinbase, common.KEYFILE_PW)
web3.geth.miner.start(1)
mined_txn_hash = web3.eth.sendTransaction({
'from': coinbase,
Expand Down
4 changes: 4 additions & 0 deletions tests/integration/go_ethereum/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,3 +124,7 @@ def test_shh_post(self, web3):

class GoEthereumAdminModuleTest(GoEthereumAdminModuleTest):
pass


class GoEthereumPersonalModuleTest(GoEthereumPersonalModuleTest):
pass
8 changes: 4 additions & 4 deletions tests/integration/go_ethereum/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,9 +152,9 @@ def emitter_contract_address(emitter_contract, address_conversion_func):

@pytest.fixture
def unlocked_account(web3, unlockable_account, unlockable_account_pw):
web3.geth.personal.unlockAccount(unlockable_account, unlockable_account_pw)
web3.geth.personal.unlock_account(unlockable_account, unlockable_account_pw)
yield unlockable_account
web3.geth.personal.lockAccount(unlockable_account)
web3.geth.personal.lock_account(unlockable_account)


@pytest.fixture(scope='module')
Expand All @@ -174,9 +174,9 @@ def unlockable_account_dual_type(unlockable_account, address_conversion_func):

@pytest.yield_fixture
def unlocked_account_dual_type(web3, unlockable_account_dual_type, unlockable_account_pw):
web3.geth.personal.unlockAccount(unlockable_account_dual_type, unlockable_account_pw)
web3.geth.personal.unlock_account(unlockable_account_dual_type, unlockable_account_pw)
yield unlockable_account_dual_type
web3.geth.personal.lockAccount(unlockable_account_dual_type)
web3.geth.personal.lock_account(unlockable_account_dual_type)


@pytest.fixture(scope="module")
Expand Down
14 changes: 7 additions & 7 deletions tests/integration/test_ethereum_tester.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ def unlockable_account_pw(web3):

@pytest.fixture(scope='module')
def unlockable_account(web3, unlockable_account_pw):
account = web3.geth.personal.importRawKey(UNLOCKABLE_PRIVATE_KEY, unlockable_account_pw)
account = web3.geth.personal.import_raw_key(UNLOCKABLE_PRIVATE_KEY, unlockable_account_pw)
web3.eth.sendTransaction({
'from': web3.eth.coinbase,
'to': account,
Expand All @@ -158,9 +158,9 @@ def unlockable_account(web3, unlockable_account_pw):

@pytest.fixture
def unlocked_account(web3, unlockable_account, unlockable_account_pw):
web3.geth.personal.unlockAccount(unlockable_account, unlockable_account_pw)
web3.geth.personal.unlock_account(unlockable_account, unlockable_account_pw)
yield unlockable_account
web3.geth.personal.lockAccount(unlockable_account)
web3.geth.personal.lock_account(unlockable_account)


@pytest.fixture()
Expand All @@ -170,9 +170,9 @@ def unlockable_account_dual_type(unlockable_account, address_conversion_func):

@pytest.fixture
def unlocked_account_dual_type(web3, unlockable_account_dual_type, unlockable_account_pw):
web3.geth.personal.unlockAccount(unlockable_account_dual_type, unlockable_account_pw)
web3.geth.personal.unlock_account(unlockable_account_dual_type, unlockable_account_pw)
yield unlockable_account_dual_type
web3.geth.personal.lockAccount(unlockable_account_dual_type)
web3.geth.personal.lock_account(unlockable_account_dual_type)


@pytest.fixture(scope="module")
Expand Down Expand Up @@ -310,13 +310,13 @@ class TestEthereumTesterNetModule(NetModuleTest):
# Use web3.geth.personal namespace for testing eth-tester
class TestEthereumTesterPersonalModule(GoEthereumPersonalModuleTest):
test_personal_sign_and_ecrecover = not_implemented(
GoEthereumPersonalModuleTest.test_personal_sign_and_ecrecover,
GoEthereumPersonalModuleTest.test_personal_sign_and_ec_recover,
ValueError,
)

# Test overridden here since eth-tester returns False rather than None for failed unlock
def test_personal_unlockAccount_failure(self,
web3,
unlockable_account_dual_type):
result = web3.geth.personal.unlockAccount(unlockable_account_dual_type, 'bad-password')
result = web3.geth.personal.unlock_account(unlockable_account_dual_type, 'bad-password')
assert result is False
Loading