Giter Site home page Giter Site logo

eth-testrpc's Introduction

Ethereum Test RPC server

Join the chat at https://gitter.im/pipermerriam/eth-testrpc

Ethereum Test RPC

Limited RPC client intended for use with automated testing. Uses pythereum to run an Ethereum client behind the scenes without the need for mining or networking. The result is an Ethereum client that provides instant results and quick feedback during development.

Install

Installing is easy, through pip:

$ pip install eth-testrpc

Or, to upgrade:

pip install eth-testrpc --upgrade

Or, to install with gevent threads

pip install eth-testrpc[gevent]

And then set the environment variable TESTRPC_THREADING_BACKEND=gevent

Run

Installing through pip will make the testrpc-py command available on your machine:

$ testrpc

This will run testrpc on localhost:8545. You can pass through a different port (-p, --port) or domain (-d, --domain).

Implemented methods

The RPC methods currently implemented are:

  • eth_coinbase
  • eth_accounts
  • eth_gasPrice
  • eth_blockNumber
  • eth_sendTransaction
  • eth_sendRawTransaction
  • eth_call
  • eth_getCompilers
  • eth_compileSolidity
  • eth_getCode (only supports block number “latest”)
  • eth_getBalance
  • eth_getTransactionCount
  • eth_getTransactionByHash
  • eth_getTransactionReceipt
  • eth_newBlockFilter (temporarily removed until implemented in underlying library)
  • eth_newFilter (temporarily removed until implemented in underlying library)
  • eth_getFilterChanges (temporarily removed until implemented in underlying library)
  • eth_uninstallFilter (temporarily removed until implemented in underlying library)
  • eth_protocolVersion ( see rpc_configure)
  • eth_syncing ( see rpc_configure)
  • eth_mining ( see rpc_configure)
  • web3_sha3
  • web3_clientVersion
  • net_version (see rpc_configure)
  • net_listening (see rpc_configure)
  • net_peerCount (see rpc_configure)

There’s also special non-standard methods that aren’t included within the original RPC specification:

  • evm_reset : No params, no return value.
  • evm_snapshot : No params. Returns the integer id of the snapshot created.
  • evm_revert : One optional param. Reverts to the snapshot id passed, or the latest snapshot.

When calling evm_reset, the testrpc will revert the state of its internal chain back to the genesis block and it will act as if no processing of transactions has taken place. Similarly, you can use evm_snapshot and evm_revert methods to save and restore the evm state as desired. Example use cases for these methods are as follows:

  • evm_reset : Run once at the beginning of your test suite.
  • evm_snapshot : Run at the beginning of each test, snapshotting the state of the evm.
  • evm_revert : Run at the end of each test, reverting back to a known clean state.

TestRPC also exposes the evm_mine method for advancing the test evm by some number of blocks.

  • evm_mine : Optionally supply an integer for the number of blocks to mine. Default is 1 block. No return value.

TestRPC exposes the testing_timeTravel method for fast-forwarding to a future timestamp.

  • testing_timeTravel : Takes an integer timestamp that must be greater than the timestamp of the current latest block.

TestRPC exposes the rpc_configure method which can be used to modify the static values returned by the following endpoints.

  • eth_protocolVersion (default 63)
  • eth_syncing (default False)
  • eth_mining (default True)
  • net_version (default 1)
  • net_listening (default False)
  • net_peerCount (default 0)
  • homestead_block_number (default 0)
  • dao_fork_block_number (default 0)
  • anti_dos_fork_block_number (default 0)
  • clearing_fork_block_number (default 0)

The rpc_configure takes two parameters.

  • key: string representing the rpc method on which you want to change the return value.
  • value: the value that should be returned by the endpoint.

The homestead, dao, anti_dos and clearing fork configurations determine which block number the respective fork rules should come into effect. All default to 0.

TestRPC uses a default gas limit of 4000000. To change this set the environment variable TESTRPC_GAS_LIMIT to the desired value.

Releasing a new version (for eth-testrpc developers)

  • Bump version number in setup.py
  • Add entry to CHANGES.txt
  • Tag the release.
git tag -s -m "X.X.X Release" vX.X.X
git push --tags
  • Go make the release on github for the tag you just pushed
  • Build and push release to PyPI
make release

License

MIT

Consensys

This library was originally authored by Consensys and transferred later when it was no longer maintained. A big thanks for them to creating this extremely useful library.

eth-testrpc's People

Contributors

4gn3s avatar afdudley avatar carver avatar chetan avatar dependabot[bot] avatar detoo avatar ethers avatar gitter-badger avatar jmlubin avatar pipermerriam avatar rainbreak avatar ryepdx avatar simondlr avatar tcoulter avatar voith avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

eth-testrpc's Issues

eth-testrpc 1.3.5 has requirement rlp<=0.6.0,>=0.4.7 but you'll have rlp 1.0.3

  • versions: web3 4.7.2, testrpc 1.3.5, python 3.5.3
  • OS: linux

What was wrong?

virtualenv -p python3 env/py3eth
source env/py3eth/bin/activate

pip3 install rlp eth-testrpc

results in a red line

...
eth-testrpc 1.3.5 has requirement rlp<=0.6.0,>=0.4.7, but you'll have rlp 1.0.3 which is incompatible.
...

Cute Animal Picture

