• Stars
    star
    163
  • Rank 231,141 (Top 5 %)
  • Language
    Python
  • License
    MIT License
  • Created over 9 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Used for testing all maner of Ethereum JSON-RPC interactions.

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.

More Repositories

1

ethereum-datetime

Date-Time utilities for ethereum contracts.
Python
373
star
2

ethereum-function-signature-registry

Registry of 4byte function signatures and their human readable counterparts.
Python
210
star
3

flex

Swagger schema validator
Python
149
star
4

am-i-underpaid

A simple application for a group of employees to find out their average salaries without exposing any individual salary information.
JavaScript
84
star
5

ipfs-persistence-consortium

A consortium to help persist IPFS objects until Swarm arrives
Python
73
star
6

ethereum-computation-market

A marketplace for trustless off chain computation.
Python
56
star
7

ethereum-grove

Fast, efficient, queryable storage for ethereum contracts.
Python
52
star
8

ethereum-string-utils

String utility functions for ethereum contracts
Python
41
star
9

ethereum-usd-oracle

USD oracle for ethereum
30
star
10

ethereum-uuid

UUID v4 Generation
Python
22
star
11

devcon2-token

An identity token issued at Devcon 2
Python
16
star
12

ethereum-identity

Identity platform for Ethereum
Python
14
star
13

django-emailtools

Sending emails just got more awesomer.
Python
11
star
14

ethereum-rpc-client

[DEPRECATED] You should use web3.py instead.
Python
10
star
15

ethereum-stack-depth-lib

Solidity library for checking whether the call stack can be increased by a certain amount.
Python
10
star
16

ethereum-ipc-client

DEPRECATED - Use web3.py instead.
Python
9
star
17

ethereum-gas-proxy

An ethereum library that proxies calls and repays the transaction sender their gas costs.
Python
6
star
18

ethereum-cron

Crontab parsing for ethereum contracts.
Python
6
star
19

ethereum-accounting

Basic accounting tools for ethereum contracts
Python
5
star
20

ethereum-alarm-client

Client for executing scheduled calls for the ethereum alarm clock.
Python
5
star
21

django-fallback-storage

Use multiple storage backends for django file storage
Python
4
star
22

ethereum-alarm-clock-docs

Documentation for the ethereum Alarm service.
4
star
23

Placenoun

Like placekitten.com but instead it places whatever noun you supply
Python
4
star
24

python-style-guide

A style guide for how to write python
4
star
25

ethereum-REP-insurance-multisig

Multisignature insurance contract to hold REP tokens
Python
3
star
26

ethereum-phone-number-services

Phone number based services for ethereum
Python
3
star
27

django-game-of-life

A django project to simulate conways game of life
JavaScript
3
star
28

py-parity

Python wrapper around the Parity Ethereum client
Python
3
star
29

LPD8806-wrapper

Wrapper for the LPD8806 drivers to abstract strips as a grid.
Java
3
star
30

snorse

Unicode Snowman Morse Code Translator
Python
2
star
31

ethereum-client-utils

Python
2
star
32

ethereum-alarm-governance

Democratic governance framework for Ethereum Alarm Clock related contracts.
Python
2
star
33

Intentions

An informal contract between the developer and the users of the software.
2
star
34

ethereum-resource-pool

Python
2
star
35

ethereum-contract

Python
2
star
36

ethereum-data-exchange

API for inter-contract data exchange.
Python
1
star
37

Mosy

Genetic algorithm for high dimensional nearest neighbor search
Python
1
star
38

ethereum-alarm-canary

Canary for the Ethereum Alarm Clock coal mine.
Python
1
star
39

ethereum-wallet

Wallet contract
Python
1
star
40

se-onboarding

Simple Energy Onboarding
Makefile
1
star
41

ethereum-replicator

Self replecating ethereum contract.
Python
1
star
42

speleobox

Tooling for generating paths for a speliobox
Python
1
star
43

django-unsigned-fields

Django fields for representing relationships via unsigned integers.
Python
1
star
44

perjury

Tools for content generation.
Python
1
star