Example #1
0
def test_db():
    set_db()
    db = DB(utils.get_db_path())
    a, b = DB(utils.get_db_path()), DB(utils.get_db_path())
    assert a == b
    assert a.uncommitted == b.uncommitted
    a.put('a', 'b')
    b.get('a') == 'b'
    assert a.uncommitted == b.uncommitted
    a.commit()
    assert a.uncommitted == b.uncommitted
    assert 'test' not in db
    set_db()
    assert a != DB(utils.get_db_path())
Example #2
0
def test_db():
    set_db()
    db = DB(utils.get_db_path())
    a, b = DB(utils.get_db_path()),  DB(utils.get_db_path())
    assert a == b
    assert a.uncommitted == b.uncommitted
    a.put('a', 'b')
    b.get('a') == 'b'
    assert a.uncommitted == b.uncommitted
    a.commit()
    assert a.uncommitted == b.uncommitted
    assert 'test' not in db
    set_db()
    assert a != DB(utils.get_db_path())
Example #3
0
def check_chain_version(config):
    key = '__chain_version__'
    chain_version = str(Packeter.ETHEREUM_PROTOCOL_VERSION)
    db_path = get_db_path()
    db = DB(db_path)
    if not key in db:
        db.put(key, chain_version)
    if db.get(key) != chain_version:
        print \
"""
ATTENTION --------------------------------------------------------------------
the chain in the db (V:%r) doesn't match the the software version (V:%r)
This may lead to unexpected errors.
Consider to delete the db directory: %s
--------- --------------------------------------------------------------------
""" % (db.get(key), chain_version, db_path)
        time.sleep(5)
Example #4
0
def check_chain_version(config):
    key = '__chain_version__'
    chain_version = str(Packeter.ETHEREUM_PROTOCOL_VERSION)
    db_path = get_db_path()
    db = DB(db_path)
    if not key in db:
        db.put(key, chain_version)
    if db.get(key) != chain_version:
        print \
"""
ATTENTION --------------------------------------------------------------------
the chain in the db (V:%r) doesn't match the the software version (V:%r)
This may lead to unexpected errors.
Consider to delete the db directory: %s
--------- --------------------------------------------------------------------
""" % (db.get(key), chain_version, db_path)
        time.sleep(5)
Example #5
0
def test_genesis():
    k, v, k2, v2 = accounts()
    set_db()
    blk = blocks.genesis({v: utils.denoms.ether * 1})
    sr = blk.state_root
    db = DB(utils.get_db_path())
    assert blk.state.db.db == db.db
    db.put(blk.hash, blk.serialize())
    blk.state.db.commit()
    assert sr in db
    db.commit()
    assert sr in db
    blk2 = blocks.genesis({v: utils.denoms.ether * 1})
    blk3 = blocks.genesis()
    assert blk == blk2
    assert blk != blk3
    set_db()
    blk2 = blocks.genesis({v: utils.denoms.ether * 1})
    blk3 = blocks.genesis()
    assert blk == blk2
    assert blk != blk3
Example #6
0
def test_genesis():
    k, v, k2, v2 = accounts()
    set_db()
    blk = blocks.genesis({v: utils.denoms.ether * 1})
    sr = blk.state_root
    db = DB(utils.get_db_path())
    assert blk.state.db.db == db.db
    db.put(blk.hash, blk.serialize())
    blk.state.db.commit()
    assert sr in db
    db.commit()
    assert sr in db
    blk2 = blocks.genesis({v: utils.denoms.ether * 1})
    blk3 = blocks.genesis()
    assert blk == blk2
    assert blk != blk3
    set_db()
    blk2 = blocks.genesis({v: utils.denoms.ether * 1})
    blk3 = blocks.genesis()
    assert blk == blk2
    assert blk != blk3
Example #7
0
def test_db():
    db = DB(utils.get_db_path())
    assert 'test' not in db
Example #8
0
def db_store(blk):
    db = DB(utils.get_db_path())
    db.put(blk.hash, blk.serialize())
    db.commit()
    assert blocks.get_block(blk.hash) == blk
Example #9
0
def test_db():
    db = DB(utils.get_db_path())
    assert 'test' not in db
Example #10
0
def db_store(blk):
    db = DB(utils.get_db_path())
    db.put(blk.hash, blk.serialize())
    db.commit()
    assert blocks.get_block(blk.hash) == blk