https://assets.heart.co.uk/2013/04/cute-giraffe-1359464944-view-1.jpeg

Invalid block timestamp

  • eth-testrpc Version 1.3.3
  • py-geth Version: 2.0.0
  • go-ethereum Version: 1.7.3
  • Python Version: 3.6.4
  • OS: linux

What was wrong?

block.timestamp in solidity returns wrong time, somewhere between 1400000000 and 1500000000.

There is similar old issue: #25

Cute Animal Picture

mongoose2

Filters from "latest" to "latest" always return empty list

Package versions:
eth-testrpc: 0.8.7
ethereum-tester-client: 1.2.5
geth: 1.5.3, 1.5.4

What was wrong?

When using filters, if filter has {"fromBlock": "latest", "toBlock": "latest"} (to retrieve logs from the most recently mined transaction), testrpc returns an empty list, while geth returns a correct log.
A minimal example which shows the current behaviour:

import pytest
from eth_tester_client.utils import encode_address
from ethereum import tester


@pytest.fixture(params=[
    'testrpc',
    'temp',
])
def chain(project, request):
    with project.get_chain(request.param) as chain:
        if request.param == 'temp':
            address = chain.web3.personal.importRawKey(tester.keys[0], "")
            assert address == encode_address(tester.accounts[0])
            chain.web3.personal.unlockAccount(address, "", duration=0)
            chain.wait.for_unlock(address)
        yield chain


def deploy(chain, contract_name):
    contract_factory = chain.get_contract_factory(contract_name)
    deploy_txn_hash = contract_factory.deploy()
    deploy_address = chain.wait.for_contract_address(deploy_txn_hash, timeout=120)
    return contract_factory(address=deploy_address)


def test_latest_logs(chain):
    contract = deploy(chain, 'TestContract')
    event_filter = contract.pastEvents('TestEvent', {"fromBlock": "latest",
                                                     "toBlock": "latest"})
    txn_hash = contract.transact().do_action(1234)
    chain.wait.for_receipt(txn_hash)
    event_logs = event_filter.get()
    assert event_logs
    event_logs = filter(lambda log: log["transactionHash"] == txn_hash, event_logs)
    assert len([e["args"] for e in event_logs]) > 0

and the TestContract.sol:

contract TestContract {
    event TestEvent(uint value);
    function do_action(uint value){
        TestEvent(value);
    }
}

When running, I get:

____ test_latest_logs[testrpc] ____

chain = <populus.chain.TestRPCChain object at 0x7fa413aa0f50>

    def test_latest_logs(chain):
        contract = deploy(chain, 'TestContract')
        event_filter = contract.pastEvents('TestEvent', {"fromBlock": "latest",
                                                         "toBlock": "latest"})
        txn_hash = contract.transact().do_action(1234)
        chain.wait.for_receipt(txn_hash)
        event_logs = event_filter.get()
>       assert event_logs
E       assert []

tests/unit/testrpc_bug_logs.py:43: AssertionError

...

===== 1 failed, 1 passed in 13.80 seconds =====

Cute Animal Picture

wet tiger

testrpc.py", line 294, in eth_compileSolidity

Hi,

I get an error in testrpc.py performing the truffle deploy:

$ truffle deploy --force
Using environment development.
Compiling BusinessPartnerFS.sol...

Server error: File "/home/m9000/.local/lib/python2.7/site-packages/testrpc/testrpc.py", line 294, in eth_compileSolidity | KeyError: 'binary'

Hint: Some clients don't send helpful error messages through the RPC. See client logs for more details.
Warning: Compilation failed. See above. Used --force, continuing.

The eth-testrpc package ist up-to-date
https://gist.github.com/mtgran/d5c3f3cf7da1f4f6a09a

I am currently using Python 2.7.9 and solc 0.1.2-0/Release-Linux/g++/int

Docker Support?

  • py-geth Version: x.x.x
  • go-ethereum Version: x.x.x
  • Python Version: x.x.x
  • OS: osx/linux/win

What was wrong?

Nothing wrong, but it would be convenient to have a docker container for easier developer env setup. For example, I am running web3.py locally but I need a testrpc running to test with. Since I'm also running web3.py in docker, I could simply add a eth-testrpc docker image to the docker-compose.yml file and the web3.py docker container would have access to the test port 8545.

Cute Animal Picture

nerd_dog

seems like it's downstream but...

  • py-geth Version: 1.2.0
  • go-ethereum Version: 1.4.11
  • Python Version: 3.5
  • OS: linux

What was wrong?

ok I'm trying to run my tests on a machine I used 6 months ago, so I might have messed up with deps, but this seems so weird to me that nobody got this error yet, it seems like it's downstream in ethereum/tester.py
while I can definitely understand that the print should have parenthesis for python3, I don't know how to fix in my install,
that serpent.py file, where does it come from ?
other machine runs the same code fine

