Prevent bug when reusing type ids in hashing (#1075)

* practice TDD

* implement a hashmap 2-phases approach

* use nicer types

* add test for cache filling

* adjust test

---------

Co-authored-by: James Wilson <james@jsdw.me>
This commit is contained in:
Tadeo Hepperle
2023-07-19 19:49:08 +02:00
committed by GitHub
parent 84df959d28
commit 475a1413e4
2 changed files with 139 additions and 61 deletions
+2 -2
View File
@@ -20,7 +20,7 @@ mod from_into;
mod utils;
use scale_info::{form::PortableForm, PortableRegistry, Variant};
use std::collections::{HashMap, HashSet};
use std::collections::HashMap;
use std::sync::Arc;
use utils::ordered_map::OrderedMap;
use utils::variant_index::VariantIndex;
@@ -152,7 +152,7 @@ impl Metadata {
Some(crate::utils::validation::get_type_hash(
&self.types,
id,
&mut HashSet::<u32>::new(),
&mut HashMap::new(),
))
}
}