Repository: paritytech/substrate
File: client/service/test/src/client/mod.rs (Rust)

Code before:
	assert_eq!(
		block_on(client.check_block(check_block_b1.clone())).unwrap(),
		ImportResult::MissingState,
	);
	check_block_b1.allow_missing_state = true;
	assert_eq!(
		block_on(client.check_block(check_block_b1.clone())).unwrap(),
		ImportResult::imported(false),
	);
	check_block_b1.parent_hash = H256::random();
	assert_eq!(
		block_on(client.check_block(check_block_b1.clone())).unwrap(),
		ImportResult::UnknownParent,
	);
}

#[test]
fn storage_keys_iter_prefix_and_start_key_works() {
	let child_info = ChildInfo::new_default(b"child");
	let client = TestClientBuilder::new()
		.add_extra_child_storage(&child_info, b"first".to_vec(), vec![0u8; 32])
		.add_extra_child_storage(&child_info, b"second".to_vec(), vec![0u8; 32])
		.add_extra_child_storage(&child_info, b"third".to_vec(), vec![0u8; 32])
		.build();

	let block_hash = client.block_hash_from_id(&BlockId::Number(0)).unwrap().unwrap();

	let child_root = b":child_storage:default:child".to_vec();
	let prefix = StorageKey(array_bytes::hex2bytes_unchecked("3a"));
	let child_prefix = StorageKey(b"sec".to_vec());

	let res: Vec<_> = client
		.storage_keys_iter(&block_hash, Some(&prefix), None)
		.unwrap()
		.map(|x| x.0)
		.collect();
	assert_eq!(
		res,
		[
			child_root.clone(),
			array_bytes::hex2bytes_unchecked("3a636f6465"),
			array_bytes::hex2bytes_unchecked("3a686561707061676573"),
		]
	);

	let res: Vec<_> = client
		.storage_keys_iter(
			&block_hash,
			Some(&prefix),
			Some(&StorageKey(array_bytes::hex2bytes_unchecked("3a636f6465"))),
		)

Review comment (suggestion):
```suggestion
	let block_hash = client.info().best_hash;
```

Code after:
	assert_eq!(
		block_on(client.check_block(check_block_b1.clone())).unwrap(),
		ImportResult::MissingState,
	);
	check_block_b1.allow_missing_state = true;
	assert_eq!(
		block_on(client.check_block(check_block_b1.clone())).unwrap(),
		ImportResult::imported(false),
	);
	check_block_b1.parent_hash = H256::random();
	assert_eq!(
		block_on(client.check_block(check_block_b1.clone())).unwrap(),
		ImportResult::UnknownParent,
	);
}

#[test]
fn storage_keys_iter_prefix_and_start_key_works() {
	let child_info = ChildInfo::new_default(b"child");
	let client = TestClientBuilder::new()
		.add_extra_child_storage(&child_info, b"first".to_vec(), vec![0u8; 32])
		.add_extra_child_storage(&child_info, b"second".to_vec(), vec![0u8; 32])
		.add_extra_child_storage(&child_info, b"third".to_vec(), vec![0u8; 32])
		.build();

	let block_hash = client.info().best_hash;

	let child_root = b":child_storage:default:child".to_vec();
	let prefix = StorageKey(array_bytes::hex2bytes_unchecked("3a"));
	let child_prefix = StorageKey(b"sec".to_vec());

	let res: Vec<_> = client
		.storage_keys_iter(&block_hash, Some(&prefix), None)
		.unwrap()
		.map(|x| x.0)
		.collect();
	assert_eq!(
		res,
		[
			child_root.clone(),
			array_bytes::hex2bytes_unchecked("3a636f6465"),
			array_bytes::hex2bytes_unchecked("3a686561707061676573"),
		]
	);

	let res: Vec<_> = client
		.storage_keys_iter(
			&block_hash,
			Some(&prefix),
			Some(&StorageKey(array_bytes::hex2bytes_unchecked("3a636f6465"))),
		)