Traceback (most recent call last):
  File "/usr/local/bin/py.test", line 11, in <module>
    sys.exit(main())
  File "/usr/local/lib/python3.5/dist-packages/_pytest/config.py", line 47, in main
    config = _prepareconfig(args, plugins)
  File "/usr/local/lib/python3.5/dist-packages/_pytest/config.py", line 132, in _prepareconfig
    pluginmanager=pluginmanager, args=args)
  File "/usr/local/lib/python3.5/dist-packages/_pytest/vendored_packages/pluggy.py", line 724, in __call__
    return self._hookexec(self, self._nonwrappers + self._wrappers, kwargs)
  File "/usr/local/lib/python3.5/dist-packages/_pytest/vendored_packages/pluggy.py", line 338, in _hookexec
    return self._inner_hookexec(hook, methods, kwargs)
  File "/usr/local/lib/python3.5/dist-packages/_pytest/vendored_packages/pluggy.py", line 333, in <lambda>
    _MultiCall(methods, kwargs, hook.spec_opts).execute()
  File "/usr/local/lib/python3.5/dist-packages/_pytest/vendored_packages/pluggy.py", line 595, in execute
    return _wrapped_call(hook_impl.function(*args), self.execute)
  File "/usr/local/lib/python3.5/dist-packages/_pytest/vendored_packages/pluggy.py", line 249, in _wrapped_call
    wrap_controller.send(call_outcome)
  File "/usr/local/lib/python3.5/dist-packages/_pytest/helpconfig.py", line 32, in pytest_cmdline_parse
    config = outcome.get_result()
  File "/usr/local/lib/python3.5/dist-packages/_pytest/vendored_packages/pluggy.py", line 278, in get_result
    raise ex[1].with_traceback(ex[2])
  File "/usr/local/lib/python3.5/dist-packages/_pytest/vendored_packages/pluggy.py", line 264, in __init__
    self.result = func()
  File "/usr/local/lib/python3.5/dist-packages/_pytest/vendored_packages/pluggy.py", line 596, in execute
    res = hook_impl.function(*args)
  File "/usr/local/lib/python3.5/dist-packages/_pytest/config.py", line 880, in pytest_cmdline_parse
    self.parse(args)
  File "/usr/local/lib/python3.5/dist-packages/_pytest/config.py", line 1030, in parse
    self._preparse(args, addopts=addopts)
  File "/usr/local/lib/python3.5/dist-packages/_pytest/config.py", line 993, in _preparse
    self.pluginmanager.load_setuptools_entrypoints(entrypoint_name)
  File "/usr/local/lib/python3.5/dist-packages/_pytest/vendored_packages/pluggy.py", line 501, in load_setuptools_entrypoints
    plugin = ep.load()
  File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 2230, in load
    return self.resolve()
  File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 2236, in resolve
    module = __import__(self.module_name, fromlist=['__name__'], level=0)
  File "/usr/local/lib/python3.5/dist-packages/populus-1.0.0b9-py3.5.egg/populus/__init__.py", line 3, in <module>
    from .project import Project
  File "/usr/local/lib/python3.5/dist-packages/populus-1.0.0b9-py3.5.egg/populus/project.py", line 39, in <module>
    from populus.chain import (
  File "/usr/local/lib/python3.5/dist-packages/populus-1.0.0b9-py3.5.egg/populus/chain.py", line 8, in <module>
    from testrpc import testrpc
  File "/usr/local/lib/python3.5/dist-packages/testrpc/testrpc.py", line 7, in <module>
    from ethereum.tester import (
  File "/usr/local/lib/python3.5/dist-packages/ethereum/tester.py", line 47, in <module>
    import serpent  # pylint: disable=wrong-import-position
  File "/usr/local/bin/serpent.py", line 225
    print json.dumps(o)
             ^
SyntaxError: invalid syntax

Cute Animal Picture

omg it is cutet

Out of gas error when using constructors

The following contract

contract TestContract {

    address public creator;
    address[] public array1;
    address[] public array2;

    function TestContract(bytes2 someStuff,
              bytes32 moreStuff,
              address[] _array1,
              bytes32[] _array2,
              uint _additionalStuff) {

    creator = msg.sender;             
    array1 = _array1;

    }    
}

with the following test in truffle:

contract 'TestContract', (accounts) ->

  it "should construct and populate ", (done) ->
    stuff = "0x1220"
    stuff2 = "0x1c8aff950685c2ed4bc3174f3472287b56d9517b9c948127319a09a7a36deac8"
    array2 = ["0x416c696365", "0x426f62"]
    array1 = [accounts[0], accounts[1]]
    num = 2
    TestContract.new(stuff, stuff2, array1, array2, num, {gasLimit: 3000000}).then (ctr) ->
      ctr.creator.call(0).then (creator) ->
        assert.strictEqual(creator, accounts[0], "Wrong creator!")
        done()
      .catch (err) ->
        done(err)

gives out-of-gas error in the testrpc. If any of the inputs are commented out it succeeds and it also succeeds if the line array1 = _array1; is commented out. 3000000 gasLimit should be enough here I think.

debug_traceTransaction integration

{"jsonrpc":"2.0","id":331,"method":"debug_traceTransaction","params":["0x9cda11aa741ebc2b737a1844e33d82b5a40e05f442c2f84667445c96dca93a9b",{"disableStorage":true,"disableMemory":false,"disableStack":false,"fullStorage":false}]}

Answer: Method not found

It would be really awesome if with the testrpc-py could we debug the transactions using remix!

log0 in a contract's constructor fails if the creator has not sent a transaction.

Take the following code on a FRESH testrpc:

logtest = "contract logtest { function logtest() { log0(\"A\"); } }"
compiled = web3.eth.compile.solidity(logtest)
web3.eth.sendTransaction(compiled.logtest.code)

It will complain

Error: Server error:   File "/home/xxx/.virtualenvs/truffle/local/lib/python2.7/site-packages/testrpc/testrpc.py", line 169, in __call__ | AttributeError: state instance has no attribute 'last_tx'

However, if you send a non-contract transaction before that, it will work.

Failure to install on ubuntu 16.04

  • py-geth Version: py-geth-1.10.2
  • go-ethereum Version: 1.7.2-stable
  • Python Version: Python 2.7.12
  • OS: ubuntu 16.04

What was wrong?

Running the pip install eth-testrpc command, I get the following errors:

x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fno-strict-aliasing -Wdate-time -D_FORTIFY_SOURCE=2 -g -fstack-protector-strong -Wformat -Werror=format-security -fPIC -DHAVE_CONFIG_H -DHAVE_CLOCK_GETTIME=1 -DHAVE_LIBRT=1 -DHAVE_POSIX_MEMALIGN=1 -DHAVE_STRUCT_SYSINFO=1 -DHAVE_STRUCT_SYSINFO_MEM_UNIT=1 -DHAVE_STRUCT_SYSINFO_TOTALRAM=1 -DHAVE_SYSINFO=1 -DHAVE_SYS_SYSINFO_H=1 -D_FILE_OFFSET_BITS=64 -Iscrypt-1.2.0 -Iscrypt-1.2.0/lib -Iscrypt-1.2.0/lib/scryptenc -Iscrypt-1.2.0/lib/crypto -Iscrypt-1.2.0/lib/util -Iscrypt-1.2.0/libcperciva/cpusupport -Iscrypt-1.2.0/libcperciva/alg -Iscrypt-1.2.0/libcperciva/util -Iscrypt-1.2.0/libcperciva/crypto -I/usr/include/python2.7 -c scrypt-1.2.0/libcperciva/crypto/crypto_aes.c -o build/temp.linux-x86_64-2.7/scrypt-1.2.0/libcperciva/crypto/crypto_aes.o -O2
scrypt-1.2.0/libcperciva/crypto/crypto_aes.c:6:25: fatal error: openssl/aes.h: No such file or directory
compilation terminated.
error: command 'x86_64-linux-gnu-gcc' failed with exit status 1

----------------------------------------
Failed building wheel for scrypt
Running setup.py clean for scrypt
Failed to build scrypt
nstalling collected packages: json-rpc, click, pbkdf2, scrypt, PyYAML, pycryptodome, repoze.lru, pysha3, pycparser, cffi, secp256k1, pyethash, bitcoin, rlp, ethereum, Werkzeug, eth-testrpc
Running setup.py install for scrypt ... error
  Complete output from command /usr/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-oc3oXW/scrypt/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-gE3Zil-record/install-record.txt --single-version-externally-managed --compile --user --prefix=:
  running install
  running build
  running build_py
  creating build
  creating build/lib.linux-x86_64-2.7
  copying scrypt.py -> build/lib.linux-x86_64-2.7
  running build_ext
  building '_scrypt' extension
  creating build/temp.linux-x86_64-2.7
  creating build/temp.linux-x86_64-2.7/src
  creating build/temp.linux-x86_64-2.7/scrypt-1.2.0
  creating build/temp.linux-x86_64-2.7/scrypt-1.2.0/lib
  creating build/temp.linux-x86_64-2.7/scrypt-1.2.0/lib/crypto
...
  x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fno-strict-aliasing -Wdate-time -D_FORTIFY_SOURCE=2 -g -fstack-protector-strong -Wformat -Werror=format-security -fPIC -DHAVE_CONFIG_H -DHAVE_CLOCK_GETTIME=1 -DHAVE_LIBRT=1 -DHAVE_POSIX_MEMALIGN=1 -DHAVE_STRUCT_SYSINFO=1 -DHAVE_STRUCT_SYSINFO_MEM_UNIT=1 -DHAVE_STRUCT_SYSINFO_TOTALRAM=1 -DHAVE_SYSINFO=1 -DHAVE_SYS_SYSINFO_H=1 -D_FILE_OFFSET_BITS=64 -Iscrypt-1.2.0 -Iscrypt-1.2.0/lib -Iscrypt-1.2.0/lib/scryptenc -Iscrypt-1.2.0/lib/crypto -Iscrypt-1.2.0/lib/util -Iscrypt-1.2.0/libcperciva/cpusupport -Iscrypt-1.2.0/libcperciva/alg -Iscrypt-1.2.0/libcperciva/util -Iscrypt-1.2.0/libcperciva/crypto -I/usr/include/python2.7 -c scrypt-1.2.0/libcperciva/crypto/crypto_aes.c -o build/temp.linux-x86_64-2.7/scrypt-1.2.0/libcperciva/crypto/crypto_aes.o -O2
  scrypt-1.2.0/libcperciva/crypto/crypto_aes.c:6:25: fatal error: openssl/aes.h: No such file or directory
  compilation terminated.
  error: command 'x86_64-linux-gnu-gcc' failed with exit status 1
  
  ----------------------------------------
Command "/usr/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-oc3oXW/scrypt/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-gE3Zil-record/install-record.txt --single-version-externally-managed --compile --user --prefix=" failed with error code 1 in /tmp/pip-build-oc3oXW/scrypt/


Cute Animal Picture

https://i.pinimg.com/originals/b1/57/67/b157677864c2046e4ae09e35a39dcd0f.gif

UserWarning: implicit cast from 'char *' to a different pointer type:

  • py-geth Version: x.x.x
  • go-ethereum Version: x.x.x
  • Python Version: 2.7.6
  • OS: linux

What was wrong?

when I start testrpc server using command line "testrpc" , I encountered the bug which is
" /usr/local/lib/python2.7/dist-packages/pycryptodome-3.4-py2.7-linux-x86_64.egg/Crypto/Hash/keccak.py:139: UserWarning: implicit cast from 'char *' to a different pointer type: will be forbidden in the future (check that the types are as you expect; use an explicit ffi.cast() if they are correct)
c_size_t(self.digest_size))
TestRPC/0.8.7/linux2/python2.7.6"
how to fix it?
Please include information like:

  • full output of the error you received
  • what command you ran
  • the code that caused the failure

Cute Animal Picture

put a cute animal picture here.

Adding more accounts to testrpc-py

  • OS: Linux Lubuntu 16.04

I am using testrpc-py for research purposes, and in that regard it would be perfect to add more accounts. In the js testrpc this is simply done by initialise testrpc --accounts "number"
However, I have not found a simple manner of increasing the amount for testrpc-py. Is there a command for this, or could I implement it another way?

image

eth-testrpc doesn't install cleanly from PyPI

Installing eth-testrpc from PyPI is not clean. Despite the fact that jsonrpclib and ethereum are listed as dependencies in setup.py, they need to be installed manually before running pip install eth-testrpc.

To reproduce this issue, make sure to use an empty virtual env.

New release on PyPi

Can you make a new release on PyPi? Quite a lot of changes has happened since v0.8.7. Would be nice if that could be included in a new release. If the code base is ready to be release that is, of course.

december-31-2011-01-45-40-dog

Sending value to a contract doesn't seem to work

This code gives a TransactionFailed. If I change value to 0, it works, but then I can't actually have contracts use send/transfer. It also doesn't work to do a send transaction with the to being the contractAddress.

from testrpc.client import EthTesterClient
from solc import *
from solc.exceptions import SolcError

c = EthTesterClient()

ac = sorted(c.get_accounts())

contract = """
contract c {

function f() returns (int) {
  return 10;
}

}
"""

bin = compile_source(contract,optimize=True).values()[0]['bin']

txnHash = c.send_transaction(_from = ac[0], data = bytes(bin), value=1000)

txnReceipt = c.get_transaction_receipt(txnHash)
contractAddress = txnReceipt['contractAddress']

print (contractAddress), c.get_balance(contractAddress)

Cannot run: import error (set_logging_level)

  • Python Version: 2.7.11+
  • OS: linux
  • pyethereum version: 1.3.6
  • eth-testrpc version: 0.3.2

What was wrong?

When trying to run testrpc (without any additional arguments), I get the following error:

⇒ testrpc                          
Traceback (most recent call last):
  File "/home/mylogin/.virtualenvs/myvenv/bin/testrpc", line 7, in <module>
    from testrpc.__main__ import main
  File "/home/mylogin/.virtualenvs/myvenv/local/lib/python2.7/site-packages/testrpc/__main__.py", line 6, in <module>
    from ethereum.tester import (
ImportError: cannot import name set_logging_level

Change JSON-RPC libraries?

I'm trying to use Test RPC in conjunction with my gulp-ethertest tool, but it looks like jsonrpclib is pretty easily brought to its knees by simple test cases. In particular, jsonrpclib seems to have a request-prioritization problem that leads to early requests for filter logs to be drowned out by block filter watchers. In a private testing environment, requests would ideally be handled in a more-or-less-FIFO order. (Which is to be expected in a multi-threaded server, of course, but parallel request processing is really not a positive in this case.)

Alternatively, introducing an optional delay between mining blocks might help.

eth-testrpc installation errors (e.g. python)

Hi,

the installation of eth-testrpc raises several errors. Interessting is the python too:

http://pastebin.com/yKrXXMZa

The installation was done with "pip install eth-testrpc"
It seems that the installation uses a python3 library although python2.7 is needed.
If you see in the log, the library python2.7 is used in most part of the installation, but there is an error concerning the utils_py3.py library, between others

Regards
SkyDog

The `"earliest"` block identifier should return block #1

What was wrong?

Currently if you call eth_getBlockByNumber("earliest") you will get the genesis block which is block number 0. Based on the behavior of geth and parity, this should be returning block number 1.

Cute Animal Picture

put a cute animal picture here.

t-ezkrmv

I have problems with install of testrpc

  • py-geth Version: -
  • go-ethereum Version: -
  • Python Version: 2.7.12
  • OS: linux (ubuntu 16.0,4)

What was wrong?

Please include information like:

  • full output of the error you received

command: sudo pip install eth-testrpc

The directory '/home/tzaika/.cache/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
The directory '/home/tzaika/.cache/pip' or its parent directory is not owned by the current user and caching wheels has been disabled. check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
Collecting eth-testrpc
Downloading eth-testrpc-1.3.3.tar.gz
Requirement already satisfied: Werkzeug>=0.11.10 in /usr/local/lib/python2.7/dist-packages (from eth-testrpc)
Requirement already satisfied: click>=6.6 in /usr/local/lib/python2.7/dist-packages (from eth-testrpc)
Collecting ethereum<2.0.0,>=1.6.1 (from eth-testrpc)
Downloading ethereum-1.6.1.tar.gz (128kB)
100% |████████████████████████████████| 133kB 1.2MB/s
Collecting json-rpc>=1.10.3 (from eth-testrpc)
Downloading json_rpc-1.10.8-py2.py3-none-any.whl (40kB)
100% |████████████████████████████████| 40kB 6.4MB/s
Collecting rlp>=0.4.7 (from eth-testrpc)
Downloading rlp-0.6.0.tar.gz
Requirement already satisfied: repoze.lru in /usr/local/lib/python2.7/dist-packages (from ethereum<2.0.0,>=1.6.1->eth-testrpc)
Requirement already satisfied: PyYAML in /usr/local/lib/python2.7/dist-packages (from ethereum<2.0.0,>=1.6.1->eth-testrpc)
Requirement already satisfied: pbkdf2 in /usr/local/lib/python2.7/dist-packages (from ethereum<2.0.0,>=1.6.1->eth-testrpc)
Requirement already satisfied: bitcoin in /usr/local/lib/python2.7/dist-packages (from ethereum<2.0.0,>=1.6.1->eth-testrpc)
Requirement already satisfied: pycryptodome>=3.3.1 in /usr/local/lib/python2.7/dist-packages (from ethereum<2.0.0,>=1.6.1->eth-testrpc)
Collecting secp256k1 (from ethereum<2.0.0,>=1.6.1->eth-testrpc)
Downloading secp256k1-0.13.2.tar.gz (156kB)
100% |████████████████████████████████| 163kB 1.9MB/s
Collecting scrypt (from ethereum<2.0.0,>=1.6.1->eth-testrpc)
Downloading scrypt-0.8.6.tar.gz (52kB)
100% |████████████████████████████████| 61kB 2.0MB/s
Collecting pysha3>=1.0.1 (from ethereum<2.0.0,>=1.6.1->eth-testrpc)
Downloading pysha3-1.0.2-cp27-cp27mu-manylinux1_i686.whl (56kB)
100% |████████████████████████████████| 61kB 8.1MB/s
Collecting pyethash (from ethereum<2.0.0,>=1.6.1->eth-testrpc)
Downloading pyethash-0.1.27.tar.gz
Requirement already satisfied: cffi>=1.3.0 in /usr/local/lib/python2.7/dist-packages (from secp256k1->ethereum<2.0.0,>=1.6.1->eth-testrpc)
Requirement already satisfied: pycparser in /usr/local/lib/python2.7/dist-packages (from cffi>=1.3.0->secp256k1->ethereum<2.0.0,>=1.6.1->eth-testrpc)
Installing collected packages: secp256k1, scrypt, pysha3, rlp, pyethash, ethereum, json-rpc, eth-testrpc
Running setup.py install for secp256k1 ... error
Complete output from command /usr/bin/python -u -c "import setuptools, tokenize;file='/tmp/pip-build-imzweV/secp256k1/setup.py';f=getattr(tokenize, 'open', open)(file);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, file, 'exec'))" install --record /tmp/pip-vToneS-record/install-record.txt --single-version-externally-managed --compile:
0.29.1
Using bundled libsecp256k1
running install
running build
running build_py
creating build
creating build/lib.linux-i686-2.7
creating build/lib.linux-i686-2.7/secp256k1
copying secp256k1/main.py -> build/lib.linux-i686-2.7/secp256k1
copying secp256k1/init.py -> build/lib.linux-i686-2.7/secp256k1
running build_clib
/tmp/pip-build-imzweV/secp256k1/libsecp256k1/autogen.sh: 3: /tmp/pip-build-imzweV/secp256k1/libsecp256k1/autogen.sh: autoreconf: not found
Traceback (most recent call last):
File "", line 1, in
File "/tmp/pip-build-imzweV/secp256k1/setup.py", line 295, in
"Topic :: Security :: Cryptography"
File "/usr/local/lib/python2.7/dist-packages/setuptools/init.py", line 129, in setup
return distutils.core.setup(**attrs)
File "/usr/lib/python2.7/distutils/core.py", line 151, in setup
dist.run_commands()
File "/usr/lib/python2.7/distutils/dist.py", line 953, in run_commands
self.run_command(cmd)
File "/usr/lib/python2.7/distutils/dist.py", line 972, in run_command
cmd_obj.run()
File "/usr/local/lib/python2.7/dist-packages/setuptools/command/install.py", line 61, in run
return orig.install.run(self)
File "/usr/lib/python2.7/distutils/command/install.py", line 601, in run
self.run_command('build')
File "/usr/lib/python2.7/distutils/cmd.py", line 326, in run_command
self.distribution.run_command(command)
File "/usr/lib/python2.7/distutils/dist.py", line 972, in run_command
cmd_obj.run()
File "/usr/lib/python2.7/distutils/command/build.py", line 128, in run
self.run_command(cmd_name)
File "/usr/lib/python2.7/distutils/cmd.py", line 326, in run_command
self.distribution.run_command(command)
File "/usr/lib/python2.7/distutils/dist.py", line 972, in run_command
cmd_obj.run()
File "/tmp/pip-build-imzweV/secp256k1/setup.py", line 165, in run
cwd=absolute("libsecp256k1"),
File "/usr/lib/python2.7/subprocess.py", line 541, in check_call
raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['/tmp/pip-build-imzweV/secp256k1/libsecp256k1/autogen.sh']' returned non-zero exit status 127

----------------------------------------

Command "/usr/bin/python -u -c "import setuptools, tokenize;file='/tmp/pip-build-imzweV/secp256k1/setup.py';f=getattr(tokenize, 'open', open)(file);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, file, 'exec'))" install --record /tmp/pip-vToneS-record/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /tmp/pip-build-imzweV/secp256k1/

  • what command you ran
    install

