예제 #1
0
def run_test(name):

    logger.debug('testing %s' % name)
    t = trie.Trie(new_db())
    data = load_tests()[name]

    for k in data['in']:
        logger.debug('updating with (%s, %s)' % (k, k))
        t.update(k, k)
    for point, prev, nxt in data['tests']:
        assert nxt == (t.next(point) or '')
        assert prev == (t.prev(point) or '')
예제 #2
0
def run_test(name):

    logger.debug('testing %s' % name)
    t = trie.Trie(new_db())
    data = fixture_to_bytes(load_tests()[name])

    for k in data['in']:
        logger.debug('updating with (%s, %s)' % (k, k))
        k = to_string(k)
        t.update(k, k)
    for point, prev, nxt in data['tests']:
        assert to_string(nxt) == (t.next(point) or b'')
        assert to_string(prev) == (t.prev(point) or b'')
예제 #3
0
import ethereum.processblock as processblock
import ethereum.blocks as blocks
import ethereum.transactions as transactions
import rlp
from rlp.utils import decode_hex, encode_hex
import ethereum.ethpow as ethpow
import ethereum.utils as utils
from ethereum.chain import Chain
from ethereum.db import EphemDB
from ethereum.tests.utils import new_db

from ethereum.slogging import get_logger, configure_logging
logger = get_logger()
# configure_logging('eth.vm:trace,eth.vm.memory:info')

_db = new_db()


@pytest.fixture(scope='function')
def db():
    return EphemDB()
alt_db = db


def env(db):
    return blocks.Env(db)


@pytest.fixture(scope="module")
def accounts():
    k = utils.sha3(b'cow')
예제 #4
0
from ethereum.transaction_queue import TransactionQueue
import rlp
from rlp.utils import decode_hex, encode_hex
import ethereum.pow.ethpow as ethpow
import ethereum.utils as utils
from ethereum.pow.chain import Chain
from ethereum.db import EphemDB
from ethereum.tests.utils import new_db
from ethereum.state import State
from ethereum.block import Block
from ethereum.consensus_strategy import get_consensus_strategy

from ethereum.slogging import get_logger
logger = get_logger()

_db = new_db()

# from ethereum.slogging import LogRecorder, configure_logging, set_level
# config_string = ':info,eth.vm.log:trace,eth.vm.op:trace,eth.vm.stack:trace,eth.vm.exit:trace,eth.pb.msg:trace,eth.pb.tx:debug'
# configure_logging(config_string=config_string)


@pytest.fixture(scope='function')
def db():
    return EphemDB()


alt_db = db


@pytest.fixture(scope="module")
예제 #5
0
def test_genesis_hash(genesis_fixture):
    genesis = blocks.genesis(new_db())
    assert genesis.hex_hash() == genesis_fixture['genesis_hash']
예제 #6
0
def test_genesis_initial_alloc(genesis_fixture):
    genesis = blocks.genesis(new_db())
    for k, v in list(blocks.GENESIS_INITIAL_ALLOC.items()):
        assert genesis.get_balance(k) == v.get("balance", 0) or v.get("wei", 0)
예제 #7
0
def test_genesis_state_root(genesis_fixture):
    genesis = blocks.genesis(new_db())
    assert encode_hex(genesis.state_root) == genesis_fixture['genesis_state_root']
예제 #8
0
    """
    genesis_fixture = None
    fn = os.path.join(testutils.fixture_path, 'BasicTests', 'genesishashestest.json')
    with open(fn, 'r') as f:
        genesis_fixture = json.load(f)
    assert genesis_fixture is not None, "Could not read genesishashtest.json from fixtures. Make sure you did 'git submodule init'!"
    # FIXME: assert that link is uptodate
    for k in ('genesis_rlp_hex', 'genesis_state_root', 'genesis_hash'):
        assert k in genesis_fixture
    return genesis_fixture


def test_genesis_state_root(genesis_fixture):
    genesis = blocks.genesis(new_db())
    assert encode_hex(genesis.state_root) == genesis_fixture['genesis_state_root']


def test_genesis_initial_alloc(genesis_fixture):
    genesis = blocks.genesis(new_db())
    for k, v in list(blocks.GENESIS_INITIAL_ALLOC.items()):
        assert genesis.get_balance(k) == v.get("balance", 0) or v.get("wei", 0)


def test_genesis_hash(genesis_fixture):
    genesis = blocks.genesis(new_db())
    assert genesis.hex_hash() == genesis_fixture['genesis_hash']


if __name__ == '__main__':
    print('current genesis:', blocks.genesis(new_db()).hex_hash())