From 0dfd86dce91fcd9828fc532eed7bb18c49f3a469 Mon Sep 17 00:00:00 2001 From: Piper Merriam Date: Thu, 7 Jul 2016 13:03:15 -0600 Subject: [PATCH] fix more tests --- requirements-dev.txt | 2 +- tests/eth-module/test_eth_sign.py | 9 ++++++++- tests/personal-module/conftest.py | 4 ++-- web3/main.py | 2 +- 4 files changed, 12 insertions(+), 5 deletions(-) diff --git a/requirements-dev.txt b/requirements-dev.txt index bdbd4f9..1a6ce21 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -1,7 +1,7 @@ pytest>=2.8.2 pytest-pythonpath>=0.3 tox>=1.8.0 -eth-testrpc==0.3.2 +eth-testrpc==0.4.0 py-geth>=0.5.0 # Until pyethereum > 1.3.6 is released. https://github.com/ethereum/pyethereum/tarball/b06829e56e2a3de5276077a611ed8813b6cf5e74 diff --git a/tests/eth-module/test_eth_sign.py b/tests/eth-module/test_eth_sign.py index 269d477..2bb2360 100644 --- a/tests/eth-module/test_eth_sign.py +++ b/tests/eth-module/test_eth_sign.py @@ -12,6 +12,7 @@ from eth_tester_client.utils import ( coerce_args_to_bytes, ) +from web3.web3.rpcprovider import TestRPCProvider from web3.utils.encoding import ( force_bytes, encode_hex, @@ -51,6 +52,9 @@ def extract_ecdsa_signer(msg_hash, signature): def test_eth_sign(web3): + if isinstance(web3.currentProvider, TestRPCProvider): + pytest.skip("testrpc doesn't implement `getBlockTransactionCount`") + private_key_hex = b'0x5e95384d8050109aab08c1922d3c230739bc16976553c317e5d0b87b59371f2a' private_key = decode_hex(private_key_hex) @@ -95,9 +99,12 @@ def test_eth_sign(web3): # Verify the signature against the public key derived from the # original private key. It fails. + rec_id = signature_bytes[64] + if is_string(rec_id): + rec_id = ord(rec_id) recoverable_signature = priv_key.ecdsa_recoverable_deserialize( signature_bytes[:64], - signature_bytes[64], + rec_id, ) signature = priv_key.ecdsa_recoverable_convert(recoverable_signature) is_valid = priv_key.pubkey.ecdsa_verify( diff --git a/tests/personal-module/conftest.py b/tests/personal-module/conftest.py index b2cc3f9..8926aaa 100644 --- a/tests/personal-module/conftest.py +++ b/tests/personal-module/conftest.py @@ -31,11 +31,11 @@ def password_account(web3, account_password, initial_balance = 1000000000000000000000 # 1,000 ether - funding_txn_hash = web3.eth.sendTransaction({ + funding_txn_hash = web3.personal.signAndSendTransaction({ 'from': web3.eth.coinbase, 'to': address, 'value': initial_balance, - }) + }, account_password) wait_for_transaction(funding_txn_hash) assert web3.eth.getBalance(address) == initial_balance diff --git a/web3/main.py b/web3/main.py index a58ea78..7f3e005 100644 --- a/web3/main.py +++ b/web3/main.py @@ -93,7 +93,7 @@ class Web3(object): def sha3(self, string, encoding=None): if encoding is not None: raise ValueError("encoding parameter currently not supported") - return self._requestManager.request_blocking('web3_sha3', [encode_hex(string)]) + return self._requestManager.request_blocking('web3_sha3', [string]) def isConnected(self): return self.currentProvider and self.currentProvider.isConnected()