I have already solved some similar problems with:
pip install --upgrade setuptools
apt install -y libmysqlclient-dev

and yet i am stuck

Does this work with Python 3.5?

Hello Friends:

Does this work with Python 3.5? Sometimes the pip3 install of a package will succeed even though it is not supported. :)

Thank you!

Implement `eth_sign`

The eth_sign interface hasn't been implemented.

  • Don't add the secp256k1 dependency.
  • Have the eth_sign function check whether secp256k1 is available and if so, execute the signing. If not, return a user friendly error message instructing them to install the dependency.

Request to implement block filter and pending transaction filter

  • Python Version: 3.6
  • OS: Ubuntu 17.10

Please finish implementing methods for block filter and pending transaction filter methods. Currently they are throwing NotImplementedError.

Details:
eth-testrpc/rpc.py line number: 187
Method : eth_newBlockFilter

eth-testrpc/rpc.py line number: 191
Method : eth_newPendingTransactionFilter

Bad date generated for Solidity's 'now'

When my Solidity contracts store a date with now, I later get a value like 1410973360 when I query that date. This is about a year in the past (the clock on my computer is fine). Perhaps this is a pyethereum issue?

Make testrpc a module

Hi,
I think something is missing in the install instructions. I follow them and I got the error:

$ python testrpc.py
Traceback (most recent call last):
  File "testrpc.py", line 3, in <module>
    from jsonrpclib.SimpleJSONRPCServer import SimpleJSONRPCServer
