示例#1
0
def test_deserialize_commit():
    k, v, k2, v2 = accounts()
    db = new_db()
    blk = blocks.genesis(db)
    db.put(blk.hash, blk.serialize())
    db.commit()
    assert blk == blocks.get_block(db, blk.hash)
示例#2
0
def test_mine_block_with_transaction():
    k, v, k2, v2 = accounts()
    set_db()
    blk = mkgenesis({v: utils.denoms.ether * 1})
    db_store(blk)
    tx = get_transaction()
    blk2 = mine_next_block(blk, coinbase=v, transactions=[tx])
    db_store(blk2)
    assert blocks.get_block(blk2.hash) == blk2
    assert tx.gasprice == 0
    assert blk2.get_balance(
        v) == blocks.BLOCK_REWARD + blk.get_balance(v) - tx.value
    assert blk.state.db.db == blk2.state.db.db
    assert blk2.get_parent() == blk
    assert tx in blk2.get_transactions()
    assert not tx in blk.get_transactions()
示例#3
0
def test_mine_block_with_transaction():
    k, v, k2, v2 = accounts()
    set_db()
    blk = blocks.genesis({v: utils.denoms.ether * 1})
    db_store(blk)
    tx = get_transaction()
    blk2 = mine_next_block(blk, coinbase=v, transactions=[tx])
    db_store(blk2)
    assert blocks.get_block(blk2.hash) == blk2
    assert tx.gasprice == 0
    assert blk2.get_balance(
        v) == blocks.BLOCK_REWARD + blk.get_balance(v) - tx.value
    assert blk.state.db.db == blk2.state.db.db
    assert blk2.get_parent() == blk
    assert tx in blk2.get_transactions()
    assert not tx in blk.get_transactions()
示例#4
0
def db_store(blk):
    utils.db_put(blk.hash, blk.serialize())
    assert blocks.get_block(blk.hash) == blk
示例#5
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
示例#6
0
def db_store(blk):
    utils.db_put(blk.hash, blk.serialize())
    assert blocks.get_block(blk.hash) == blk
示例#7
0
def store_block(blk):
    blk.db.put(blk.hash, blk.serialize())
    assert blocks.get_block(blk.db, blk.hash) == blk
示例#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