You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: state.rs
    path of file: ./repos/parity-ethereum/ethcore/snapshot/snapshot-tests/src
    
    the code of the file until where you have to start completion: // Copyright 2015-2020 Parity Technologies (UK) Ltd.
// This file is part of Parity Ethereum.

// Parity Ethereum is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.

// Parity Ethereum is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.

// You should have received a copy of the GNU General Public License
// along with Parity Ethereum.  If not, see <http://www.gnu.org/licenses/>.

//! State snapshotting tests.

use std::sync::Arc;
use std::sync::atomic::AtomicBool;

use keccak_hash::{KECCAK_NULL_RLP, keccak};
use common_types::{
	basic_account::BasicAccount,
	errors::{EthcoreError as Error, SnapshotError},
	snapshot::{ManifestData, Progress},
};
use snapshot::{
	test_helpers::to_fat_rlps,
	chunk_state, StateRebuilder, SNAPSHOT_SUBPARTS,
	io::{PackedReader, PackedWriter, SnapshotReader, SnapshotWriter},
};
use rand::SeedableRng;
use rand_xorshift::XorShiftRng;
use ethereum_types::
    
fn get_code_from_prev_chunk() {
	use std::collections::HashSet;
	use rlp::RlpStream;
	use ethereum_types::{H256, U256};
	use hash_db::{HashDB, EMPTY_PREFIX};

	use account_db::{AccountDBMut, AccountDB};

	let code = b"this is definitely code";
	let mut used_code = HashSet::new();
	let mut acc_stream = RlpStream::new_list(4);
	acc_stream.append(&U256::default())
		.append(&U256::default())
		.append(&KECCAK_NULL_RLP)
		.append(&keccak(code));

	let (h1, h2) = (H256::random(), H256::random());

	// two accounts with the same code, one per chunk.
	// first one will have code inlined,
	// second will just have its hash.
	let thin_rlp = acc_stream.out();
	let acc: BasicAccount = ::rlp::decode(&thin_rlp).expect("error decoding basic account");

	let mut make_chunk = |acc, hash| {
		let mut db = journaldb::new_memory_db();
		AccountDBMut::from_hash(&mut db, hash).insert(EMPTY_PREFIX, &code[..]);
		let p = RwLock::new(Progress::new());
		let fat_rlp = to_fat_rlps(
			&hash,
			&acc,
			&AccountDB::from_hash(&db, hash),
			&mut used_code,
			usize::max_value(),
			usize::max_value(),
			&p
		).unwrap();
		let mut stream = RlpStream::new_list(1);
		stream.append_raw(&fat_rlp[0], 1);
		stream.out()
	};

	let chunk1 = make_chunk(acc.clone(), h1);
	let chunk2 = make_chunk(acc, h2);

	let tempdir = TempDir::new("").unwrap();
	let db_cfg = DatabaseConfig::with_columns(ethcore_db::NUM_COLUMNS);
	let new_db = Arc::new(Database::open(&db_cfg, tempdir.path().to_str().unwrap()).unwrap());

	{
		let mut rebuilder = StateRebuilder::new(new_db.clone(), Algorithm::OverlayRecent);
		let flag = AtomicBool::new(true);

		rebuilder.feed(&chunk1, &flag).unwrap();
		rebuilder.feed(&chunk2, &flag).unwrap();

		rebuilder.finalize(1000, H256::random()).unwrap();
	}

	let state_db = journaldb::new(new_db, Algorithm::OverlayRecent, ethcore_db::COL_STATE);
	assert_eq!(state_db.earliest_era(), Some(1000));
}