ImportError: No module named jsonrpclib.SimpleJSONRPCServer

Error in instllation over window

Hi
I am try to install testrpc on window but is shown a error "pkg-config" required through pip(python).

Please help me to resolve this dependency .

testrpc

Unable to Install eth-testrpc on Mac OSX

  • geth Version: 1.7.3
  • Python Version: 2.7.10
  • OS: osx

Here's the full output and the command when running pip install eth-testrpc:

➜  EthereumPrivate pip install eth-testrpc
Collecting eth-testrpc
  Downloading eth-testrpc-1.3.3.tar.gz
Collecting Werkzeug>=0.11.10 (from eth-testrpc)
  Downloading Werkzeug-0.12.2-py2.py3-none-any.whl (312kB)
    100% |████████████████████████████████| 317kB 967kB/s
Collecting click>=6.6 (from eth-testrpc)
  Downloading click-6.7-py2.py3-none-any.whl (71kB)
    100% |████████████████████████████████| 71kB 1.8MB/s
Collecting ethereum<2.0.0,>=1.6.1 (from eth-testrpc)
  Downloading ethereum-1.6.1.tar.gz (128kB)
    100% |████████████████████████████████| 133kB 446kB/s
Collecting json-rpc>=1.10.3 (from eth-testrpc)
  Downloading json_rpc-1.10.8-py2.py3-none-any.whl (40kB)
    100% |████████████████████████████████| 40kB 1.3MB/s
