Skip to content
This repository was archived by the owner on May 23, 2023. It is now read-only.

Commit 259db25

Browse files
committed
rm:chainmanager and config references
1 parent 145c67e commit 259db25

File tree

3 files changed

+5
-60
lines changed

3 files changed

+5
-60
lines changed

ethereum/tests/test_chain.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
import ethereum.utils as utils
99
import ethereum.ethash_utils as ethash_utils
1010
from ethereum.db import EphemDB
11-
from tests.utils import new_db, get_chainmanager, new_chainmanager
11+
from ethereum.tests.utils import new_db
1212

1313
from ethereum.slogging import get_logger, configure_logging
1414
logger = get_logger()

ethereum/tests/utils.py

Lines changed: 4 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -11,34 +11,18 @@
1111
import json
1212
import os
1313
import tempfile
14-
import pyethereum.utils as utils
15-
import pyethereum.testutils as testutils
16-
from pyethereum.db import DB as DB
17-
from pyethereum.config import get_default_config as _get_default_config
14+
import ethereum.utils as utils
15+
import ethereum.testutils as testutils
16+
from ethereum.db import DB as DB
1817
__TESTDATADIR = "../tests"
1918

2019
tempdir = tempfile.mktemp()
2120

22-
def new_chainmanager(db=None, genesis=None):
23-
return get_chainmanager(db=db or new_db(), genesis=genesis)
24-
25-
def get_chainmanager(db, genesis=None):
26-
# creates cm with db or new
27-
import pyethereum.chainmanager as chainmanager
28-
cm = chainmanager.ChainManager()
29-
cm.configure(db=db, config=new_config(), genesis=genesis)
30-
return cm
31-
32-
def new_config(data_dir=None):
33-
cfg = _get_default_config()
34-
if not data_dir:
35-
data_dir = tempfile.mktemp()
36-
cfg.set('misc', 'data_dir', data_dir)
37-
return cfg
3821

3922
def load_test_data(fname):
4023
return json.loads(open(os.path.join(__TESTDATADIR, fname)).read())
4124

25+
4226
def new_db():
4327
return DB(utils.db_path(tempfile.mktemp()))
4428

ethereum/testutils.py

Lines changed: 0 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
import rlp
44
from rlp.utils import decode_hex, encode_hex, ascii_chr, str_to_bytes
55
from ethereum import processblock as pb
6-
76
import copy
87
from ethereum.db import EphemDB
98
from ethereum.utils import to_string, safe_ord
@@ -407,44 +406,6 @@ def get_blocks_from_textdump(data):
407406
return blocks
408407

409408

410-
def test_chain_data(blks, db=None, skip=0):
411-
if db is None:
412-
db = EphemDB()
413-
414-
chain_manager = utils.get_chainmanager(db, blocks.genesis(db))
415-
416-
# Total quantity of ether
417-
tot = sum([int(y["balance"]) for x, y in
418-
list(chain_manager.head.to_dict(True)["state"].items())])
419-
420-
# Guaranteed safe funds in each account
421-
safe = {x: y["balance"] for x, y in
422-
list(chain_manager.head.to_dict(True)["state"].items())}
423-
424-
# Process blocks sequentially
425-
for blk in blks[skip:]:
426-
print(blk.number, encode_hex(blk.hash),
427-
'%d txs' % len(blk.transaction_list))
428-
head = chain_manager.head
429-
assert blocks.check_header_pow(blk.header_args)
430-
chain_manager.receive_chain([blk])
431-
newhead = chain_manager.head
432-
newtot = sum([int(y["balance"]) for x, y in
433-
list(newhead.to_dict(True)["state"].items())])
434-
if newtot != tot + newhead.ether_delta:
435-
raise Exception("Ether balance sum mismatch: %d %d" %
436-
(newtot, tot + newhead.ether_delta))
437-
for tx in blk.get_transactions():
438-
safe[tx.sender] = max(safe.get(tx.sender, 0) - tx.value, 0)
439-
tot = newtot
440-
if blk.hash not in chain_manager:
441-
print('block could not be added')
442-
assert head == chain_manager.head
443-
chain_manager.head.deserialize_child(blk.rlpdata)
444-
assert blk.hash in chain_manager
445-
return safe
446-
447-
448409
def fixture_to_bytes(value):
449410
if isinstance(value, str):
450411
return str_to_bytes(value)

0 commit comments

Comments
 (0)