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)
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()
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()
def db_store(blk): utils.db_put(blk.hash, blk.serialize()) assert blocks.get_block(blk.hash) == blk
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
def store_block(blk): blk.db.put(blk.hash, blk.serialize()) assert blocks.get_block(blk.db, blk.hash) == blk