Collecting rlp>=0.4.7 (from eth-testrpc)
  Downloading rlp-0.6.0.tar.gz
Collecting repoze.lru (from ethereum<2.0.0,>=1.6.1->eth-testrpc)
  Downloading repoze.lru-0.7.tar.gz
Collecting PyYAML (from ethereum<2.0.0,>=1.6.1->eth-testrpc)
  Downloading PyYAML-3.12.tar.gz (253kB)
    100% |████████████████████████████████| 256kB 2.4MB/s
Collecting pbkdf2 (from ethereum<2.0.0,>=1.6.1->eth-testrpc)
  Downloading pbkdf2-1.3.tar.gz
Collecting bitcoin (from ethereum<2.0.0,>=1.6.1->eth-testrpc)
  Downloading bitcoin-1.1.42.tar.gz
Collecting pycryptodome>=3.3.1 (from ethereum<2.0.0,>=1.6.1->eth-testrpc)
  Downloading pycryptodome-3.4.7.tar.gz (6.5MB)
    100% |████████████████████████████████| 6.5MB 197kB/s
Collecting secp256k1 (from ethereum<2.0.0,>=1.6.1->eth-testrpc)
  Downloading secp256k1-0.13.2-cp27-cp27m-macosx_10_6_intel.whl (68kB)
    100% |████████████████████████████████| 71kB 729kB/s
