mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-26 09:57:56 +00:00
feat: generalize some functions in sp-trie (#12376)
* feat: add to_memory_db to StorageProof * feat: add iter method and generalize iter_nodes * fmt * feat: generalize `encode_compact` like `decode_compact`, add to_compact_proof to StorageProof * fix to_compact_proof * improve by suggestions * improve by suggestions Co-authored-by: Bastian Köcher <git@kchr.de>
This commit is contained in:
@@ -1939,13 +1939,13 @@ mod tests {
|
||||
let (proof, count) =
|
||||
prove_range_read_with_size(remote_backend, None, None, 0, None).unwrap();
|
||||
// Always contains at least some nodes.
|
||||
assert_eq!(proof.into_memory_db::<BlakeTwo256>().drain().len(), 3);
|
||||
assert_eq!(proof.to_memory_db::<BlakeTwo256>().drain().len(), 3);
|
||||
assert_eq!(count, 1);
|
||||
|
||||
let remote_backend = trie_backend::tests::test_trie(state_version, None, None);
|
||||
let (proof, count) =
|
||||
prove_range_read_with_size(remote_backend, None, None, 800, Some(&[])).unwrap();
|
||||
assert_eq!(proof.clone().into_memory_db::<BlakeTwo256>().drain().len(), 9);
|
||||
assert_eq!(proof.to_memory_db::<BlakeTwo256>().drain().len(), 9);
|
||||
assert_eq!(count, 85);
|
||||
let (results, completed) = read_range_proof_check::<BlakeTwo256>(
|
||||
remote_root,
|
||||
@@ -1968,7 +1968,7 @@ mod tests {
|
||||
let remote_backend = trie_backend::tests::test_trie(state_version, None, None);
|
||||
let (proof, count) =
|
||||
prove_range_read_with_size(remote_backend, None, None, 50000, Some(&[])).unwrap();
|
||||
assert_eq!(proof.clone().into_memory_db::<BlakeTwo256>().drain().len(), 11);
|
||||
assert_eq!(proof.to_memory_db::<BlakeTwo256>().drain().len(), 11);
|
||||
assert_eq!(count, 132);
|
||||
let (results, completed) =
|
||||
read_range_proof_check::<BlakeTwo256>(remote_root, proof, None, None, None, None)
|
||||
@@ -2053,7 +2053,7 @@ mod tests {
|
||||
)
|
||||
.unwrap();
|
||||
// Always contains at least some nodes.
|
||||
assert!(proof.clone().into_memory_db::<BlakeTwo256>().drain().len() > 0);
|
||||
assert!(proof.to_memory_db::<BlakeTwo256>().drain().len() > 0);
|
||||
assert!(count < 3); // when doing child we include parent and first child key.
|
||||
|
||||
let (result, completed_depth) = read_range_proof_check_with_child::<BlakeTwo256>(
|
||||
|
||||
@@ -980,7 +980,7 @@ pub mod tests {
|
||||
let proof = backend.extract_proof().unwrap();
|
||||
|
||||
let mut nodes = Vec::new();
|
||||
for node in proof.iter_nodes() {
|
||||
for node in proof.into_iter_nodes() {
|
||||
let hash = BlakeTwo256::hash(&node);
|
||||
// Only insert the node/value that contains the important data.
|
||||
if hash != value_hash {
|
||||
|
||||
Reference in New Issue
Block a user