Skip to content

Commit 1fe0609

Browse files
committed
Use doctest for 'building chains' example
1 parent 5faa8f5 commit 1fe0609

File tree

1 file changed

+19
-19
lines changed

1 file changed

+19
-19
lines changed

docs/guides/eth/building_chains.rst

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -15,32 +15,32 @@ after you define the VM ranges. For example, to set up a chain that would track
1515
the mainnet Ethereum network until block 1920000, you could create this chain
1616
class:
1717

18-
::
18+
.. doctest::
1919

20-
from eth import constants, Chain
21-
from eth.vm.forks.frontier import FrontierVM
22-
from eth.vm.forks.homestead import HomesteadVM
23-
from eth.chains.mainnet import HOMESTEAD_MAINNET_BLOCK
24-
25-
chain_class = Chain.configure(
26-
__name__='Test Chain',
27-
vm_configuration=(
28-
(constants.GENESIS_BLOCK_NUMBER, FrontierVM),
29-
(HOMESTEAD_MAINNET_BLOCK, HomesteadVM),
30-
),
31-
)
20+
>>> from eth import constants, Chain
21+
>>> from eth.vm.forks.frontier import FrontierVM
22+
>>> from eth.vm.forks.homestead import HomesteadVM
23+
>>> from eth.chains.mainnet import HOMESTEAD_MAINNET_BLOCK
24+
25+
>>> chain_class = Chain.configure(
26+
... __name__='Test Chain',
27+
... vm_configuration=(
28+
... (constants.GENESIS_BLOCK_NUMBER, FrontierVM),
29+
... (HOMESTEAD_MAINNET_BLOCK, HomesteadVM),
30+
... ),
31+
... )
3232

3333
Then to initialize, you can start it up with an in-memory database:
3434

35-
::
35+
.. doctest::
3636

37-
from eth.db.backends.memory import MemoryDB
38-
from eth.chains.mainnet import MAINNET_GENESIS_HEADER
37+
>>> from eth.db.backends.memory import MemoryDB
38+
>>> from eth.chains.mainnet import MAINNET_GENESIS_HEADER
3939

40-
# start a fresh in-memory db
40+
>>> # start a fresh in-memory db
4141

42-
# initialize a fresh chain
43-
chain = chain_class.from_genesis_header(MemoryDB(), MAINNET_GENESIS_HEADER)
42+
>>> # initialize a fresh chain
43+
>>> chain = chain_class.from_genesis_header(MemoryDB(), MAINNET_GENESIS_HEADER)
4444

4545

4646
Using the LightPeerChain object

0 commit comments

Comments
 (0)