Collecting scrypt (from ethereum<2.0.0,>=1.6.1->eth-testrpc)
  Downloading scrypt-0.8.0-cp27-cp27m-macosx_10_11_x86_64.whl
Collecting pysha3>=1.0.1 (from ethereum<2.0.0,>=1.6.1->eth-testrpc)
  Downloading pysha3-1.0.2.tar.gz (829kB)
    100% |████████████████████████████████| 829kB 672kB/s
Collecting pyethash (from ethereum<2.0.0,>=1.6.1->eth-testrpc)
  Downloading pyethash-0.1.27.tar.gz
Collecting cffi>=1.3.0 (from secp256k1->ethereum<2.0.0,>=1.6.1->eth-testrpc)
  Downloading cffi-1.11.2-cp27-cp27m-macosx_10_6_intel.whl (238kB)
    100% |████████████████████████████████| 245kB 879kB/s
Collecting pycparser (from cffi>=1.3.0->secp256k1->ethereum<2.0.0,>=1.6.1->eth-testrpc)
  Downloading pycparser-2.18.tar.gz (245kB)
    100% |████████████████████████████████| 256kB 1.1MB/s
Installing collected packages: Werkzeug, click, repoze.lru, PyYAML, pbkdf2, bitcoin, pycryptodome, pycparser, cffi, secp256k1, scrypt, pysha3, rlp, pyethash, ethereum, json-rpc, eth-testrpc
Exception:
Traceback (most recent call last):
  File "/Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg/pip/basecommand.py", line 215, in main
    status = self.run(options, args)
  File "/Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg/pip/commands/install.py", line 342, in run
    prefix=options.prefix_path,
  File "/Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg/pip/req/req_set.py", line 784, in install
    **kwargs
  File "/Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg/pip/req/req_install.py", line 851, in install
    self.move_wheel_files(self.source_dir, root=root, prefix=prefix)
  File "/Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg/pip/req/req_install.py", line 1064, in move_wheel_files
    isolated=self.isolated,
  File "/Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg/pip/wheel.py", line 345, in move_wheel_files
    clobber(source, lib_dir, True)
  File "/Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg/pip/wheel.py", line 316, in clobber
    ensure_dir(destdir)
  File "/Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg/pip/utils/__init__.py", line 83, in ensure_dir
    os.makedirs(path)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/os.py", line 157, in makedirs
    mkdir(name, mode)
