Skip to main content

An Ethereum simulator for aiding smart contract development.

Project description

# Ethereum Test RPC server

[![Join the chat at https://gitter.im/pipermerriam/eth-testrpc](https://badges.gitter.im/pipermerriam/eth-testrpc.svg)](https://gitter.im/pipermerriam/eth-testrpc?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)

## Ethereum Test RPC

Limited RPC client intended for use with automated testing. Uses [pythereum](https://github.com/ethereum/pyethereum) 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 `

### Run

Installing through pip will make the testrpc 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 a single block.

  • evm_mine : No params, no return value.

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)

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 and dao fork configurations determine which block number the fork rules should come into effect. Both default to 0.

### 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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

eth-testrpc-0.9.0b1.tar.gz (13.6 kB view details)

Uploaded Source

Built Distribution

eth_testrpc-0.9.0b1-py3-none-any.whl (18.2 kB view details)

Uploaded Python 3

File details

Details for the file eth-testrpc-0.9.0b1.tar.gz.

File metadata

File hashes

Hashes for eth-testrpc-0.9.0b1.tar.gz
Algorithm Hash digest
SHA256 7546032c14b660875be540074ca7168d845ede6ff9c6fa791f233b9807512582
MD5 babc10c38ca6a3959d0f487f9922197a
BLAKE2b-256 dc4ad6579845cec8875deb03e15638c56cb85772c8dbda153c1fab5e1c5542da

See more details on using hashes here.

File details

Details for the file eth_testrpc-0.9.0b1-py3-none-any.whl.

File metadata

File hashes

Hashes for eth_testrpc-0.9.0b1-py3-none-any.whl
Algorithm Hash digest
SHA256 84657e63ff384345f87995350e00ce2d85f9c3badb9bd04ecf46e3447f0281f7
MD5 9f0812ae04859b2dea1dcfaa54608209
BLAKE2b-256 4720a7ed692f15c4c5549626b7a653c67590565cb6c8c37351f8e36c54d10162

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page