BlockId removal: &Hash to Hash (#12626)

It changes &Block::Hash argument to Block::Hash.

This PR is part of BlockId::Number refactoring analysis (paritytech/substrate#11292)
This commit is contained in:
Michal Kucharczyk
2022-11-07 22:42:16 +01:00
committed by GitHub
parent 7c4bfc9749
commit 1ed70004e7
49 changed files with 428 additions and 441 deletions
+21 -21
View File
@@ -346,7 +346,7 @@ fn block_builder_works_with_transactions() {
.expect("block 1 was just imported. qed");
assert_eq!(client.chain_info().best_number, 1);
assert_ne!(client.state_at(&hash1).unwrap().pairs(), client.state_at(&hash0).unwrap().pairs());
assert_ne!(client.state_at(hash1).unwrap().pairs(), client.state_at(hash0).unwrap().pairs());
assert_eq!(
client
.runtime_api()
@@ -405,10 +405,10 @@ fn block_builder_does_not_include_invalid() {
assert_eq!(client.chain_info().best_number, 1);
assert_ne!(
client.state_at(&hashof1).unwrap().pairs(),
client.state_at(&hashof0).unwrap().pairs()
client.state_at(hashof1).unwrap().pairs(),
client.state_at(hashof0).unwrap().pairs()
);
assert_eq!(client.body(&hashof1).unwrap().unwrap().len(), 1)
assert_eq!(client.body(hashof1).unwrap().unwrap().len(), 1)
}
#[test]
@@ -870,7 +870,7 @@ fn import_with_justification() {
.unwrap()
.block;
block_on(client.import(BlockOrigin::Own, a2.clone())).unwrap();
client.finalize_block(&a2.hash(), None).unwrap();
client.finalize_block(a2.hash(), None).unwrap();
// A2 -> A3
let justification = Justifications::from((TEST_ENGINE_ID, vec![1, 2, 3]));
@@ -884,11 +884,11 @@ fn import_with_justification() {
assert_eq!(client.chain_info().finalized_hash, a3.hash());
assert_eq!(client.justifications(&a3.hash()).unwrap(), Some(justification));
assert_eq!(client.justifications(a3.hash()).unwrap(), Some(justification));
assert_eq!(client.justifications(&a1.hash()).unwrap(), None);
assert_eq!(client.justifications(a1.hash()).unwrap(), None);
assert_eq!(client.justifications(&a2.hash()).unwrap(), None);
assert_eq!(client.justifications(a2.hash()).unwrap(), None);
finality_notification_check(&mut finality_notifications, &[a1.hash(), a2.hash()], &[]);
finality_notification_check(&mut finality_notifications, &[a3.hash()], &[]);
@@ -999,7 +999,7 @@ fn finalizing_diverged_block_should_trigger_reorg() {
// we finalize block B1 which is on a different branch from current best
// which should trigger a re-org.
ClientExt::finalize_block(&client, &b1.hash(), None).unwrap();
ClientExt::finalize_block(&client, b1.hash(), None).unwrap();
// B1 should now be the latest finalized
assert_eq!(client.chain_info().finalized_hash, b1.hash());
@@ -1023,7 +1023,7 @@ fn finalizing_diverged_block_should_trigger_reorg() {
assert_eq!(client.chain_info().best_hash, b3.hash());
ClientExt::finalize_block(&client, &b3.hash(), None).unwrap();
ClientExt::finalize_block(&client, b3.hash(), None).unwrap();
finality_notification_check(&mut finality_notifications, &[b1.hash()], &[]);
finality_notification_check(&mut finality_notifications, &[b2.hash(), b3.hash()], &[a2.hash()]);
@@ -1121,7 +1121,7 @@ fn finality_notifications_content() {
// Postpone import to test behavior of import of finalized block.
ClientExt::finalize_block(&client, &a2.hash(), None).unwrap();
ClientExt::finalize_block(&client, a2.hash(), None).unwrap();
// Import and finalize D4
block_on(client.import_as_final(BlockOrigin::Own, d4.clone())).unwrap();
@@ -1285,7 +1285,7 @@ fn doesnt_import_blocks_that_revert_finality() {
// we will finalize A2 which should make it impossible to import a new
// B3 at the same height but that doesn't include it
ClientExt::finalize_block(&client, &a2.hash(), None).unwrap();
ClientExt::finalize_block(&client, a2.hash(), None).unwrap();
let import_err = block_on(client.import(BlockOrigin::Own, b3)).err().unwrap();
let expected_err =
@@ -1320,7 +1320,7 @@ fn doesnt_import_blocks_that_revert_finality() {
.unwrap()
.block;
block_on(client.import(BlockOrigin::Own, a3.clone())).unwrap();
ClientExt::finalize_block(&client, &a3.hash(), None).unwrap();
ClientExt::finalize_block(&client, a3.hash(), None).unwrap();
finality_notification_check(&mut finality_notifications, &[a1.hash(), a2.hash()], &[]);
@@ -1620,7 +1620,7 @@ fn storage_keys_iter_prefix_and_start_key_works() {
let child_prefix = StorageKey(b"sec".to_vec());
let res: Vec<_> = client
.storage_keys_iter(&block_hash, Some(&prefix), None)
.storage_keys_iter(block_hash, Some(&prefix), None)
.unwrap()
.map(|x| x.0)
.collect();
@@ -1635,7 +1635,7 @@ fn storage_keys_iter_prefix_and_start_key_works() {
let res: Vec<_> = client
.storage_keys_iter(
&block_hash,
block_hash,
Some(&prefix),
Some(&StorageKey(array_bytes::hex2bytes_unchecked("3a636f6465"))),
)
@@ -1646,7 +1646,7 @@ fn storage_keys_iter_prefix_and_start_key_works() {
let res: Vec<_> = client
.storage_keys_iter(
&block_hash,
block_hash,
Some(&prefix),
Some(&StorageKey(array_bytes::hex2bytes_unchecked("3a686561707061676573"))),
)
@@ -1656,7 +1656,7 @@ fn storage_keys_iter_prefix_and_start_key_works() {
assert_eq!(res, Vec::<Vec<u8>>::new());
let res: Vec<_> = client
.child_storage_keys_iter(&block_hash, child_info.clone(), Some(&child_prefix), None)
.child_storage_keys_iter(block_hash, child_info.clone(), Some(&child_prefix), None)
.unwrap()
.map(|x| x.0)
.collect();
@@ -1664,7 +1664,7 @@ fn storage_keys_iter_prefix_and_start_key_works() {
let res: Vec<_> = client
.child_storage_keys_iter(
&block_hash,
block_hash,
child_info,
None,
Some(&StorageKey(b"second".to_vec())),
@@ -1684,7 +1684,7 @@ fn storage_keys_iter_works() {
let prefix = StorageKey(array_bytes::hex2bytes_unchecked(""));
let res: Vec<_> = client
.storage_keys_iter(&block_hash, Some(&prefix), None)
.storage_keys_iter(block_hash, Some(&prefix), None)
.unwrap()
.take(9)
.map(|x| array_bytes::bytes2hex("", &x.0))
@@ -1706,7 +1706,7 @@ fn storage_keys_iter_works() {
let res: Vec<_> = client
.storage_keys_iter(
&block_hash,
block_hash,
Some(&prefix),
Some(&StorageKey(array_bytes::hex2bytes_unchecked("3a636f6465"))),
)
@@ -1729,7 +1729,7 @@ fn storage_keys_iter_works() {
let res: Vec<_> = client
.storage_keys_iter(
&block_hash,
block_hash,
Some(&prefix),
Some(&StorageKey(array_bytes::hex2bytes_unchecked(
"7d5007603a7f5dd729d51d93cf695d6465789443bb967c0d1fe270e388c96eaa",