OSError: [Errno 13] Permission denied: '/Library/Python/2.7/site-packages/Werkzeug-0.12.2.dist-info'

Thoughts?

Memory Leak

When running testrpc it shows this output. eth_getBlockByNumber keeps printing

Private keys 
1)...
....

eth_getBlockByNumber
eth_getBlockByNumber
eth_getBlockByNumber
eth_getBlockByNumber
eth_getBlockByNumber
eth_getBlockByNumber
warning: possible EventEmitter memory leak detected. 11 listeners added. Use emitter.setMaxListeners() to increase limit.
eth_getBlockByNumber
eth_getBlockByNumber
eth_getBlockByNumber
....

It happens only when metamask is connected

`sendTransaction` does not support `nonce` parameter

  • py-geth Version: x.x.x
  • go-ethereum Version: x.x.x
  • Python Version: 3.6.2
  • OS: osx

What was wrong?

When passing a custom nonce to web3.eth.sendTransaction, an _send_transaction() got an unexpected keyword argument 'nonce' exception is raised. It is probably because the:

    def _send_transaction(self, _from=None, to=None, gas=None, gas_price=None,
                          value=0, data=b''):

method does not have a nonce keyword argument.

If it is too complicated too implement it perfectly, maybe it should just compare the nonce passed with the next nonce available and just throw an exception if it's not equal...? I wanted to unit-test a piece of code which explicitly passes nonces in order to do some dynamic gas price manipulation, but I cannot because of the above :(

Cute Animal Picture

image

what is the time unit of the block timestamps in testrpc?

  • versions: web3 4.7.2, testrpc 1.3.5, python 3.5.3
  • OS: linux

What was wrong?

when I read
web3.eth.getBlock(blockNumber) ["timestamp"]
from two blocks
which were actually (i.e. I measured) produced at 38.8 seconds apart.

and then subtract these timestamps, I get a difference of 7945 units.

Why not 39, or 38800 or 38800000 ?
i.e. anything that remotely resembles {,milli,micro,nano}seconds.

Have a look:
what-are-the-units-of-the-block-timestamp

I had hammered 1000 transactions at testrpc-py, which took 38.8 seconds to finish.

Cute Animal Picture

http://www.vidaenigmatica.org/wp-content/uploads/2016/12/cute-croc.jpg

Different transaction hashes

tx_hash is differs from tx_data["hash"]

def eth_getTransactionReceipt(tx_hash):
    print "eth_getTransactionReceipt"

    global transaction_contract_addresses

    tx_data = eth_getTransactionByHash(tx_hash)
    block_data = eth_getBlockByNumber(tx_data["blockNumber"], False)

    return {
        "transactionHash": tx_data["hash"],

eth_sendTransaction invalid param gasPrice

When I run script that runs perfectly fine on geth/(js)testrpc eth-testrpc throws error with message _send_transaction() got an unexpected keyword argument 'gasPrice'.
gasPrice should be translated to internal gas_price.

ERROR When i run pip

When i run pip install eth_testrpc
the error happend:Command "python setup.py egg_info" failed with error code 1 in C:\Users\ADMINI1
\AppData\Local\Temp\pip-install-x7wkmr35\secp256k1
Then i try run pip install eth_testrpc-1.3.5-py3-none-any.whl
the error happend:Command "python setup.py egg_info" failed with error code 1 in C:\Users\ADMINI
1
\AppData\Local\Temp\pip-install-a_m14ezn\secp256k1
So ,How can i install it?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.